blob: c98d1a7f61b0a6e3327b267cb0f0bea3b0095642 [file] [log] [blame]
Patrick Williamsd849ec72016-08-17 14:59:38 -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"
5PRIORITY = "optional"
6DEPENDS = "libxml2 libcap"
7RDEPENDS_${PN} = " \
8 rsync \
9 gzip \
10 libcap-bin \
11 bridge-utils \
12 dnsmasq \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013 initscripts \
Patrick Williamsd849ec72016-08-17 14:59:38 -050014 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 \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050022"
23RDEPENDS_${PN}_append_libc-glibc = "\
Patrick Williamse69d2352017-02-23 20:56:04 -060024 glibc-utils \
Patrick Williamsd849ec72016-08-17 14:59:38 -050025"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026
Patrick Williamsd849ec72016-08-17 14:59:38 -050027RDEPENDS_${PN}-ptest += "file make"
28
29SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \
30 file://lxc-1.0.0-disable-udhcp-from-busybox-template.patch \
31 file://runtest.patch \
32 file://run-ptest \
33 file://automake-ensure-VPATH-builds-correctly.patch \
34 file://lxc-fix-B-S.patch \
35 file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \
36 file://logs-optionally-use-base-filenames-to-report-src-fil.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050037 file://Use-AC_HEADER_MAJOR-to-detect-major-minor-makedev.patch \
Patrick Williamsd849ec72016-08-17 14:59:38 -050038 "
39
40SRC_URI[md5sum] = "04a7245a614cd3296b0ae9ceeeb83fbb"
41SRC_URI[sha256sum] = "5b737e114d8ef1feb193fba936d77a5697a7c8a10199a068cdd90d1bd27c10e4"
42
43S = "${WORKDIR}/${BPN}-${PV}"
44
45# Let's not configure for the host distro.
46#
Patrick Williamse69d2352017-02-23 20:56:04 -060047PTEST_CONF = "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '--enable-tests', '', d)}"
Patrick Williamsd849ec72016-08-17 14:59:38 -050048EXTRA_OECONF += "--with-distro=${DISTRO} ${PTEST_CONF}"
49
50EXTRA_OECONF += "--with-init-script=\
51${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'sysvinit,', '', d)}\
52${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
53
54EXTRA_OECONF += "--enable-log-src-basename"
55
Patrick Williamse69d2352017-02-23 20:56:04 -060056CFLAGS_append = " -Wno-error=deprecated-declarations"
57
Patrick Williamsd849ec72016-08-17 14:59:38 -050058PACKAGECONFIG ??= "templates \
Patrick Williamse69d2352017-02-23 20:56:04 -060059 ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \
Patrick Williamsd849ec72016-08-17 14:59:38 -050060"
61PACKAGECONFIG[doc] = "--enable-doc --enable-api-docs,--disable-doc --disable-api-docs,,"
62PACKAGECONFIG[rpath] = "--enable-rpath,--disable-rpath,,"
63PACKAGECONFIG[apparmour] = "--enable-apparmor,--disable-apparmor,apparmor,apparmor"
64PACKAGECONFIG[templates] = ",,, ${PN}-templates"
65PACKAGECONFIG[selinux] = "--enable-selinux,--disable-selinux,libselinux,libselinux"
66PACKAGECONFIG[seccomp] ="--enable-seccomp,--disable-seccomp,libseccomp,libseccomp"
67PACKAGECONFIG[python] = "--enable-python,--disable-python,python3,python3-core"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068PACKAGECONFIG[lua] = "--enable-lua,--disable-lua,lua,lua"
Patrick Williamsd849ec72016-08-17 14:59:38 -050069
70# required by python3 to run setup.py
71export BUILD_SYS
72export HOST_SYS
73export STAGING_INCDIR
74export STAGING_LIBDIR
75
76inherit autotools pkgconfig ptest update-rc.d systemd python3native
77
78SYSTEMD_PACKAGES = "${PN}-setup"
79SYSTEMD_SERVICE_${PN}-setup = "lxc.service"
80SYSTEMD_AUTO_ENABLE_${PN}-setup = "disable"
81
82INITSCRIPT_PACKAGES = "${PN}-setup"
83INITSCRIPT_NAME_{PN}-setup = "lxc"
84INITSCRIPT_PARAMS_${PN}-setup = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
85
86FILES_${PN}-doc = "${mandir} ${infodir}"
87# For LXC the docdir only contains example configuration files and should be included in the lxc package
88FILES_${PN} += "${docdir}"
89FILES_${PN} += "${libdir}/python3*"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050090FILES_${PN} += "${datadir}/lua/*"
91FILES_${PN} += "${libdir}/lua/lxc/*"
92FILES_${PN}-dbg += "${libdir}/lua/lxc/.debug"
93FILES_${PN}-dbg += "${libexecdir}/lxc/.debug ${libexecdir}/lxc/hooks/.debug"
Patrick Williamsd849ec72016-08-17 14:59:38 -050094PACKAGES =+ "${PN}-templates ${PN}-setup ${PN}-networking"
95FILES_${PN}-templates += "${datadir}/lxc/templates"
96RDEPENDS_${PN}-templates += "bash"
97
98ALLOW_EMPTY_${PN}-networking = "1"
99
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500100FILES_${PN}-setup += "${sysconfdir}/tmpfiles.d"
101FILES_${PN}-setup += "${systemd_system_unitdir}"
102FILES_${PN}-setup += "${sysconfdir}/init.d"
Patrick Williamsd849ec72016-08-17 14:59:38 -0500103
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
Patrick Williamse69d2352017-02-23 20:56:04 -0600123 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
Patrick Williamsd849ec72016-08-17 14:59:38 -0500124 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}