Package: dpkg-dev
Version: 1.19.7
Severity: normal
Tags: patch

Dear Maintainer,

[tl;dr: dpkg-buildpackage --hook-init=foo=bar errors out; patch attached.]

   * What led up to the situation?

I was trying to build a package in a chroot and inject some additional
flags into CFLAGS.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

I read the pdebuild(1) and dpkg-buildflags(1) manual pages and ran the
following command:

    % pdebuild -- --debbuildopts "--hook-init='echo APPEND CFLAGS -std=c89 > 
/etc/dpkg/buildflags.conf'"

   * What was the outcome of this action?

[[[
I: Building the package
I: Running cd /build/zsh-syntax-highlighting-0.6.0/ && env 
PATH="/usr/sbin:/usr/bin:/sbin:/bin" HOME="/nonexistent" dpkg-buildpackage -us 
-uc --source-option=--extend-diff-ignore=^tags$ --hook-init='echo APPEND CFLAGS 
-std=c89 > /etc/dpkg/buildflags.conf' -rfakeroot
dpkg-buildpackage: error: unknown hook name init=echo APPEND CFLAGS -std
]]]

(zsh-syntax-highlighting is just a random package that doesn't have any
source files in C; the error should be repeatable with any package.)

   * What outcome did you expect instead?

I expected the string «--hook-init='echo APPEND CFLAGS -std=c89 > 
/etc/dpkg/buildflags.conf'»
in argv to be taken as creating an «init» hook whose value is the shell
command «echo APPEND CFLAGS -std=c89 > /etc/dpkg/buildflags.conf».

I believe the following patch (against current git) should do the trick:

[[[
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index 2c49738b5..1332ca716 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -238,7 +238,7 @@ while (@ARGV) {
        $check_command = $1;
     } elsif (/^--check-option=(.*)$/) {
        push @check_opts, $1;
-    } elsif (/^--hook-(.+)=(.*)$/) {
+    } elsif (/^--hook-(.+?)=(.*)$/) {
        my ($hook_name, $hook_cmd) = ($1, $2);
        usageerr(g_('unknown hook name %s'), $hook_name)
            if not exists $hook{$hook_name};
]]]

Cheers,

Daniel

Reply via email to