From e3367a17054a70074c4a225e6073d3743959d05d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 27 Feb 2009 15:11:25 -0500 Subject: dh override targets * dh: debian/rules override targets can change what is run for a specific debhelper command in a sequence. * dh: Redid all the examples to use override targets, since these eliminate all annoying boilerplate and are much easier to understand than the old method. * Remove rules.simple example, there's no need to use explcit targets with dh anymore. (cherry picked from commit 0f3f59fe6058edfda4010dc88bd3b8aa3ae70a6d) Conflicts: Debian/Debhelper/Dh_Getopt.pm Debian/Debhelper/Dh_Lib.pm debian/changelog dh --- Debian/Debhelper/Dh_Getopt.pm | 9 +++++++++ Debian/Debhelper/Dh_Lib.pm | 34 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 17 deletions(-) (limited to 'Debian') diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm index f8e02889..d8019337 100644 --- a/Debian/Debhelper/Dh_Getopt.pm +++ b/Debian/Debhelper/Dh_Getopt.pm @@ -191,6 +191,15 @@ sub parseopts { "<>" => \&NonOption, ); + # DH_INTERNAL_OPTIONS is used to pass additional options from + # dh through an override target to a command. + if (defined $ENV{DH_INTERNAL_OPTIONS}) { + $ENV{DH_INTERNAL_OPTIONS}=~s/^\s+//; + $ENV{DH_INTERNAL_OPTIONS}=~s/\s+$//; + unshift @ARGV, split(/\s+/,$ENV{DH_INTERNAL_OPTIONS}); + } + + my $ret=getoptions(\@ARGV, $options); if (!$ret) { error("unknown option; aborting"); } diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm index 6be25f9d..871adf48 100644 --- a/Debian/Debhelper/Dh_Lib.pm +++ b/Debian/Debhelper/Dh_Lib.pm @@ -31,15 +31,9 @@ sub init { # 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 # 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}) || + (defined $ENV{DH_INTERNAL_OPTIONS} && length $ENV{DH_INTERNAL_OPTIONS}) || + grep /^-/, @ARGV) { eval "use Debian::Debhelper::Dh_Getopt"; error($!) if $@; %dh=Debian::Debhelper::Dh_Getopt::parseopts(); @@ -114,14 +108,20 @@ sub init { my $write_log=1; sub END { if ($? == 0 && $write_log) { - my $cmd=basename($0); - foreach my $package (@{$dh{DOPACKAGES}}) { - my $ext=pkgext($package); - my $log="debian/${ext}debhelper.log"; - open(LOG, ">>", $log) || error("failed to write to ${log}: $!"); - print LOG $cmd."\n"; - close LOG; - } + write_log(basename($0), @{$dh{DOPACKAGES}}); + } +} + +sub write_log { + my $cmd=shift; + my @packages=@_; + + foreach my $package (@packages) { + my $ext=pkgext($package); + my $log="debian/${ext}debhelper.log"; + open(LOG, ">>", $log) || error("failed to write to ${log}: $!"); + print LOG $cmd."\n"; + close LOG; } } -- cgit v1.2.3