diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-10 14:35:29 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-12 15:27:17 +0100 |
commit | fd1517e2b51a170f2427122c6b95396db251d827 (patch) | |
tree | dabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/live-vm-common.bbclass | |
parent | 10317912ee319ccf7f83605d438b5cbf9663f296 (diff) | |
download | poky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz |
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take
advantage of new bitbake functionality to check class scope/usage.
(From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/live-vm-common.bbclass')
-rw-r--r-- | meta/classes-recipe/live-vm-common.bbclass | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/meta/classes-recipe/live-vm-common.bbclass b/meta/classes-recipe/live-vm-common.bbclass new file mode 100644 index 0000000000..b619f3a4be --- /dev/null +++ b/meta/classes-recipe/live-vm-common.bbclass | |||
@@ -0,0 +1,100 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | # Some of the vars for vm and live image are conflicted, this function | ||
8 | # is used for fixing the problem. | ||
9 | def set_live_vm_vars(d, suffix): | ||
10 | vars = ['GRUB_CFG', 'SYSLINUX_CFG', 'ROOT', 'LABELS', 'INITRD'] | ||
11 | for var in vars: | ||
12 | var_with_suffix = var + '_' + suffix | ||
13 | if d.getVar(var): | ||
14 | bb.warn('Found potential conflicted var %s, please use %s rather than %s' % \ | ||
15 | (var, var_with_suffix, var)) | ||
16 | elif d.getVar(var_with_suffix): | ||
17 | d.setVar(var, d.getVar(var_with_suffix)) | ||
18 | |||
19 | |||
20 | EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}" | ||
21 | EFI_PROVIDER ?= "grub-efi" | ||
22 | EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}" | ||
23 | |||
24 | MKDOSFS_EXTRAOPTS ??= "-S 512" | ||
25 | |||
26 | # Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not | ||
27 | # contain "efi". This way legacy is supported by default if neither is | ||
28 | # specified, maintaining the original behavior. | ||
29 | def pcbios(d): | ||
30 | pcbios = bb.utils.contains("MACHINE_FEATURES", "pcbios", "1", "0", d) | ||
31 | if pcbios == "0": | ||
32 | pcbios = bb.utils.contains("MACHINE_FEATURES", "efi", "0", "1", d) | ||
33 | return pcbios | ||
34 | |||
35 | PCBIOS = "${@pcbios(d)}" | ||
36 | PCBIOS_CLASS = "${@['','syslinux'][d.getVar('PCBIOS') == '1']}" | ||
37 | |||
38 | # efi_populate_common DEST BOOTLOADER | ||
39 | efi_populate_common() { | ||
40 | # DEST must be the root of the image so that EFIDIR is not | ||
41 | # nested under a top level directory. | ||
42 | DEST=$1 | ||
43 | |||
44 | install -d ${DEST}${EFIDIR} | ||
45 | |||
46 | install -m 0644 ${DEPLOY_DIR_IMAGE}/$2-${EFI_BOOT_IMAGE} ${DEST}${EFIDIR}/${EFI_BOOT_IMAGE} | ||
47 | EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') | ||
48 | printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${DEST}/startup.nsh | ||
49 | } | ||
50 | |||
51 | efi_iso_populate() { | ||
52 | iso_dir=$1 | ||
53 | efi_populate $iso_dir | ||
54 | # Build a EFI directory to create efi.img | ||
55 | mkdir -p ${EFIIMGDIR}/${EFIDIR} | ||
56 | cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR} | ||
57 | cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR} | ||
58 | |||
59 | EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') | ||
60 | printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${EFIIMGDIR}/startup.nsh | ||
61 | |||
62 | if [ -f "$iso_dir/initrd" ] ; then | ||
63 | cp $iso_dir/initrd ${EFIIMGDIR} | ||
64 | fi | ||
65 | } | ||
66 | |||
67 | efi_hddimg_populate() { | ||
68 | efi_populate $1 | ||
69 | } | ||
70 | |||
71 | inherit ${EFI_CLASS} | ||
72 | inherit ${PCBIOS_CLASS} | ||
73 | |||
74 | populate_kernel() { | ||
75 | dest=$1 | ||
76 | install -d $dest | ||
77 | |||
78 | # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use. | ||
79 | bbnote "Trying to install ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} as $dest/${KERNEL_IMAGETYPE}" | ||
80 | if [ -e ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} ]; then | ||
81 | install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} $dest/${KERNEL_IMAGETYPE} | ||
82 | else | ||
83 | bbwarn "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE} doesn't exist" | ||
84 | fi | ||
85 | |||
86 | # initrd is made of concatenation of multiple filesystem images | ||
87 | if [ -n "${INITRD}" ]; then | ||
88 | rm -f $dest/initrd | ||
89 | for fs in ${INITRD} | ||
90 | do | ||
91 | if [ -s "$fs" ]; then | ||
92 | cat $fs >> $dest/initrd | ||
93 | else | ||
94 | bbfatal "$fs is invalid. initrd image creation failed." | ||
95 | fi | ||
96 | done | ||
97 | chmod 0644 $dest/initrd | ||
98 | fi | ||
99 | } | ||
100 | |||