Package: debhelper
Version: 7.3.15
Severity: wishlist
Tags: patch

Hello,

the attached patch adds dh addons add_command_arguments() API that allows
addons to specify additional arguments which dh will run the specified
debhelper command(s) with.

I think this could be useful to develop dh addons that would serve as
templates. For example, a large group of packages (e.g. KDE) needs to run
dh_compress -Xfoobar rather than dh_compress. Currently, there is no way
(neither via make includes, nor dh addons unless I'm missing something) to
provide the following functionality:

1) Run `dh_compress -Xfoobar` by default.
2) Clearly allow to override this in debian/rules if needed.

If this was done via addons, 1) would be configured via addon and 2) would be
possible via usual dh overrides.

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (101, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.31-rc6-amd64 (SMP w/1 CPU core)
Locale: LANG=lt_LT.UTF-8, LC_CTYPE=lt_LT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages debhelper depends on:
ii  binutils              2.19.51.20090805-1 The GNU assembler, linker and bina
ii  dpkg-dev              1.15.3.1           Debian package development tools
ii  file                  5.03-1             Determines file type using "magic"
ii  html2text             1.3.2a-14          advanced HTML to text converter
ii  man-db                2.5.5-3            on-line manual pager
ii  perl                  5.10.0-25          Larry Wall's Practical Extraction 
ii  perl-base             5.10.0-25          minimal Perl system
ii  po-debconf            1.0.16             tool for managing templates file t

debhelper recommends no packages.

Versions of packages debhelper suggests:
pn  dh-make                       <none>     (no description available)

-- no debconf information
>From ef45d89b203e8c3c02f8c809c716bd3349552952 Mon Sep 17 00:00:00 2001
From: Modestas Vainius <[email protected]>
Date: Mon, 24 Aug 2009 21:08:54 +0300
Subject: [PATCH] Allow dh addons to pass arguments to debhelper commands

Add dh addons add_command_arguments() API that allows addons to specify
additional arguments which dh will run the specified debhelper command(s) with.

Signed-off-by: Modestas Vainius <[email protected]>
---
 dh              |   18 +++++++++++++++++-
 doc/PROGRAMMING |    5 +++++
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/dh b/dh
index bdd78c5..9cb7751 100755
--- a/dh
+++ b/dh
@@ -293,6 +293,9 @@ $sequences{binary} = [...@{$sequences{install}}, qw{
 }, @b];
 $sequences{'binary-arch'} = [...@{$sequences{binary}}];
 
+# Command arguments
+my %command_args;
+
 # sequence addon interface
 sub _insert {
        my $offset=shift;
@@ -333,6 +336,16 @@ sub add_command {
        my $sequence=shift;
        unshift @{$sequences{$sequence}}, $command;
 }
+sub add_command_arguments {
+       my $command=shift;
+       if (@_) {
+               push @{$command_args{$command}}, @_;
+       }
+       else {
+               # Do not pass any additional arguments
+               delete $command_args{$command};
+       }
+}
 
 if ($dh{LIST}) {
        my %addons;
@@ -485,7 +498,10 @@ sub run {
        my @packag...@{shift()};
        my @exclu...@{shift()};
        my @optio...@_;
-       
+
+       # Default command arguments if any
+       unshift @options, @{$command_args{$command}} if exists 
$command_args{$command};
+
        # If some packages are excluded, add flags
        # to prevent them from being acted on.
        push @options, map { "-N$_" } @exclude;
diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING
index 4be09b1..acbfe5f 100644
--- a/doc/PROGRAMMING
+++ b/doc/PROGRAMMING
@@ -270,6 +270,11 @@ 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_arguments($command, $arg1, $arg2, ...)
+       Append $arg1, $arg2 etc. to the list of additional arguments which
+       dh uses to run the $command with. If no arguments are specified,
+       additional arguments added previously are cleared for the $command.
+
 Buildsystem Classes:
 -------------------
 
-- 
1.6.3.3

Reply via email to