~mwhudson/ubuntu/xenial/juju-core/mwhudson

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
#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# NOTE: debian/gocode/src will contain symlinks to system provided
#       dev packages, which will be used over those in the upstream
#       juju-core codebase.

export GOPATH:=$(CURDIR)/debian/gocode:$(CURDIR)
export PATH:=$(CURDIR)/bin:$(PATH)

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

ifeq ($(shell lsb_release -cs | sed -r 's/saucy|precise/old/'),old)
	DB_DEP = -Vdist:Depends="mongodb-server (>= 2.4.6)"
else
	DB_DEP = -Vdist:Depends="juju-mongodb (>= 2.4.6)"
endif

%:
	dh $@ --with=golang

COMMON_FLAGS:= -v
golang_archs:= amd64 i386 armhf s390x ppc64el arm64
ifeq (,$(filter $(DEB_HOST_ARCH), $(golang_archs)))
# NOTE(james-page) statically link libgo for the jujud binary for gccgo
# this allows the binary to be re-cut for upstream tool distribution and
# mimics the behaviour of the golang gc compiler.
JUJUD_FLAGS:= -gccgoflags -static-libgo
endif

# NOTE: ensure /usr/share/gocode is use in preference to any
#       embedded source for dependencies.
override_dh_auto_configure:
	dh_auto_configure
	mkdir -p debian/gocode/src
	ln -s /usr/share/gocode/src/* debian/gocode/src

override_dh_auto_install:
	go install $(COMMON_FLAGS) github.com/juju/juju/cmd/juju
	go install $(COMMON_FLAGS) github.com/juju/juju/cmd/plugins/juju-metadata
	go install $(COMMON_FLAGS) github.com/juju/juju/cmd/plugins/juju-upgrade-mongo
	go install $(COMMON_FLAGS) $(JUJUD_FLAGS) github.com/juju/juju/cmd/jujud
	echo '#!/bin/sh\nexport PATH=/usr/lib/juju-$(VERSION)/bin:"$$PATH"\nexec juju "$$@"' > bin/juju-$(VERSION)
	chmod 755 bin/juju-$(VERSION)
	mkdir -p debian/home
	HOME=debian/home $(CURDIR)/src/github.com/juju/juju/scripts/generate-docs.py man -o juju.1
	dh_install bin/juju usr/lib/juju-$(VERSION)/bin
	dh_install bin/juju-metadata usr/lib/juju-$(VERSION)/bin
	dh_install bin/juju-upgrade-mongo usr/lib/juju-$(VERSION)/bin
	dh_install bin/jujud usr/lib/juju-$(VERSION)/bin
	dh_install bin/juju-$(VERSION) usr/bin
	dh_install juju.1 usr/lib/juju-$(VERSION)/man/man1
	dh_install src/github.com/juju/juju/etc/bash_completion.d/juju2 \
	           usr/share/bash-completion/completions
	dh_auto_install

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-2.0.1.gz
	dh_link

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

override_dh_auto_clean:
	rm -rf bin juju.1
	rm -rf pkg bin debian/home debian/gocode
	find . -name "*.pyc" -delete || :
	dh_auto_clean

# Don't strip golang compiled binaries as this does
# not function correctly
override_dh_strip:
	:

override_dh_builddeb:
	dh_builddeb -- -Zxz

override_dh_gencontrol:
	dh_gencontrol -- $(DB_DEP)