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