blob: e1d8b1843b6470fa784bb903c965f98360a6de42 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001# 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
Brad Bishop6e60e8b2018-02-01 10:27:11 -05007 if d.getVar(var):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05008 bb.warn('Found potential conflicted var %s, please use %s rather than %s' % \
9 (var, var_with_suffix, var))
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010 elif d.getVar(var_with_suffix):
11 d.setVar(var, d.getVar(var_with_suffix))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050012
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
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018MKDOSFS_EXTRAOPTS ??= "-S 512"
19
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050020# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
21# contain "efi". This way legacy is supported by default if neither is
22# specified, maintaining the original behavior.
23def pcbios(d):
24 pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
25 if pcbios == "0":
26 pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d)
27 return pcbios
28
29PCBIOS = "${@pcbios(d)}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS') == '1']}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050031
32inherit ${EFI_CLASS}
33inherit ${PCBIOS_CLASS}
34
35KERNEL_IMAGETYPE ??= "bzImage"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060036VM_DEFAULT_KERNEL ??= "${KERNEL_IMAGETYPE}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050037
38populate_kernel() {
39 dest=$1
40 install -d $dest
41
42 # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060043 bbnote "Trying to install ${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} as $dest/vmlinuz"
44 if [ -e ${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} ]; then
45 install -m 0644 ${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} $dest/vmlinuz
46 else
47 bbwarn "${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} doesn't exist"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050048 fi
49
50 # initrd is made of concatenation of multiple filesystem images
51 if [ -n "${INITRD}" ]; then
52 rm -f $dest/initrd
53 for fs in ${INITRD}
54 do
55 if [ -s "$fs" ]; then
56 cat $fs >> $dest/initrd
57 else
58 bbfatal "$fs is invalid. initrd image creation failed."
59 fi
60 done
61 chmod 0644 $dest/initrd
62 fi
63}
64