rules 7.41 KB
Newer Older
Paul Tagliamonte's avatar
Paul Tagliamonte committed
1 2 3
#!/usr/bin/make -f
# -*- makefile -*-

4 5 6 7 8 9
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export HOME=$(CURDIR)/debian/tmp

#export DH_GOLANG_BUILDPKG := github.com/docker/docker github.com/docker/cli
Dmitry Smirnov's avatar
Dmitry Smirnov committed
10
export DH_GOLANG_GO_GENERATE := 1
11
export DH_GOLANG_INSTALL_ALL := 1
12
export DH_GOLANG_INSTALL_EXTRA := testdata/
13
export DH_GOLANG_EXCLUDES := \
14 15
    integration-cli \
    vendor
16

17
# temporary build path (see http://golang.org/doc/code.html#GOPATH)
Tianon Gravi's avatar
Tianon Gravi committed
18
OUR_GOPATH := $(CURDIR)/.gopath
19
export GOPATH := $(OUR_GOPATH)
Tianon Gravi's avatar
Tianon Gravi committed
20

21
export DOCKER_VERSION := $(shell cat VERSION)
22
export DOCKER_GITCOMMIT := $(shell ./debian/helpers/gitcommit.sh $(DOCKER_VERSION))
23 24 25 26
ifndef DOCKER_GITCOMMIT
  $(error Missing DOCKER_GITCOMMIT - see debian/upstream-version-gitcommits)
endif

27
export BUILDTIME := $(shell dpkg-parsechangelog -SDate)
Tianon Gravi's avatar
Tianon Gravi committed
28

29 30 31
# have "make.sh" keep "bundle/$(DOCKER_VERSION)" around between runs (we clean it up appropriately ourselves)
export KEEPBUNDLE := 1

Dmitry Smirnov's avatar
Dmitry Smirnov committed
32 33
## AppArmor can be optionally used in Debian and is there by default in Ubuntu,
## so we need support for it compiled into our binary same story with SELinux.
34
export DOCKER_BUILDTAGS := apparmor seccomp selinux ambient
35

36 37
## prefer Go 1.7 explicitly if it's available (golang-1.7-go)
#export PATH := /usr/lib/go-1.7/bin:$(PATH)
Paul Tagliamonte's avatar
Paul Tagliamonte committed
38

39
APPARMOR_RECOMMENDS := $(shell dpkg-vendor --is Ubuntu && echo apparmor)
40 41
BUILT_LIBC := $(shell dpkg-query -f '$${source:Package} (= $${source:Version})' -W libc-dev-bin)

42 43
%:
	dh $@ --buildsystem=golang --with=bash-completion,golang --builddirectory=.gopath
44

45 46
override_dh_clean:
	dh_clean
47
	$(RM) -v -r autogen bundles man/man*/
48 49
#	-find . -type f -name '*.pb.go' -delete -printf 'removed %p\n'            ## delete generated .pb.go files
	## Remove Files-Excluded (when built from checkout or non-DFSG tarball):
50
	$(RM) -rv `perl -0nE 'say grep { $$_=q{ */}.$$_ } split(/\s+/,$$1) if m{^Files\-Excluded:\s*(.*?)(?:\n\n|^Files|^Comment:)}sm;' debian/copyright`
51
	-find */vendor -mindepth 1 -type d -empty -delete -printf 'removed %p\n'
52

53
override_dh_auto_configure:
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
## dh_auto_configure symlinks dirs from "/usr/share/gocode/src" into
## $(OUR_GOPATH) unless folders already exist there in which case files
## are copied. Pre-making directories allows us to use debhelper to
## create proper GOPATH source tree yet have certain directories writable
## even if they are provided by already installed package.
	mkdir -pv $(OUR_GOPATH)/src/github.com/docker/cli
	mkdir -pv $(OUR_GOPATH)/src/github.com/docker/docker
	mkdir -pv $(OUR_GOPATH)/src/github.com/docker/libnetwork
	mkdir -pv $(OUR_GOPATH)/src/github.com/docker/swarmkit
	mkdir -pv $(OUR_GOPATH)/src/github.com/docker/distribution
	mkdir -pv $(OUR_GOPATH)/src/github.com/docker/go-events
	mkdir -pv $(OUR_GOPATH)/src/github.com/docker/go-metrics
	mkdir -pv $(OUR_GOPATH)/src/github.com/containerd/containerd

#	## Prepare builddirectory but throw away sourcedirectory.
	DH_GOPKG="__IGNORE__" dh_auto_configure

## Each package must be removed from working tree first, in case some
## of the packages that we are going to build are already installed.
## This is also useful for building in unclean environment.
##
## This is _necessary_ to avoid merging packages that we build with
## pre-installed packages. See #827226 for details.
## Debhelper knows only about "main" DH_GOPKG package but we build several
## and we have to ensure that build tree is properly prepared.
	$(RM) -r              $(OUR_GOPATH)/src/github.com/docker/cli
	cp -ra  cli           $(OUR_GOPATH)/src/github.com/docker/cli

	$(RM) -r              $(OUR_GOPATH)/src/github.com/docker/docker
	cp -ra  engine        $(OUR_GOPATH)/src/github.com/docker/docker

	$(RM) -r              $(OUR_GOPATH)/src/github.com/docker/libnetwork
	cp -ra  libnetwork    $(OUR_GOPATH)/src/github.com/docker/libnetwork

	$(RM) -r              $(OUR_GOPATH)/src/github.com/docker/swarmkit
	cp -ra  swarmkit      $(OUR_GOPATH)/src/github.com/docker/swarmkit

	$(RM) -r              $(OUR_GOPATH)/src/github.com/docker/distribution
	cp -ra  distribution  $(OUR_GOPATH)/src/github.com/docker/distribution

	$(RM) -r              $(OUR_GOPATH)/src/github.com/docker/go-events
	cp -ra  go-events     $(OUR_GOPATH)/src/github.com/docker/go-events

	$(RM) -r              $(OUR_GOPATH)/src/github.com/docker/go-metrics
	cp -ra  go-metrics    $(OUR_GOPATH)/src/github.com/docker/go-metrics

	$(RM) -r              $(OUR_GOPATH)/src/github.com/containerd/containerd
	cp -ra  containerd    $(OUR_GOPATH)/src/github.com/containerd/containerd

#	cp -ra  containerd/vendor/github.com/containerd/continuity    $(OUR_GOPATH)/src/github.com/containerd/
#	cp -ra  engine/vendor/github.com/docker/distribution          $(OUR_GOPATH)/src/github.com/docker/
105

106 107 108
override_dh_auto_build-indep:
	# noop

109
override_dh_auto_build-arch:
110
## order is important:
111 112 113 114 115 116 117 118 119 120 121

##	## FIXME: DH_GOLANG_BUILDPKG --> DH_GOPKG
	DH_GOLANG_BUILDPKG="github.com/docker/distribution"    dh_auto_build -v

	DH_GOPKG="github.com/docker/libnetwork"                dh_auto_build -v

##	## FIXME: DH_GOLANG_BUILDPKG --> DH_GOPKG
	DH_GOLANG_BUILDPKG="github.com/docker/swarmkit"        dh_auto_build -v

	export DH_GOPKG="github.com/containerd/containerd" ;\
        export REV="`grep $${DH_GOPKG} engine/vendor.conf | head -1 | awk '{print $$2}'`" ;\
122
        dh_auto_build -v -- -tags "$(DOCKER_BUILDTAGS)" \
123 124 125 126
          -ldflags "-X $${DH_GOPKG}/version.Version=$(DOCKER_VERSION) -X $${DH_GOPKG}/version.Revision=$${REV}"

	DH_GOPKG="github.com/docker/go-events"                 dh_auto_build -v
	DH_GOPKG="github.com/docker/go-metrics"                dh_auto_build -v
127
	
128 129
##	build ("cd" first to ensure we build from within GOPATH)
	cd '$(OUR_GOPATH)/src/github.com/docker/docker' \
130
        && VERSION=$(DOCKER_VERSION) ./hack/make.sh dynbinary
131
	
132 133 134
	cd '$(OUR_GOPATH)/src/github.com/docker/cli' \
        && DISABLE_WARN_OUTSIDE_CONTAINER=1 LDFLAGS='' \
           $(MAKE) VERSION=$(DOCKER_VERSION) GITCOMMIT=$(DOCKER_GITCOMMIT) dynbinary manpages
Tianon Gravi's avatar
Tianon Gravi committed
135
	
136 137
#	# compile man pages
#	./man/md2man-all.sh -q
Paul Tagliamonte's avatar
Paul Tagliamonte committed
138

139
override_dh_auto_test-indep:
140 141 142
	DH_GOLANG_EXCLUDES="integration-cli integration test/integration" \
        dh_auto_test -v --max-parallel=4 -- -short

143 144 145 146
override_dh_auto_test-arch:
###     [[[ DO NOT DISABLE TESTS ]]]  [[[ DO *NOT* DISABLE TESTS ]]]
	DH_GOLANG_EXCLUDES="integration-cli integration test/integration" \
        dh_auto_test -v --max-parallel=4 -- -short
147 148 149 150 151 152 153 154 155 156
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	## Test engine:
#	cd '$(OUR_GOPATH)/src/$(DH_GOPKG)' \
#        && TESTFLAGS='-test.short' ./hack/make.sh test-unit
	cd $(OUR_GOPATH)/src/github.com/docker/docker \
        && TESTFLAGS='-test.short' ./hack/test/unit

	## Test CLI:
	cd $(OUR_GOPATH)/src/github.com/docker/cli \
        && DISABLE_WARN_OUTSIDE_CONTAINER=1 $(MAKE) test-unit
157 158

	.gopath/bin/containerd -version
159
endif
Paul Tagliamonte's avatar
Paul Tagliamonte committed
160

161 162 163 164
override_dh_install:
	## Do not install extra license files:
	dh_install -XLICENSE

165
override_dh_auto_install:
166 167
	## skip dh_auto_install to stop dh_golang trying to copy bits
	## for /usr/share/gocode (we use dh_install/dh-exec for that)
168

169
override_dh_installinit:
170
	dh_installinit -v --name=docker --no-stop-on-upgrade --no-restart-after-upgrade
171 172

override_dh_installsystemd:
173
	dh_installsystemd -v --name=docker --no-stop-on-upgrade --no-restart-after-upgrade
Paul Tagliamonte's avatar
Paul Tagliamonte committed
174

175 176
override_dh_installudev:
	# use priority z80 to match the upstream priority of 80
Dmitry Smirnov's avatar
Dmitry Smirnov committed
177
	dh_installudev -v --name=docker --priority=z80
178

179 180 181 182
override_dh_gencontrol:
	echo 'apparmor:Recommends=$(APPARMOR_RECOMMENDS)' >> debian/docker.io.substvars
	echo 'libc:Built-Using=$(BUILT_LIBC)' >> debian/docker.io.substvars
	dh_gencontrol