uefi.conf: add config file holding configuration for UEFI applications
PATCH v3 1/9 uefi.conf: add config file holding configuration for UEFI applications
From: Dmitry Eremin-Solenikov <[email protected]>
Create new config file defining common variables for all UEFI-related packages (bootloaders, test applications, etc).
--- meta/conf/uefi.conf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 meta/conf/uefi.conf
meta/conf/uefi.conf new file +16 -0
@@ -0,0 +1,16 @@ +# Location of EFI files inside EFI System Partition +EFIDIR ?= "/EFI/BOOT" + +# Prefix where ESP is mounted inside rootfs. Set to empty if package is going +# to be installed to ESP directly +EFI_PREFIX ?= "/boot" + +# Location inside rootfs. +EFI_FILES_PATH = "${EFI_PREFIX}${EFIDIR}" + +# Determine name of bootloader image +EFI_BOOT_IMAGE ?= "bootINVALID.efi" +EFI_BOOT_IMAGE_x86-64 = "bootx64.efi" +EFI_BOOT_IMAGE_x86 = "bootia32.efi" +EFI_BOOT_IMAGE_aarch64 = "bootaa64.efi" +EFI_BOOT_IMAGE_arm = "bootarm.efi"
Signature · 1 line
2.23.0
PATCH v3 2/9 grub-bootconf: switch to uefi.conf
From: Dmitry Eremin-Solenikov <[email protected]>
Use variables from uefi.conf instead of hardcoding them in the recipe.
--- meta/recipes-bsp/grub/grub-bootconf_1.00.bb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
meta/recipes-bsp/grub/grub-bootconf_1.00.bb +5 -5
@@ -9,6 +9,8 @@ RPROVIDES_${PN} += "virtual/grub-bootconf" inherit grub-efi-cfg +require conf/uefi.conf + S = "${WORKDIR}" GRUB_CFG = "${S}/grub-bootconf"
@@ -23,10 +25,8 @@ python do_configure() { do_configure[vardeps] += "APPEND ROOT" do_install() { - install -d ${D}/boot - install -d ${D}/boot/EFI - install -d ${D}/boot/EFI/BOOT - install grub-bootconf ${D}/boot/EFI/BOOT/grub.cfg + install -d ${D}${EFI_FILES_PATH} + install grub-bootconf ${D}${EFI_FILES_PATH}/grub.cfg } -FILES_${PN} = "/boot/EFI/BOOT/grub.cfg" +FILES_${PN} = "${EFI_FILES_PATH}/grub.cfg"
Signature · 1 line
2.23.0
PATCH v3 3/9 grub-efi: switch to uefi.conf
In reply to [email protected]From: Dmitry Eremin-Solenikov <[email protected]>
Use variables from uefi.conf instead of hardcoding them in the recipe.
--- meta/recipes-bsp/grub/grub-efi_2.04.bb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
meta/recipes-bsp/grub/grub-efi_2.04.bb +7 -10
@@ -1,5 +1,7 @@ require grub2.inc +require conf/uefi.conf + GRUBPLATFORM = "efi" DEPENDS_append_class-target = " grub-efi-native"
@@ -18,18 +20,15 @@ python __anonymous () { prefix = "" if d.getVar('EFI_PROVIDER') == "grub-efi" else "grub-efi-" if target == "x86_64": grubtarget = 'x86_64' - grubimage = prefix + "bootx64.efi" elif re.match('i.86', target): grubtarget = 'i386' - grubimage = prefix + "bootia32.efi" elif re.match('aarch64', target): grubtarget = 'arm64' - grubimage = prefix + "bootaa64.efi" elif re.match('arm', target): grubtarget = 'arm' - grubimage = prefix + "bootarm.efi" else: raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target) + grubimage = prefix + d.getVar("EFI_BOOT_IMAGE") d.setVar("GRUB_TARGET", grubtarget) d.setVar("GRUB_IMAGE", grubimage) prefix = "grub-efi-" if prefix == "" else ""
@@ -45,7 +44,7 @@ do_mkimage() { cd ${B} # Search for the grub.cfg on the local boot media by using the # built in cfg file provided via this recipe - grub-mkimage -c ../cfg -p /EFI/BOOT -d ./grub-core/ \ + grub-mkimage -c ../cfg -p ${EFIDIR} -d ./grub-core/ \ -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \ ${GRUB_BUILDIN} }
@@ -57,10 +56,8 @@ do_mkimage_class-native() { } do_install_append_class-target() { - install -d ${D}/boot - install -d ${D}/boot/EFI - install -d ${D}/boot/EFI/BOOT - install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}/boot/EFI/BOOT/${GRUB_IMAGE} + install -d ${D}${EFI_FILES_PATH} + install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}${EFI_FILES_PATH}/${GRUB_IMAGE} } do_install_class-native() {
@@ -100,7 +97,7 @@ addtask deploy after do_install before do_build FILES_${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \ ${datadir}/grub \ - /boot/EFI/BOOT/${GRUB_IMAGE} \ + ${EFI_FILES_PATH}/${GRUB_IMAGE} \ " FILES_${PN}_remove_aarch64 = "${libdir}/grub/${GRUB_TARGET}-efi"
Signature · 1 line
2.23.0
PATCH v3 4/9 grub-efi.bbclass: switch to uefi.conf
In reply to [email protected]From: Dmitry Eremin-Solenikov <[email protected]>
Use variables from uefi.conf instead of hardcoding them in the class.
--- meta/classes/grub-efi-cfg.bbclass | 1 - meta/classes/grub-efi.bbclass | 20 ++++---------------- 2 files changed, 4 insertions(+), 17 deletions(-)
meta/classes/grub-efi-cfg.bbclass +0 -1
@@ -23,7 +23,6 @@ GRUB_TIMEOUT ?= "10" #FIXME: build this from the machine config GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" -EFIDIR = "/EFI/BOOT" GRUB_ROOT ?= "${ROOT}" APPEND ?= ""
meta/classes/grub-efi.bbclass +4 -16
@@ -1,4 +1,5 @@ inherit grub-efi-cfg +require conf/uefi.conf efi_populate() { # DEST must be the root of the image so that EFIDIR is not
@@ -7,22 +8,9 @@ efi_populate() { install -d ${DEST}${EFIDIR} - GRUB_IMAGE="grub-efi-bootia32.efi" - DEST_IMAGE="bootia32.efi" - if [ -n "${MLPREFIX}" ]; then - if [ "${TARGET_ARCH_MULTILIB_ORIGINAL}" = "x86_64" ]; then - GRUB_IMAGE="grub-efi-bootx64.efi" - DEST_IMAGE="bootx64.efi" - fi - else - if [ "${TARGET_ARCH}" = "x86_64" ]; then - GRUB_IMAGE="grub-efi-bootx64.efi" - DEST_IMAGE="bootx64.efi" - fi - fi - install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST}${EFIDIR}/${DEST_IMAGE} + install -m 0644 ${DEPLOY_DIR_IMAGE}/grub-efi-${EFI_BOOT_IMAGE} ${DEST}${EFIDIR}/${EFI_BOOT_IMAGE} EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') - printf 'fs0:%s\%s\n' "$EFIPATH" "$DEST_IMAGE" >${DEST}/startup.nsh + printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${DEST}/startup.nsh install -m 0644 ${GRUB_CFG} ${DEST}${EFIDIR}/grub.cfg }
@@ -35,7 +23,7 @@ efi_iso_populate() { cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR} cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR} EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') - printf 'fs0:%s\%s\n' "$EFIPATH" "$GRUB_IMAGE" > ${EFIIMGDIR}/startup.nsh + printf 'fs0:%s\%s\n' "$EFIPATH" "grub-efi-${EFI_BOOT_IMAGE}" > ${EFIIMGDIR}/startup.nsh if [ -f "$iso_dir/initrd" ] ; then cp $iso_dir/initrd ${EFIIMGDIR} fi
Signature · 1 line
2.23.0
PATCH v3 5/9 systemd-boot: switch to uefi.conf
In reply to [email protected]From: Dmitry Eremin-Solenikov <[email protected]>
Use variables from uefi.conf instead of hardcoding them in the recipe.
--- meta/recipes-core/systemd/systemd-boot_243.bb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
meta/recipes-core/systemd/systemd-boot_243.bb +6 -9
@@ -1,6 +1,8 @@ require systemd.inc FILESEXTRAPATHS =. "${FILE_DIRNAME}/systemd:" +require conf/uefi.conf + DEPENDS = "intltool-native libcap util-linux gnu-efi gperf-native" # NOTE: These three patches are in theory not needed, but we haven't
@@ -33,16 +35,13 @@ python __anonymous () { import re target = d.getVar('TARGET_ARCH') prefix = "" if d.getVar('EFI_PROVIDER') == "systemd-boot" else "systemd-" - if target == "x86_64": - systemdimage = prefix + "bootx64.efi" - else: - systemdimage = prefix + "bootia32.efi" + systemdimage = prefix + d.getVar("EFI_BOOT_IMAGE") d.setVar("SYSTEMD_BOOT_IMAGE", systemdimage) prefix = "systemd-" if prefix == "" else "" d.setVar("SYSTEMD_BOOT_IMAGE_PREFIX", prefix) } -FILES_${PN} = "/boot/EFI/BOOT/${SYSTEMD_BOOT_IMAGE}" +FILES_${PN} = "${EFI_FILES_PATH}/${SYSTEMD_BOOT_IMAGE}" RDEPENDS_${PN} += "virtual/systemd-bootconf"
@@ -61,10 +60,8 @@ do_compile() { } do_install() { - install -d ${D}/boot - install -d ${D}/boot/EFI - install -d ${D}/boot/EFI/BOOT - install ${B}/src/boot/efi/systemd-boot*.efi ${D}/boot/EFI/BOOT/${SYSTEMD_BOOT_IMAGE} + install -d ${D}${EFI_FILES_PATH} + install ${B}/src/boot/efi/systemd-boot*.efi ${D}${EFI_FILES_PATH}/${SYSTEMD_BOOT_IMAGE} } do_deploy () {
Signature · 1 line
2.23.0
PATCH v3 6/9 systemd-boot.bbclass: switch to uefi.conf
In reply to [email protected]From: Dmitry Eremin-Solenikov <[email protected]>
Use variables from uefi.conf instead of hardcoding them in the class.
--- meta/classes/systemd-boot.bbclass | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
meta/classes/systemd-boot.bbclass +4 -11
@@ -11,28 +11,21 @@ do_bootimg[depends] += "${MLPREFIX}systemd-boot:do_deploy" -EFIDIR = "/EFI/BOOT" +require conf/uefi.conf # Need UUID utility code. inherit fs-uuid efi_populate() { DEST=$1 - EFI_IMAGE="systemd-bootia32.efi" - DEST_EFI_IMAGE="bootia32.efi" - if [ "${TARGET_ARCH}" = "x86_64" ]; then - EFI_IMAGE="systemd-bootx64.efi" - DEST_EFI_IMAGE="bootx64.efi" - fi - install -d ${DEST}${EFIDIR} # systemd-boot requires these paths for configuration files # they are not customizable so no point in new vars install -d ${DEST}/loader install -d ${DEST}/loader/entries - install -m 0644 ${DEPLOY_DIR_IMAGE}/${EFI_IMAGE} ${DEST}${EFIDIR}/${DEST_EFI_IMAGE} + install -m 0644 ${DEPLOY_DIR_IMAGE}/systemd-${EFI_BOOT_IMAGE} ${DEST}${EFIDIR}/${EFI_BOOT_IMAGE} EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') - printf 'fs0:%s\%s\n' "$EFIPATH" "$DEST_EFI_IMAGE" >${DEST}/startup.nsh + printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${DEST}/startup.nsh install -m 0644 ${SYSTEMD_BOOT_CFG} ${DEST}/loader/loader.conf for i in ${SYSTEMD_BOOT_ENTRIES}; do install -m 0644 ${i} ${DEST}/loader/entries
@@ -47,7 +40,7 @@ efi_iso_populate() { cp -r $iso_dir/loader ${EFIIMGDIR} cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR} EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') - echo "fs0:${EFIPATH}\\${DEST_EFI_IMAGE}" > ${EFIIMGDIR}/startup.nsh + echo "fs0:${EFIPATH}\\${EFI_BOOT_IMAGE}" > ${EFIIMGDIR}/startup.nsh if [ -f "$iso_dir/initrd" ] ; then cp $iso_dir/initrd ${EFIIMGDIR} fi
Signature · 1 line
2.23.0
PATCH v3 7/9 uefi.bbclass: provide efi population functions for live images
In reply to [email protected]From: Dmitry Eremin-Solenikov <[email protected]>
Define common functions for populating EFI directories in live image.
--- meta/classes/uefi.bbclass | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 meta/classes/uefi.bbclass
meta/classes/uefi.bbclass new file +29 -0
@@ -0,0 +1,29 @@ +require conf/uefi.conf + +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} + + install -m 0644 ${DEPLOY_DIR_IMAGE}/$2-${EFI_BOOT_IMAGE} ${DEST}${EFIDIR}/${EFI_BOOT_IMAGE} + EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') + printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${DEST}/startup.nsh +} + +efi_iso_populate_common() { + iso_dir=$1 + efi_populate $iso_dir + # Build a EFI directory to create efi.img + mkdir -p ${EFIIMGDIR}/${EFIDIR} + cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR} + cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR} + + EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') + printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${EFIIMGDIR}/startup.nsh + + if [ -f "$iso_dir/initrd" ] ; then + cp $iso_dir/initrd ${EFIIMGDIR} + fi +}
Signature · 1 line
2.23.0
PATCH v3 8/9 grub-efi.bbclass: use efi_*_populate_common
In reply to [email protected]From: Dmitry Eremin-Solenikov <[email protected]>
Use common code form uefi.bbclass to populate efi directories.
--- meta/classes/grub-efi.bbclass | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
meta/classes/grub-efi.bbclass +3 -21
@@ -1,32 +1,14 @@ inherit grub-efi-cfg -require conf/uefi.conf +inherit uefi 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} - - install -m 0644 ${DEPLOY_DIR_IMAGE}/grub-efi-${EFI_BOOT_IMAGE} ${DEST}${EFIDIR}/${EFI_BOOT_IMAGE} - EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') - printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${DEST}/startup.nsh + efi_populate_common "$1" grub-efi install -m 0644 ${GRUB_CFG} ${DEST}${EFIDIR}/grub.cfg } efi_iso_populate() { - iso_dir=$1 - efi_populate $iso_dir - # Build a EFI directory to create efi.img - mkdir -p ${EFIIMGDIR}/${EFIDIR} - cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR} - cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR} - EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') - printf 'fs0:%s\%s\n' "$EFIPATH" "grub-efi-${EFI_BOOT_IMAGE}" > ${EFIIMGDIR}/startup.nsh - if [ -f "$iso_dir/initrd" ] ; then - cp $iso_dir/initrd ${EFIIMGDIR} - fi + efi_iso_populate_common "$1" } efi_hddimg_populate() {
Signature · 1 line
2.23.0
PATCH v3 9/9 systemd-boot.bbclass: use efi_*_populate_common
In reply to [email protected]From: Dmitry Eremin-Solenikov <[email protected]>
Use common code form uefi.bbclass to populate efi directories.
--- meta/classes/systemd-boot.bbclass | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
meta/classes/systemd-boot.bbclass +4 -16
@@ -11,21 +11,17 @@ do_bootimg[depends] += "${MLPREFIX}systemd-boot:do_deploy" -require conf/uefi.conf +inherit uefi # Need UUID utility code. inherit fs-uuid efi_populate() { - DEST=$1 + efi_populate_common "$1" systemd - install -d ${DEST}${EFIDIR} # systemd-boot requires these paths for configuration files # they are not customizable so no point in new vars install -d ${DEST}/loader install -d ${DEST}/loader/entries - install -m 0644 ${DEPLOY_DIR_IMAGE}/systemd-${EFI_BOOT_IMAGE} ${DEST}${EFIDIR}/${EFI_BOOT_IMAGE} - EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') - printf 'fs0:%s\%s\n' "$EFIPATH" "${EFI_BOOT_IMAGE}" >${DEST}/startup.nsh install -m 0644 ${SYSTEMD_BOOT_CFG} ${DEST}/loader/loader.conf for i in ${SYSTEMD_BOOT_ENTRIES}; do install -m 0644 ${i} ${DEST}/loader/entries
@@ -33,17 +29,9 @@ efi_populate() { } efi_iso_populate() { - iso_dir=$1 - efi_populate $iso_dir - mkdir -p ${EFIIMGDIR}/${EFIDIR} - cp $iso_dir/${EFIDIR}/* ${EFIIMGDIR}${EFIDIR} + efi_iso_populate_common "$1" + cp -r $iso_dir/loader ${EFIIMGDIR} - cp $iso_dir/${KERNEL_IMAGETYPE} ${EFIIMGDIR} - EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g') - echo "fs0:${EFIPATH}\\${EFI_BOOT_IMAGE}" > ${EFIIMGDIR}/startup.nsh - if [ -f "$iso_dir/initrd" ] ; then - cp $iso_dir/initrd ${EFIIMGDIR} - fi } efi_hddimg_populate() {
Signature · 1 line
2.23.0
Quoted 11 lines · On Tue, 2019-09-17 at 18:36 +0300, [email protected] wrote:
From: Dmitry Eremin-Solenikov <[email protected]>
Create new config file defining common variables for all UEFI-related packages (bootloaders, test applications, etc).
Signed-off-by: Dmitry Eremin-Solenikov <
[email protected]>--- meta/conf/uefi.conf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 meta/conf/uefi.conf
This is heading in the right direction however if we're going to try and clean things up I've concluded we need to do it properly and get it right.
Now I understand more about how this configuration file is being used, should it be called image-uefi.conf ?
I feel really strongly that we do not want an uefi.bbclass, its simply not warranted and will just continue to expand the current mess of classes. If all we need it for is some functions, those functions should be added elsewhere.
I hadn't realised they were shell functions earlier, sorry about that. One option could be to convert them to python since they could be written in python easily. You could call a python function as a prefunc or postfunc of another shell or python function.
Other options could be to make them shell commands (via the script directory) or create an image-functions.bbclass which contains such shared functions generically. As long as things are namespaced (which they already are), that should be fine. I would ask that documentation comments be added to them to say what the functions do.
I'm also on the lookout for tests of these kinds of codepaths. Code is much more likely to be accepted if tests are added for it. I'm not quite sure what would make most sense here in this case buts its a general point I will be pushing for going forward.
Cheers,
Richard
Hello,
ср, 18 сент. 2019 г. в 01:16, Richard Purdie
<[email protected]>:
Quoted 14 lines · On Tue, 2019-09-17 at 18:36 +0300, [email protected] wrote:
Quoted 11 lines
From: Dmitry Eremin-Solenikov <[email protected]>
Create new config file defining common variables for all UEFI-related packages (bootloaders, test applications, etc).
Signed-off-by: Dmitry Eremin-Solenikov <
[email protected]>--- meta/conf/uefi.conf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 meta/conf/uefi.conf
Quoted 6 lines
This is heading in the right direction however if we're going to try and clean things up I've concluded we need to do it properly and get it right.
Now I understand more about how this configuration file is being used, should it be called image-uefi.conf ?
Fine, I will rename the conf file
Quoted 4 lines
I feel really strongly that we do not want an uefi.bbclass, its simply not warranted and will just continue to expand the current mess of classes. If all we need it for is some functions, those functions should be added elsewhere.
As those EFI_PROVIDER bootloader classes are called only form live-vm-common, maybe I should just add them to live-vm-common and make individual classes _append those functions?
Quoted 4 lines
I'm also on the lookout for tests of these kinds of codepaths. Code is much more likely to be accepted if tests are added for it. I'm not quite sure what would make most sense here in this case buts its a general point I will be pushing for going forward.
What kind of tests would you like? This code already exists and is called as a part of any live image generation.
Signature · 2 lines
With best wishes Dmitry
Quoted 16 lines · Dmitry Eremin-Solenikov
ср, 18 сент. 2019 г. в 01:16, Richard Purdie
<[email protected]>:Quoted 5 lines · On Tue, 2019-09-17 at 18:36 +0300, [email protected] wrote:
Quoted 1 line
Now I understand more about how this configuration file is being used,
should it be called image-uefi.conf ?Fine, I will rename the conf file
Quoted 5 lines
I feel really strongly that we do not want an uefi.bbclass, its simply
not warranted and will just continue to expand the current mess of classes. If all we need it for is some functions, those functions should be added elsewhere.
Quoted 3 lines
As those
EFI_PROVIDERbootloader classes are called only form live-vm-common, maybe I should just add them to live-vm-common and make individual classes_appendthose functions?
That sounds much better.
Quoted 8 lines
Quoted 5 lines
I'm also on the lookout for tests of these kinds of codepaths. Code is
much more likely to be accepted if tests are added for it. I'm not quite sure what would make most sense here in this case buts its a general point I will be pushing for going forward.What kind of tests would you like? This code already exists and is called as a part of any live image generation.
I think these patches are ok, you hinted this was part of a larger set of changes and I'm worried about the fit/signed image/uboot codepaths though which are in a similar area to some of this.
Its something to be mindful of as if changes are made to something which isn't currently tested I will be asking for tests.
Cheers,
Richard