File: rules

package info (click to toggle)
docker.io 20.10.24%2Bdfsg1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 60,824 kB
  • sloc: sh: 5,621; makefile: 593; ansic: 179; python: 162; asm: 7
file content (164 lines) | stat: -rwxr-xr-x 6,366 bytes parent folder | download | duplicates (3)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/make -f
# -*- makefile -*-

include /usr/share/dpkg/default.mk

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# The engine is built and tested using upstream scripts
# and Makefiles, rather than dh_auto_*. Therefore we can't rely
# on dh to set the environment for us, we have to do it here.
export GOPATH := $(CURDIR)/_build
export GOCACHE := $(GOPATH)/go-build
export GO111MODULE := off
export GOPROXY := off

#export DH_GOLANG_BUILDPKG := github.com/docker/docker github.com/docker/cli
export DH_GOLANG_GO_GENERATE := 1
export DH_GOLANG_INSTALL_ALL := 1
export DH_GOLANG_INSTALL_EXTRA := testdata/
export DH_GOLANG_EXCLUDES := \
    integration-cli \
    overlay_test \
    vendor

# Package names
CLI_PKG        := github.com/docker/cli
ENGINE_PKG     := github.com/docker/docker
LIBNETWORK_PKG := github.com/docker/libnetwork
SWARMKIT_PKG   := github.com/docker/swarmkit

# Version and commits
DOCKER_VERSION := $(DEB_VERSION_UPSTREAM)
ENGINE_GITCOMMIT := $(shell ./debian/helpers/gitcommit.sh engine $(DOCKER_VERSION))
ifndef ENGINE_GITCOMMIT
  $(error Missing ENGINE_GITCOMMIT - see debian/helpers/engine-gitcommits)
endif
CLI_GITCOMMIT    := $(shell ./debian/helpers/gitcommit.sh cli $(DOCKER_VERSION))
ifndef CLI_GITCOMMIT
  $(error Missing CLI_GITCOMMIT - see debian/helpers/cli-gitcommits)
endif

# Cf. scripts/build/binary scripts/build/.variables
CLI_BUILDTIME := $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" +"%Y-%m-%dT%H:%M:%SZ")
CLI_BUILDTAGS := pkcs11
CLI_LDFLAGS   += -X $(CLI_PKG)/cli/version.BuildTime=$(CLI_BUILDTIME)
CLI_LDFLAGS   += -X $(CLI_PKG)/cli/version.GitCommit=$(CLI_GITCOMMIT)
CLI_LDFLAGS   += -X $(CLI_PKG)/cli/version.Version=$(DOCKER_VERSION)
ifeq (,$(filter $(DEB_BUILD_ARCH), mipsel mips64el))
CLI_BUILDMODE := -buildmode=pie
endif

# engine: have "make.sh" keep "bundle/$(DOCKER_VERSION)" around between runs
# (we clean it up appropriately ourselves)
ENGINE_KEEPBUNDLE := 1

ENGINE_BUILDTAGS := apparmor seccomp
ENGINE_TESTFLAGS := -test.short

BUILT_LIBC := $(shell dpkg-query -f '$${source:Package} (= $${source:Version})' -W libc-dev-bin)

%:
	dh $@ --buildsystem=golang --with=bash-completion,golang --builddirectory=_build

override_dh_golang:
## Set DH_GOLANG_BUILDPKG so that Built-Using is properly generated.
	DH_GOLANG_BUILDPKG="$(CLI_PKG)/... $(ENGINE_PKG)/... $(LIBNETWORK_PKG)/... $(SWARMKIT_PKG)/..." \
	  dh_golang -O--buildsystem=golang -O--builddirectory=_build

override_dh_clean:
	dh_clean
	$(RM) -v -r autogen bundles man/man*/
#	-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):
	$(RM) -rv `perl -0nE 'say grep { $$_=q{ */}.$$_ } split(/\s+/,$$1) if m{^Files\-Excluded:\s*(.*?)(?:\n\n|^Files|^Comment:)}sm;' debian/copyright`
	-find */vendor -mindepth 1 -type d -empty -delete -printf 'removed %p\n'

override_dh_auto_configure:
## dh_auto_configure symlinks dirs from "/usr/share/gocode/src" into
## $(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 $(GOPATH)/src/$(CLI_PKG)
	mkdir -pv $(GOPATH)/src/$(ENGINE_PKG)
	mkdir -pv $(GOPATH)/src/$(LIBNETWORK_PKG)
	mkdir -pv $(GOPATH)/src/$(SWARMKIT_PKG)

## 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              $(GOPATH)/src/$(CLI_PKG)
	cp -ra  cli           $(GOPATH)/src/$(CLI_PKG)
	$(RM) -r              $(GOPATH)/src/$(ENGINE_PKG)
	cp -ra  engine        $(GOPATH)/src/$(ENGINE_PKG)
	$(RM) -r              $(GOPATH)/src/$(LIBNETWORK_PKG)
	cp -ra  libnetwork    $(GOPATH)/src/$(LIBNETWORK_PKG)
	$(RM) -r              $(GOPATH)/src/$(SWARMKIT_PKG)
	cp -ra  swarmkit      $(GOPATH)/src/$(SWARMKIT_PKG)

override_dh_auto_build:
## Order is important:

	DH_GOPKG=$(LIBNETWORK_PKG) dh_auto_build -v

##	## FIXME: DH_GOLANG_BUILDPKG --> DH_GOPKG
	DH_GOLANG_BUILDPKG=$(SWARMKIT_PKG) dh_auto_build -v

##	build ("cd" first to ensure we build from within GOPATH)
	cd $(GOPATH)/src/$(ENGINE_PKG) \
	&& KEEPBUNDLE=$(ENGINE_KEEPBUNDLE) VERSION=$(DOCKER_VERSION) DOCKER_BUILDTAGS='$(ENGINE_BUILDTAGS)' \
	   DOCKER_GITCOMMIT=$(ENGINE_GITCOMMIT) PRODUCT=docker ./hack/make.sh dynbinary

	DH_GOPKG=$(CLI_PKG) DH_GOLANG_BUILDPKG=$(CLI_PKG)/cmd/docker \
	  dh_auto_build -v -- -tags '$(CLI_BUILDTAGS)' -ldflags '$(CLI_LDFLAGS)' $(CLI_BUILDMODE)
	cd $(GOPATH)/src/$(CLI_PKG) && ./scripts/docs/generate-man.sh

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	## Test engine:
	cd $(GOPATH)/src/$(ENGINE_PKG) \
	&& TESTFLAGS='$(ENGINE_TESTFLAGS)' ./hack/test/unit

	## Test CLI:
	cd $(GOPATH)/src/$(CLI_PKG) \
	&& DISABLE_WARN_OUTSIDE_CONTAINER=1 $(MAKE) test-unit
endif

override_dh_install:
	## Rename binaries
	cd $(GOPATH)/src/$(ENGINE_PKG)/bundles/dynbinary-daemon \
	&& mv dockerd-$(DOCKER_VERSION) dockerd
	cd $(GOPATH)/bin \
	&& mv proxy docker-proxy
	## Do not install extra license files:
	dh_install -XLICENSE
	## Apparmor thing, not sure it's needed, we don't install a profile
	dh_apparmor --profile-name=docker.io -pdocker.io

override_dh_auto_install:
	## skip dh_auto_install to stop dh_golang trying to copy bits
	## for /usr/share/gocode (we use dh_install for that)

override_dh_installinit:
	dh_installinit -v --name=docker --no-stop-on-upgrade --no-restart-after-upgrade

override_dh_installsystemd:
	dh_installsystemd -v --name=docker --no-stop-on-upgrade --no-restart-after-upgrade

override_dh_installudev:
	# use priority z80 to match the upstream priority of 80
	dh_installudev -v --name=docker --priority=z80

override_dh_gencontrol:
	echo 'libc:Built-Using=$(BUILT_LIBC)' >> debian/docker.io.substvars
	dh_gencontrol