The following commit has been merged in the master branch:
commit 1a72094cb7a1d822b4716586de9ffc987cea4016
Author: Raphaël Hertzog <[email protected]>
Date:   Mon Nov 9 23:54:50 2009 +0100

    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.

diff --git a/debian/changelog b/debian/changelog
index 7c067b1..a526330 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -78,6 +78,9 @@ dpkg (1.15.5) UNRELEASED; urgency=low
     Thanks to Mike Hommey for the idea. Closes: #554689
   * 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.
+  * 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 ]
   * Czech (Miroslav Kure).
diff --git a/man/dpkg-source.1 b/man/dpkg-source.1
index 4815cea..98d3386 100644
--- a/man/dpkg-source.1
+++ b/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
 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
+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
 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
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index cfb3392..de4e3b5 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -25,6 +25,7 @@ use Dpkg::ErrorHandling;
 use Dpkg::Arch qw(debarch_eq);
 use Dpkg::Deps;
 use Dpkg::Compression;
+use Dpkg::Conf;
 use Dpkg::Control::Info;
 use Dpkg::Control::Fields;
 use Dpkg::Substvars;
@@ -66,6 +67,7 @@ my %override;
 my $substvars = Dpkg::Substvars->new();
 my $tar_ignore_default_pattern_done;
 
+my @options;
 my @cmdline_options;
 my @cmdline_formats;
 while (@ARGV && $ARGV[0] =~ m/^-/) {
@@ -76,7 +78,38 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
         setopmode('-x');
     } elsif (m/^--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;
     } elsif (m/^-Z(.*)$/) {
        my $compression = $1;
@@ -146,14 +179,6 @@ unless (defined($options{'opmode'})) {
 
 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;
 
     $changelogfile ||= "$dir/debian/changelog";

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to