]> git.donarmstrong.com Git - debhelper.git/commitdiff
Fix warning about unknown options passed to commands in override targets.
authorJoey Hess <joey@gnu.kitenet.net>
Mon, 4 Jan 2010 21:06:08 +0000 (16:06 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Mon, 4 Jan 2010 21:06:08 +0000 (16:06 -0500)
dh used DH_OVERRIDE_UNKNOWN_OPTIONS, which was too broad as it affected
commands run via override targets and caused there to be no warning about
unknown options.

Now unknown options are only ignored when parsing DH_INTERNAL_OPTIONS and
dh's own options.

Debian/Debhelper/Dh_Getopt.pm
Debian/Debhelper/Dh_Lib.pm
debian/changelog
dh

index edb3be764edf114493efd5f15a213fdcc0b73838..0d0210720c57e36b60f3c78cec9584fcd52902ed 100644 (file)
@@ -68,10 +68,11 @@ sub NonOption {
 
 sub getoptions {
        my $array=shift;
-       my %options=%{shift()} if ref $_[0];
+       my %params=@_;
+       my %options=%{$params{options}} if ref $params{options};
        
        my $oldwarn;
-       if ($ENV{DH_IGNORE_UNKNOWN_OPTIONS}) {
+       if ($params{ignore_unknown_options}) {
                $oldwarn=$SIG{__WARN__};
                $SIG{__WARN__}=sub {};
        }
@@ -141,7 +142,7 @@ sub getoptions {
                "<>" => \&NonOption,
        );
 
-       if ($ENV{DH_IGNORE_UNKNOWN_OPTIONS}) {
+       if ($params{ignore_unknown_options}) {
                $SIG{__WARN__}=$oldwarn;
                return 1;
        }
@@ -158,7 +159,7 @@ sub split_options_string {
 
 # Parse options and set %dh values.
 sub parseopts {
-       my $options=shift;
+       my %params=@_;
        
        my @ARGV_extra;
 
@@ -166,7 +167,7 @@ sub parseopts {
        # dh through an override target to a command.
        if (defined $ENV{DH_INTERNAL_OPTIONS}) {
                @ARGV_extra=split(/\x1e/, $ENV{DH_INTERNAL_OPTIONS});
-               getoptions(\@ARGV_extra, $options);
+               getoptions(\@ARGV_extra, %params, ignore_unknown_options => 1);
 
                # Avoid forcing acting on packages specified in
                # DH_INTERNAL_OPTIONS. This way, -p can be specified
@@ -185,18 +186,16 @@ sub parseopts {
                delete $dh{DOARCH};
        }
        
-       # DH_OPTIONS can contain additional options
-       # to be parsed like @ARGV, but with unknown options
-       # skipped.
+       # DH_OPTIONS can contain additional options to be parsed like @ARGV
        if (defined $ENV{DH_OPTIONS}) {
                @ARGV_extra=split_options_string($ENV{DH_OPTIONS});
-               my $ret=getoptions(\@ARGV_extra, $options);
+               my $ret=getoptions(\@ARGV_extra, %params);
                if (!$ret) {
                        warning("warning: ignored unknown options in DH_OPTIONS");
                }
        }
 
-       my $ret=getoptions(\@ARGV, $options);
+       my $ret=getoptions(\@ARGV, %params);
        if (!$ret) {
                warning("warning: unknown options will be a fatal error in a future debhelper release");
                #error("unknown option; aborting");
index a4e357095da2b2afe16d83df1125dd0bdc7e2b5e..f37ff5188699c09f938a8d365b4ea7f4ce5d87fa 100644 (file)
@@ -33,7 +33,7 @@ sub init {
            grep /^-/, @ARGV) {
                eval "use Debian::Debhelper::Dh_Getopt";
                error($@) if $@;
-               Debian::Debhelper::Dh_Getopt::parseopts($params{options});
+               Debian::Debhelper::Dh_Getopt::parseopts(%params);
        }
 
        # Another way to set excludes.
index bb8563cc48826e97c773a6e54ed42ed79b463f79..a3f1fbcf8a0ae418e9e6a2ed946cd1dc0dacafe1 100644 (file)
@@ -3,6 +3,7 @@ debhelper (7.4.12) UNRELEASED; urgency=low
   * dh_bugfiles: Doc typo. Closes: #563269
   * 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.
 
  -- Joey Hess <joeyh@debian.org>  Fri, 01 Jan 2010 13:00:22 -0500
 
diff --git a/dh b/dh
index c90cf0e286752c72288edc86863bf58fa0c8da2d..96a6b84af474eb84fa36ebe913fd54c8e9fdf0a4 100755 (executable)
--- a/dh
+++ b/dh
@@ -220,29 +220,29 @@ my @ARGV_orig=@ARGV;
 # (and comes first so python-central loads later and can disable it).
 unshift @ARGV, "--with=python-support";
                
-# Disable complaints about unknown options for both dh and the commands
-# it runs. This is done because dh accepts and passes on options that may
-# be specific to only some debhelper commands.
-$ENV{DH_IGNORE_UNKNOWN_OPTIONS}=1;
-
 init(options => {
-       "until=s" => \$dh{UNTIL},
-       "after=s" => \$dh{AFTER},
-       "before=s" => \$dh{BEFORE},
-       "remaining" => \$dh{REMAINING},
-       "with=s" => sub {
-               my ($option,$value)=@_;
-               push @{$dh{WITH}},split(",", $value);
-       },
-       "without=s" => sub {
-               my ($option,$value)=@_;
-               @{$dh{WITH}} = grep { $_ ne $value } @{$dh{WITH}};
+               "until=s" => \$dh{UNTIL},
+               "after=s" => \$dh{AFTER},
+               "before=s" => \$dh{BEFORE},
+               "remaining" => \$dh{REMAINING},
+               "with=s" => sub {
+                       my ($option,$value)=@_;
+                       push @{$dh{WITH}},split(",", $value);
+               },
+               "without=s" => sub {
+                       my ($option,$value)=@_;
+                       @{$dh{WITH}} = grep { $_ ne $value } @{$dh{WITH}};
+               },
+               "l" => \$dh{LIST},
+               "list" => \$dh{LIST},
        },
-       "l" => \$dh{LIST},
-       "list" => \$dh{LIST},
-});
+       # Disable complaints about unknown options; they are passed on the
+       # debhelper commands.
+       ignore_unknown_options => 1,
+);
 inhibit_log();
 
+
 # If make is using a jobserver, but it is not available
 # to this process, clean out MAKEFLAGS. This avoids
 # ugly warnings when calling make.