blob: 93d5a10672e25961faa2b541fc0e4c71e724aa98 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001DESCRIPTION = "lxc aims to use these new functionnalities to provide an userspace container object"
2SECTION = "console/utils"
3LICENSE = "GPLv2"
4LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c"
5DEPENDS = "libxml2 libcap"
6RDEPENDS_${PN} = " \
7 rsync \
8 gzip \
9 libcap-bin \
10 bridge-utils \
11 dnsmasq \
12 perl-module-strict \
13 perl-module-getopt-long \
14 perl-module-vars \
15 perl-module-warnings-register \
16 perl-module-exporter \
17 perl-module-constant \
18 perl-module-overload \
19 perl-module-exporter-heavy \
20 gmp \
21 libidn \
22 gnutls \
23 nettle \
24"
25RDEPENDS_${PN}-ptest += "file make gmp nettle gnutls bash"
26
27SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \
28 file://lxc-1.0.0-disable-udhcp-from-busybox-template.patch \
29 file://runtest.patch \
30 file://run-ptest \
31 file://automake-ensure-VPATH-builds-correctly.patch \
32 file://lxc-fix-B-S.patch \
33 file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \
34 file://logs-optionally-use-base-filenames-to-report-src-fil.patch \
35 file://cgroups-work-around-issue-in-gcc-7.patch \
36 "
37
38SRC_URI[md5sum] = "7bfd95280522d7936c0979dfea92cdb5"
39SRC_URI[sha256sum] = "0d8e34b302cfe4c40c6c9ae5097096aa5cc2c1dfceea3f0f22e3e16c4a4e8494"
40
41S = "${WORKDIR}/${BPN}-${PV}"
42
43# Let's not configure for the host distro.
44#
45PTEST_CONF = "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '--enable-tests', '', d)}"
46EXTRA_OECONF += "--with-distro=${DISTRO} ${PTEST_CONF}"
47
48EXTRA_OECONF += "--with-init-script=\
49${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'sysvinit,', '', d)}\
50${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
51
52EXTRA_OECONF += "--enable-log-src-basename"
53
54CFLAGS_append = " -Wno-error=deprecated-declarations"
55
56PACKAGECONFIG ??= "templates \
57 ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \
58"
59PACKAGECONFIG[doc] = "--enable-doc --enable-api-docs,--disable-doc --disable-api-docs,,"
60PACKAGECONFIG[rpath] = "--enable-rpath,--disable-rpath,,"
61PACKAGECONFIG[apparmour] = "--enable-apparmor,--disable-apparmor,apparmor,apparmor"
62PACKAGECONFIG[templates] = ",,, ${PN}-templates"
63PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux,libselinux,libselinux"
64PACKAGECONFIG[seccomp] ="--enable-seccomp,--disable-seccomp,libseccomp,libseccomp"
65PACKAGECONFIG[python] = "--enable-python,--disable-python,python3,python3-core"
66PACKAGECONFIG[lua] = "--enable-lua,--disable-lua,lua,lua"
67
68# required by python3 to run setup.py
69export BUILD_SYS
70export HOST_SYS
71export STAGING_INCDIR
72export STAGING_LIBDIR
73
74inherit autotools pkgconfig ptest update-rc.d systemd python3native
75
76SYSTEMD_PACKAGES = "${PN}-setup"
77SYSTEMD_SERVICE_${PN}-setup = "lxc.service"
78SYSTEMD_AUTO_ENABLE_${PN}-setup = "disable"
79
80INITSCRIPT_PACKAGES = "${PN}-setup"
81INITSCRIPT_NAME_{PN}-setup = "lxc"
82INITSCRIPT_PARAMS_${PN}-setup = "defaults"
83
84FILES_${PN}-doc = "${mandir} ${infodir}"
85# For LXC the docdir only contains example configuration files and should be included in the lxc package
86FILES_${PN} += "${docdir}"
87FILES_${PN} += "${libdir}/python3*"
88FILES_${PN} += "${datadir}/bash-completion"
89FILES_${PN}-dbg += "${libexecdir}/lxc/.debug"
90FILES_${PN}-dbg += "${libexecdir}/lxc/hooks/.debug"
91PACKAGES =+ "${PN}-templates ${PN}-setup ${PN}-networking ${PN}-lua"
92FILES_lua-${PN} = "${datadir}/lua ${libdir}/lua"
93FILES_lua-${PN}-dbg += "${libdir}/lua/lxc/.debug"
94FILES_${PN}-templates += "${datadir}/lxc/templates"
95RDEPENDS_${PN}-templates += "bash"
96
97ALLOW_EMPTY_${PN}-networking = "1"
98
99FILES_${PN}-setup += "/etc/tmpfiles.d"
100FILES_${PN}-setup += "/lib/systemd/system"
101FILES_${PN}-setup += "/usr/lib/systemd/system"
102FILES_${PN}-setup += "/etc/init.d"
103
104PRIVATE_LIBS_${PN}-ptest = "liblxc.so.1"
105
106CACHED_CONFIGUREVARS += " \
107 ac_cv_path_PYTHON='${STAGING_BINDIR_NATIVE}/python3-native/python3' \
108 am_cv_python_pyexecdir='${exec_prefix}/${libdir}/python3.5/site-packages' \
109 am_cv_python_pythondir='${prefix}/${libdir}/python3.5/site-packages' \
110"
111
112do_install_append() {
113 # The /var/cache/lxc directory created by the Makefile
114 # is wiped out in volatile, we need to create this at boot.
115 rm -rf ${D}${localstatedir}/cache
116 install -d ${D}${sysconfdir}/default/volatiles
117 echo "d root root 0755 ${localstatedir}/cache/lxc none" \
118 > ${D}${sysconfdir}/default/volatiles/99_lxc
119
120 for i in `grep -l "#! */bin/bash" ${D}${datadir}/lxc/hooks/*`; do \
121 sed -e 's|#! */bin/bash|#!/bin/sh|' -i $i; done
122
123 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
124 install -d ${D}${sysconfdir}/init.d
125 install -m 755 config/init/sysvinit/lxc* ${D}${sysconfdir}/init.d
126 fi
127
128 # since python3-native is used for install location this will not be
129 # suitable for the target and we will have to correct the package install
130 if ${@bb.utils.contains('PACKAGECONFIG', 'python', 'true', 'false', d)}; then
131 if [ -d ${D}${exec_prefix}/lib/python* ]; then mv ${D}${exec_prefix}/lib/python* ${D}${libdir}/; fi
132 rmdir --ignore-fail-on-non-empty ${D}${exec_prefix}/lib
133 fi
134}
135
136EXTRA_OEMAKE += "TEST_DIR=${D}${PTEST_PATH}/src/tests"
137
138do_install_ptest() {
139 oe_runmake -C src/tests install-ptest
140}
141
142pkg_postinst_${PN}() {
143 if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then
144 /etc/init.d/populate-volatile.sh update
145 fi
146}
147
148pkg_postinst_${PN}-networking() {
149 if [ "x$D" != "x" ]; then
150 exit 1
151 fi
152
153 # setup for our bridge
154 echo "lxc.network.link=lxcbr0" >> ${sysconfdir}/lxc/default.conf
155
156cat >> /etc/network/interfaces << EOF
157
158auto lxcbr0
159iface lxcbr0 inet dhcp
160 bridge_ports eth0
161 bridge_fd 0
162 bridge_maxwait 0
163EOF
164
165cat<<EOF>/etc/network/if-pre-up.d/lxcbr0
166#! /bin/sh
167
168if test "x\$IFACE" = xlxcbr0 ; then
169 brctl show |grep lxcbr0 > /dev/null 2>/dev/null
170 if [ \$? != 0 ] ; then
171 brctl addbr lxcbr0
172 brctl addif lxcbr0 eth0
173 ip addr flush eth0
174 ifconfig eth0 up
175 fi
176fi
177EOF
178chmod 755 /etc/network/if-pre-up.d/lxcbr0
179}