Explorar el Código

dpkg-source: read sticky options from <dir>/debian/source/options

Modify dpkg-source -b/--print-format 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>).

The options read from that file are printed in the log to better diagnose
errors that might appear from its usage.
Raphaël Hertzog hace 16 años
padre
commit
1a72094cb7
Se han modificado 3 ficheros con 46 adiciones y 9 borrados
  1. 3 0
      debian/changelog
  2. 9 0
      man/dpkg-source.1
  3. 34 9
      scripts/dpkg-source.pl

+ 3 - 0
debian/changelog

@@ -78,6 +78,9 @@ dpkg (1.15.5) UNRELEASED; urgency=low
     Thanks to Mike Hommey for the idea. Closes: #554689
     Thanks to Mike Hommey for the idea. Closes: #554689
   * Add new option --print-format to dpkg-source to be able to know by advance
   * Add new option --print-format to dpkg-source to be able to know by advance
     the source format that would be used during a build.
     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>).
 
 
   [ Updated dpkg translations ]
   [ Updated dpkg translations ]
   * Czech (Miroslav Kure).
   * Czech (Miroslav Kure).

+ 9 - 0
man/dpkg-source.1

@@ -503,6 +503,15 @@ or trailing spaces are allowed.
 This file contains a list of binary files (one per line) that should be
 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.
 included in the debian tarball. Leading and trailing spaces are stripped.
 Lines starting with "#" are comments and are skipped. Empty lines are ignored.
 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
+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.
+.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.
 .SS debian/patches/series
 .SS debian/patches/series
 This file lists all patches that have to be applied (in the given order)
 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
 on top of the upstream source package. Leading and trailing spaces are

+ 34 - 9
scripts/dpkg-source.pl

@@ -25,6 +25,7 @@ use Dpkg::ErrorHandling;
 use Dpkg::Arch qw(debarch_eq);
 use Dpkg::Arch qw(debarch_eq);
 use Dpkg::Deps;
 use Dpkg::Deps;
 use Dpkg::Compression;
 use Dpkg::Compression;
+use Dpkg::Conf;
 use Dpkg::Control::Info;
 use Dpkg::Control::Info;
 use Dpkg::Control::Fields;
 use Dpkg::Control::Fields;
 use Dpkg::Substvars;
 use Dpkg::Substvars;
@@ -66,6 +67,7 @@ my %override;
 my $substvars = Dpkg::Substvars->new();
 my $substvars = Dpkg::Substvars->new();
 my $tar_ignore_default_pattern_done;
 my $tar_ignore_default_pattern_done;
 
 
+my @options;
 my @cmdline_options;
 my @cmdline_options;
 my @cmdline_formats;
 my @cmdline_formats;
 while (@ARGV && $ARGV[0] =~ m/^-/) {
 while (@ARGV && $ARGV[0] =~ m/^-/) {
@@ -76,7 +78,38 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
         setopmode('-x');
         setopmode('-x');
     } elsif (m/^--print-format$/) {
     } elsif (m/^--print-format$/) {
 	setopmode('--print-format');
 	setopmode('--print-format');
-    } elsif (m/^--format=(.*)$/) {
+    } else {
+	push @options, $_;
+    }
+}
+
+my $dir;
+if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
+    if (not scalar(@ARGV)) {
+	usageerr(_g("%s needs a directory"), $options{'opmode'});
+    }
+    $dir = File::Spec->catdir(shift(@ARGV));
+    stat($dir) || syserr(_g("cannot stat directory %s"), $dir);
+    if (not -d $dir) {
+	error(_g("directory argument %s is not a directory"), $dir);
+    }
+    my $conf = Dpkg::Conf->new();
+    my $optfile = File::Spec->catfile($dir, "debian", "source", "options");
+    $conf->load($optfile) if -f $optfile;
+    # --format options are not allowed, they would take precedence
+    # over real command line options, debian/source/format should be used
+    # instead
+    @$conf = grep { ! /^--format=/ } @$conf;
+    if (@$conf) {
+	info(_g("using options from %s: %s"), $optfile, "$conf")
+	    unless $options{'opmode'} eq "--print-format";
+	unshift @options, @$conf;
+    }
+}
+
+while (@options) {
+    $_ = shift(@options);
+    if (m/^--format=(.*)$/) {
         push @cmdline_formats, $1;
         push @cmdline_formats, $1;
     } elsif (m/^-Z(.*)$/) {
     } elsif (m/^-Z(.*)$/) {
 	my $compression = $1;
 	my $compression = $1;
@@ -146,14 +179,6 @@ unless (defined($options{'opmode'})) {
 
 
 if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
 if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
 
 
-    if (not scalar(@ARGV)) {
-	usageerr(_g("%s needs a directory"), $options{'opmode'});
-    }
-    my $dir = File::Spec->catdir(shift(@ARGV));
-    stat($dir) || syserr(_g("cannot stat directory %s"), $dir);
-    if (not -d $dir) {
-	error(_g("directory argument %s is not a directory"), $dir);
-    }
     $options{'ARGV'} = \@ARGV;
     $options{'ARGV'} = \@ARGV;
 
 
     $changelogfile ||= "$dir/debian/changelog";
     $changelogfile ||= "$dir/debian/changelog";