From 87a6c84025424c3effe80ada9ebd46d5738bcb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= Date: Thu, 20 Jun 2024 12:57:25 +0200 Subject: [PATCH] Fix boot slot A marked as bad on the very first boot (#3435) On the very first boot, grubenv doesn't exist and loading and saving it silently fails. However, it is later created by the hassos-persists script and the missing information are added by grub.cfg on the next boot. As the consequence, when RAUC tries to get information from grubenv on the first boot, ORDER variable is missing and the slot is reported as bad. Fixes #3376 --- buildroot-external/board/pc/generic-x86-64/hassos-hook.sh | 1 + buildroot-external/board/pc/ova/hassos-hook.sh | 1 + tests/smoke_test/test_basic.py | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/buildroot-external/board/pc/generic-x86-64/hassos-hook.sh b/buildroot-external/board/pc/generic-x86-64/hassos-hook.sh index c9dc1dacd85..82e732905ea 100755 --- a/buildroot-external/board/pc/generic-x86-64/hassos-hook.sh +++ b/buildroot-external/board/pc/generic-x86-64/hassos-hook.sh @@ -17,6 +17,7 @@ function hassos_pre_image() { grub-editenv "${EFIPART_DATA}/EFI/BOOT/grubenv-B" set ORDER="B A" grub-editenv "${EFIPART_DATA}/EFI/BOOT/grubenv-B" set B_OK=1 grub-editenv "${EFIPART_DATA}/EFI/BOOT/grubenv-B" set B_TRY=0 + cp "${EFIPART_DATA}/EFI/BOOT/grubenv-A" "${EFIPART_DATA}/EFI/BOOT/grubenv" cp -r "${EFIPART_DATA}/"* "${BOOT_DATA}/" } diff --git a/buildroot-external/board/pc/ova/hassos-hook.sh b/buildroot-external/board/pc/ova/hassos-hook.sh index d22c574ca53..8506a0f32af 100755 --- a/buildroot-external/board/pc/ova/hassos-hook.sh +++ b/buildroot-external/board/pc/ova/hassos-hook.sh @@ -17,6 +17,7 @@ function hassos_pre_image() { grub-editenv "${EFIPART_DATA}/EFI/BOOT/grubenv-B" set ORDER="B A" grub-editenv "${EFIPART_DATA}/EFI/BOOT/grubenv-B" set B_OK=1 grub-editenv "${EFIPART_DATA}/EFI/BOOT/grubenv-B" set B_TRY=0 + cp "${EFIPART_DATA}/EFI/BOOT/grubenv-A" "${EFIPART_DATA}/EFI/BOOT/grubenv" cp -r "${EFIPART_DATA}/"* "${BOOT_DATA}/" } diff --git a/tests/smoke_test/test_basic.py b/tests/smoke_test/test_basic.py index 6396a29d7aa..fa4fe80e2bf 100644 --- a/tests/smoke_test/test_basic.py +++ b/tests/smoke_test/test_basic.py @@ -35,6 +35,14 @@ def check_container_running(container_name): _LOGGER.info("%s", "\n".join(output)) +@pytest.mark.dependency(depends=["test_init"]) +def test_rauc_status(shell): + output = shell.run_check("rauc status --output-format=shell") + # RAUC_BOOT_PRIMARY won't be set if correct grub env is missing + assert "RAUC_BOOT_PRIMARY='kernel.0'" in output + assert "rauc-WARNING" not in "\n".join(output) + + @pytest.mark.dependency(depends=["test_init"]) def test_dmesg(shell): output = shell.run_check("dmesg")