Control: tags -1 patch

On Sun, Sep 01, 2013 at 12:46:12PM +0200, Vincent Bernat wrote:
> Package: dh-golang
> Version: 1.1
> Severity: normal
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Hi!
> 
> I have a package (log4go, https://code.google.com/p/log4go/) which
> contains an "example" directory. When building with dh-golang, it
> tries to build it as a module and fails with an error:
> 
> cd 
> /tmp/buildd/golang-log4go-0.0~hg48/obj-x86_64-linux-gnu/src/code.google.com/p/log4go/examples
> /usr/lib/go/pkg/tool/linux_amd64/6g -o 
> $WORK/code.google.com/p/log4go/examples/_obj/_go_.6 -p 
> code.google.com/p/log4go/examples -complete -D 
> _/tmp/buildd/golang-log4go-0.0~hg48/obj-x86_64-linux-gnu/src/code.google.com/p/log4go/examples
>  -I $WORK -I 
> /tmp/buildd/golang-log4go-0.0~hg48/obj-x86_64-linux-gnu/pkg/linux_amd64 
> ./ConsoleLogWriter_Manual.go ./FileLogWriter_Manual.go 
> ./SimpleNetLogServer.go ./SocketLogWriter_Manual.go 
> ./XMLConfigurationExample.go
> # code.google.com/p/log4go/examples
> src/code.google.com/p/log4go/examples/FileLogWriter_Manual.go:17: main 
> redeclared in this block
>         previous declaration at 
> src/code.google.com/p/log4go/examples/ConsoleLogWriter_Manual.go:9
> src/code.google.com/p/log4go/examples/SimpleNetLogServer.go:21: main 
> redeclared in this block
>         previous declaration at 
> src/code.google.com/p/log4go/examples/FileLogWriter_Manual.go:17
> src/code.google.com/p/log4go/examples/SimpleNetLogServer.go:25: not enough 
> arguments in call to net.ResolveUDPAddr
> src/code.google.com/p/log4go/examples/SocketLogWriter_Manual.go:9: main 
> redeclared in this block
>         previous declaration at 
> src/code.google.com/p/log4go/examples/SimpleNetLogServer.go:21
> src/code.google.com/p/log4go/examples/XMLConfigurationExample.go:5: main 
> redeclared in this block
>         previous declaration at 
> src/code.google.com/p/log4go/examples/SocketLogWriter_Manual.go:9
> dh_auto_build: go install -x -v code.google.com/p/log4go/... returned exit 
> code 2
> make: *** [build] Error 2
> dpkg-buildpackage: error: debian/rules build gave error exit status 2
> 
> Looking at how dh-golang works, I see it asks to build
> code/google/com/p/log4go/... I am unsure of the correct way to handle
> this. Either this should not be the default or this should be
> configurable or maybe upstream should do something to declare the
> directory as not a module?

I hit this problem as well in a package I'm working on, so I wrote a patch for
dh-golang that implements the "DH_GOLANG_NO_RECURSE" option which disables
recursing into sub-directories when "go build" and "go test" are run.

I already tested this on both my package and golang-log4go and it seems to work
fine, so maybe this can be applied to the dh-golang package. See attached patch.

Cheers
From 6c3e113c46790988dadf5970f1a0af55b8faf011 Mon Sep 17 00:00:00 2001
From: Alessandro Ghedini <[email protected]>
Date: Mon, 21 Jul 2014 17:07:11 +0200
Subject: [PATCH] Implement DH_GOLANG_NO_RECURSE option

Closes: #721496
---
 lib/Debian/Debhelper/Buildsystem/golang.pm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/Debian/Debhelper/Buildsystem/golang.pm b/lib/Debian/Debhelper/Buildsystem/golang.pm
index b34a5f2..7eafb07 100644
--- a/lib/Debian/Debhelper/Buildsystem/golang.pm
+++ b/lib/Debian/Debhelper/Buildsystem/golang.pm
@@ -111,16 +111,24 @@ sub configure {
 
 sub build {
     my $this = shift;
+    my $no_recurse = (exists($ENV{DH_GOLANG_NO_RECURSE}) &&
+                   $ENV{DH_GOLANG_NO_RECURSE} == 1);
+
+    my $pkg = $no_recurse ? "$ENV{DH_GOPKG}" : "$ENV{DH_GOPKG}/...";
 
     $ENV{GOPATH} = $this->{cwd} . '/' . $this->get_builddir();
-    $this->doit_in_builddir("go", "install", "-v", @_, "$ENV{DH_GOPKG}/...");
+    $this->doit_in_builddir("go", "install", "-v", @_, $pkg);
 }
 
 sub test {
     my $this = shift;
+    my $no_recurse = (exists($ENV{DH_GOLANG_NO_RECURSE}) &&
+                   $ENV{DH_GOLANG_NO_RECURSE} == 1);
+
+    my $pkg = $no_recurse ? "$ENV{DH_GOPKG}" : "$ENV{DH_GOPKG}/...";
 
     $ENV{GOPATH} = $this->{cwd} . '/' . $this->get_builddir();
-    $this->doit_in_builddir("go", "test", "-v", @_, "$ENV{DH_GOPKG}/...");
+    $this->doit_in_builddir("go", "test", "-v", @_, $pkg);
 }
 
 sub install {
-- 
2.0.1

Attachment: signature.asc
Description: Digital signature

Reply via email to