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