Fix build issue for wayland-ivi-extension in kirkstone
[AGL/meta-agl-devel.git] / meta-agl-lxc / classes / lxc-config.bbclass
1 # Helper class for installing LXC guest configuration.
2 # Assumes that:
3 # - Recipe name is 'lxc-config-' + <guest name>
4 # - Corresponding files {config,system.conf}.<guest name>.in are in
5 #   the file search path
6 # - That references to the DRM lease device name are parameterized
7 #   with @DRM_LEASE_DEVICE@ in the .in files
8 # As well:
9 # - The .in files can optionally use the @LXC_AUTO_START@ parameter
10 #   to pick up the value of the LXC_AUTO_START variable for use in
11 #   defining lxc.start.auto.  The default value is "0", so recipes
12 #   need to assign the variable to "1" to have the associated
13 #   container start automatically.
14
15 python __anonymous() {
16     bpn = d.getVar('BPN')
17     if not bpn.startswith('lxc-config-'):
18         bb.error('Recipe name does not start with \'lxc-config-\'')
19     config = bpn[11:]
20     d.setVar('LXC_CONFIG_NAME', config)
21     src_uri = 'file://basic.in' \
22               + ' file://mount.in' \
23               + ' file://network.in' \
24               + ' file://environment.in' \
25               + ' file://misc.in' \
26               + ' file://system.conf.' + config + '.in'
27     d.setVar('SRC_URI', src_uri)
28 }
29
30 S = "${WORKDIR}"
31
32 inherit allarch
33
34 DRM_LEASE_DEVICE ??= "card0-HDMI-A-1"
35
36 DRM_LEASE_DEVICE:qemuall ?= "card0-Virtual-1"
37
38 LXC_AUTO_START ??= "0"
39
40 do_configure[noexec] = "1"
41 do_compile[noexec] = "1"
42
43 do_install () {
44     rm -f ${WORKDIR}/config.${LXC_CONFIG_NAME}.in
45     files="basic.in mount.in network.in environment.in misc.in"
46     for f in ${files}; do
47         cat ${WORKDIR}/$f >> ${WORKDIR}/config.${LXC_CONFIG_NAME}.in
48     done
49
50     install -m 0755 -d ${D}/var/lib/lxc/${LXC_CONFIG_NAME}
51     for f in config.${LXC_CONFIG_NAME}.in system.conf.${LXC_CONFIG_NAME}.in; do
52         sed -e 's|@DRM_LEASE_DEVICE@|${DRM_LEASE_DEVICE}|g' \
53             -e 's|@LXC_AUTO_START@|${LXC_AUTO_START}|g' \
54             ${WORKDIR}/$f > ${D}${localstatedir}/lib/lxc/${LXC_CONFIG_NAME}/${f%.${LXC_CONFIG_NAME}.in}
55     done
56 }
57
58 FILES:${PN} = "${localstatedir}/lib/lxc/"