f702da18461af58872d9956fea8c750ad38f362e
[AGL/meta-agl-devel.git] / meta-agl-lxc / recipes-platform / images / lxc-host-image-minimal.bb
1 SUMMARY = "A minimal container host image"
2
3 require recipes-platform/images/agl-image-boot.inc
4
5 IMAGE_INSTALL += " \
6     lxc \
7     ${LXC_CONTAINER_CONFIGS} \
8 "
9
10 CONTAINER_IMAGES ??= ""
11
12 LXC_CONTAINER_CONFIGS ?= ""
13
14 IMAGE_LINGUAS = " "
15
16 NO_RECOMMENDATIONS = "1"
17
18 python __anonymous() {
19     for c in (d.getVar('CONTAINER_IMAGES') or "").split():
20         (mc, image) = c.split(':')
21         dependency = 'mc::' + mc + ':' + image + ':do_image_complete'
22         d.setVarFlag('do_rootfs', 'mcdepends', dependency)
23
24         # Assume there is a X-lxc-config package for guest-image-X
25         config = image
26         if config.startswith('guest-image-'):
27             config = config[len('guest-image-'):]
28         d.appendVar('LXC_CONTAINER_CONFIGS', 'lxc-config-' + config)
29 }
30
31 install_container_images() {
32     for c in ${CONTAINER_IMAGES}; do
33         config=${c%:*}
34         image=${c#*:}
35         name=${image#guest-image-}
36         rm -rf  ${IMAGE_ROOTFS}/var/lib/machines/${name}
37         install -m 0755 -d ${IMAGE_ROOTFS}/var/lib/machines/${name}
38         src="${TOPDIR}/tmp-${config}/deploy/images/${MACHINE}/${image}-${MACHINE}.tar.bz2"
39         bbnote "Installing ${src}"
40         tar -C ${IMAGE_ROOTFS}/var/lib/machines/${name} -xf ${src}
41     done
42 }
43
44 #
45 # Force rebuild of rootfs on every build to work around mcdepends issue
46 #
47 # NOTE:
48 # This is currently required as bitbake fails to trigger do_rootfs
49 # sometimes even when the guest image has in fact rebuilt.  This is
50 # being investigated with upstream.
51 #
52 do_rootfs[nostamp] = "1"
53
54 ROOTFS_POSTPROCESS_COMMAND += "install_container_images; "
55
56 IMAGE_ROOTFS_EXTRA_SPACE_append = "${@bb.utils.contains("DISTRO_FEATURES", "systemd", " + 4096", "" ,d)}"
57