]> git.donarmstrong.com Git - debhelper.git/blobdiff - Debian/Debhelper/Dh_Lib.pm
Ignore unknown options in DH_OPTIONS. Debhelper will always ignore such options,...
[debhelper.git] / Debian / Debhelper / Dh_Lib.pm
index badbe87ede4361d8a69b0ed4196a07a4b91a3209..4df64c8748a1b3f98d9abcab5d449eabc905e063 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Library functions for debhelper programs, perl version.
 #
-# Joey Hess, GPL copyright 1997-2000.
+# Joey Hess, GPL copyright 1997-2008.
 
 package Debian::Debhelper::Dh_Lib;
 use strict;
@@ -20,29 +20,17 @@ use vars qw(@ISA @EXPORT %dh);
 my $max_compat=7;
 
 sub init {
-       # If DH_OPTIONS is set, prepend it @ARGV.
-       if (defined($ENV{DH_OPTIONS})) {
-               # Ignore leading/trailing whitespace.
-               $ENV{DH_OPTIONS}=~s/^\s+//;
-               $ENV{DH_OPTIONS}=~s/\s+$//;
-               unshift @ARGV,split(/\s+/,$ENV{DH_OPTIONS});
-       }
+       my %params=@_;
 
-       # Check to see if an argument on the command line starts with a dash.
-       # if so, we need to pass this off to the resource intensive 
+       # Check to see if an option line starts with a dash,
+       # or DH_OPTIONS is set.
+       # If so, we need to pass this off to the resource intensive 
        # Getopt::Long, which I'd prefer to avoid loading at all if possible.
-       my $parseopt=undef;
-       my $arg;
-       foreach $arg (@ARGV) {
-               if ($arg=~m/^-/) {
-                       $parseopt=1;
-                       last;
-               }       
-       }
-       if ($parseopt) {
+       if ((defined $ENV{DH_OPTIONS} && length $ENV{DH_OPTIONS}) ||
+           grep /^-/, @ARGV) {
                eval "use Debian::Debhelper::Dh_Getopt";
-               error($!) if $@;
-               %dh=Debian::Debhelper::Dh_Getopt::parseopts();
+               error($@) if $@;
+               Debian::Debhelper::Dh_Getopt::parseopts($params{options});
        }
 
        # Another way to set excludes.
@@ -117,7 +105,8 @@ sub END {
                my $cmd=basename($0);
                foreach my $package (@{$dh{DOPACKAGES}}) {
                        my $ext=pkgext($package);
-                       open(LOG, ">>", "debian/${ext}debhelper.log") || error("failed to write to log");
+                       my $log="debian/${ext}debhelper.log";
+                       open(LOG, ">>", $log) || error("failed to write to ${log}: $!");
                        print LOG $cmd."\n";
                        close LOG;
                }