From 3a7e9667ef4905be212f3afa58c8dd5549fd2227 Mon Sep 17 00:00:00 2001 From: Andrei Gherzan <andrei.gherzan@huawei.com> Date: Wed, 10 Aug 2022 01:14:38 +0200 Subject: [PATCH] oniro-grub-bootconf: Respect KERNEL_IMAGETYPE as opposed to hardcoding bzImage This patch makes sure that the resulting cfg takes into consideration the kernel image type for the specific machine. This change makes now the recipe/package machine specific so we drop allarch and set PACKAGE_ARCH accordingly. Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com> --- meta-oniro-core/recipes-bsp/grub/files/grub.cfg | 13 +++++++------ .../recipes-bsp/grub/oniro-grub-bootconf.bb | 9 ++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/meta-oniro-core/recipes-bsp/grub/files/grub.cfg b/meta-oniro-core/recipes-bsp/grub/files/grub.cfg index b72bf6f9..ec80e3bd 100644 --- a/meta-oniro-core/recipes-bsp/grub/files/grub.cfg +++ b/meta-oniro-core/recipes-bsp/grub/files/grub.cfg @@ -33,24 +33,25 @@ echo "note: loaded SYSOTA_BOOT_ACTIVE=$SYSOTA_BOOT_ACTIVE SYSOTA_BOOT_TRY=$SYSOT # Recover active slot if the file is corrupted. if [ -z "$SYSOTA_BOOT_ACTIVE" ]; then echo "warning: SYSOTA_BOOT_ACTIVE is unset, attempting recovery" - if [ -e "(hd0,gpt2)/boot/bzImage" -a -e "(hd0,gpt3)/boot/bzImage" ]; then + if [ -e "(hd0,gpt2)/boot/@KERNEL_IMAGETYPE@" -a -e "(hd0,gpt3)/boot/@KERNEL_IMAGETYPE@" ]; then # Both slots are available, pick the more recent slot. # TODO: handle rollback prevention flags (how?) - if [ "(hd0,gpt2)/boot/bzImage" -nt "(hd0,gpt3)/boot/bzImage" ]; then + if [ "(hd0,gpt2)/boot/@KERNEL_IMAGETYPE@" -nt "(hd0,gpt3)/boot/@KERNEL_IMAGETYPE@" ]; then echo "note: recovered SYSOTA_BOOT_ACTIVE=A (slot A kernel is newer than slot B)" set SYSOTA_BOOT_ACTIVE="A" else echo "note: recovered SYSOTA_BOOT_ACTIVE=B (slot B kernel is newer than slot A)" set SYSOTA_BOOT_ACTIVE="B" fi - elif [ -e "(hd0,gpt2)/boot/bzImage" ]; then + elif [ -e "(hd0,gpt2)/boot/@KERNEL_IMAGETYPE@" ]; then echo "note: recovered SYSOTA_BOOT_ACTIVE=A" set SYSOTA_BOOT_ACTIVE="A" - elif [ -e "(hd0,gpt3)/boot/bzImage" ]; then + elif [ -e "(hd0,gpt3)/boot/@KERNEL_IMAGETYPE@" ]; then echo "note: recovered SYSOTA_BOOT_ACTIVE=B" set SYSOTA_BOOT_ACTIVE="B" else echo "error: cannot recover GRUB environment block: both slots are corrupted, halting" + shell halt fi @@ -81,9 +82,9 @@ fi # https://gitlab.eclipse.org/eclipse/oniro-core/sysota/-/wikis/Boot%20Assets%20Specification#efigrub if [ "$SLOT" == "A" ]; then # TODO pass root partition by partuuid. - linux "(hd0,gpt2)/boot/bzImage" root=/dev/sda2 rauc.slot=A $CMDLINE + linux "(hd0,gpt2)/boot/@KERNEL_IMAGETYPE@" root=/dev/sda2 rauc.slot=A $CMDLINE elif [ "$SLOT" == "B" ]; then - linux "(hd0,gpt3)/boot/bzImage" root=/dev/sda3 rauc.slot=B $CMDLINE + linux "(hd0,gpt3)/boot/@KERNEL_IMAGETYPE@" root=/dev/sda3 rauc.slot=B $CMDLINE else echo "error: cannot select slot to boot from, halting" halt diff --git a/meta-oniro-core/recipes-bsp/grub/oniro-grub-bootconf.bb b/meta-oniro-core/recipes-bsp/grub/oniro-grub-bootconf.bb index 856c0aa2..ebd10411 100644 --- a/meta-oniro-core/recipes-bsp/grub/oniro-grub-bootconf.bb +++ b/meta-oniro-core/recipes-bsp/grub/oniro-grub-bootconf.bb @@ -16,7 +16,7 @@ SRC_URI = " \ file://grubenv \ " -inherit allarch deploy +inherit deploy RPROVIDES:${PN} += "virtual-grub-bootconf" @@ -32,17 +32,18 @@ do_install() { # testing. install -d ${D}${EFI_FILES_PATH} install -m 644 grub.cfg ${D}${EFI_FILES_PATH}/grub.cfg + sed -i "s/@KERNEL_IMAGETYPE@/${KERNEL_IMAGETYPE}/g" ${D}${EFI_FILES_PATH}/grub.cfg install -m 644 grubenv ${D}${EFI_FILES_PATH}/grubenv } do_deploy() { # Install the boot assets into DEPLOYDIR. The deploy bbclass # eventually copies those into the boot partition. - install -m 644 ${WORKDIR}/grub.cfg ${DEPLOYDIR} + install -m 644 ${D}${EFI_FILES_PATH}/grub.cfg ${DEPLOYDIR} # Unlike grub.cfg, nothing installs this file to the boot partition # automatically. It is handled by extending IMAGE_EFI_BOOT_FILES from # conf/distro/oniro-linux.conf. - install -m 644 ${WORKDIR}/grubenv ${DEPLOYDIR} + install -m 644 ${D}${EFI_FILES_PATH}/grubenv ${DEPLOYDIR} } # Cargo-cult from a similar recipe. @@ -52,3 +53,5 @@ FILES:${PN} = "\ ${EFI_FILES_PATH}/grub.cfg \ ${EFI_FILES_PATH}/grubenv \ " + +PACKAGE_ARCH = "${MACHINE_ARCH}" -- GitLab