From: Reichel Andreas <[email protected]> Add an efibootguard.bbclass similar to gummiboot.bbclass. This way, the EFI_PROVIDER variable can be set to 'efibootguard', to use efibootguard as bootloader. The rest is handled by image-live.bbclass from poky/meta layer.
Signed-off-by: Andreas Reichel <[email protected]> --- meta-efibootguard/classes/efibootguard.bbclass | 88 ++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 meta-efibootguard/classes/efibootguard.bbclass diff --git a/meta-efibootguard/classes/efibootguard.bbclass b/meta-efibootguard/classes/efibootguard.bbclass new file mode 100644 index 0000000..7e77650 --- /dev/null +++ b/meta-efibootguard/classes/efibootguard.bbclass @@ -0,0 +1,88 @@ +# EFI Boot Guard +# +# Copyright (c) Siemens AG, 2017 +# +# Authors: +# Andreas Reichel <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2. +# See the COPYING.GPLv2 file in the top-level directory. + +# Set EFI_PROVIDER = "efibootguard" to use efibootguard on your live images instead of grub-efi +# (images built by image-live.bbclass or image-vm.bbclass) + +# Authors: Claudius Heine (ch [at) denx.de) +# Andreas Reichel (andreas.reichel.ext [at) siemens.com) + +do_bootimg[depends] += "${MLPREFIX}efibootguard:do_deploy" +do_bootimg[depends] += "${MLPREFIX}efibootguard-native:do_deploy" +do_bootdirectdisk[depends] += "${MLPREFIX}efibootguard:do_deploy" + +EFIDIR = "/EFI/BOOT" + +inherit fs-uuid +inherit logging + +efi_populate() { + DEST=$1 + if [ "${TARGET_ARCH}" = "i586" ]; then + EFI_IMAGE="efibootguardia32.efi" + DEST_EFI_IMAGE="bootia32.efi" + elif [ "${TARGET_ARCH}" = "x86_64" ]; then + EFI_IMAGE="efibootguardx64.efi" + DEST_EFI_IMAGE="bootx64.efi" + else + bbfatal "Invalid target architecture for efibootguard: ${TARGET_ARCH}. Only i586 and x86_64 are supported." + fi + install -d ${DEST}${EFIDIR} + install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE} ${DEST}${EFIDIR}/${DEST_EFI_IMAGE} +} + +efi_iso_populate() { + # Code copied from gummiboot.bbclass + iso_dir=$1 + efi_populate $iso_dir + mkdir -p ${EFIIMGDIR}/${EFIDIR} + cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR} + cp $iso_dir/vmlinuz ${EFIIMGDIR} + EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') + echo "fs0:${EFIPATH}\\${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh + if [ -f "$iso_dir/initrd" ] ; then + cp $iso_dir/initrd ${EFIIMGDIR} + fi +} + +efi_hddimg_populate() { + efi_populate $1 +} + +python build_efi_cfg() { + # This function is expected by image-live.bbclass + # If an iso is built for example as rescue medium, we only have one filesystem with efibootguard + # So a boot configuration is needed on this iso file system. + from subprocess import Popen, PIPE + + skipiso = d.getVar("NOISO", True) + if not skipiso == "1": + bb.note("Generating iso default boot configuration.") + isodir = os.path.join(d.getVar("S", True), "iso") + bindir_native = d.getVar("STAGING_BINDIR_NATIVE", True); + bg_setenv_cmd = os.path.join(bindir_native, "bg_setenv") + olddir = os.getcwd() + + make_isodir_cmd = ["mkdir", "-p", isodir] + p = Popen(make_isodir_cmd) + + os.chdir(isodir) + p = Popen([bg_setenv_cmd, "--file", "--kernel=vmlinuz", "--watchdog=30"], \ + stdout=PIPE, stderr=PIPE) + (out, err) = p.communicate() + os.chdir(olddir) + if not p.returncode == 0: + bb.fatal("Could not execute bg_setenv. Please make sure efibootguard-native is installed.") + + bb.debug(2, "bg_setenv returned %s %s" % (out, err)) + + else: + bb.debug(2, "No iso built, no default boot configuration.") +} -- 2.14.1 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20170905123727.24381-3-andreas.reichel.ext%40siemens.com. For more options, visit https://groups.google.com/d/optout.
