]> git.donarmstrong.com Git - debhelper.git/commitdiff
Allow dh addons to pass options to debhelper commands
authorModestas Vainius <modestas@vainius.eu>
Wed, 26 Aug 2009 20:40:45 +0000 (16:40 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Wed, 26 Aug 2009 20:40:45 +0000 (16:40 -0400)
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 <modestas@vainius.eu>
dh
doc/PROGRAMMING

diff --git a/dh b/dh
index bdd78c52591ab68bc94ddc968ded73c2fddecd7f..f03bf006d8179b614f60496364a671b6f20c6d99 100755 (executable)
--- 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 ".
index 4be09b1c67dc7112a7790e6ed39afd6e324c8389..211e57eef9570472a0c32fe8705f4d8a19a5c51f 100644 (file)
@@ -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:
 -------------------