Gentoo Archives: gentoo-commits

From: "Manuel Rüger" <mrueg@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/docker/, app-emulation/docker/files/
Date: Fri, 06 Apr 2018 22:03:06
Message-Id: 1523052057.f76e0c651a4a7b7cc722e3fd506151a786078c70.mrueg@gentoo
1 commit: f76e0c651a4a7b7cc722e3fd506151a786078c70
2 Author: Manuel Rüger <mrueg <AT> gentoo <DOT> org>
3 AuthorDate: Fri Apr 6 22:00:12 2018 +0000
4 Commit: Manuel Rüger <mrueg <AT> gentoo <DOT> org>
5 CommitDate: Fri Apr 6 22:00:57 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f76e0c65
7
8 app-emulation/docker: Add Patch
9
10 https://github.com/moby/moby/issues/36809
11
12 Package-Manager: Portage-2.3.28, Repoman-2.3.9
13
14 app-emulation/docker/docker-18.03.0-r1.ebuild | 303 +++++++++++++++++++++
15 .../bsc1073877-docker-apparmor-add-signal.patch | 20 ++
16 2 files changed, 323 insertions(+)
17
18 diff --git a/app-emulation/docker/docker-18.03.0-r1.ebuild b/app-emulation/docker/docker-18.03.0-r1.ebuild
19 new file mode 100644
20 index 00000000000..62b861abdf8
21 --- /dev/null
22 +++ b/app-emulation/docker/docker-18.03.0-r1.ebuild
23 @@ -0,0 +1,303 @@
24 +# Copyright 1999-2018 Gentoo Foundation
25 +# Distributed under the terms of the GNU General Public License v2
26 +
27 +EAPI=6
28 +
29 +EGO_PN="github.com/docker/docker-ce"
30 +
31 +if [[ ${PV} = *9999* ]]; then
32 + # Docker cannot be fetched via "go get", thanks to autogenerated code
33 + EGIT_REPO_URI="https://${EGO_PN}.git"
34 + EGIT_CHECKOUT_DIR="${WORKDIR}/${P}/src/${EGO_PN}"
35 + inherit git-r3
36 +else
37 + inherit versionator
38 + if [ "$(get_version_component_count)" = 4 ]; then
39 + MY_PV="$(replace_version_separator 3 '-ce-')"
40 + else
41 + MY_PV="$PV-ce"
42 + fi
43 + DOCKER_GITCOMMIT="0520e24"
44 + EGIT_COMMIT="v${MY_PV}"
45 + SRC_URI="https://${EGO_PN}/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz"
46 + KEYWORDS="~amd64 ~arm"
47 + [ "$DOCKER_GITCOMMIT" ] || die "DOCKER_GITCOMMIT must be added manually for each bump!"
48 + inherit golang-vcs-snapshot
49 +fi
50 +inherit bash-completion-r1 golang-base linux-info systemd udev user
51 +
52 +DESCRIPTION="The core functions you need to create Docker images and run Docker containers"
53 +HOMEPAGE="https://dockerproject.org"
54 +LICENSE="Apache-2.0"
55 +SLOT="0"
56 +IUSE="apparmor aufs btrfs +container-init +device-mapper hardened +overlay pkcs11 seccomp"
57 +
58 +# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#build-dependencies
59 +CDEPEND="
60 + >=dev-db/sqlite-3.7.9:3
61 + device-mapper? (
62 + >=sys-fs/lvm2-2.02.89[thin]
63 + )
64 + seccomp? ( >=sys-libs/libseccomp-2.2.1 )
65 + apparmor? ( sys-libs/libapparmor )
66 +"
67 +
68 +DEPEND="
69 + ${CDEPEND}
70 +
71 + dev-go/go-md2man
72 +
73 + btrfs? (
74 + >=sys-fs/btrfs-progs-3.16.1
75 + )
76 +"
77 +
78 +# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies
79 +# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#optional-dependencies
80 +RDEPEND="
81 + ${CDEPEND}
82 + >=net-firewall/iptables-1.4
83 + sys-process/procps
84 + >=dev-vcs/git-1.7
85 + >=app-arch/xz-utils-4.9
86 + dev-libs/libltdl
87 + ~app-emulation/containerd-1.0.2
88 + ~app-emulation/runc-1.0.0_rc5[apparmor?,seccomp?]
89 + ~app-emulation/docker-proxy-0.8.0_p20180314
90 + container-init? ( >=sys-process/tini-0.16.1[static] )
91 +"
92 +
93 +RESTRICT="installsources strip"
94 +
95 +S="${WORKDIR}/${P}/src/${EGO_PN}"
96 +
97 +PATCHES=( "${FILESDIR}"/bsc1073877-docker-apparmor-add-signal.patch )
98 +
99 +# see "contrib/check-config.sh" from upstream's sources
100 +CONFIG_CHECK="
101 + ~NAMESPACES ~NET_NS ~PID_NS ~IPC_NS ~UTS_NS
102 + ~CGROUPS ~CGROUP_CPUACCT ~CGROUP_DEVICE ~CGROUP_FREEZER ~CGROUP_SCHED ~CPUSETS ~MEMCG
103 + ~KEYS
104 + ~VETH ~BRIDGE ~BRIDGE_NETFILTER
105 + ~NF_NAT_IPV4 ~IP_NF_FILTER ~IP_NF_TARGET_MASQUERADE
106 + ~NETFILTER_XT_MATCH_ADDRTYPE ~NETFILTER_XT_MATCH_CONNTRACK ~NETFILTER_XT_MATCH_IPVS
107 + ~IP_NF_NAT ~NF_NAT ~NF_NAT_NEEDED
108 + ~POSIX_MQUEUE
109 +
110 + ~USER_NS
111 + ~SECCOMP
112 + ~CGROUP_PIDS
113 + ~MEMCG_SWAP ~MEMCG_SWAP_ENABLED
114 +
115 + ~BLK_CGROUP ~BLK_DEV_THROTTLING ~IOSCHED_CFQ ~CFQ_GROUP_IOSCHED
116 + ~CGROUP_PERF
117 + ~CGROUP_HUGETLB
118 + ~NET_CLS_CGROUP
119 + ~CFS_BANDWIDTH ~FAIR_GROUP_SCHED ~RT_GROUP_SCHED
120 + ~IP_VS ~IP_VS_PROTO_TCP ~IP_VS_PROTO_UDP ~IP_VS_NFCT ~IP_VS_RR
121 +
122 + ~VXLAN
123 + ~CRYPTO ~CRYPTO_AEAD ~CRYPTO_GCM ~CRYPTO_SEQIV ~CRYPTO_GHASH ~XFRM_ALGO ~XFRM_USER
124 + ~IPVLAN
125 + ~MACVLAN ~DUMMY
126 +"
127 +
128 +ERROR_KEYS="CONFIG_KEYS: is mandatory"
129 +ERROR_MEMCG_SWAP="CONFIG_MEMCG_SWAP: is required if you wish to limit swap usage of containers"
130 +ERROR_RESOURCE_COUNTERS="CONFIG_RESOURCE_COUNTERS: is optional for container statistics gathering"
131 +
132 +ERROR_BLK_CGROUP="CONFIG_BLK_CGROUP: is optional for container statistics gathering"
133 +ERROR_IOSCHED_CFQ="CONFIG_IOSCHED_CFQ: is optional for container statistics gathering"
134 +ERROR_CGROUP_PERF="CONFIG_CGROUP_PERF: is optional for container statistics gathering"
135 +ERROR_CFS_BANDWIDTH="CONFIG_CFS_BANDWIDTH: is optional for container statistics gathering"
136 +ERROR_XFRM_ALGO="CONFIG_XFRM_ALGO: is optional for secure networks"
137 +ERROR_XFRM_USER="CONFIG_XFRM_USER: is optional for secure networks"
138 +
139 +pkg_setup() {
140 + if kernel_is lt 3 10; then
141 + ewarn ""
142 + ewarn "Using Docker with kernels older than 3.10 is unstable and unsupported."
143 + ewarn " - http://docs.docker.com/engine/installation/binaries/#check-kernel-dependencies"
144 + fi
145 +
146 + if kernel_is le 3 18; then
147 + CONFIG_CHECK+="
148 + ~RESOURCE_COUNTERS
149 + "
150 + fi
151 +
152 + if kernel_is le 3 13; then
153 + CONFIG_CHECK+="
154 + ~NETPRIO_CGROUP
155 + "
156 + else
157 + CONFIG_CHECK+="
158 + ~CGROUP_NET_PRIO
159 + "
160 + fi
161 +
162 + if kernel_is lt 4 5; then
163 + CONFIG_CHECK+="
164 + ~MEMCG_KMEM
165 + "
166 + ERROR_MEMCG_KMEM="CONFIG_MEMCG_KMEM: is optional"
167 + fi
168 +
169 + if kernel_is lt 4 7; then
170 + CONFIG_CHECK+="
171 + ~DEVPTS_MULTIPLE_INSTANCES
172 + "
173 + fi
174 +
175 + if use aufs; then
176 + CONFIG_CHECK+="
177 + ~AUFS_FS
178 + ~EXT4_FS_POSIX_ACL ~EXT4_FS_SECURITY
179 + "
180 + ERROR_AUFS_FS="CONFIG_AUFS_FS: is required to be set if and only if aufs-sources are used instead of aufs4/aufs3"
181 + fi
182 +
183 + if use btrfs; then
184 + CONFIG_CHECK+="
185 + ~BTRFS_FS
186 + ~BTRFS_FS_POSIX_ACL
187 + "
188 + fi
189 +
190 + if use device-mapper; then
191 + CONFIG_CHECK+="
192 + ~BLK_DEV_DM ~DM_THIN_PROVISIONING ~EXT4_FS ~EXT4_FS_POSIX_ACL ~EXT4_FS_SECURITY
193 + "
194 + fi
195 +
196 + if use overlay; then
197 + CONFIG_CHECK+="
198 + ~OVERLAY_FS ~EXT4_FS_SECURITY ~EXT4_FS_POSIX_ACL
199 + "
200 + fi
201 +
202 + linux-info_pkg_setup
203 +
204 + # create docker group for the code checking for it in /etc/group
205 + enewgroup docker
206 +}
207 +
208 +src_compile() {
209 + export GOPATH="${WORKDIR}/${P}"
210 +
211 + # setup CFLAGS and LDFLAGS for separate build target
212 + # see https://github.com/tianon/docker-overlay/pull/10
213 + export CGO_CFLAGS="-I${ROOT}/usr/include"
214 + export CGO_LDFLAGS="-L${ROOT}/usr/$(get_libdir)"
215 +
216 + # if we're building from a tarball, we need the GITCOMMIT value
217 + [ "$DOCKER_GITCOMMIT" ] && export DOCKER_GITCOMMIT
218 +
219 + # fake golang layout
220 + ln -s docker-ce/components/engine ../docker || die
221 + ln -s docker-ce/components/cli ../cli || die
222 +
223 + # let's set up some optional features :)
224 + export DOCKER_BUILDTAGS=''
225 + for gd in aufs btrfs device-mapper overlay; do
226 + if ! use $gd; then
227 + DOCKER_BUILDTAGS+=" exclude_graphdriver_${gd//-/}"
228 + fi
229 + done
230 +
231 + for tag in apparmor pkcs11 seccomp; do
232 + if use $tag; then
233 + DOCKER_BUILDTAGS+=" $tag"
234 + fi
235 + done
236 +
237 + pushd components/engine || die
238 +
239 + if use hardened; then
240 + sed -i "s/EXTLDFLAGS_STATIC='/&-fno-PIC /" hack/make.sh || die
241 + grep -q -- '-fno-PIC' hack/make.sh || die 'hardened sed failed'
242 + sed "s/LDFLAGS_STATIC_DOCKER='/&-extldflags -fno-PIC /" \
243 + -i hack/make/dynbinary-daemon || die
244 + grep -q -- '-fno-PIC' hack/make/dynbinary-daemon || die 'hardened sed failed'
245 + fi
246 +
247 + # build daemon
248 + VERSION="$(cat ../../VERSION)" \
249 + ./hack/make.sh dynbinary || die 'dynbinary failed'
250 +
251 + popd || die # components/engine
252 +
253 + pushd components/cli || die
254 +
255 + # build cli
256 + emake \
257 + LDFLAGS="$(usex hardened '-extldflags -fno-PIC' '')" \
258 + VERSION="$(cat ../../VERSION)" \
259 + GITCOMMIT="${DOCKER_GITCOMMIT}" \
260 + DISABLE_WARN_OUTSIDE_CONTAINER=1 \
261 + dynbinary || die
262 +
263 + # build man pages
264 + go build -o gen-manpages github.com/docker/cli/man || die
265 + ./gen-manpages --root . --target ./man/man1 || die
266 + ./man/md2man-all.sh -q || die
267 + rm gen-manpages || die
268 + # see "components/cli/scripts/docs/generate-man.sh" (which also does "go get" for go-md2man)
269 +
270 + popd || die # components/cli
271 +}
272 +
273 +src_install() {
274 + dosym containerd /usr/bin/docker-containerd
275 + dosym containerd-shim /usr/bin/docker-containerd-shim
276 + dosym runc /usr/bin/docker-runc
277 + use container-init && dosym tini /usr/bin/docker-init
278 +
279 + pushd components/engine || die
280 + newbin "$(readlink -f bundles/latest/dynbinary-daemon/dockerd)" dockerd
281 +
282 + newinitd contrib/init/openrc/docker.initd docker
283 + newconfd contrib/init/openrc/docker.confd docker
284 +
285 + systemd_dounit contrib/init/systemd/docker.{service,socket}
286 +
287 + udev_dorules contrib/udev/*.rules
288 +
289 + dodoc AUTHORS CONTRIBUTING.md CHANGELOG.md NOTICE README.md
290 + dodoc -r docs/*
291 +
292 + insinto /usr/share/vim/vimfiles
293 + doins -r contrib/syntax/vim/ftdetect
294 + doins -r contrib/syntax/vim/syntax
295 +
296 + # note: intentionally not using "doins" so that we preserve +x bits
297 + dodir /usr/share/${PN}/contrib
298 + cp -R contrib/* "${ED}/usr/share/${PN}/contrib"
299 + popd || die # components/engine
300 +
301 + pushd components/cli || die
302 +
303 + newbin build/docker-* docker
304 +
305 + doman man/man*/*
306 +
307 + dobashcomp contrib/completion/bash/*
308 + insinto /usr/share/zsh/site-functions
309 + doins contrib/completion/zsh/_*
310 + popd || die # components/cli
311 +}
312 +
313 +pkg_postinst() {
314 + udev_reload
315 +
316 + elog
317 + elog "To use Docker, the Docker daemon must be running as root. To automatically"
318 + elog "start the Docker daemon at boot, add Docker to the default runlevel:"
319 + elog " rc-update add docker default"
320 + elog "Similarly for systemd:"
321 + elog " systemctl enable docker.service"
322 + elog
323 + elog "To use Docker as a non-root user, add yourself to the 'docker' group:"
324 + elog " usermod -aG docker youruser"
325 + elog
326 +}
327
328 diff --git a/app-emulation/docker/files/bsc1073877-docker-apparmor-add-signal.patch b/app-emulation/docker/files/bsc1073877-docker-apparmor-add-signal.patch
329 new file mode 100644
330 index 00000000000..6bc3fa494e3
331 --- /dev/null
332 +++ b/app-emulation/docker/files/bsc1073877-docker-apparmor-add-signal.patch
333 @@ -0,0 +1,20 @@
334 +From: Goldwyn Rodrigues <rgoldwyn@××××.com>
335 +Subject: Allow signal mediation while for apparmor profile
336 +
337 +Allows docker processes under docker-default ot receive all signals.
338 +
339 +Signed-off-by: Goldwyn Rodrigues <rgoldwyn@××××.com>
340 +---
341 + components/engine/profiles/apparmor/template.go | 1 +
342 + 1 file changed, 1 insertion(+)
343 +
344 +--- a/components/engine/profiles/apparmor/template.go
345 ++++ b/components/engine/profiles/apparmor/template.go
346 +@@ -17,6 +17,7 @@ profile {{.Name}} flags=(attach_disconne
347 + capability,
348 + file,
349 + umount,
350 ++ signal (receive) peer=unconfined,
351 +
352 + deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir)
353 + # deny write to files not in /proc/<number>/** or /proc/sys/**