Debian Codegraph @

debian/rules

raw symbols SCIP
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3
4 include /usr/share/dpkg/default.mk
5
6 # Uncomment this to turn on verbose mode.
7 #export DH_VERBOSE=1
8
9 # The engine is built and tested using upstream scripts
10 # and Makefiles, rather than dh_auto_*. Therefore we can't rely
11 # on dh to set the environment for us, we have to do it here.
12 export GOPATH := $(CURDIR)/_build
13 export GOCACHE := $(GOPATH)/go-build
14 export GO111MODULE := off
15 export GOPROXY := off
16
17 #export DH_GOLANG_BUILDPKG := github.com/docker/docker github.com/docker/cli
18 export DH_GOLANG_GO_GENERATE := 1
19 export DH_GOLANG_INSTALL_ALL := 1
20 export DH_GOLANG_INSTALL_EXTRA := testdata/
21 export DH_GOLANG_EXCLUDES := \
22 integration-cli \
23 overlay_test \
24 vendor
25
26 # Package names
27 CLI_PKG := github.com/docker/cli
28 ENGINE_PKG := github.com/docker/docker
29 BUILDKIT_PKG := github.com/moby/buildkit
30
31 # Version and commits
32 DOCKER_VERSION := $(DEB_VERSION_UPSTREAM)
33 ENGINE_GITCOMMIT := $(shell ./debian/helpers/gitcommit.sh engine $(DOCKER_VERSION))
34 ifndef ENGINE_GITCOMMIT
35 $(error Missing ENGINE_GITCOMMIT - see debian/helpers/engine-gitcommits)
36 endif
37 CLI_GITCOMMIT := $(shell ./debian/helpers/gitcommit.sh cli $(DOCKER_VERSION))
38 ifndef CLI_GITCOMMIT
39 $(error Missing CLI_GITCOMMIT - see debian/helpers/cli-gitcommits)
40 endif
41
42 # Cf. scripts/build/binary scripts/build/.variables
43 CLI_BUILDTIME := $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" +"%Y-%m-%dT%H:%M:%SZ")
44 CLI_BUILDTAGS := pkcs11
45 CLI_LDFLAGS += -X $(CLI_PKG)/cli/version.BuildTime=$(CLI_BUILDTIME)
46 CLI_LDFLAGS += -X $(CLI_PKG)/cli/version.GitCommit=$(CLI_GITCOMMIT)
47 CLI_LDFLAGS += -X $(CLI_PKG)/cli/version.Version=$(DOCKER_VERSION)
48 ifeq (,$(filter $(DEB_BUILD_ARCH), mipsel mips64el))
49 CLI_BUILDMODE := -buildmode=pie
50 endif
51
52 # Cf. hack/make.sh hack/make/.binary
53 ENGINE_BUILDTIME := $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" --rfc-3339 ns | sed -e 's/ /T/')
54 ENGINE_BUILDTAGS := apparmor seccomp journald
55 ENGINE_TESTFLAGS := -test.short -vet=off
56 ENGINE_LDFLAGS := -w
57 ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.Version=$(DOCKER_VERSION)
58 ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.GitCommit=$(ENGINE_GITCOMMIT)
59 ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.BuildTime=$(ENGINE_BUILDTIME)
60 ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.PlatformName=
61 ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.ProductName=docker
62 ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.DefaultProductLicense=
63
64 ifeq (,$(filter $(DEB_BUILD_ARCH), mipsel mips64el))
65 ENGINE_BUILDMODE := -buildmode=pie
66 endif
67
68 BUILT_LIBC := $(shell dpkg-query -f '$${source:Package} (= $${source:Version})' -W libc-dev-bin)
69
70 %:
71 dh $@ --buildsystem=golang --with=bash-completion,golang --builddirectory=_build
72
73 override_dh_golang:
74 ## Set DH_GOLANG_BUILDPKG so that Static-Built-Using is properly generated.
75 DH_GOLANG_BUILDPKG="$(CLI_PKG)/... $(ENGINE_PKG)/... $(BUILDKIT_PKG)/..." \
76 dh_golang -O--buildsystem=golang -O--builddirectory=_build
77
78 override_dh_clean:
79 dh_clean
80 $(RM) -v -r autogen bundles man/man*/ debian/tmphome
81 # -find . -type f -name '*.pb.go' -delete -printf 'removed %p\n' ## delete generated .pb.go files
82 ## Remove Files-Excluded (when built from checkout or non-DFSG tarball):
83 $(RM) -rv `perl -0nE 'say grep { $$_=q{ */}.$$_ } split(/\s+/,$$1) if m{^Files\-Excluded:\s*(.*?)(?:\n\n|^Files|^Comment:)}sm;' debian/copyright`
84 -find */vendor -mindepth 1 -type d -empty -delete -printf 'removed %p\n'
85
86 override_dh_auto_configure:
87 ## dh_auto_configure symlinks dirs from "/usr/share/gocode/src" into
88 ## $(GOPATH) unless folders already exist there in which case files
89 ## are copied. Pre-making directories allows us to use debhelper to
90 ## create proper GOPATH source tree yet have certain directories writable
91 ## even if they are provided by already installed package.
92 mkdir -pv $(GOPATH)/src/$(CLI_PKG)
93 mkdir -pv $(GOPATH)/src/$(ENGINE_PKG)
94 mkdir -pv $(GOPATH)/src/$(BUILDKIT_PKG)
95
96 ## Prepare builddirectory but throw away sourcedirectory.
97 DH_GOPKG="__IGNORE__" dh_auto_configure
98
99 ## Each package must be removed from working tree first, in case some
100 ## of the packages that we are going to build are already installed.
101 ## This is also useful for building in unclean environment.
102 ##
103 ## This is _necessary_ to avoid merging packages that we build with
104 ## pre-installed packages. See #827226 for details.
105 ## Debhelper knows only about "main" DH_GOPKG package but we build several
106 ## and we have to ensure that build tree is properly prepared.
107 $(RM) -r $(GOPATH)/src/$(CLI_PKG)
108 cp -ra cli $(GOPATH)/src/$(CLI_PKG)
109 $(RM) -r $(GOPATH)/src/$(ENGINE_PKG)
110 cp -ra engine $(GOPATH)/src/$(ENGINE_PKG)
111 $(RM) -r $(GOPATH)/src/$(BUILDKIT_PKG)
112 cp -ra buildkit $(GOPATH)/src/$(BUILDKIT_PKG)
113
114 override_dh_auto_build:
115 ## Order is important:
116
117 # enable when we start additional binaries, such as buildkitd, etc.
118 # GENERATE=0 avoid protoc and gogoprotobuf dependencies
119 #DH_GOPKG=$(BUILDKIT_PKG) DH_GOLANG_GO_GENERATE=0 dh_auto_build -v
120
121 DH_GOPKG=$(ENGINE_PKG) DH_GOLANG_BUILDPKG=$(ENGINE_PKG)/cmd/dockerd \
122 dh_auto_build -v -- -tags '$(ENGINE_BUILDTAGS)' $(ENGINE_BUILDMODE) -ldflags '$(ENGINE_LDFLAGS)'
123
124 DH_GOPKG=$(ENGINE_PKG) DH_GOLANG_BUILDPKG=$(ENGINE_PKG)/cmd/docker-proxy \
125 dh_auto_build -v -- -tags '$(ENGINE_BUILDTAGS)' $(ENGINE_BUILDMODE) -ldflags '$(ENGINE_LDFLAGS)'
126
127 DH_GOPKG=$(CLI_PKG) DH_GOLANG_BUILDPKG=$(CLI_PKG)/cmd/docker \
128 dh_auto_build -v -- -tags '$(CLI_BUILDTAGS)' -ldflags '$(CLI_LDFLAGS)' $(CLI_BUILDMODE)
129 cd $(GOPATH)/src/$(CLI_PKG) && ./scripts/docs/generate-man.sh
130
131 override_dh_auto_test:
132 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
133 # basic smoke test -- these must pass
134 _build/bin/docker --version
135 _build/bin/dockerd --version
136
137 ## Test engine:
138 cd $(GOPATH)/src/$(ENGINE_PKG) && PATH=$(GOPATH)/bin:$(PATH) TESTFLAGS='$(ENGINE_TESTFLAGS)' ./hack/test/unit
139
140 mkdir -p $(CURDIR)/debian/tmphome/tmp
141 cd $(GOPATH)/src/$(CLI_PKG) && HOME=$(CURDIR)/debian/tmphome TMPDIR=$(CURDIR)/debian/tmphome/tmp PATH=$(GOPATH)/bin:$(PATH) DISABLE_WARN_OUTSIDE_CONTAINER=1 $(MAKE) test-unit GO111MODULE=off
142 endif
143
144 override_dh_install:
145 ## Do not install extra license files:
146 dh_install -XLICENSE
147 ## Apparmor thing, not sure it's needed, we don't install a profile
148 dh_apparmor --profile-name=docker.io -pdocker.io
149
150 override_dh_auto_install:
151 ## skip dh_auto_install to stop dh_golang trying to copy bits
152 ## for /usr/share/gocode (we use dh_install for that)
153
154 override_dh_installinit:
155 dh_installinit -v --name=docker --no-stop-on-upgrade --no-restart-after-upgrade
156
157 override_dh_installsystemd:
158 dh_installsystemd -v --name=docker --no-stop-on-upgrade --no-restart-after-upgrade
159
160 override_dh_installudev:
161 # use priority z80 to match the upstream priority of 80
162 dh_installudev -v --name=docker --priority=z80