~juju-qa/ubuntu/xenial/juju/juju-1.25.4

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
#!/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-1.25
VERSION:=$(shell sed -n 's/^const version = "\(1\.[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/xenial/new/'),new)
	DB_DEP = -Vdist:Depends="juju-mongodb2.6"
else
	DB_DEP = -Vdist:Depends="juju-mongodb (>= 2.4.6)"
endif

%:
	dh $@ --with=golang

COMMON_FLAGS:= -x -v -work
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:
	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-restore
	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-1
	chmod 755 bin/juju-1
	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-restore usr/lib/juju-$(VERSION)/bin
	dh_install src/github.com/juju/juju/cmd/plugins/juju-backup/juju-backup usr/lib/juju-$(VERSION)/bin
	dh_install bin/jujud usr/lib/juju-$(VERSION)/bin
	dh_install bin/juju-1 usr/bin
	dh_install juju.1 usr/lib/juju-$(VERSION)/man/man1
	# TODO: Add back bash completion for juju-1 name only.
	dh_auto_install

override_dh_link:
	dh_link -pjuju-1 usr/lib/juju-$(VERSION)/man/man1/juju.1.gz /usr/share/man/man1/juju-1.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)