1 # Copyright 1999-2018 Gentoo Foundation
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}"
15 if [ "$(get_version_component_count)" = 4 ]; then
16 MY_PV="$(replace_version_separator 3 '-ce-')"
20 DOCKER_GITCOMMIT="0520e24"
21 EGIT_COMMIT="v${MY_PV}"
22 SRC_URI="https://${EGO_PN}/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz"
23 KEYWORDS="~amd64 ~arm"
24 [ "$DOCKER_GITCOMMIT" ] || die "DOCKER_GITCOMMIT must be added manually for each bump!"
25 inherit golang-vcs-snapshot
27 inherit bash-completion-r1 golang-base linux-info systemd udev user
29 DESCRIPTION="The core functions you need to create Docker images and run Docker containers"
30 HOMEPAGE="https://dockerproject.org"
33 IUSE="apparmor aufs btrfs +container-init +device-mapper hardened +overlay pkcs11 seccomp"
35 # https://github.com/docker/docker/blob/master/project/PACKAGERS.md#build-dependencies
37 >=dev-db/sqlite-3.7.9:3
39 >=sys-fs/lvm2-2.02.89[thin]
41 seccomp? ( >=sys-libs/libseccomp-2.2.1 )
42 apparmor? ( sys-libs/libapparmor )
51 >=sys-fs/btrfs-progs-3.16.1
55 # https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies
56 # https://github.com/docker/docker/blob/master/project/PACKAGERS.md#optional-dependencies
59 >=net-firewall/iptables-1.4
62 >=app-arch/xz-utils-4.9
64 ~app-emulation/containerd-1.0.2
65 ~app-emulation/runc-1.0.0_rc5[apparmor?,seccomp?]
66 ~app-emulation/docker-proxy-0.8.0_p20180314
67 container-init? ( >=sys-process/tini-0.16.1[static] )
70 RESTRICT="installsources strip"
72 S="${WORKDIR}/${P}/src/${EGO_PN}"
74 # see "contrib/check-config.sh" from upstream's sources
76 ~NAMESPACES ~NET_NS ~PID_NS ~IPC_NS ~UTS_NS
77 ~CGROUPS ~CGROUP_CPUACCT ~CGROUP_DEVICE ~CGROUP_FREEZER ~CGROUP_SCHED ~CPUSETS ~MEMCG
79 ~VETH ~BRIDGE ~BRIDGE_NETFILTER
80 ~NF_NAT_IPV4 ~IP_NF_FILTER ~IP_NF_TARGET_MASQUERADE
81 ~NETFILTER_XT_MATCH_ADDRTYPE ~NETFILTER_XT_MATCH_CONNTRACK ~NETFILTER_XT_MATCH_IPVS
82 ~IP_NF_NAT ~NF_NAT ~NF_NAT_NEEDED
88 ~MEMCG_SWAP ~MEMCG_SWAP_ENABLED
90 ~BLK_CGROUP ~BLK_DEV_THROTTLING ~IOSCHED_CFQ ~CFQ_GROUP_IOSCHED
94 ~CFS_BANDWIDTH ~FAIR_GROUP_SCHED ~RT_GROUP_SCHED
95 ~IP_VS ~IP_VS_PROTO_TCP ~IP_VS_PROTO_UDP ~IP_VS_NFCT ~IP_VS_RR
98 ~CRYPTO ~CRYPTO_AEAD ~CRYPTO_GCM ~CRYPTO_SEQIV ~CRYPTO_GHASH ~XFRM_ALGO ~XFRM_USER
103 ERROR_KEYS="CONFIG_KEYS: is mandatory"
104 ERROR_MEMCG_SWAP="CONFIG_MEMCG_SWAP: is required if you wish to limit swap usage of containers"
105 ERROR_RESOURCE_COUNTERS="CONFIG_RESOURCE_COUNTERS: is optional for container statistics gathering"
107 ERROR_BLK_CGROUP="CONFIG_BLK_CGROUP: is optional for container statistics gathering"
108 ERROR_IOSCHED_CFQ="CONFIG_IOSCHED_CFQ: is optional for container statistics gathering"
109 ERROR_CGROUP_PERF="CONFIG_CGROUP_PERF: is optional for container statistics gathering"
110 ERROR_CFS_BANDWIDTH="CONFIG_CFS_BANDWIDTH: is optional for container statistics gathering"
111 ERROR_XFRM_ALGO="CONFIG_XFRM_ALGO: is optional for secure networks"
112 ERROR_XFRM_USER="CONFIG_XFRM_USER: is optional for secure networks"
115 if kernel_is lt 3 10; then
117 ewarn "Using Docker with kernels older than 3.10 is unstable and unsupported."
118 ewarn " - http://docs.docker.com/engine/installation/binaries/#check-kernel-dependencies"
121 if kernel_is le 3 18; then
127 if kernel_is le 3 13; then
137 if kernel_is lt 4 5; then
141 ERROR_MEMCG_KMEM="CONFIG_MEMCG_KMEM: is optional"
144 if kernel_is lt 4 7; then
146 ~DEVPTS_MULTIPLE_INSTANCES
153 ~EXT4_FS_POSIX_ACL ~EXT4_FS_SECURITY
155 ERROR_AUFS_FS="CONFIG_AUFS_FS: is required to be set if and only if aufs-sources are used instead of aufs4/aufs3"
165 if use device-mapper; then
167 ~BLK_DEV_DM ~DM_THIN_PROVISIONING ~EXT4_FS ~EXT4_FS_POSIX_ACL ~EXT4_FS_SECURITY
173 ~OVERLAY_FS ~EXT4_FS_SECURITY ~EXT4_FS_POSIX_ACL
179 # create docker group for the code checking for it in /etc/group
184 export GOPATH="${WORKDIR}/${P}"
186 # setup CFLAGS and LDFLAGS for separate build target
187 # see https://github.com/tianon/docker-overlay/pull/10
188 export CGO_CFLAGS="-I${ROOT}/usr/include"
189 export CGO_LDFLAGS="-L${ROOT}/usr/$(get_libdir)"
191 # if we're building from a tarball, we need the GITCOMMIT value
192 [ "$DOCKER_GITCOMMIT" ] && export DOCKER_GITCOMMIT
195 ln -s docker-ce/components/engine ../docker || die
196 ln -s docker-ce/components/cli ../cli || die
198 # let's set up some optional features :)
199 export DOCKER_BUILDTAGS=''
200 for gd in aufs btrfs device-mapper overlay; do
202 DOCKER_BUILDTAGS+=" exclude_graphdriver_${gd//-/}"
206 for tag in apparmor pkcs11 seccomp; do
208 DOCKER_BUILDTAGS+=" $tag"
212 pushd components/engine || die
214 if use hardened; then
215 sed -i "s/EXTLDFLAGS_STATIC='/&-fno-PIC /" hack/make.sh || die
216 grep -q -- '-fno-PIC' hack/make.sh || die 'hardened sed failed'
217 sed "s/LDFLAGS_STATIC_DOCKER='/&-extldflags -fno-PIC /" \
218 -i hack/make/dynbinary-daemon || die
219 grep -q -- '-fno-PIC' hack/make/dynbinary-daemon || die 'hardened sed failed'
223 VERSION="$(cat ../../VERSION)" \
224 ./hack/make.sh dynbinary || die 'dynbinary failed'
226 popd || die # components/engine
228 pushd components/cli || die
232 LDFLAGS="$(usex hardened '-extldflags -fno-PIC' '')" \
233 VERSION="$(cat ../../VERSION)" \
234 GITCOMMIT="${DOCKER_GITCOMMIT}" \
235 DISABLE_WARN_OUTSIDE_CONTAINER=1 \
239 go build -o gen-manpages github.com/docker/cli/man || die
240 ./gen-manpages --root . --target ./man/man1 || die
241 ./man/md2man-all.sh -q || die
242 rm gen-manpages || die
243 # see "components/cli/scripts/docs/generate-man.sh" (which also does "go get" for go-md2man)
245 popd || die # components/cli
249 dosym containerd /usr/bin/docker-containerd
250 dosym containerd-shim /usr/bin/docker-containerd-shim
251 dosym runc /usr/bin/docker-runc
252 use container-init && dosym tini /usr/bin/docker-init
254 pushd components/engine || die
255 newbin "$(readlink -f bundles/latest/dynbinary-daemon/dockerd)" dockerd
257 newinitd contrib/init/openrc/docker.initd docker
258 newconfd contrib/init/openrc/docker.confd docker
260 systemd_dounit contrib/init/systemd/docker.{service,socket}
262 udev_dorules contrib/udev/*.rules
264 dodoc AUTHORS CONTRIBUTING.md CHANGELOG.md NOTICE README.md
267 insinto /usr/share/vim/vimfiles
268 doins -r contrib/syntax/vim/ftdetect
269 doins -r contrib/syntax/vim/syntax
271 # note: intentionally not using "doins" so that we preserve +x bits
272 dodir /usr/share/${PN}/contrib
273 cp -R contrib/* "${ED}/usr/share/${PN}/contrib"
274 popd || die # components/engine
276 pushd components/cli || die
278 newbin build/docker-* docker
282 dobashcomp contrib/completion/bash/*
283 insinto /usr/share/zsh/site-functions
284 doins contrib/completion/zsh/_*
285 popd || die # components/cli
292 elog "To use Docker, the Docker daemon must be running as root. To automatically"
293 elog "start the Docker daemon at boot, add Docker to the default runlevel:"
294 elog " rc-update add docker default"
295 elog "Similarly for systemd:"
296 elog " systemctl enable docker.service"
298 elog "To use Docker as a non-root user, add yourself to the 'docker' group:"
299 elog " usermod -aG docker youruser"