blob: 734697f9e6287e7e4aa9f3678c8d15da5b21d388 [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
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"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060034VM_DEFAULT_KERNEL ??= "${KERNEL_IMAGETYPE}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050035
36populate_kernel() {
37 dest=$1
38 install -d $dest
39
40 # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use.
Patrick Williamsc0f7c042017-02-23 20:41:17 -060041 bbnote "Trying to install ${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} as $dest/vmlinuz"
42 if [ -e ${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} ]; then
43 install -m 0644 ${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} $dest/vmlinuz
44 else
45 bbwarn "${DEPLOY_DIR_IMAGE}/${VM_DEFAULT_KERNEL} doesn't exist"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050046 fi
47
48 # initrd is made of concatenation of multiple filesystem images
49 if [ -n "${INITRD}" ]; then
50 rm -f $dest/initrd
51 for fs in ${INITRD}
52 do
53 if [ -s "$fs" ]; then
54 cat $fs >> $dest/initrd
55 else
56 bbfatal "$fs is invalid. initrd image creation failed."
57 fi
58 done
59 chmod 0644 $dest/initrd
60 fi
61}
62