소스 검색

dpkg-source: parse only long options from debian/source/options

debian/source/options can now only contain long options. The
following lines would result in "--option1 --option1=value"
passed to dpkg-source -b:
 option1
 option2 = value

Dpkg::Conf has been modified to refuse short options by default.
Raphaël Hertzog 16 년 전
부모
커밋
362bc31aa6
4개의 변경된 파일25개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 1
      debian/changelog
  2. 17 7
      man/dpkg-source.1
  3. 5 0
      scripts/Dpkg/Conf.pm
  4. 2 2
      scripts/dpkg-source.pl

+ 1 - 1
debian/changelog

@@ -85,7 +85,7 @@ dpkg (1.15.5) UNRELEASED; urgency=low
     the source format that would be used during a build.
   * Modify dpkg-source -b to use default build options from
     debian/source/options. Thus it's now possible to have sticky options, for
-    example for the choice of a compression method (-Z<comp>).
+    example for the choice of a compression method (--compression=<comp>).
   * dpkg-source outputs the list of upstream files modified by the diff.gz
     (applies only to source packages using format 1.0). Closes: #482166
     It also recommends usage of 3.0 (quilt) format during dpkg-source -b if it

+ 17 - 7
man/dpkg-source.1

@@ -116,7 +116,7 @@ Override or add an output control file field.
 .BI \-U field
 Remove an output control file field.
 .TP
-.BR \-Z \fIcompression\fP
+.BR \-Z "\fIcompression\fP, " \-\-compression =\fIcompression\fP
 Specify the compression to use for created files (tarballs and diffs).
 Note that this option will not cause existing tarballs to be recompressed,
 it only affects new files. Supported values are:
@@ -124,7 +124,7 @@ it only affects new files. Supported values are:
 \fIgzip\fP is the default. \fIxz\fP is only supported since
 dpkg-dev 1.15.5.
 .TP
-.BR \-z \fIlevel\fP
+.BR \-z "\fIlevel\fP, " \-\-compression\-level =\fIlevel\fP
 Compression level to use. As with \fB\-Z\fP it only affects newly created
 files. Supported values are:
 .IR 1 " to " 9 ", " best ", and " fast .
@@ -509,14 +509,24 @@ This file contains a list of binary files (one per line) that should be
 included in the debian tarball. Leading and trailing spaces are stripped.
 Lines starting with "#" are comments and are skipped. Empty lines are ignored.
 .SS debian/source/options
-This file contains a list of options that should be automatically
+This file contains a list of long options that should be automatically
 prepended to the set of command line options of a \fBdpkg\-source \-b\fR
-or \fBdpkg\-source \-\-print\-format\fR call. Options like \fB\-Z\fR and
-\fB\-z\fR are well suited for this file.
+or \fBdpkg\-source \-\-print\-format\fR call. Options like
+\fB\-\-compression\fR and \fB\-\-compression\-level\fR are well suited for
+this file.
 .P
 Each option should be put on a separate line. Empty lines and lines
-starting with "#" are ignored. \fB\-\-format\fR options are not accepted
-in this file, you should use \fBdebian/source/format\fR instead.
+starting with "#" are ignored. The leading "--" should be
+stripped and short options are not allowed. Optional spaces are allowed
+around the "=" symbol and optional quotes are allowed around the value.
+Here's an example of such a file:
+.P
+  # let dpkg-source create a debian.tar.bz2 with maximal compression
+  compression = "bzip2"
+  compression-level = 9
+.P
+Note: \fBformat\fR options are not accepted in this file, you should
+use \fBdebian/source/format\fR instead.
 .SS debian/patches/series
 This file lists all patches that have to be applied (in the given order)
 on top of the upstream source package. Leading and trailing spaces are

+ 5 - 0
scripts/Dpkg/Conf.pm

@@ -51,6 +51,7 @@ sub new {
 
     my $self = {
 	options => [],
+	allow_short => 0,
     };
     bless $self, $class;
 
@@ -88,6 +89,10 @@ sub parse {
 	s/\s+=\s+/=/;         # Remove spaces around the first =
 	s/\s+/=/ unless m/=/; # First spaces becomes = if no =
 	next if /^#/ or /^$/; # Skip empty lines and comments
+	if (/^-[^-]/ and not $self->{'allow_short'}) {
+	    warning(_g("short option not allowed in %s, line %d"), $desc, $.);
+	    next;
+	}
 	if (/^(\S+)(?:=(.*))?$/) {
 	    my ($name, $value) = ($1, $2);
 	    $name = "--$name" unless $name =~ /^-/;

+ 2 - 2
scripts/dpkg-source.pl

@@ -112,14 +112,14 @@ while (@options) {
     $_ = shift(@options);
     if (m/^--format=(.*)$/) {
         push @cmdline_formats, $1;
-    } elsif (m/^-Z(.*)$/) {
+    } elsif (m/^-(?:Z|-compression=)(.*)$/) {
 	my $compression = $1;
 	$options{'compression'} = $compression;
 	$options{'comp_ext'} = $comp_ext{$compression};
 	usageerr(_g("%s is not a supported compression"), $compression)
 	    unless $comp_supported{$compression};
 	Dpkg::Source::Compressor->set_default_compression($compression);
-    } elsif (m/^-z(.*)$/) {
+    } elsif (m/^-(?:z|-compression-level=)(.*)$/) {
 	my $comp_level = $1;
 	$options{'comp_level'} = $comp_level;
 	usageerr(_g("%s is not a compression level"), $comp_level)