[lxc-devel] [lxd-pkg-ubuntu/dpm-xenial] follow dh-golang's expectations a little more

mwhudson on Github lxc-bot at linuxcontainers.org
Tue Feb 2 02:14:55 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 739 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160202/1c67f3ea/attachment.bin>
-------------- next part --------------
From 766c657a34b1c1d3a11b93aec29c59eb4dddf508 Mon Sep 17 00:00:00 2001
From: Michael Hudson-Doyle <michael.hudson at canonical.com>
Date: Tue, 2 Feb 2016 14:46:39 +1300
Subject: [PATCH 1/2] remove extraneous debugging

Signed-off-by: Michael Hudson-Doyle <michael.hudson at canonical.com>
---
 debian/helpers/link-from-bundled   | 1 -
 debian/helpers/link-from-installed | 1 -
 2 files changed, 2 deletions(-)

diff --git a/debian/helpers/link-from-bundled b/debian/helpers/link-from-bundled
index c97ac2b..a8bf580 100755
--- a/debian/helpers/link-from-bundled
+++ b/debian/helpers/link-from-bundled
@@ -1,4 +1,3 @@
 #!/bin/sh
-set -x
 mkdir -p ${GOPATH}/src/$(dirname $1)
 ln -sT $(realpath dist/src/$1) ${GOPATH}/src/$1
diff --git a/debian/helpers/link-from-installed b/debian/helpers/link-from-installed
index 0276f41..d61b651 100755
--- a/debian/helpers/link-from-installed
+++ b/debian/helpers/link-from-installed
@@ -1,4 +1,3 @@
 #!/bin/sh
-set -x
 mkdir -p ${GOPATH}/src/$(dirname $1)
 ln -sT /usr/share/gocode/src/$1 ${GOPATH}/src/$1

From 0a3d2a7227103eb4f717b351c79368500919776f Mon Sep 17 00:00:00 2001
From: Michael Hudson-Doyle <michael.hudson at canonical.com>
Date: Tue, 2 Feb 2016 15:09:54 +1300
Subject: [PATCH 2/2] follow dh-golang's expectations a little more

dh-golang sets up the GOPATH in the configure stage, not the build stage, so
it feels cleaner to do the fixing up lxd's packaging needs to do immediately
after that. This requires a fix to remove github.com/lxc/lxd/dist, because
dh-golang's build stage runs go install github.com/lxc/lxd/... and that gets
very confused when all the bundled deps are still there!

All this makes building lxd against shared libraries easier.

Signed-off-by: Michael Hudson-Doyle <michael.hudson at canonical.com>
---
 debian/rules | 39 ++++++++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/debian/rules b/debian/rules
index 74970ae..2744f38 100755
--- a/debian/rules
+++ b/debian/rules
@@ -10,27 +10,41 @@ VERSION=$(shell grep "var Version" $(CURDIR)/shared/flex.go | cut -d'"' -f2)
 # temporary build path (see http://golang.org/doc/code.html#GOPATH)
 export DH_GOPKG := github.com/lxc/lxd
 export GOPATH := $(CURDIR)/obj-$(DEB_BUILD_GNU_TYPE)
-export USE_EMBEDDED := false
+export USE_EMBEDDED := true
 
 %:
 	dh $@ --with systemd --buildsystem=golang --with=golang
 
 # Ugly workaround for bundled dependencies
-override_dh_auto_build:
-	# Get a clean GOPATH
+override_dh_auto_configure:
+	dh_auto_configure
+
+	# dh-golang's configure has copied the source tree into GOPATH. But
+	# because lxd gets some dependencies from the archive and some from
+	# the copies bundled in dist, we have to unpick a bunch of what it has
+	# done and set it up again.
+
+	# Remove the extra copy of dist dh-golang has copied onto GOPATH (or
+	# when dh-golang tries to run go install github.com/lxc/lxd/... things
+	# get very confused).
+	rm -Rf ${GOPATH}/src/github.com/lxc/lxd/dist
+
+	# Move the lxd source aside while we do this.
 	mv ${GOPATH}/src/github.com/lxc/lxd ${GOPATH}/lxd.tmp
+
+	# Clean GOPATH.
 	rm -Rf ${GOPATH}/src
 
 ifeq ($(USE_EMBEDDED), true)
+	# If we get all dependencis from dist, just copy it onto GOPATH.
 	cp -R dist/src ${GOPATH}
-	rm ${GOPATH}/src/github.com/lxc/lxd
-endif
 
-	# Setup the build environment
-	mkdir -p ${GOPATH}/src/github.com/lxc/
-	mv ${GOPATH}/lxd.tmp ${GOPATH}/src/github.com/lxc/lxd
+	# But not the symlink for lxd.
+	rm -f ${GOPATH}/src/github.com/lxc/lxd
+else
+	# If not, link depedencies from dist or from where the distro package
+	# has installed it, as appropriate.
 
-ifeq ($(USE_EMBEDDED), false)
 	# Packaged dependencies
 	debian/helpers/link-from-installed github.com/coreos/go-systemd
 	debian/helpers/link-from-installed github.com/dustinkirkland/golang-petname
@@ -60,10 +74,9 @@ ifeq ($(USE_EMBEDDED), false)
 	debian/helpers/link-from-bundled github.com/gosexy/gettext
 endif
 
-	go install -v github.com/lxc/lxd/lxc
-	go install -v github.com/lxc/lxd/lxd
-	go install -v github.com/lxc/lxd/fuidshift
-	go install -v github.com/lxc/lxd/lxd-bridge/lxd-bridge-proxy
+	# And put the lxd source back again.
+	mkdir -p ${GOPATH}/src/github.com/lxc/
+	mv ${GOPATH}/lxd.tmp ${GOPATH}/src/github.com/lxc/lxd
 
 override_dh_install:
 	# Install the manpages


More information about the lxc-devel mailing list