]> git.donarmstrong.com Git - debhelper.git/commitdiff
solve the dh -Bbuild problem
authorJoey Hess <joey@gnu.kitenet.net>
Mon, 4 Jan 2010 23:41:51 +0000 (18:41 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Tue, 5 Jan 2010 00:00:49 +0000 (19:00 -0500)
* Add -O option, which can be used to pass options to commands, ignoring
  options that they do not support.
* dh: Use -O to pass user-specified options to the commands it runs.
  This solves the problem with passing "-Bbuild" to dh, where commands
  that do not support -B would see a bogus -u option. Closes: #541773
  (It also ensures that the commands dh prints out can really be run.)

Debian/Debhelper/Dh_Getopt.pm
debhelper.pod
debian/changelog
dh

index 0d0210720c57e36b60f3c78cec9584fcd52902ed..4df3eed27ae26944d40afe27820e86c516ab36ca 100644 (file)
@@ -69,15 +69,8 @@ sub NonOption {
 sub getoptions {
        my $array=shift;
        my %params=@_;
-       my %options=%{$params{options}} if ref $params{options};
-       
-       my $oldwarn;
-       if ($params{ignore_unknown_options}) {
-               $oldwarn=$SIG{__WARN__};
-               $SIG{__WARN__}=sub {};
-       }
 
-       my $ret=Getopt::Long::GetOptionsFromArray($array,
+       my %options=(   
                "v" => \$dh{VERBOSE},
                "verbose" => \$dh{VERBOSE},
 
@@ -137,18 +130,37 @@ sub getoptions {
                
                "ignore=s" => \&AddIgnore,
 
-               %options,
+               "O=s" => sub { my($option,$value)=@_;
+                       # Try to parse an option, but ignore it
+                       # if it is not known.
+                       if (getoptions([$value], %params, test => 1)) {
+                               getoptions([$value], %params);
+                       }
+               },
+
+               (ref $params{options} ? %{$params{options}} : ()) ,
 
                "<>" => \&NonOption,
        );
 
-       if ($params{ignore_unknown_options}) {
-               $SIG{__WARN__}=$oldwarn;
-               return 1;
+       if ($params{test}) {
+               foreach my $key (keys %options) {
+                       $options{$key}=sub {};
+               }
        }
-       else {
-               return $ret;
+
+       my $oldwarn;
+       if ($params{test} || $params{ignore_unknown_options}) {
+               $oldwarn=$SIG{__WARN__};
+               $SIG{__WARN__}=sub {};
+       }
+       my $ret=Getopt::Long::GetOptionsFromArray($array, %options);
+       if ($oldwarn) {
+               $SIG{__WARN__}=$oldwarn;
        }
+
+       return 1 if $params{ignore_unknown_options};
+       return $ret;
 }
 
 sub split_options_string {
@@ -171,7 +183,7 @@ sub parseopts {
 
                # Avoid forcing acting on packages specified in
                # DH_INTERNAL_OPTIONS. This way, -p can be specified
-               # at the command line to act on a specific package, and if
+               # at the command line to act on a specific package, but when
                # nothing is specified, the excludes will cause the set of
                # packages DH_INTERNAL_OPTIONS specifies to be acted on.
                if (defined $dh{DOPACKAGES}) {
index a4765baba8367f458a96f5fa1cc80a07056a061a..03d0f90b1a79a5297df492a0d3560318b0bccd2c 100644 (file)
@@ -156,6 +156,13 @@ This little-used option changes the package which debhelper considers the
 one for which debian/foo files can be used instead of the usual
 debian/package.foo files.
 
+=item B<-O=>I<option|bundle>
+
+This is used by L<dh(1)> when passing user-specified options to all the
+commands it runs. If the command supports the specified option or option
+bundle, it will take effect. If the command does not support the option (or
+any part of an option bundle), it will be ignored.
+
 =back
 
 =head1 COMMON DEBHELPER OPTIONS
index a3f1fbcf8a0ae418e9e6a2ed946cd1dc0dacafe1..a7aa1dc1a128a5e923d12d1495c2ba2e64c01753 100644 (file)
@@ -4,6 +4,12 @@ debhelper (7.4.12) UNRELEASED; urgency=low
   * makefile: Support the (asking for trouble) case of MAKE being set to
     something with a space in it. Closes: #563557
   * Fix warning about unknown options passed to commands in override targets.
+  * Add -O option, which can be used to pass options to commands, ignoring
+    options that they do not support.
+  * dh: Use -O to pass user-specified options to the commands it runs.
+    This solves the problem with passing "-Bbuild" to dh, where commands
+    that do not support -B would see a bogus -u option. Closes: #541773
+    (It also ensures that the commands dh prints out can really be run.)
 
  -- Joey Hess <joeyh@debian.org>  Fri, 01 Jan 2010 13:00:22 -0500
 
diff --git a/dh b/dh
index 96a6b84af474eb84fa36ebe913fd54c8e9fdf0a4..9fb209ad535517d7919a433cdf499f0b6b8bbd9e 100755 (executable)
--- a/dh
+++ b/dh
@@ -175,7 +175,7 @@ default. This is how to use dh_pycentral instead.
 
        #!/usr/bin/make -f
        %:
-               dh --with python-central $@
+               dh $@ --with python-central
 
 Here is how to force use of perl's Module::Build build system,
 which can be necessary if debhelper wrongly detects that the package
@@ -183,14 +183,14 @@ uses MakeMaker.
 
        #!/usr/bin/make -f
        %:
-               dh --buildsystem=perl_build $@
+               dh $@ --buildsystem=perl_build
 
 To patch your package using quilt, you can tell dh to use quilt's dh
 sequence addons like this:
        
        #!/usr/bin/make -f
        %:
-               dh --with quilt $@
+               dh $@ --with quilt
 
 Here is an example of overriding where the dh_auto_* commands find
 the package's source, for a package where the source is located in a
@@ -198,7 +198,7 @@ subdirectory.
 
        #!/usr/bin/make -f
        %:
-               dh --sourcedirectory=src $@
+               dh $@ --sourcedirectory=src
 
 Finally, here is a way to prevent dh from running several commands
 that you don't want it to run, by defining empty override targets for each
@@ -459,7 +459,17 @@ while (@ARGV_orig) {
        elsif ($opt =~ /^--?(no-act|remaining|(after|until|before|with|without)=)/) {
                next;
        }
-       push @options, $opt;
+       elsif ($opt=~/^-/) {
+               push @options, "-O".$opt;
+       }
+       elsif (@options) {
+               if ($options[$#options]=~/^-O--/) {
+                       $options[$#options].="=".$opt;
+               }
+               else {
+                       $options[$#options].=$opt;
+               }
+       }
 }
 
 # Figure out at what point in the sequence to start for each package.