~juju-qa/juju-release-tools/packaging-juju2-default

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1

export DH_GOPKG:=github.com/juju/juju
export BUILDPATH := obj-$(DEB_BUILD_GNU_TYPE)
export GOPATH := $(CURDIR)/$(BUILDPATH)
# Ensure installed go binaries, and "golang-1.*-go" are in the PATH.
export PATH:=$(GOPATH)/bin:/usr/lib/go-1.9/bin:/usr/lib/go-1.8/bin:/usr/lib/go-1.6/bin:$(PATH)
export USE_EMBEDDED := true

PKGDIR:=debian/juju
VERSION:=$(shell sed -n 's/^const version = "\(2\.[0-9]\+\)[\.-].*"/\1/p' $(CURDIR)/src/github.com/juju/juju/version/version.go)
ifeq ($(VERSION),)
$(error Invalid version constant in version.go)
endif

DB_DEP = -Vdist:Depends="juju-mongodb (>= 2.4.6)"

%:
	dh $@ --with=golang --buildsystem=golang

COMMON_FLAGS:= -x -v
supported_archs:= amd64 s390x ppc64el arm64

# Ugly workaround for bundled dependencies
# This is inspiried by LXD's packaging
override_dh_auto_configure:
	dh_auto_configure

	# dh-golang's configure has copied the source tree into GOPATH. But
	# because juju 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 src dh-golang has copied onto GOPATH (or
	# when dh-golang tries to run go install github.com/juju/juju/... things
	# get very confused).

	# Move the juju source aside while we do this.
	mv ${GOPATH}/src/github.com/juju/juju/src/github.com/juju/juju ${GOPATH}/juju

	# Clean GOPATH.
	rm -Rf ${GOPATH}/src


	# If we get all dependencies from source, just copy it onto GOPATH.
	cp -R src ${GOPATH}

	# But not the symlink for juju.
	rm -rf ${GOPATH}/src/github.com/juju/juju

ifeq ($(USE_EMBEDDED), false)
	# If not, link depedencies from where the distro package
	# has installed it, as appropriate.
	# Packaged dependencies
	debian/helpers/link-from-installed github.com/bmizerany/pat
	debian/helpers/link-from-installed github.com/coreos/go-systemd
	debian/helpers/link-from-installed launchpad.net/go-dbus
	debian/helpers/link-from-installed gopkg.in/tomb.v2
	debian/helpers/link-from-installed github.com/gorilla/websocket
	debian/helpers/link-from-installed golang.org/x/crypto
	debian/helpers/link-from-installed golang.org/x/net
	debian/helpers/link-from-installed gopkg.in/yaml.v2
endif

	# And put the juju source back again.
	mkdir -p ${GOPATH}/src/github.com/juju/
	mv ${GOPATH}/juju/ ${GOPATH}/src/github.com/juju/juju/

override_dh_auto_build:
	dh_auto_build -- $(COMMON_FLAGS)

# Don't run the tests -- the juju unit tests are too heavyweight to run during
# package build.
override_dh_auto_test:
	:

override_dh_auto_install:
	echo '#!/bin/sh\nexport PATH=/usr/lib/juju-$(VERSION)/bin:"$$PATH"\nexec juju "$$@"' > ${BUILDPATH}/bin/juju-$(VERSION)
	chmod 755 ${BUILDPATH}/bin/juju-$(VERSION)
	mkdir -p ${BUILDPATH}/home
	HOME=${BUILDPATH}/home $(CURDIR)/src/github.com/juju/juju/scripts/generate-docs.py man -o ${BUILDPATH}/juju.1
	dh_install ${BUILDPATH}/bin/juju usr/lib/juju-$(VERSION)/bin
	dh_install ${BUILDPATH}/bin/juju-metadata usr/lib/juju-$(VERSION)/bin
	dh_install ${BUILDPATH}/bin/jujud usr/lib/juju-$(VERSION)/bin
	dh_install ${BUILDPATH}/bin/juju-$(VERSION) usr/bin
	dh_install ${BUILDPATH}/juju.1 usr/lib/juju-$(VERSION)/man/man1
	# Install bash completion scripts
	dh_install src/github.com/juju/juju/etc/bash_completion.d/juju-version \
	           usr/share/bash-completion/completions
	dh_install src/github.com/juju/juju/etc/bash_completion.d/juju \
	           usr/share/bash-completion/completions
	dh_install debian/juju-2.conf usr/lib/sysctl.d

override_dh_link:
	dh_link -pjuju-2.0 usr/bin/juju-$(VERSION) usr/bin/juju
	dh_link -pjuju-2.0 usr/lib/juju-$(VERSION)/man/man1/juju.1.gz usr/share/man/man1/juju.1.gz
	dh_link -pjuju-2.0 usr/lib/juju-$(VERSION)/man/man1/juju.1.gz usr/share/man/man1/juju-$(VERSION).1.gz
	dh_link

override_dh_compress:
	dh_compress usr/lib/juju-$(VERSION)/man/man1/juju.1
	dh_compress

override_dh_auto_clean:
	find . -name "*.pyc" -delete || :
	dh_auto_clean

override_dh_builddeb:
	dh_builddeb -- -Zxz

override_dh_gencontrol:
	dh_gencontrol -- $(DB_DEP)