Add automatic start support for IVI guest.
[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://config.' + config + \
22               '.in file://system.conf.' + config + '.in'
23     d.setVar('SRC_URI', src_uri)
24 }
25
26 S = "${WORKDIR}"
27
28 inherit allarch
29
30 DRM_LEASE_DEVICE ??= "card0-HDMI-A-1"
31
32 DRM_LEASE_DEVICE:qemuall ?= "card0-Virtual-1"
33
34 LXC_AUTO_START ??= "0"
35
36 do_configure[noexec] = "1"
37 do_compile[noexec] = "1"
38
39 do_install () {
40     install -m 0755 -d ${D}/var/lib/lxc/${LXC_CONFIG_NAME}
41     for f in config.${LXC_CONFIG_NAME}.in system.conf.${LXC_CONFIG_NAME}.in; do
42         sed -e 's|@DRM_LEASE_DEVICE@|${DRM_LEASE_DEVICE}|g' \
43             -e 's|@LXC_AUTO_START@|${LXC_AUTO_START}|g' \
44             ${WORKDIR}/$f > ${D}${localstatedir}/lib/lxc/${LXC_CONFIG_NAME}/${f%.${LXC_CONFIG_NAME}.in}
45     done
46 }
47
48 FILES:${PN} = "${localstatedir}/lib/lxc/"