summaryrefslogtreecommitdiffstats
path: root/meta/classes/live-vm-common.bbclass
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-03-30 00:23:11 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-31 23:01:37 +0100
commit4d1df2cfe84fe4ad061cee01cddea4e7ae627fe4 (patch)
treecc38dc059d7d54425d10127316e5d961f5d26c92 /meta/classes/live-vm-common.bbclass
parentd6d75260fa0a9874a62acd3251b7405ed59f0cfa (diff)
downloadpoky-4d1df2cfe84fe4ad061cee01cddea4e7ae627fe4.tar.gz
image-live.bbclass/image-vm.bbclass: remove duplicated code
Move the common code to live_vm_common.bbclass and remove duplicated ones. (From OE-Core rev: 4a70cc59a0350f06d4cc48c12c3053a39191ba07) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/live-vm-common.bbclass')
-rw-r--r--meta/classes/live-vm-common.bbclass58
1 files changed, 58 insertions, 0 deletions
diff --git a/meta/classes/live-vm-common.bbclass b/meta/classes/live-vm-common.bbclass
new file mode 100644
index 0000000000..c751385e7d
--- /dev/null
+++ b/meta/classes/live-vm-common.bbclass
@@ -0,0 +1,58 @@
1# Some of the vars for vm and live image are conflicted, this function
2# is used for fixing the problem.
3def set_live_vm_vars(d, suffix):
4 vars = ['GRUB_CFG', 'SYSLINUX_CFG', 'ROOT', 'LABELS', 'INITRD']
5 for var in vars:
6 var_with_suffix = var + '_' + suffix
7 if d.getVar(var, True):
8 bb.warn('Found potential conflicted var %s, please use %s rather than %s' % \
9 (var, var_with_suffix, var))
10 elif d.getVar(var_with_suffix, True):
11 d.setVar(var, d.getVar(var_with_suffix, True))
12
13
14EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
15EFI_PROVIDER ?= "grub-efi"
16EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
17
18# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
19# contain "efi". This way legacy is supported by default if neither is
20# specified, maintaining the original behavior.
21def pcbios(d):
22 pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
23 if pcbios == "0":
24 pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d)
25 return pcbios
26
27PCBIOS = "${@pcbios(d)}"
28PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS', True) == '1']}"
29
30inherit ${EFI_CLASS}
31inherit ${PCBIOS_CLASS}
32
33KERNEL_IMAGETYPE ??= "bzImage"
34
35populate_kernel() {
36 dest=$1
37 install -d $dest
38
39 # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use.
40 if [ -e ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ]; then
41 install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} $dest/vmlinuz
42 fi
43
44 # initrd is made of concatenation of multiple filesystem images
45 if [ -n "${INITRD}" ]; then
46 rm -f $dest/initrd
47 for fs in ${INITRD}
48 do
49 if [ -s "$fs" ]; then
50 cat $fs >> $dest/initrd
51 else
52 bbfatal "$fs is invalid. initrd image creation failed."
53 fi
54 done
55 chmod 0644 $dest/initrd
56 fi
57}
58