app-emulation/docker: Remove old
[gentoo.git] / app-emulation / docker / docker-19.03.4.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 EGO_PN="github.com/docker/docker-ce"
7
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}"
12         inherit git-r3
13 else
14         DOCKER_GITCOMMIT="9013bf5"
15         MY_PV=${PV/_/-}
16         SRC_URI="https://${EGO_PN}/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz"
17         KEYWORDS="~amd64 ~arm ~arm64"
18         [ "$DOCKER_GITCOMMIT" ] || die "DOCKER_GITCOMMIT must be added manually for each bump!"
19         inherit golang-vcs-snapshot
20 fi
21 inherit bash-completion-r1 golang-base linux-info systemd udev user
22
23 DESCRIPTION="The core functions you need to create Docker images and run Docker containers"
24 HOMEPAGE="https://dockerproject.org"
25 LICENSE="Apache-2.0"
26 SLOT="0"
27 IUSE="apparmor aufs btrfs +container-init device-mapper hardened +overlay seccomp"
28
29 # https://github.com/docker/docker/blob/master/project/PACKAGERS.md#build-dependencies
30 CDEPEND="
31         >=dev-db/sqlite-3.7.9:3
32         device-mapper? (
33                 >=sys-fs/lvm2-2.02.89[thin]
34         )
35         seccomp? ( >=sys-libs/libseccomp-2.2.1 )
36         apparmor? ( sys-libs/libapparmor )
37 "
38
39 DEPEND="
40         ${CDEPEND}
41
42         >=dev-lang/go-1.12
43         dev-go/go-md2man
44
45         btrfs? (
46                 >=sys-fs/btrfs-progs-3.16.1
47         )
48 "
49
50 # https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies
51 # https://github.com/docker/docker/blob/master/project/PACKAGERS.md#optional-dependencies
52 RDEPEND="
53         ${CDEPEND}
54         >=net-firewall/iptables-1.4
55         sys-process/procps
56         >=dev-vcs/git-1.7
57         >=app-arch/xz-utils-4.9
58         dev-libs/libltdl
59         ~app-emulation/containerd-1.2.10
60         ~app-emulation/runc-1.0.0_rc9[apparmor?,seccomp?]
61         ~app-emulation/docker-proxy-0.8.0_p20191011
62         container-init? ( >=sys-process/tini-0.18.0[static] )
63 "
64
65 RESTRICT="installsources strip"
66
67 S="${WORKDIR}/${P}/src/${EGO_PN}"
68
69 # see "contrib/check-config.sh" from upstream's sources
70 CONFIG_CHECK="
71         ~NAMESPACES ~NET_NS ~PID_NS ~IPC_NS ~UTS_NS
72         ~CGROUPS ~CGROUP_CPUACCT ~CGROUP_DEVICE ~CGROUP_FREEZER ~CGROUP_SCHED ~CPUSETS ~MEMCG
73         ~KEYS
74         ~VETH ~BRIDGE ~BRIDGE_NETFILTER
75         ~IP_NF_FILTER ~IP_NF_TARGET_MASQUERADE
76         ~NETFILTER_XT_MATCH_ADDRTYPE ~NETFILTER_XT_MATCH_CONNTRACK ~NETFILTER_XT_MATCH_IPVS
77         ~IP_NF_NAT ~NF_NAT ~NF_NAT_NEEDED
78         ~POSIX_MQUEUE
79
80         ~USER_NS
81         ~SECCOMP
82         ~CGROUP_PIDS
83         ~MEMCG_SWAP ~MEMCG_SWAP_ENABLED
84
85         ~BLK_CGROUP ~BLK_DEV_THROTTLING
86         ~CGROUP_PERF
87         ~CGROUP_HUGETLB
88         ~NET_CLS_CGROUP
89         ~CFS_BANDWIDTH ~FAIR_GROUP_SCHED ~RT_GROUP_SCHED
90         ~IP_VS ~IP_VS_PROTO_TCP ~IP_VS_PROTO_UDP ~IP_VS_NFCT ~IP_VS_RR
91
92         ~VXLAN
93         ~CRYPTO ~CRYPTO_AEAD ~CRYPTO_GCM ~CRYPTO_SEQIV ~CRYPTO_GHASH ~XFRM_ALGO ~XFRM_USER
94         ~IPVLAN
95         ~MACVLAN ~DUMMY
96 "
97
98 ERROR_KEYS="CONFIG_KEYS: is mandatory"
99 ERROR_MEMCG_SWAP="CONFIG_MEMCG_SWAP: is required if you wish to limit swap usage of containers"
100 ERROR_RESOURCE_COUNTERS="CONFIG_RESOURCE_COUNTERS: is optional for container statistics gathering"
101
102 ERROR_BLK_CGROUP="CONFIG_BLK_CGROUP: is optional for container statistics gathering"
103 ERROR_IOSCHED_CFQ="CONFIG_IOSCHED_CFQ: is optional for container statistics gathering"
104 ERROR_CGROUP_PERF="CONFIG_CGROUP_PERF: is optional for container statistics gathering"
105 ERROR_CFS_BANDWIDTH="CONFIG_CFS_BANDWIDTH: is optional for container statistics gathering"
106 ERROR_XFRM_ALGO="CONFIG_XFRM_ALGO: is optional for secure networks"
107 ERROR_XFRM_USER="CONFIG_XFRM_USER: is optional for secure networks"
108
109 pkg_setup() {
110         if kernel_is lt 3 10; then
111                 ewarn ""
112                 ewarn "Using Docker with kernels older than 3.10 is unstable and unsupported."
113                 ewarn " - http://docs.docker.com/engine/installation/binaries/#check-kernel-dependencies"
114         fi
115
116         if kernel_is le 3 18; then
117                 CONFIG_CHECK+="
118                         ~RESOURCE_COUNTERS
119                 "
120         fi
121
122         if kernel_is le 3 13; then
123                 CONFIG_CHECK+="
124                         ~NETPRIO_CGROUP
125                 "
126         else
127                 CONFIG_CHECK+="
128                         ~CGROUP_NET_PRIO
129                 "
130         fi
131
132         if kernel_is lt 4 5; then
133                 CONFIG_CHECK+="
134                         ~MEMCG_KMEM
135                 "
136                 ERROR_MEMCG_KMEM="CONFIG_MEMCG_KMEM: is optional"
137         fi
138
139         if kernel_is lt 4 7; then
140                 CONFIG_CHECK+="
141                         ~DEVPTS_MULTIPLE_INSTANCES
142                 "
143         fi
144
145         if kernel_is lt 5 1; then
146                 CONFIG_CHECK+="
147                         ~NF_NAT_IPV4
148                         ~IOSCHED_CFQ
149                         ~CFQ_GROUP_IOSCHED
150                 "
151         fi
152
153         if use aufs; then
154                 CONFIG_CHECK+="
155                         ~AUFS_FS
156                         ~EXT4_FS_POSIX_ACL ~EXT4_FS_SECURITY
157                 "
158                 ERROR_AUFS_FS="CONFIG_AUFS_FS: is required to be set if and only if aufs-sources are used instead of aufs4/aufs3"
159         fi
160
161         if use btrfs; then
162                 CONFIG_CHECK+="
163                         ~BTRFS_FS
164                         ~BTRFS_FS_POSIX_ACL
165                 "
166         fi
167
168         if use device-mapper; then
169                 CONFIG_CHECK+="
170                         ~BLK_DEV_DM ~DM_THIN_PROVISIONING ~EXT4_FS ~EXT4_FS_POSIX_ACL ~EXT4_FS_SECURITY
171                 "
172         fi
173
174         if use overlay; then
175                 CONFIG_CHECK+="
176                         ~OVERLAY_FS ~EXT4_FS_SECURITY ~EXT4_FS_POSIX_ACL
177                 "
178         fi
179
180         linux-info_pkg_setup
181
182         # create docker group for the code checking for it in /etc/group
183         enewgroup docker
184 }
185
186 src_compile() {
187         export GOPATH="${WORKDIR}/${P}"
188
189         # setup CFLAGS and LDFLAGS for separate build target
190         # see https://github.com/tianon/docker-overlay/pull/10
191         export CGO_CFLAGS="-I${ROOT}/usr/include"
192         export CGO_LDFLAGS="-L${ROOT}/usr/$(get_libdir)"
193
194         # if we're building from a tarball, we need the GITCOMMIT value
195         [ "$DOCKER_GITCOMMIT" ] && export DOCKER_GITCOMMIT
196
197         # fake golang layout
198         ln -s docker-ce/components/engine ../docker || die
199         ln -s docker-ce/components/cli ../cli || die
200
201         # let's set up some optional features :)
202         export DOCKER_BUILDTAGS=''
203         for gd in aufs btrfs device-mapper overlay; do
204                 if ! use $gd; then
205                         DOCKER_BUILDTAGS+=" exclude_graphdriver_${gd//-/}"
206                 fi
207         done
208
209         for tag in apparmor seccomp; do
210                 if use $tag; then
211                         DOCKER_BUILDTAGS+=" $tag"
212                 fi
213         done
214
215         pushd components/engine || die
216
217         if use hardened; then
218                 sed -i "s/EXTLDFLAGS_STATIC='/&-fno-PIC /" hack/make.sh || die
219                 grep -q -- '-fno-PIC' hack/make.sh || die 'hardened sed failed'
220                 sed  "s/LDFLAGS_STATIC_DOCKER='/&-extldflags -fno-PIC /" \
221                         -i hack/make/dynbinary-daemon || die
222                 grep -q -- '-fno-PIC' hack/make/dynbinary-daemon || die 'hardened sed failed'
223         fi
224
225         # build daemon
226         VERSION="$(cat ../../VERSION)" \
227         ./hack/make.sh dynbinary || die 'dynbinary failed'
228
229         popd || die # components/engine
230
231         pushd components/cli || die
232
233         # build cli
234         emake \
235                 LDFLAGS="$(usex hardened '-extldflags -fno-PIC' '')" \
236                 VERSION="$(cat ../../VERSION)" \
237                 GITCOMMIT="${DOCKER_GITCOMMIT}" \
238                 DISABLE_WARN_OUTSIDE_CONTAINER=1 \
239                 dynbinary || die
240
241         # build man pages
242         go build -o gen-manpages github.com/docker/cli/man || die
243         ./gen-manpages --root . --target ./man/man1 || die
244         ./man/md2man-all.sh -q || die
245         rm gen-manpages || die
246         # see "components/cli/scripts/docs/generate-man.sh" (which also does "go get" for go-md2man)
247
248         popd || die # components/cli
249 }
250
251 src_install() {
252         dosym containerd /usr/bin/docker-containerd
253         dosym containerd-shim /usr/bin/docker-containerd-shim
254         dosym runc /usr/bin/docker-runc
255         use container-init && dosym tini /usr/bin/docker-init
256
257         pushd components/engine || die
258         newbin bundles/dynbinary-daemon/dockerd-${PV} dockerd
259
260         newinitd contrib/init/openrc/docker.initd docker
261         newconfd contrib/init/openrc/docker.confd docker
262
263         systemd_dounit contrib/init/systemd/docker.{service,socket}
264
265         udev_dorules contrib/udev/*.rules
266
267         dodoc AUTHORS CONTRIBUTING.md CHANGELOG.md NOTICE README.md
268         dodoc -r docs/*
269
270         insinto /usr/share/vim/vimfiles
271         doins -r contrib/syntax/vim/ftdetect
272         doins -r contrib/syntax/vim/syntax
273
274         # note: intentionally not using "doins" so that we preserve +x bits
275         dodir /usr/share/${PN}/contrib
276         cp -R contrib/* "${ED}/usr/share/${PN}/contrib"
277         popd || die # components/engine
278
279         pushd components/cli || die
280
281         newbin build/docker-* docker
282
283         doman man/man*/*
284
285         dobashcomp contrib/completion/bash/*
286         insinto /usr/share/fish/vendor_completions.d/
287         doins contrib/completion/fish/docker.fish
288         insinto /usr/share/zsh/site-functions
289         doins contrib/completion/zsh/_*
290         popd || die # components/cli
291 }
292
293 pkg_postinst() {
294         udev_reload
295
296         elog
297         elog "To use Docker, the Docker daemon must be running as root. To automatically"
298         elog "start the Docker daemon at boot, add Docker to the default runlevel:"
299         elog "  rc-update add docker default"
300         elog "Similarly for systemd:"
301         elog "  systemctl enable docker.service"
302         elog
303         elog "To use Docker as a non-root user, add yourself to the 'docker' group:"
304         elog "  usermod -aG docker youruser"
305         elog
306
307         elog " Devicemapper storage driver has been deprecated"
308         elog " It will be removed in a future release"
309 }