Package: dh-golang
Version: 1.12
Severity: important
Tags: patch

Building the git-lfs debian package I have found a bug in dh-golang
1.12.  The build depends line for the package
(https://github.com/github/git-lfs) is:

    Build-Depends: debhelper (>= 9), dh-golang, golang-go:native (>= 1.3.0),
    git (>= 1.8.2), ruby-ronn

This causes the following error when building the package:

    dh_golang -O--buildsystem=golang
    Can't call method "get_deps" on an undefined value at /usr/bin/dh_golang
    line 114.
    debian/rules:18: recipe for target 'binary' failed
    make: *** [binary] Error 255
    dpkg-buildpackage: error: debian/rules binary gave error exit status 2

When running dh-golang by hand the error is:

    -e: warning: can't parse dependency golang-go:native (>= 1.3.0)

The error occurs because dh_golang calls deps_parse in Dpkg::Deps which
fails on the "native" architecture.  This happens because that arch is
only allowed on build-depends lines, not depends.  In the manpage for
Dpkg::Deps, one of the flags listed for deps_parse is:

    build_dep (defaults to 0)
        If set to 1, allow build-dep only arch qualifiers, that is
        “:native”.  This should be set whenever working with build-deps.

Setting this flag on the deps_parse command fixes the issue.  Patch is
attached.


-- System Information:
Debian Release: 8.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/16 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages dh-golang depends on:
ii  debhelper     9.20150101
ii  dpkg          1.17.25
ii  libdpkg-perl  1.17.25
ii  perl          5.20.2-3+deb8u1

dh-golang recommends no packages.

dh-golang suggests no packages.

-- no debconf information
diff --git a/script/dh_golang b/script/dh_golang
index fad7998..1eb0922 100755
--- a/script/dh_golang
+++ b/script/dh_golang
@@ -106,7 +106,7 @@ if (defined($build_depends) && $build_depends ne '') {
         die 'Unexpected object (of type ' . blessed($dep) . '), has the Dpkg::Deps API changed?';
     }
 
-    my $deps = deps_parse($build_depends, reduce_restrictions => 1);
+    my $deps = deps_parse($build_depends, reduce_restrictions => 1, build_dep => 1);
     my $golang_deps = join(' ', grep { /^golang-/ }
                                 map { flatten($_) }
                                 $deps->get_deps());

Reply via email to