1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 EGO_PN="github.com/docker/docker-ce"
8 if [[ ${PV} = *9999* ]]; then
9 # Docker cannot be fetched via "go get", thanks to autogenerated code
10 EGIT_REPO_URI="https://${EGO_PN}.git"
11 EGIT_CHECKOUT_DIR="${WORKDIR}/${P}/src/${EGO_PN}"
14 DOCKER_GITCOMMIT=369ce74a
16 SRC_URI="https://${EGO_PN}/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz"
17 KEYWORDS="~amd64 ~arm ~arm64 ~ppc64"
18 [ "$DOCKER_GITCOMMIT" ] || die "DOCKER_GITCOMMIT must be added manually for each bump!"
19 inherit golang-vcs-snapshot
21 inherit bash-completion-r1 golang-base linux-info systemd udev
23 DESCRIPTION="The core functions you need to create Docker images and run Docker containers"
24 HOMEPAGE="https://dockerproject.org"
27 IUSE="apparmor aufs btrfs +container-init device-mapper hardened +overlay seccomp"
29 # https://github.com/docker/docker/blob/master/project/PACKAGERS.md#build-dependencies
32 >=dev-db/sqlite-3.7.9:3
34 >=sys-fs/lvm2-2.02.89[thin]
36 seccomp? ( >=sys-libs/libseccomp-2.2.1 )
37 apparmor? ( sys-libs/libapparmor )
47 >=sys-fs/btrfs-progs-3.16.1
51 # https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies
52 # https://github.com/docker/docker/blob/master/project/PACKAGERS.md#optional-dependencies
55 !sys-apps/systemd[-cgroup-hybrid(+)]
56 >=net-firewall/iptables-1.4
59 >=app-arch/xz-utils-4.9
61 ~app-emulation/containerd-1.2.12
62 ~app-emulation/runc-1.0.0_rc10[apparmor?,seccomp?]
63 ~app-emulation/docker-proxy-0.8.0_p20191011
64 container-init? ( >=sys-process/tini-0.18.0[static] )
67 RESTRICT="installsources strip"
69 S="${WORKDIR}/${P}/src/${EGO_PN}"
71 # see "contrib/check-config.sh" from upstream's sources
73 ~NAMESPACES ~NET_NS ~PID_NS ~IPC_NS ~UTS_NS
74 ~CGROUPS ~CGROUP_CPUACCT ~CGROUP_DEVICE ~CGROUP_FREEZER ~CGROUP_SCHED ~CPUSETS ~MEMCG
76 ~VETH ~BRIDGE ~BRIDGE_NETFILTER
77 ~IP_NF_FILTER ~IP_NF_TARGET_MASQUERADE
78 ~NETFILTER_XT_MATCH_ADDRTYPE ~NETFILTER_XT_MATCH_CONNTRACK ~NETFILTER_XT_MATCH_IPVS
85 ~MEMCG_SWAP ~MEMCG_SWAP_ENABLED
87 ~BLK_CGROUP ~BLK_DEV_THROTTLING
91 ~CFS_BANDWIDTH ~FAIR_GROUP_SCHED ~RT_GROUP_SCHED
92 ~IP_VS ~IP_VS_PROTO_TCP ~IP_VS_PROTO_UDP ~IP_VS_NFCT ~IP_VS_RR
95 ~CRYPTO ~CRYPTO_AEAD ~CRYPTO_GCM ~CRYPTO_SEQIV ~CRYPTO_GHASH ~XFRM_ALGO ~XFRM_USER
100 ERROR_KEYS="CONFIG_KEYS: is mandatory"
101 ERROR_MEMCG_SWAP="CONFIG_MEMCG_SWAP: is required if you wish to limit swap usage of containers"
102 ERROR_RESOURCE_COUNTERS="CONFIG_RESOURCE_COUNTERS: is optional for container statistics gathering"
104 ERROR_BLK_CGROUP="CONFIG_BLK_CGROUP: is optional for container statistics gathering"
105 ERROR_IOSCHED_CFQ="CONFIG_IOSCHED_CFQ: is optional for container statistics gathering"
106 ERROR_CGROUP_PERF="CONFIG_CGROUP_PERF: is optional for container statistics gathering"
107 ERROR_CFS_BANDWIDTH="CONFIG_CFS_BANDWIDTH: is optional for container statistics gathering"
108 ERROR_XFRM_ALGO="CONFIG_XFRM_ALGO: is optional for secure networks"
109 ERROR_XFRM_USER="CONFIG_XFRM_USER: is optional for secure networks"
112 if kernel_is lt 3 10; then
114 ewarn "Using Docker with kernels older than 3.10 is unstable and unsupported."
115 ewarn " - http://docs.docker.com/engine/installation/binaries/#check-kernel-dependencies"
118 if kernel_is le 3 18; then
124 if kernel_is le 3 13; then
134 if kernel_is lt 4 5; then
138 ERROR_MEMCG_KMEM="CONFIG_MEMCG_KMEM: is optional"
141 if kernel_is lt 4 7; then
143 ~DEVPTS_MULTIPLE_INSTANCES
147 if kernel_is lt 5 1; then
155 if kernel_is lt 5 2; then
164 ~EXT4_FS_POSIX_ACL ~EXT4_FS_SECURITY
166 ERROR_AUFS_FS="CONFIG_AUFS_FS: is required to be set if and only if aufs-sources are used instead of aufs4/aufs3"
176 if use device-mapper; then
178 ~BLK_DEV_DM ~DM_THIN_PROVISIONING ~EXT4_FS ~EXT4_FS_POSIX_ACL ~EXT4_FS_SECURITY
184 ~OVERLAY_FS ~EXT4_FS_SECURITY ~EXT4_FS_POSIX_ACL
192 export GOPATH="${WORKDIR}/${P}"
194 # setup CFLAGS and LDFLAGS for separate build target
195 # see https://github.com/tianon/docker-overlay/pull/10
196 export CGO_CFLAGS="-I${ROOT}/usr/include"
197 export CGO_LDFLAGS="-L${ROOT}/usr/$(get_libdir)"
199 # if we're building from a tarball, we need the GITCOMMIT value
200 [[ ${DOCKER_GITCOMMIT} ]] && export DOCKER_GITCOMMIT
203 ln -s docker-ce/components/engine ../docker || die
204 ln -s docker-ce/components/cli ../cli || die
206 # let's set up some optional features :)
207 export DOCKER_BUILDTAGS=''
208 for gd in aufs btrfs device-mapper overlay; do
210 DOCKER_BUILDTAGS+=" exclude_graphdriver_${gd//-/}"
214 for tag in apparmor seccomp; do
216 DOCKER_BUILDTAGS+=" $tag"
220 pushd components/engine || die
222 if use hardened; then
223 sed -i "s/EXTLDFLAGS_STATIC='/&-fno-PIC /" hack/make.sh || die
224 grep -q -- '-fno-PIC' hack/make.sh || die 'hardened sed failed'
225 sed "s/LDFLAGS_STATIC_DOCKER='/&-extldflags -fno-PIC /" \
226 -i hack/make/dynbinary-daemon || die
227 grep -q -- '-fno-PIC' hack/make/dynbinary-daemon || die 'hardened sed failed'
231 VERSION="$(cat ../../VERSION)" \
232 ./hack/make.sh dynbinary || die 'dynbinary failed'
234 popd || die # components/engine
236 pushd components/cli || die
240 LDFLAGS="$(usex hardened '-extldflags -fno-PIC' '')" \
241 VERSION="$(cat ../../VERSION)" \
242 GITCOMMIT="${DOCKER_GITCOMMIT}" \
243 DISABLE_WARN_OUTSIDE_CONTAINER=1 \
247 go build -o gen-manpages github.com/docker/cli/man || die
248 ./gen-manpages --root . --target ./man/man1 || die
249 ./man/md2man-all.sh -q || die
250 rm gen-manpages || die
251 # see "components/cli/scripts/docs/generate-man.sh" (which also does "go get" for go-md2man)
253 popd || die # components/cli
257 dosym containerd /usr/bin/docker-containerd
258 dosym containerd-shim /usr/bin/docker-containerd-shim
259 dosym runc /usr/bin/docker-runc
260 use container-init && dosym tini /usr/bin/docker-init
262 pushd components/engine || die
263 newbin bundles/dynbinary-daemon/dockerd-${PV} dockerd
265 newinitd contrib/init/openrc/docker.initd docker
266 newconfd contrib/init/openrc/docker.confd docker
268 systemd_dounit contrib/init/systemd/docker.{service,socket}
270 udev_dorules contrib/udev/*.rules
272 dodoc AUTHORS CONTRIBUTING.md CHANGELOG.md NOTICE README.md
275 insinto /usr/share/vim/vimfiles
276 doins -r contrib/syntax/vim/ftdetect
277 doins -r contrib/syntax/vim/syntax
279 # note: intentionally not using "doins" so that we preserve +x bits
280 dodir /usr/share/${PN}/contrib
281 cp -R contrib/* "${ED}/usr/share/${PN}/contrib"
282 popd || die # components/engine
284 pushd components/cli || die
286 newbin build/docker-* docker
290 dobashcomp contrib/completion/bash/*
291 insinto /usr/share/fish/vendor_completions.d/
292 doins contrib/completion/fish/docker.fish
293 insinto /usr/share/zsh/site-functions
294 doins contrib/completion/zsh/_*
295 popd || die # components/cli
302 elog "To use Docker, the Docker daemon must be running as root. To automatically"
303 elog "start the Docker daemon at boot, add Docker to the default runlevel:"
304 elog " rc-update add docker default"
305 elog "Similarly for systemd:"
306 elog " systemctl enable docker.service"
308 elog "To use Docker as a non-root user, add yourself to the 'docker' group:"
309 elog " usermod -aG docker youruser"
312 elog " Devicemapper storage driver has been deprecated"
313 elog " It will be removed in a future release"