From 391a6c42bc528de0e3ba34874346d290054f517e Mon Sep 17 00:00:00 2001 From: Modestas Vainius Date: Wed, 26 Aug 2009 16:40:45 -0400 Subject: Allow dh addons to pass options to debhelper commands Add dh addons APIs add_command_options()/remove_command_options() that allow addons to add additional options which dh will pass to the specified debhelper commands. Signed-off-by: Modestas Vainius --- dh | 32 ++++++++++++++++++++++++++++++++ doc/PROGRAMMING | 14 ++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/dh b/dh index bdd78c52..f03bf006 100755 --- a/dh +++ b/dh @@ -293,6 +293,9 @@ $sequences{binary} = [@{$sequences{install}}, qw{ }, @b]; $sequences{'binary-arch'} = [@{$sequences{binary}}]; +# Additional command options +my %command_opts; + # sequence addon interface sub _insert { my $offset=shift; @@ -333,6 +336,31 @@ sub add_command { my $sequence=shift; unshift @{$sequences{$sequence}}, $command; } +sub add_command_options { + my $command=shift; + push @{$command_opts{$command}}, @_; +} +sub remove_command_options { + my $command=shift; + if (@_) { + # Remove only specified options + if (my $opts = $command_opts{$command}) { + foreach my $opt (@_) { + if (ref($opt) eq "Regexp") { + $opts = [ grep ! /$opt/, @$opts ]; + } + else { + $opts = [ grep { $_ ne $opt } @$opts ]; + } + } + $command_opts{$command} = $opts; + } + } + else { + # Clear all additional options + delete $command_opts{$command}; + } +} if ($dh{LIST}) { my %addons; @@ -501,6 +529,10 @@ sub run { $command="debian/rules"; @options="override_".$override_command; } + else { + # Pass additional command options if any + unshift @options, @{$command_opts{$command}} if exists $command_opts{$command}; + } # 3 space indent lines the command being run up under the # sequence name after "dh ". diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING index 4be09b1c..211e57ee 100644 --- a/doc/PROGRAMMING +++ b/doc/PROGRAMMING @@ -270,6 +270,20 @@ add_command($new_command, $sequence) Add $new_command to the beginning of the specified sequence. If the sequence does not exist, it will be created. +add_command_options($command, $opt1, $opt2, ...) + Append $opt1, $opt2 etc. to the list of additional options which + dh passes when running the specified $command. These options are + not relayed to debhelper commands called via $command override. + +remove_command_options($command) + Clear all additional $command options previously added with + add_command_options(). + +remove_command_options($command, $opt1, $opt2, ...) + Remove $opt1, $opt2 etc. from the list of additional options which + dh passes when running the specified $command. $optX might be a string + or a regular expresion. + Buildsystem Classes: ------------------- -- cgit v1.2.3 From d64e9b242a1c3c9b35f006eec048a3cf683fc925 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Aug 2009 16:41:53 -0400 Subject: drop regex support from remove_command_options I hope that it will not be needed; indeed I doubt that remove_command_options will be used much, because sequence addons would need to try to do conflicting things to need it. And the interface makes it hard for such conflicting sequence addons to work around the other, since addons can be loaded in either order. So let's not encourage them too much, and if there's a use case later, we can made changes. I haven't applied Modestas's enhanced patch that allows adding an option to all commands because I similarly think it might not be used. If a use case comes along we can add something like that. --- dh | 7 +------ doc/PROGRAMMING | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/dh b/dh index f03bf006..710117ea 100755 --- a/dh +++ b/dh @@ -346,12 +346,7 @@ sub remove_command_options { # Remove only specified options if (my $opts = $command_opts{$command}) { foreach my $opt (@_) { - if (ref($opt) eq "Regexp") { - $opts = [ grep ! /$opt/, @$opts ]; - } - else { - $opts = [ grep { $_ ne $opt } @$opts ]; - } + $opts = [ grep { $_ ne $opt } @$opts ]; } $command_opts{$command} = $opts; } diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING index 211e57ee..5f236ebd 100644 --- a/doc/PROGRAMMING +++ b/doc/PROGRAMMING @@ -281,8 +281,7 @@ remove_command_options($command) remove_command_options($command, $opt1, $opt2, ...) Remove $opt1, $opt2 etc. from the list of additional options which - dh passes when running the specified $command. $optX might be a string - or a regular expresion. + dh passes when running the specified $command. Buildsystem Classes: ------------------- -- cgit v1.2.3 From a384f4d5349b7828f6f92382a873285f4ca520dd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Aug 2009 16:46:33 -0400 Subject: changelog --- debian/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/changelog b/debian/changelog index adb1b2f0..f95108e8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,10 @@ debhelper (7.3.16) UNRELEASED; urgency=low * dh_installdocs: Loosen the Document field parsing, to accept everything doc-base *really* accepts in a doc id (not just what it's documented to accept). Closes: #543499 + * Allow sequence addons to pass options to debhelper commands, + by adding add_command_options and remove_command_options to the interface. + Closes: #543392 + (Modestas Vainius) -- Joey Hess Mon, 24 Aug 2009 12:59:02 -0400 -- cgit v1.2.3 From 1cc05631c07ec51f77b76d886ba035d6c7739fb3 Mon Sep 17 00:00:00 2001 From: Modestas Vainius Date: Wed, 26 Aug 2009 16:49:39 -0400 Subject: Support --destdir option in dh_auto_install This patch adds --destdir option to dh_auto_install which allows to override destdir auto-selection. This basically closes #538201 since the same requested behaviour can be achieved but in a more clean way. Signed-off-by: Modestas Vainius --- dh_auto_install | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/dh_auto_install b/dh_auto_install index b57db839..b4a355f0 100755 --- a/dh_auto_install +++ b/dh_auto_install @@ -9,6 +9,7 @@ dh_auto_install - automatically runs make install or similar use strict; use Debian::Debhelper::Dh_Lib; use Debian::Debhelper::Dh_Buildsystems; +use File::Spec; use Cwd; =head1 SYNOPSIS @@ -25,10 +26,11 @@ if the environment variable is set). If there is a setup.py or Build.PL, it is used. Note that the Ant build system does not support installation, so dh_auto_install will not install files built using Ant. -The files are installed into debian// if there is only one binary -package. In the multiple binary package case, the files are instead -installed into debian/tmp/, and should be moved from there to the -appropriate package build directory using L. +Unless --destdir option is specified, the files are installed into +debian// if there is only one binary package. In the multiple binary +package case, the files are instead installed into debian/tmp/, and should be +moved from there to the appropriate package build directory using +L. DESTDIR is used to tell make where to install the files. If the Makefile was generated by MakeMaker from a Makefile.PL, it will @@ -45,6 +47,12 @@ system selection and control options. =over 4 +=item B<--destdir=>I + +Install files into the specified I. If this option is not specified, +destination directory is determined automatically as described in the +L section. + =item B<--> I Pass "params" to the program that is run. These can be used to supplement @@ -54,17 +62,23 @@ or override the any standard parameters that dh_auto_install passes. =cut -buildsystems_init(); - my $destdir; -my @allpackages=getpackages(); -if (@allpackages > 1) { - $destdir="debian/tmp"; -} -else { - $destdir=tmpdir($dh{MAINPACKAGE}); + +buildsystems_init(options => { + "destdir=s" => \$destdir, +}); + +# If destdir is not specified, determine it automatically +if (!$destdir) { + my @allpackages=getpackages(); + if (@allpackages > 1) { + $destdir="debian/tmp"; + } + else { + $destdir=tmpdir($dh{MAINPACKAGE}); + } } -$destdir=cwd()."/".$destdir; +$destdir = File::Spec->rel2abs($destdir, Cwd::cwd()); buildsystems_do("install", $destdir); -- cgit v1.2.3 From ade85c15914a3bdc2bbeb98d9be76c279e4881fa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Aug 2009 16:50:19 -0400 Subject: cwd is exported --- dh_auto_install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dh_auto_install b/dh_auto_install index b4a355f0..a5d483b1 100755 --- a/dh_auto_install +++ b/dh_auto_install @@ -78,7 +78,7 @@ if (!$destdir) { $destdir=tmpdir($dh{MAINPACKAGE}); } } -$destdir = File::Spec->rel2abs($destdir, Cwd::cwd()); +$destdir = File::Spec->rel2abs($destdir, cwd()); buildsystems_do("install", $destdir); -- cgit v1.2.3 From 055eb0b4ef0efee17b1328fbbf012af4110968d4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Aug 2009 16:52:44 -0400 Subject: changelog --- debian/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/debian/changelog b/debian/changelog index f95108e8..b89db64b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,9 @@ debhelper (7.3.16) UNRELEASED; urgency=low by adding add_command_options and remove_command_options to the interface. Closes: #543392 (Modestas Vainius) + * dh_auto_install: Add a --destdir parameter that can be used to override + the default. Closes: #538201 + (Modestas Vainius) -- Joey Hess Mon, 24 Aug 2009 12:59:02 -0400 -- cgit v1.2.3