From 843c02b737f17a2aa7018655ca9c638d137dfcc6 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 6 Mar 2024 17:26:45 -0800 Subject: [PATCH 1/2] bootupd: call bootupctl with --update-firmware This is required to write an entry to the EFI boot manager, which we ought to do (anaconda does it when installing the bootloader itself). Without this, boot of the installed system will only work if it's configured to try and boot from the hard disk using the fallback path. Signed-off-by: Adam Williamson (cherry picked from commit 0b2fc1382bf58d5c5c84e7d793f4642a985a5a07) Resolves: RHEL-40897 --- .../modules/payloads/payload/rpm_ostree/installation.py | 1 + .../modules/payloads/payload/test_rpm_ostree_tasks.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyanaconda/modules/payloads/payload/rpm_ostree/installation.py b/pyanaconda/modules/payloads/payload/rpm_ostree/installation.py index a03b8959ba6..2eb1327e090 100644 --- a/pyanaconda/modules/payloads/payload/rpm_ostree/installation.py +++ b/pyanaconda/modules/payloads/payload/rpm_ostree/installation.py @@ -437,6 +437,7 @@ def _install_bootupd(self): "install", "--auto", "--write-uuid", + "--update-firmware", "--device", dev_data.path, "/", diff --git a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_rpm_ostree_tasks.py b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_rpm_ostree_tasks.py index b32fff05b31..ca8663be9a1 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_rpm_ostree_tasks.py +++ b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_rpm_ostree_tasks.py @@ -694,8 +694,8 @@ def test_bootupd_run(self, devdata_mock, storage_mock, symlink_mock, rename_mock exec_mock.assert_has_calls([ call( "bootupctl", - ["backend", "install", "--auto", "--write-uuid", "--device", - "/dev/btldr-drv", "/"], + ["backend", "install", "--auto", "--write-uuid", "--update-firmware", + "--device", "/dev/btldr-drv", "/"], root=sysroot ), call( From 7394e1fda5cc4c082d8507fcda7dd61e6c286813 Mon Sep 17 00:00:00 2001 From: Jiri Konecny Date: Mon, 10 Jun 2024 14:46:29 +0200 Subject: [PATCH 2/2] Support leavebootorder for bootupd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If leavebootorder was specified through kickstart or kernel boot arguments we won't pass `--update-firmware` to bootupdctl. That will avoid creation of the UEFI entry for the bootloader and give people possibility for additional tweaking or debugging. This was requested by bootloader developers. Suggested-by: Timothée Ravier (cherry picked from commit 28d1aed119edc4a75c6083d8a29d425fb0d7b840) Resolves: RHEL-40897 --- .../payload/rpm_ostree/installation.py | 14 ++++-- .../payloads/payload/test_rpm_ostree_tasks.py | 43 +++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/pyanaconda/modules/payloads/payload/rpm_ostree/installation.py b/pyanaconda/modules/payloads/payload/rpm_ostree/installation.py index 2eb1327e090..4662655ede3 100644 --- a/pyanaconda/modules/payloads/payload/rpm_ostree/installation.py +++ b/pyanaconda/modules/payloads/payload/rpm_ostree/installation.py @@ -430,14 +430,22 @@ def _install_bootupd(self): device_tree = STORAGE.get_proxy(DEVICE_TREE) dev_data = DeviceData.from_structure(device_tree.GetDeviceData(bootloader.Drive)) + bootupdctl_args = [ + "--auto", + "--write-uuid", + ] + + # do not insert UEFI entry if leavebootorder was requested + if not bootloader.KeepBootOrder: + log.debug("Adding --update-firmware to bootupdctl call") + bootupdctl_args.append("--update-firmware") + rc = execWithRedirect( "bootupctl", [ "backend", "install", - "--auto", - "--write-uuid", - "--update-firmware", + *bootupdctl_args, "--device", dev_data.path, "/", diff --git a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_rpm_ostree_tasks.py b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_rpm_ostree_tasks.py index ca8663be9a1..c16d6f96b73 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_rpm_ostree_tasks.py +++ b/tests/unit_tests/pyanaconda_tests/modules/payloads/payload/test_rpm_ostree_tasks.py @@ -681,6 +681,7 @@ def test_bootupd_run(self, devdata_mock, storage_mock, symlink_mock, rename_mock proxy_mock.GetFstabSpec.return_value = "FSTAB-SPEC" proxy_mock.GetRootDevice.return_value = "device-name" proxy_mock.Drive = "btldr-drv" + proxy_mock.KeepBootOrder = False devdata_mock.from_structure.return_value.type = "something-non-btrfs-subvolume-ish" devdata_mock.from_structure.return_value.path = "/dev/btldr-drv" @@ -705,6 +706,48 @@ def test_bootupd_run(self, devdata_mock, storage_mock, symlink_mock, rename_mock ) ]) + @patch("pyanaconda.modules.payloads.payload.rpm_ostree.installation.have_bootupd") + @patch("pyanaconda.modules.payloads.payload.rpm_ostree.installation.execWithRedirect") + @patch("pyanaconda.modules.payloads.payload.rpm_ostree.installation.os.rename") + @patch("pyanaconda.modules.payloads.payload.rpm_ostree.installation.os.symlink") + @patch("pyanaconda.modules.payloads.payload.rpm_ostree.installation.STORAGE") + @patch("pyanaconda.modules.payloads.payload.rpm_ostree.installation.DeviceData") + def test_bootupd_run_with_leavebootorder(self, devdata_mock, storage_mock, symlink_mock, + rename_mock, exec_mock, have_bootupd_mock): + """Test OSTree bootloader config task, bootupd""" + exec_mock.return_value = 0 + have_bootupd_mock.return_value = True + + proxy_mock = storage_mock.get_proxy() + proxy_mock.GetArguments.return_value = ["BOOTLOADER-ARGS"] + proxy_mock.GetFstabSpec.return_value = "FSTAB-SPEC" + proxy_mock.GetRootDevice.return_value = "device-name" + proxy_mock.Drive = "btldr-drv" + proxy_mock.KeepBootOrder = True + devdata_mock.from_structure.return_value.type = "something-non-btrfs-subvolume-ish" + devdata_mock.from_structure.return_value.path = "/dev/btldr-drv" + + with tempfile.TemporaryDirectory() as sysroot: + task = ConfigureBootloader(sysroot, is_dirinstall=False) + task.run() + + rename_mock.assert_not_called() + symlink_mock.assert_not_called() + assert exec_mock.call_count == 2 + exec_mock.assert_has_calls([ + call( + "bootupctl", + ["backend", "install", "--auto", "--write-uuid", + "--device", "/dev/btldr-drv", "/"], + root=sysroot + ), + call( + "ostree", + ["admin", "instutil", "set-kargs", "BOOTLOADER-ARGS", "root=FSTAB-SPEC", "rw"], + root=sysroot + ) + ]) + @patch("pyanaconda.modules.payloads.payload.rpm_ostree.installation.execWithRedirect") @patch("pyanaconda.modules.payloads.payload.rpm_ostree.installation.os.rename") @patch("pyanaconda.modules.payloads.payload.rpm_ostree.installation.os.symlink")