Skip to content

Commit 25cf806

Browse files
committed
install: run bootupctl update if detecting bootupd on ostree
Signed-off-by: Huijing Hei <[email protected]>
1 parent 4c8db70 commit 25cf806

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

crates/lib/src/bootloader.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ pub(crate) fn install_via_bootupd(
7070
.run_inherited_with_cmd_context()
7171
}
7272

73+
#[context("Updating bootloader")]
74+
pub(crate) fn update_via_bootupd() -> Result<()> {
75+
let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv");
76+
println!("Updating bootloader via bootupd");
77+
Command::new("bootupctl")
78+
.args(["update"])
79+
.args(verbose)
80+
.log_debug()
81+
.run_inherited_with_cmd_context()
82+
}
83+
7384
#[context("Installing bootloader")]
7485
pub(crate) fn install_systemd_boot(
7586
device: &PartitionTable,

crates/lib/src/install.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,11 +1843,11 @@ fn clean_boot_directories(rootfs: &Dir, is_ostree: bool) -> Result<()> {
18431843
crate::utils::open_dir_remount_rw(rootfs, BOOT.into()).context("Opening /boot")?;
18441844

18451845
if is_ostree {
1846-
// On ostree systems, the boot directory already has our desired format, we should only
1847-
// remove the bootupd-state.json file to avoid bootupctl complaining it already exists.
1848-
bootdir
1849-
.remove_file_optional("bootupd-state.json")
1850-
.context("removing bootupd-state.json")?;
1846+
if bootdir.exists("bootupd-state.json") {
1847+
// On ostree systems with bootupd, should running bootupctl update.
1848+
crate::bootloader::update_via_bootupd()?;
1849+
}
1850+
// TODO: handle with no bootupd
18511851
} else {
18521852
// This should not remove /boot/efi note.
18531853
remove_all_in_dir_no_xdev(&bootdir, false).context("Emptying /boot")?;

0 commit comments

Comments
 (0)