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
|
#!/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
BUILDKIT_PKG := github.com/moby/buildkit
# 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
# Cf. hack/make.sh hack/make/.binary
ENGINE_BUILDTIME := $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" --rfc-3339 ns | sed -e 's/ /T/')
ENGINE_BUILDTAGS := apparmor seccomp journald
ENGINE_TESTFLAGS := -test.short
ENGINE_LDFLAGS := -w
ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.Version=$(DOCKER_VERSION)
ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.GitCommit=$(ENGINE_GITCOMMIT)
ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.BuildTime=$(ENGINE_BUILDTIME)
ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.PlatformName=
ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.ProductName=docker
ENGINE_LDFLAGS += -X $(ENGINE_PKG)/dockerversion.DefaultProductLicense=
ifeq (,$(filter $(DEB_BUILD_ARCH), mipsel mips64el))
ENGINE_BUILDMODE := -buildmode=pie
endif
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 Static-Built-Using is properly generated.
DH_GOLANG_BUILDPKG="$(CLI_PKG)/... $(ENGINE_PKG)/... $(BUILDKIT_PKG)/..." \
dh_golang -O--buildsystem=golang -O--builddirectory=_build
override_dh_clean:
dh_clean
$(RM) -v -r autogen bundles man/man*/ debian/tmphome
# -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/$(BUILDKIT_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/$(BUILDKIT_PKG)
cp -ra buildkit $(GOPATH)/src/$(BUILDKIT_PKG)
override_dh_auto_build:
## Order is important:
# enable when we start additional binaries, such as buildkitd, etc.
# GENERATE=0 avoid protoc and gogoprotobuf dependencies
#DH_GOPKG=$(BUILDKIT_PKG) DH_GOLANG_GO_GENERATE=0 dh_auto_build -v
DH_GOPKG=$(ENGINE_PKG) DH_GOLANG_BUILDPKG=$(ENGINE_PKG)/cmd/dockerd \
dh_auto_build -v -- -tags '$(ENGINE_BUILDTAGS)' $(ENGINE_BUILDMODE) -ldflags '$(ENGINE_LDFLAGS)'
DH_GOPKG=$(ENGINE_PKG) DH_GOLANG_BUILDPKG=$(ENGINE_PKG)/cmd/docker-proxy \
dh_auto_build -v -- -tags '$(ENGINE_BUILDTAGS)' $(ENGINE_BUILDMODE) -ldflags '$(ENGINE_LDFLAGS)'
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)))
# basic smoke test -- these must pass
_build/bin/docker --version
_build/bin/dockerd --version
## Test engine:
cd $(GOPATH)/src/$(ENGINE_PKG) && PATH=$(GOPATH)/bin:$(PATH) TESTFLAGS='$(ENGINE_TESTFLAGS)' ./hack/test/unit
mkdir -p $(CURDIR)/debian/tmphome/tmp
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
endif
override_dh_install:
## 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
|