From a66a367e9656f0f4e2f9e9f8932714cf9bee1725 Mon Sep 17 00:00:00 2001 From: Alexandru Avadanii Date: Sun, 21 Mar 2021 18:15:52 +0100 Subject: classes/override_grub* sync with upstream renames While at it, replace some hardcoded p7b extenstions with ${SB_FILE_EXT} and vmlinuz references with the appropiate variable (upstream no longer renames bzImage to vmlinuz in ISO root after [1]). [1] https://git.yoctoproject.org/cgit.cgi/poky/commit/?id=b6e36c01977 Change-Id: I5ce414a2f281ff2f1aeb0e26f35608cd8750855d Signed-off-by: Alexandru Avadanii Signed-off-by: Adrian Dudau --- classes/override_grub-efi-cfg.inc | 94 ++++++++++++++++++++++++++++++++ classes/override_grub-efi.inc | 89 ------------------------------ classes/override_grub-efi_secureboot.inc | 31 ----------- classes/override_live-vm-common.inc | 29 ++++++++++ images/enea-nfv-access-host-common.inc | 4 +- 5 files changed, 125 insertions(+), 122 deletions(-) create mode 100644 classes/override_grub-efi-cfg.inc delete mode 100644 classes/override_grub-efi.inc delete mode 100644 classes/override_grub-efi_secureboot.inc create mode 100644 classes/override_live-vm-common.inc diff --git a/classes/override_grub-efi-cfg.inc b/classes/override_grub-efi-cfg.inc new file mode 100644 index 0000000..42d89b7 --- /dev/null +++ b/classes/override_grub-efi-cfg.inc @@ -0,0 +1,94 @@ +## ENEA_start ## +GRUB_GRAPHICS ?= "console=tty0" +## ENEA_end ## + +python build_efi_cfg() { + import sys + + workdir = d.getVar('WORKDIR') + if not workdir: + bb.error("WORKDIR not defined, unable to package") + return + + gfxserial = d.getVar('GRUB_GFXSERIAL') or "" + + labels = d.getVar('LABELS') + if not labels: + bb.debug(1, "LABELS not defined, nothing to do") + return + + if labels == []: + bb.debug(1, "No labels, nothing to do") + return + + cfile = d.getVar('GRUB_CFG') + if not cfile: + bb.fatal('Unable to read GRUB_CFG') + + try: + cfgfile = open(cfile, 'w') + except OSError: + bb.fatal('Unable to open %s' % cfile) + + cfgfile.write('# Automatically created by OE\n') + + opts = d.getVar('GRUB_OPTS') + if opts: + for opt in opts.split(';'): + cfgfile.write('%s\n' % opt) + + cfgfile.write('default=%s\n' % (labels.split()[0])) + + timeout = d.getVar('GRUB_TIMEOUT') + if timeout: + cfgfile.write('timeout=%s\n' % timeout) + else: + cfgfile.write('timeout=50\n') + + root = d.getVar('GRUB_ROOT') + if not root: + bb.fatal('GRUB_ROOT not defined') + + if gfxserial == "1": + ## ENEA_start ## + btypes = [ [ " serial console", d.getVar('GRUB_SERIAL') or "" ], + [ " graphics console", d.getVar('GRUB_GRAPHICS') or "" ] ] + ## ENEA_end ## + else: + btypes = [ [ "", "" ] ] + + for label in labels.split(): + localdata = d.createCopy() + + overrides = localdata.getVar('OVERRIDES') + if not overrides: + bb.fatal('OVERRIDES not defined') + + localdata.setVar('OVERRIDES', 'grub_' + label + ':' + overrides) + + for btype in btypes: + cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0])) + lb = label + if label == "install": + lb = "install-efi" + kernel = localdata.getVar('KERNEL_IMAGETYPE') + cfgfile.write('linux /%s LABEL=%s' % (kernel, lb)) + + cfgfile.write(' %s' % replace_rootfs_uuid(d, root)) + + append = localdata.getVar('APPEND') + initrd = localdata.getVar('INITRD') + + if append: + append = replace_rootfs_uuid(d, append) + cfgfile.write(' %s' % (append)) + + cfgfile.write(' %s' % btype[1]) + cfgfile.write('\n') + + if initrd: + cfgfile.write('initrd /initrd') + cfgfile.write('\n}\n') + + cfgfile.close() +} diff --git a/classes/override_grub-efi.inc b/classes/override_grub-efi.inc deleted file mode 100644 index 15a7063..0000000 --- a/classes/override_grub-efi.inc +++ /dev/null @@ -1,89 +0,0 @@ -GRUB_GRAPHICS ?= "console=tty0" - -python build_efi_cfg() { - import sys - - workdir = d.getVar('WORKDIR') - if not workdir: - bb.error("WORKDIR not defined, unable to package") - return - - gfxserial = d.getVar('GRUB_GFXSERIAL') or "" - - labels = d.getVar('LABELS') - if not labels: - bb.debug(1, "LABELS not defined, nothing to do") - return - - if labels == []: - bb.debug(1, "No labels, nothing to do") - return - - cfile = d.getVar('GRUB_CFG') - if not cfile: - bb.fatal('Unable to read GRUB_CFG') - - try: - cfgfile = open(cfile, 'w') - except OSError: - bb.fatal('Unable to open %s' % cfile) - - cfgfile.write('# Automatically created by OE\n') - - opts = d.getVar('GRUB_OPTS') - if opts: - for opt in opts.split(';'): - cfgfile.write('%s\n' % opt) - - cfgfile.write('default=%s\n' % (labels.split()[0])) - - timeout = d.getVar('GRUB_TIMEOUT') - if timeout: - cfgfile.write('timeout=%s\n' % timeout) - else: - cfgfile.write('timeout=50\n') - - root = d.getVar('GRUB_ROOT') - if not root: - bb.fatal('GRUB_ROOT not defined') - - if gfxserial == "1": - btypes = [ [ " serial console", d.getVar('GRUB_SERIAL') or "" ], - [ " graphics console", d.getVar('GRUB_GRAPHICS') or "" ] ] - else: - btypes = [ [ "", "" ] ] - - for label in labels.split(): - localdata = d.createCopy() - - overrides = localdata.getVar('OVERRIDES') - if not overrides: - bb.fatal('OVERRIDES not defined') - - for btype in btypes: - localdata.setVar('OVERRIDES', label + ':' + overrides) - - cfgfile.write('\nmenuentry \'%s%s\'{\n' % (label, btype[0])) - lb = label - if label == "install": - lb = "install-efi" - cfgfile.write('linux /vmlinuz LABEL=%s' % (lb)) - - cfgfile.write(' %s' % replace_rootfs_uuid(d, root)) - - append = localdata.getVar('APPEND') - initrd = localdata.getVar('INITRD') - - if append: - append = replace_rootfs_uuid(d, append) - cfgfile.write(' %s' % (append)) - - cfgfile.write(' %s' % btype[1]) - cfgfile.write('\n') - - if initrd: - cfgfile.write('initrd /initrd') - cfgfile.write('\n}\n') - - cfgfile.close() -} diff --git a/classes/override_grub-efi_secureboot.inc b/classes/override_grub-efi_secureboot.inc deleted file mode 100644 index b944ec8..0000000 --- a/classes/override_grub-efi_secureboot.inc +++ /dev/null @@ -1,31 +0,0 @@ -efi_populate() { - # DEST must be the root of the image so that EFIDIR is not - # nested under a top level directory. - DEST=$1 - - install -d ${DEST}${EFIDIR} - - GRUB_IMAGE="grub-efi-bootia32.efi" - DEST_IMAGE="bootia32.efi" - if [ "${TARGET_ARCH}" = "x86_64" ]; then - GRUB_IMAGE="grub-efi-bootx64.efi" - DEST_IMAGE="bootx64.efi" - fi - - #Install EFI binaries - install -m 0644 ${IMAGE_ROOTFS}/boot/efi${EFIDIR}/*.* ${DEST}${EFIDIR} - - #Install kernel and initramfs sig - install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}.p7b ${DEST}/vmlinuz.p7b - install -m 0644 ${INITRD_LIVE}.p7b ${DEST}/initrd.p7b - - EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') - printf 'fs0:%s\%s\n' "$EFIPATH" "$DEST_IMAGE" >${DEST}/startup.nsh - - install -m 0644 ${GRUB_CFG} ${DEST}${EFIDIR}/grub.cfg - - #Install UEFI keys - install -d ${DEST}/uefi_sb_keys - install -m 0644 ${DEPLOY_DIR_IMAGE}/user-keys/uefi_sb_keys/*.crt ${DEST}/uefi_sb_keys/ - install -m 0644 ${DEPLOY_DIR_IMAGE}/user-keys/uefi_sb_keys/*.esl ${DEST}/uefi_sb_keys/ -} diff --git a/classes/override_live-vm-common.inc b/classes/override_live-vm-common.inc new file mode 100644 index 0000000..dc8e076 --- /dev/null +++ b/classes/override_live-vm-common.inc @@ -0,0 +1,29 @@ +# efi_populate_common DEST BOOTLOADER +efi_populate_common() { + # DEST must be the root of the image so that EFIDIR is not + # nested under a top level directory. + DEST=$1 + + install -d ${DEST}${EFIDIR} + + ## ENEA_start ## + # install -m 0644 ${DEPLOY_DIR_IMAGE}/$2-${EFI_BOOT_IMAGE} ${DEST}${EFIDIR}/${EFI_BOOT_IMAGE} + ## ENEA_end ## + + EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') + printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${DEST}/startup.nsh + + ## ENEA_start ## + # Install EFI binaries + install -m 0644 ${IMAGE_ROOTFS}/boot/efi${EFIDIR}/*.* ${DEST}${EFIDIR} + + # Install kernel and initramfs sig + install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}${SB_FILE_EXT} ${DEST}/${KERNEL_IMAGETYPE}${SB_FILE_EXT} + install -m 0644 ${INITRD_LIVE}${SB_FILE_EXT} ${DEST}/initrd${SB_FILE_EXT} + + # Install UEFI keys + install -d ${DEST}/uefi_sb_keys + install -m 0644 ${DEPLOY_DIR_IMAGE}/user-keys/uefi_sb_keys/*.crt ${DEST}/uefi_sb_keys/ + install -m 0644 ${DEPLOY_DIR_IMAGE}/user-keys/uefi_sb_keys/*.esl ${DEST}/uefi_sb_keys/ + ## ENEA_end ## +} diff --git a/images/enea-nfv-access-host-common.inc b/images/enea-nfv-access-host-common.inc index 82e9792..d984f95 100644 --- a/images/enea-nfv-access-host-common.inc +++ b/images/enea-nfv-access-host-common.inc @@ -2,10 +2,10 @@ IMAGE_FSTYPES += "hddimg" REQUIRE_FILES = " \ images/enea-nfv-access-common.inc \ - classes/override_grub-efi.inc \ + classes/override_grub-efi-cfg.inc \ " REQUIRE_FILES_append_df-efi-secure-boot = " \ - classes/override_grub-efi_secureboot.inc \ + classes/override_live-vm-common.inc \ images/secure-boot.inc \ " -- cgit v1.2.3-54-g00ecf