1 |
commit: dd450253467dd8d704a398d794d1a704cac81ecc |
2 |
Author: i.Dark_Templar <darktemplar <AT> dark-templar-archives <DOT> net> |
3 |
AuthorDate: Sun Nov 5 08:50:03 2017 +0000 |
4 |
Commit: Matthias Maier <tamiko <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jan 30 17:00:12 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dd450253 |
7 |
|
8 |
app-emulation/lxc: bump to version 2.1.1. |
9 |
|
10 |
[tamiko: regenerate metadata to make remote hook happy] |
11 |
|
12 |
Closes: https://bugs.gentoo.org/636572 |
13 |
Closes: https://github.com/gentoo/gentoo/pull/6128 |
14 |
Signed-off-by: Matthias Maier <tamiko <AT> gentoo.org> |
15 |
|
16 |
app-emulation/lxc/Manifest | 1 + |
17 |
...ps-enable-container-without-CAP_SYS_ADMIN.patch | 164 +++++++++++++++++ |
18 |
.../files/lxc-2.1.1-fix-cgroup2-detection.patch | 26 +++ |
19 |
app-emulation/lxc/files/lxc.initd.7 | 124 +++++++++++++ |
20 |
app-emulation/lxc/lxc-2.1.1.ebuild | 201 +++++++++++++++++++++ |
21 |
5 files changed, 516 insertions(+) |
22 |
|
23 |
diff --git a/app-emulation/lxc/Manifest b/app-emulation/lxc/Manifest |
24 |
index c9008c2d3c8..5c6a4ead6f8 100644 |
25 |
--- a/app-emulation/lxc/Manifest |
26 |
+++ b/app-emulation/lxc/Manifest |
27 |
@@ -2,3 +2,4 @@ DIST lxc-1.0.11.tar.gz 850645 BLAKE2B 1a8eff91d970d3160d5ca7338f4e4d68c722a277a8 |
28 |
DIST lxc-1.0.8.tar.gz 575127 BLAKE2B 246ac7a2b4306c52a741b2f763bcc81d9999fb27942ef93d6a786ed2ea010c646f5a2388407d26425387b8a819cacae927c8512995bf19b11d610e1887ea6470 SHA512 f552a4f48bb47d26c6b9ddaf8221a439c0848e3f54ec41b77d54717c21bddd56193941046cc96c699790e8265e762a926469c25ee687adcf7795f2906b1c260a |
29 |
DIST lxc-2.0.7.tar.gz 792557 BLAKE2B e5f1e6d8961938200e116527fab8ce341cf285826afdccac88f4bae65ffd649a406dac7555024557f38c4b415a59cd3b5fb255f1dbf015ce01d4975bed3b1c80 SHA512 eb48dc800ce43d2f4d46e0cecc4d0a714b3e22c6a4975776b54d17d1d20d5a1411e6b605215282f1f77286ddf22b61c80b86b83752191fc18023894ef7a1c44d |
30 |
DIST lxc-2.0.9.tar.gz 1333044 BLAKE2B 44d405bf933923a020a6aadca9d84cfce04db72ac0ef1a727c83eca8121683419a2e74849f08fb4773010002928b424840fa9ec19ab619e420b1dfb5156de5c6 SHA512 c7c595fbc6163e500700b756ae30c96b70d41b9bf297a609622b5d5b8431171ed8db70fa8368c3b9650c86452820e9da7f329f9186ae75c24a7adb15d5826102 |
31 |
+DIST lxc-2.1.1.tar.gz 1378640 BLAKE2B 5fca516540a886729434579ff99acf3baa06977fa0e0b6f24dbf15094626335fc073597d308276e3dd20e27ceabf1477cc8e99d1fd24cf50b9aed2720b887b69 SHA512 2989d57acddfe091adcf8031721c3c9a2f8eff5476bd6155366b76ea7511e0f6120e669276e056e3963863e0f0acf3b095d44c36fa6652e67c197671f28cbdd4 |
32 |
|
33 |
diff --git a/app-emulation/lxc/files/lxc-2.1.1-cgroups-enable-container-without-CAP_SYS_ADMIN.patch b/app-emulation/lxc/files/lxc-2.1.1-cgroups-enable-container-without-CAP_SYS_ADMIN.patch |
34 |
new file mode 100644 |
35 |
index 00000000000..8493491d0d6 |
36 |
--- /dev/null |
37 |
+++ b/app-emulation/lxc/files/lxc-2.1.1-cgroups-enable-container-without-CAP_SYS_ADMIN.patch |
38 |
@@ -0,0 +1,164 @@ |
39 |
+From b635e92d21d2a4d71a553388f18cfa08f44bf1ba Mon Sep 17 00:00:00 2001 |
40 |
+From: Christian Brauner <christian.brauner@××××××.com> |
41 |
+Date: Mon, 30 Oct 2017 14:16:46 +0100 |
42 |
+Subject: [PATCH] cgroups: enable container without CAP_SYS_ADMIN |
43 |
+ |
44 |
+In case cgroup namespaces are supported but we do not have CAP_SYS_ADMIN we |
45 |
+need to mount cgroups for the container. This patch enables both privileged and |
46 |
+unprivileged containers without CAP_SYS_ADMIN. |
47 |
+ |
48 |
+Closes #1737. |
49 |
+ |
50 |
+Signed-off-by: Christian Brauner <christian.brauner@××××××.com> |
51 |
+--- |
52 |
+ src/lxc/cgroups/cgfs.c | 3 ++- |
53 |
+ src/lxc/cgroups/cgfsng.c | 52 +++++++++++++++++++++++++++++++++++++++++++++--- |
54 |
+ src/lxc/cgroups/cgroup.c | 2 +- |
55 |
+ src/lxc/conf.c | 3 --- |
56 |
+ src/lxc/conf.h | 1 + |
57 |
+ 5 files changed, 53 insertions(+), 8 deletions(-) |
58 |
+ |
59 |
+diff --git a/src/lxc/cgroups/cgfs.c b/src/lxc/cgroups/cgfs.c |
60 |
+index bcbd6613..efd627f0 100644 |
61 |
+--- a/src/lxc/cgroups/cgfs.c |
62 |
++++ b/src/lxc/cgroups/cgfs.c |
63 |
+@@ -1418,11 +1418,12 @@ static bool cgroupfs_mount_cgroup(void *hdata, const char *root, int type) |
64 |
+ struct cgfs_data *cgfs_d; |
65 |
+ struct cgroup_process_info *info, *base_info; |
66 |
+ int r, saved_errno = 0; |
67 |
++ struct lxc_handler *handler = hdata; |
68 |
+ |
69 |
+ if (cgns_supported()) |
70 |
+ return true; |
71 |
+ |
72 |
+- cgfs_d = hdata; |
73 |
++ cgfs_d = handler->cgroup_data; |
74 |
+ if (!cgfs_d) |
75 |
+ return false; |
76 |
+ base_info = cgfs_d->info; |
77 |
+diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c |
78 |
+index e43edd7d..ec6440c1 100644 |
79 |
+--- a/src/lxc/cgroups/cgfsng.c |
80 |
++++ b/src/lxc/cgroups/cgfsng.c |
81 |
+@@ -50,6 +50,7 @@ |
82 |
+ #include <linux/types.h> |
83 |
+ #include <linux/kdev_t.h> |
84 |
+ |
85 |
++#include "caps.h" |
86 |
+ #include "cgroup.h" |
87 |
+ #include "cgroup_utils.h" |
88 |
+ #include "commands.h" |
89 |
+@@ -1616,17 +1617,49 @@ do_secondstage_mounts_if_needed(int type, struct hierarchy *h, |
90 |
+ return 0; |
91 |
+ } |
92 |
+ |
93 |
++static int mount_cgroup_cgns_supported(struct hierarchy *h, const char *controllerpath) |
94 |
++{ |
95 |
++ int ret; |
96 |
++ char *controllers = NULL; |
97 |
++ char *type = "cgroup2"; |
98 |
++ |
99 |
++ if (!h->is_cgroup_v2) { |
100 |
++ controllers = lxc_string_join(",", (const char **)h->controllers, false); |
101 |
++ if (!controllers) |
102 |
++ return -ENOMEM; |
103 |
++ type = "cgroup"; |
104 |
++ } |
105 |
++ |
106 |
++ ret = mount("cgroup", controllerpath, type, MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RELATIME, controllers); |
107 |
++ free(controllers); |
108 |
++ if (ret < 0) { |
109 |
++ SYSERROR("Failed to mount %s with cgroup filesystem type %s", controllerpath, type); |
110 |
++ return -1; |
111 |
++ } |
112 |
++ |
113 |
++ DEBUG("Mounted %s with cgroup filesystem type %s", controllerpath, type); |
114 |
++ return 0; |
115 |
++} |
116 |
++ |
117 |
+ static bool cgfsng_mount(void *hdata, const char *root, int type) |
118 |
+ { |
119 |
+- struct cgfsng_handler_data *d = hdata; |
120 |
++ int i; |
121 |
+ char *tmpfspath = NULL; |
122 |
+ bool retval = false; |
123 |
+- int i; |
124 |
++ struct lxc_handler *handler = hdata; |
125 |
++ struct cgfsng_handler_data *d = handler->cgroup_data; |
126 |
++ bool has_cgns = false, has_sys_admin = true; |
127 |
+ |
128 |
+ if ((type & LXC_AUTO_CGROUP_MASK) == 0) |
129 |
+ return true; |
130 |
+ |
131 |
+- if (cgns_supported()) |
132 |
++ has_cgns = cgns_supported(); |
133 |
++ if (!lxc_list_empty(&handler->conf->keepcaps)) |
134 |
++ has_sys_admin = in_caplist(CAP_SYS_ADMIN, &handler->conf->keepcaps); |
135 |
++ else |
136 |
++ has_sys_admin = !in_caplist(CAP_SYS_ADMIN, &handler->conf->caps); |
137 |
++ |
138 |
++ if (has_cgns && has_sys_admin) |
139 |
+ return true; |
140 |
+ |
141 |
+ tmpfspath = must_make_path(root, "/sys/fs/cgroup", NULL); |
142 |
+@@ -1662,6 +1695,19 @@ static bool cgfsng_mount(void *hdata, const char *root, int type) |
143 |
+ free(controllerpath); |
144 |
+ goto bad; |
145 |
+ } |
146 |
++ |
147 |
++ if (has_cgns && !has_sys_admin) { |
148 |
++ /* If cgroup namespaces are supported but the container |
149 |
++ * will not have CAP_SYS_ADMIN after it has started we |
150 |
++ * need to mount the cgroups manually. |
151 |
++ */ |
152 |
++ r = mount_cgroup_cgns_supported(h, controllerpath); |
153 |
++ free(controllerpath); |
154 |
++ if (r < 0) |
155 |
++ goto bad; |
156 |
++ continue; |
157 |
++ } |
158 |
++ |
159 |
+ if (mount_cgroup_full(type, h, controllerpath, d->container_cgroup) < 0) { |
160 |
+ free(controllerpath); |
161 |
+ goto bad; |
162 |
+diff --git a/src/lxc/cgroups/cgroup.c b/src/lxc/cgroups/cgroup.c |
163 |
+index 674e3090..36a665b1 100644 |
164 |
+--- a/src/lxc/cgroups/cgroup.c |
165 |
++++ b/src/lxc/cgroups/cgroup.c |
166 |
+@@ -166,7 +166,7 @@ bool cgroup_chown(struct lxc_handler *handler) |
167 |
+ bool cgroup_mount(const char *root, struct lxc_handler *handler, int type) |
168 |
+ { |
169 |
+ if (ops) |
170 |
+- return ops->mount_cgroup(handler->cgroup_data, root, type); |
171 |
++ return ops->mount_cgroup(handler, root, type); |
172 |
+ |
173 |
+ return false; |
174 |
+ } |
175 |
+diff --git a/src/lxc/conf.c b/src/lxc/conf.c |
176 |
+index d2fab945..44d97843 100644 |
177 |
+--- a/src/lxc/conf.c |
178 |
++++ b/src/lxc/conf.c |
179 |
+@@ -210,9 +210,6 @@ __thread struct lxc_conf *current_config; |
180 |
+ struct lxc_conf *current_config; |
181 |
+ #endif |
182 |
+ |
183 |
+-/* Declare this here, since we don't want to reshuffle the whole file. */ |
184 |
+-static int in_caplist(int cap, struct lxc_list *caps); |
185 |
+- |
186 |
+ static struct mount_opt mount_opt[] = { |
187 |
+ { "async", 1, MS_SYNCHRONOUS }, |
188 |
+ { "atime", 1, MS_NOATIME }, |
189 |
+diff --git a/src/lxc/conf.h b/src/lxc/conf.h |
190 |
+index c61f861e..63e71e2d 100644 |
191 |
+--- a/src/lxc/conf.h |
192 |
++++ b/src/lxc/conf.h |
193 |
+@@ -402,5 +402,6 @@ extern unsigned long add_required_remount_flags(const char *s, const char *d, |
194 |
+ unsigned long flags); |
195 |
+ extern int run_script(const char *name, const char *section, const char *script, |
196 |
+ ...); |
197 |
++extern int in_caplist(int cap, struct lxc_list *caps); |
198 |
+ |
199 |
+ #endif /* __LXC_CONF_H */ |
200 |
+-- |
201 |
+2.13.6 |
202 |
+ |
203 |
|
204 |
diff --git a/app-emulation/lxc/files/lxc-2.1.1-fix-cgroup2-detection.patch b/app-emulation/lxc/files/lxc-2.1.1-fix-cgroup2-detection.patch |
205 |
new file mode 100644 |
206 |
index 00000000000..c16d28ac303 |
207 |
--- /dev/null |
208 |
+++ b/app-emulation/lxc/files/lxc-2.1.1-fix-cgroup2-detection.patch |
209 |
@@ -0,0 +1,26 @@ |
210 |
+From cdfe90a49f516b0f1210d181980f14a4765e10da Mon Sep 17 00:00:00 2001 |
211 |
+From: Christian Brauner <christian.brauner@××××××.com> |
212 |
+Date: Mon, 30 Oct 2017 14:17:20 +0100 |
213 |
+Subject: [PATCH] cgfsng: fix cgroup2 detection |
214 |
+ |
215 |
+Signed-off-by: Christian Brauner <christian.brauner@××××××.com> |
216 |
+--- |
217 |
+ src/lxc/cgroups/cgfsng.c | 2 +- |
218 |
+ 1 file changed, 1 insertion(+), 1 deletion(-) |
219 |
+ |
220 |
+diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c |
221 |
+index 897336f0..e43edd7d 100644 |
222 |
+--- a/src/lxc/cgroups/cgfsng.c |
223 |
++++ b/src/lxc/cgroups/cgfsng.c |
224 |
+@@ -815,7 +815,7 @@ static void add_controller(char **clist, char *mountpoint, char *base_cgroup) |
225 |
+ new->fullcgpath = NULL; |
226 |
+ |
227 |
+ /* record if this is the cgroup v2 hierarchy */ |
228 |
+- if (!strcmp(base_cgroup, "cgroup2")) |
229 |
++ if (clist && !strcmp(*clist, "cgroup2")) |
230 |
+ new->is_cgroup_v2 = true; |
231 |
+ else |
232 |
+ new->is_cgroup_v2 = false; |
233 |
+-- |
234 |
+2.13.6 |
235 |
+ |
236 |
|
237 |
diff --git a/app-emulation/lxc/files/lxc.initd.7 b/app-emulation/lxc/files/lxc.initd.7 |
238 |
new file mode 100644 |
239 |
index 00000000000..6a42b6aac52 |
240 |
--- /dev/null |
241 |
+++ b/app-emulation/lxc/files/lxc.initd.7 |
242 |
@@ -0,0 +1,124 @@ |
243 |
+#!/sbin/openrc-run |
244 |
+# Copyright 1999-2017 Gentoo Foundation |
245 |
+# Distributed under the terms of the GNU General Public License v2 |
246 |
+ |
247 |
+CONTAINER=${SVCNAME#*.} |
248 |
+ |
249 |
+LXC_PATH=`lxc-config lxc.lxcpath` |
250 |
+ |
251 |
+lxc_get_configfile() { |
252 |
+ if [ -f "${LXC_PATH}/${CONTAINER}.conf" ]; then |
253 |
+ echo "${LXC_PATH}/${CONTAINER}.conf" |
254 |
+ elif [ -f "${LXC_PATH}/${CONTAINER}/config" ]; then |
255 |
+ echo "${LXC_PATH}/${CONTAINER}/config" |
256 |
+ else |
257 |
+ eerror "Unable to find a suitable configuration file." |
258 |
+ eerror "If you set up the container in a non-standard" |
259 |
+ eerror "location, please set the CONFIGFILE variable." |
260 |
+ return 1 |
261 |
+ fi |
262 |
+} |
263 |
+ |
264 |
+[ $CONTAINER != $SVCNAME ] && CONFIGFILE=${CONFIGFILE:-$(lxc_get_configfile)} |
265 |
+ |
266 |
+lxc_get_var() { |
267 |
+ awk 'BEGIN { FS="[ \t]*=[ \t]*" } $1 == "'$1'" { print $2; exit }' ${CONFIGFILE} |
268 |
+} |
269 |
+ |
270 |
+lxc_get_net_link_type() { |
271 |
+ awk 'BEGIN { FS="[ \t]*=[ \t]*"; _link=""; _type="" } |
272 |
+ $1 == "lxc.network.type" {_type=$2;} |
273 |
+ $1 == "lxc.network.link" {_link=$2;} |
274 |
+ match($1, /lxc\.net\.[[:digit:]]+\.type/) {_type=$2;} |
275 |
+ match($1, /lxc\.net\.[[:digit:]]+\.link/) {_link=$2;} |
276 |
+ {if(_link != "" && _type != ""){ |
277 |
+ printf("%s:%s\n", _link, _type ); |
278 |
+ _link=""; _type=""; |
279 |
+ }; }' <${CONFIGFILE} |
280 |
+} |
281 |
+ |
282 |
+checkconfig() { |
283 |
+ if [ ${CONTAINER} = ${SVCNAME} ]; then |
284 |
+ eerror "You have to create an init script for each container:" |
285 |
+ eerror " ln -s lxc /etc/init.d/lxc.container" |
286 |
+ return 1 |
287 |
+ fi |
288 |
+ |
289 |
+ # no need to output anything, the function takes care of that. |
290 |
+ [ -z "${CONFIGFILE}" ] && return 1 |
291 |
+ |
292 |
+ utsname=$(lxc_get_var lxc.uts.name) |
293 |
+ if [ -z "$utsname" ] ; then |
294 |
+ utsname=$(lxc_get_var lxc.utsname) |
295 |
+ fi |
296 |
+ |
297 |
+ if [ "${CONTAINER}" != "${utsname}" ]; then |
298 |
+ eerror "You should use the same name for the service and the" |
299 |
+ eerror "container. Right now the container is called ${utsname}" |
300 |
+ return 1 |
301 |
+ fi |
302 |
+} |
303 |
+ |
304 |
+depend() { |
305 |
+ # be quiet, since we have to run depend() also for the |
306 |
+ # non-muxed init script, unfortunately. |
307 |
+ checkconfig 2>/dev/null || return 0 |
308 |
+ |
309 |
+ config ${CONFIGFILE} |
310 |
+ need localmount |
311 |
+ use lxcfs |
312 |
+ |
313 |
+ local _x _if |
314 |
+ for _x in $(lxc_get_net_link_type); do |
315 |
+ _if=${_x%:*} |
316 |
+ case "${_x##*:}" in |
317 |
+ # when the network type is set to phys, we can make use of a |
318 |
+ # network service (for instance to set it up before we disable |
319 |
+ # the net_admin capability), but we might also not set it up |
320 |
+ # at all on the host and leave the net_admin capable service |
321 |
+ # to take care of it. |
322 |
+ phys) use net.${_if} ;; |
323 |
+ *) need net.${_if} ;; |
324 |
+ esac |
325 |
+ done |
326 |
+} |
327 |
+ |
328 |
+start() { |
329 |
+ checkconfig || return 1 |
330 |
+ rm -f /var/log/lxc/${CONTAINER}.log |
331 |
+ |
332 |
+ rootpath=$(lxc_get_var lxc.rootfs) |
333 |
+ |
334 |
+ # Check the format of our init and the chroot's init, to see |
335 |
+ # if we have to use linux32 or linux64; always use setarch |
336 |
+ # when required, as that makes it easier to deal with |
337 |
+ # x32-based containers. |
338 |
+ case $(scanelf -BF '%a#f' ${rootpath}/sbin/init) in |
339 |
+ EM_X86_64) setarch=linux64;; |
340 |
+ EM_386) setarch=linux32;; |
341 |
+ esac |
342 |
+ |
343 |
+ ebegin "Starting ${CONTAINER}" |
344 |
+ env -i ${setarch} $(which lxc-start) -l WARN -n ${CONTAINER} -f ${CONFIGFILE} -d -o /var/log/lxc/${CONTAINER}.log |
345 |
+ sleep 1 |
346 |
+ |
347 |
+ # lxc-start -d will _always_ report a correct startup, even if it |
348 |
+ # failed, so rather than trust that, check that the cgroup exists. |
349 |
+ [ -d /sys/fs/cgroup/cpuset/lxc/${CONTAINER} ] |
350 |
+ eend $? |
351 |
+} |
352 |
+ |
353 |
+stop() { |
354 |
+ checkconfig || return 1 |
355 |
+ |
356 |
+ |
357 |
+ if ! [ -d /sys/fs/cgroup/cpuset/lxc/${CONTAINER} ]; then |
358 |
+ ewarn "${CONTAINER} doesn't seem to be started." |
359 |
+ return 0 |
360 |
+ fi |
361 |
+ |
362 |
+ # 10s should be enough to shut everything down |
363 |
+ ebegin "Stopping ${CONTAINER}" |
364 |
+ lxc-stop -t 10 -n ${CONTAINER} |
365 |
+ eend $? |
366 |
+} |
367 |
|
368 |
diff --git a/app-emulation/lxc/lxc-2.1.1.ebuild b/app-emulation/lxc/lxc-2.1.1.ebuild |
369 |
new file mode 100644 |
370 |
index 00000000000..7ddad1b7527 |
371 |
--- /dev/null |
372 |
+++ b/app-emulation/lxc/lxc-2.1.1.ebuild |
373 |
@@ -0,0 +1,201 @@ |
374 |
+# Copyright 1999-2017 Gentoo Foundation |
375 |
+# Distributed under the terms of the GNU General Public License v2 |
376 |
+ |
377 |
+EAPI="6" |
378 |
+ |
379 |
+PYTHON_COMPAT=( python{3_4,3_5} ) |
380 |
+DISTUTILS_OPTIONAL=1 |
381 |
+ |
382 |
+inherit autotools bash-completion-r1 distutils-r1 linux-info versionator flag-o-matic systemd |
383 |
+ |
384 |
+DESCRIPTION="LinuX Containers userspace utilities" |
385 |
+HOMEPAGE="https://linuxcontainers.org/" |
386 |
+SRC_URI="https://linuxcontainers.org/downloads/lxc/${P}.tar.gz" |
387 |
+ |
388 |
+KEYWORDS="~amd64 ~arm ~arm64" |
389 |
+ |
390 |
+LICENSE="LGPL-3" |
391 |
+SLOT="0" |
392 |
+IUSE="cgmanager doc examples lua python seccomp" |
393 |
+ |
394 |
+RDEPEND="net-libs/gnutls |
395 |
+ sys-libs/libcap |
396 |
+ cgmanager? ( app-admin/cgmanager ) |
397 |
+ lua? ( >=dev-lang/lua-5.1:= ) |
398 |
+ python? ( ${PYTHON_DEPS} ) |
399 |
+ seccomp? ( sys-libs/libseccomp )" |
400 |
+ |
401 |
+DEPEND="${RDEPEND} |
402 |
+ doc? ( app-text/docbook-sgml-utils ) |
403 |
+ >=sys-kernel/linux-headers-3.2" |
404 |
+ |
405 |
+RDEPEND="${RDEPEND} |
406 |
+ sys-process/criu |
407 |
+ sys-apps/util-linux |
408 |
+ app-misc/pax-utils |
409 |
+ virtual/awk" |
410 |
+ |
411 |
+CONFIG_CHECK="~CGROUPS ~CGROUP_DEVICE |
412 |
+ ~CPUSETS ~CGROUP_CPUACCT |
413 |
+ ~CGROUP_SCHED |
414 |
+ |
415 |
+ ~NAMESPACES |
416 |
+ ~IPC_NS ~USER_NS ~PID_NS |
417 |
+ |
418 |
+ ~NETLINK_DIAG ~PACKET_DIAG |
419 |
+ ~INET_UDP_DIAG ~INET_TCP_DIAG |
420 |
+ ~UNIX_DIAG ~CHECKPOINT_RESTORE |
421 |
+ |
422 |
+ ~CGROUP_FREEZER |
423 |
+ ~UTS_NS ~NET_NS |
424 |
+ ~VETH ~MACVLAN |
425 |
+ |
426 |
+ ~POSIX_MQUEUE |
427 |
+ ~!NETPRIO_CGROUP |
428 |
+ |
429 |
+ ~!GRKERNSEC_CHROOT_MOUNT |
430 |
+ ~!GRKERNSEC_CHROOT_DOUBLE |
431 |
+ ~!GRKERNSEC_CHROOT_PIVOT |
432 |
+ ~!GRKERNSEC_CHROOT_CHMOD |
433 |
+ ~!GRKERNSEC_CHROOT_CAPS |
434 |
+ ~!GRKERNSEC_PROC |
435 |
+ ~!GRKERNSEC_SYSFS_RESTRICT |
436 |
+" |
437 |
+ |
438 |
+ERROR_DEVPTS_MULTIPLE_INSTANCES="CONFIG_DEVPTS_MULTIPLE_INSTANCES: needed for pts inside container" |
439 |
+ |
440 |
+ERROR_CGROUP_FREEZER="CONFIG_CGROUP_FREEZER: needed to freeze containers" |
441 |
+ |
442 |
+ERROR_UTS_NS="CONFIG_UTS_NS: needed to unshare hostnames and uname info" |
443 |
+ERROR_NET_NS="CONFIG_NET_NS: needed for unshared network" |
444 |
+ |
445 |
+ERROR_VETH="CONFIG_VETH: needed for internal (host-to-container) networking" |
446 |
+ERROR_MACVLAN="CONFIG_MACVLAN: needed for internal (inter-container) networking" |
447 |
+ |
448 |
+ERROR_NETLINK_DIAG="CONFIG_NETLINK_DIAG: needed for lxc-checkpoint" |
449 |
+ERROR_PACKET_DIAG="CONFIG_PACKET_DIAG: needed for lxc-checkpoint" |
450 |
+ERROR_INET_UDP_DIAG="CONFIG_INET_UDP_DIAG: needed for lxc-checkpoint" |
451 |
+ERROR_INET_TCP_DIAG="CONFIG_INET_TCP_DIAG: needed for lxc-checkpoint" |
452 |
+ERROR_UNIX_DIAG="CONFIG_UNIX_DIAG: needed for lxc-checkpoint" |
453 |
+ERROR_CHECKPOINT_RESTORE="CONFIG_CHECKPOINT_RESTORE: needed for lxc-checkpoint" |
454 |
+ |
455 |
+ERROR_POSIX_MQUEUE="CONFIG_POSIX_MQUEUE: needed for lxc-execute command" |
456 |
+ |
457 |
+ERROR_NETPRIO_CGROUP="CONFIG_NETPRIO_CGROUP: as of kernel 3.3 and lxc 0.8.0_rc1 this causes LXCs to fail booting." |
458 |
+ |
459 |
+ERROR_GRKERNSEC_CHROOT_MOUNT="CONFIG_GRKERNSEC_CHROOT_MOUNT: some GRSEC features make LXC unusable see postinst notes" |
460 |
+ERROR_GRKERNSEC_CHROOT_DOUBLE="CONFIG_GRKERNSEC_CHROOT_DOUBLE: some GRSEC features make LXC unusable see postinst notes" |
461 |
+ERROR_GRKERNSEC_CHROOT_PIVOT="CONFIG_GRKERNSEC_CHROOT_PIVOT: some GRSEC features make LXC unusable see postinst notes" |
462 |
+ERROR_GRKERNSEC_CHROOT_CHMOD="CONFIG_GRKERNSEC_CHROOT_CHMOD: some GRSEC features make LXC unusable see postinst notes" |
463 |
+ERROR_GRKERNSEC_CHROOT_CAPS="CONFIG_GRKERNSEC_CHROOT_CAPS: some GRSEC features make LXC unusable see postinst notes" |
464 |
+ERROR_GRKERNSEC_PROC="CONFIG_GRKERNSEC_PROC: this GRSEC feature is incompatible with unprivileged containers" |
465 |
+ERROR_GRKERNSEC_SYSFS_RESTRICT="CONFIG_GRKERNSEC_SYSFS_RESTRICT: this GRSEC feature is incompatible with unprivileged containers" |
466 |
+ |
467 |
+DOCS=(AUTHORS CONTRIBUTING MAINTAINERS NEWS README doc/FAQ.txt) |
468 |
+ |
469 |
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" |
470 |
+ |
471 |
+pkg_setup() { |
472 |
+ kernel_is -lt 4 7 && CONFIG_CHECK="${CONFIG_CHECK} ~DEVPTS_MULTIPLE_INSTANCES" |
473 |
+ linux-info_pkg_setup |
474 |
+} |
475 |
+ |
476 |
+src_prepare() { |
477 |
+ eapply "${FILESDIR}"/${PN}-2.0.6-bash-completion.patch |
478 |
+ #558854 |
479 |
+ eapply "${FILESDIR}"/${PN}-2.0.5-omit-sysconfig.patch |
480 |
+ eapply "${FILESDIR}"/${PN}-2.1.1-fix-cgroup2-detection.patch |
481 |
+ eapply "${FILESDIR}"/${PN}-2.1.1-cgroups-enable-container-without-CAP_SYS_ADMIN.patch |
482 |
+ eapply_user |
483 |
+ eautoreconf |
484 |
+} |
485 |
+ |
486 |
+src_configure() { |
487 |
+ append-flags -fno-strict-aliasing |
488 |
+ |
489 |
+ if use python; then |
490 |
+ #541932 |
491 |
+ python_setup "python3*" |
492 |
+ export PKG_CONFIG_PATH="${T}/${EPYTHON}/pkgconfig:${PKG_CONFIG_PATH}" |
493 |
+ fi |
494 |
+ |
495 |
+ # I am not sure about the --with-rootfs-path |
496 |
+ # /var/lib/lxc is probably more appropriate than |
497 |
+ # /usr/lib/lxc. |
498 |
+ # Note by holgersson: Why is apparmor disabled? |
499 |
+ econf \ |
500 |
+ --localstatedir=/var \ |
501 |
+ --bindir=/usr/bin \ |
502 |
+ --sbindir=/usr/bin \ |
503 |
+ --with-config-path=/var/lib/lxc \ |
504 |
+ --with-rootfs-path=/var/lib/lxc/rootfs \ |
505 |
+ --with-distro=gentoo \ |
506 |
+ --with-runtime-path=/run \ |
507 |
+ --disable-apparmor \ |
508 |
+ --disable-werror \ |
509 |
+ $(use_enable cgmanager) \ |
510 |
+ $(use_enable doc) \ |
511 |
+ $(use_enable examples) \ |
512 |
+ $(use_enable lua) \ |
513 |
+ $(use_enable python) \ |
514 |
+ $(use_enable seccomp) |
515 |
+} |
516 |
+ |
517 |
+python_compile() { |
518 |
+ distutils-r1_python_compile build_ext -I ../ -L ../${PN} |
519 |
+} |
520 |
+ |
521 |
+src_compile() { |
522 |
+ default |
523 |
+ |
524 |
+ if use python; then |
525 |
+ pushd "${S}/src/python-${PN}" > /dev/null |
526 |
+ distutils-r1_src_compile |
527 |
+ popd > /dev/null |
528 |
+ fi |
529 |
+} |
530 |
+ |
531 |
+src_install() { |
532 |
+ default |
533 |
+ |
534 |
+ mv "${ED}"/usr/share/bash-completion/completions/${PN} "${ED}"/$(get_bashcompdir)/${PN}-start || die |
535 |
+ # start-ephemeral is no longer a command but removing it here |
536 |
+ # generates QA warnings (still in upstream completion script) |
537 |
+ bashcomp_alias ${PN}-start \ |
538 |
+ ${PN}-{attach,cgroup,copy,console,create,destroy,device,execute,freeze,info,monitor,snapshot,start-ephemeral,stop,unfreeze,wait} |
539 |
+ |
540 |
+ if use python; then |
541 |
+ pushd "${S}/src/python-lxc" > /dev/null |
542 |
+ # Unset DOCS. This has been handled by the default target |
543 |
+ unset DOCS |
544 |
+ distutils-r1_src_install |
545 |
+ popd > /dev/null |
546 |
+ fi |
547 |
+ |
548 |
+ keepdir /etc/lxc /var/lib/lxc/rootfs /var/log/lxc |
549 |
+ |
550 |
+ find "${D}" -name '*.la' -delete |
551 |
+ |
552 |
+ # Gentoo-specific additions! |
553 |
+ newinitd "${FILESDIR}/${PN}.initd.7" ${PN} |
554 |
+ |
555 |
+ # Remember to compare our systemd unit file with the upstream one |
556 |
+ # config/init/systemd/lxc.service.in |
557 |
+ systemd_newunit "${FILESDIR}"/${PN}_at.service.4 "lxc@.service" |
558 |
+} |
559 |
+ |
560 |
+pkg_postinst() { |
561 |
+ elog "" |
562 |
+ elog "Starting from version ${PN}-1.1.0-r3, the default lxc path has been" |
563 |
+ elog "moved from /etc/lxc to /var/lib/lxc. If you still want to use /etc/lxc" |
564 |
+ elog "please add the following to your /etc/lxc/default.conf" |
565 |
+ elog "lxc.lxcpath = /etc/lxc" |
566 |
+ elog "" |
567 |
+ elog "There is an init script provided with the package now; no documentation" |
568 |
+ elog "is currently available though, so please check out /etc/init.d/lxc ." |
569 |
+ elog "You _should_ only need to symlink it to /etc/init.d/lxc.configname" |
570 |
+ elog "to start the container defined into /etc/lxc/configname.conf ." |
571 |
+ elog "For further information about LXC development see" |
572 |
+ elog "http://blog.flameeyes.eu/tag/lxc" # remove once proper doc is available |
573 |
+ elog "" |
574 |
+} |