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