]> git.donarmstrong.com Git - debhelper.git/blobdiff - Debian/Debhelper/Dh_Getopt.pm
In v8 mode, do not allow directly passing unknown options to debhelper commands....
[debhelper.git] / Debian / Debhelper / Dh_Getopt.pm
index 4df3eed27ae26944d40afe27820e86c516ab36ca..257fe6493c8d6de61600dbf3c0f596837c7f5882 100644 (file)
@@ -70,6 +70,11 @@ sub getoptions {
        my $array=shift;
        my %params=@_;
 
+       if (! exists $params{bundling} || $params{bundling}) {
+               Getopt::Long::config("bundling");
+       }
+
+       my @test;
        my %options=(   
                "v" => \$dh{VERBOSE},
                "verbose" => \$dh{VERBOSE},
@@ -130,14 +135,8 @@ sub getoptions {
                
                "ignore=s" => \&AddIgnore,
 
-               "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);
-                       }
-               },
-
+               "O=s" => sub { push @test, $_[1] },
+             
                (ref $params{options} ? %{$params{options}} : ()) ,
 
                "<>" => \&NonOption,
@@ -159,6 +158,16 @@ sub getoptions {
                $SIG{__WARN__}=$oldwarn;
        }
 
+       foreach my $opt (@test) {
+               # Try to parse an option, and skip it
+               # if it is not known.
+               if (getoptions([$opt], %params,
+                               ignore_unknown_options => 0,
+                               test => 1)) {
+                       getoptions([$opt], %params);
+               }
+       }
+
        return 1 if $params{ignore_unknown_options};
        return $ret;
 }
@@ -179,7 +188,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, %params, ignore_unknown_options => 1);
+               getoptions(\@ARGV_extra, %params);
 
                # Avoid forcing acting on packages specified in
                # DH_INTERNAL_OPTIONS. This way, -p can be specified
@@ -209,8 +218,9 @@ sub parseopts {
 
        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");
+               if (! compat(7)) {
+                       error("unknown option; aborting");
+               }
        }
 
        # Check to see if -V was specified. If so, but no parameters were
@@ -229,7 +239,7 @@ sub parseopts {
                        warning("You asked that all arch in(dep) packages be built, but there are none of that type.");
                        exit(0);
                }
-               push @{$dh{DOPACKAGES}},getpackages();
+               push @{$dh{DOPACKAGES}},getpackages("both");
        }
 
        # Remove excluded packages from the list of packages to act on.
@@ -271,9 +281,4 @@ sub parseopts {
        @ARGV=@{$dh{ARGV}} if exists $dh{ARGV};
 }
 
-sub import {
-       # Enable bundling of short command line options.
-       Getopt::Long::config("bundling");
-}              
-
 1