Skip to content

Commit f427fb7

Browse files
composefs/boot: Fix sd-boot order on update
Grub sorts its BLS config in descending order, while sd-boot sorts the configs in ascending order. While upgrading we were always setting the new sort key to be `1` which would work for Grub but not for sd-boot. Fixes: #1777 Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 63d09b6 commit f427fb7

File tree

1 file changed

+10
-2
lines changed
  • crates/lib/src/bootc_composefs

1 file changed

+10
-2
lines changed

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,11 @@ pub(crate) fn setup_composefs_bls_boot(
474474
let boot_digest = compute_boot_digest(usr_lib_modules_vmlinuz, &repo)
475475
.context("Computing boot digest")?;
476476

477-
let default_sort_key = "1";
477+
let default_sort_key = match bootloader {
478+
Bootloader::Grub => "1",
479+
Bootloader::Systemd => "0",
480+
};
481+
478482
let default_title_version = (id.to_hex(), default_sort_key.to_string());
479483

480484
let osrel_res = osrel_title_and_version(fs, &repo)?;
@@ -540,7 +544,11 @@ pub(crate) fn setup_composefs_bls_boot(
540544
let boot_dir = Dir::open_ambient_dir(&entry_paths.config_path, ambient_authority())?;
541545

542546
let mut booted_bls = get_booted_bls(&boot_dir)?;
543-
booted_bls.sort_key = Some("0".into()); // entries are sorted by their filename in reverse order
547+
booted_bls.sort_key = match bootloader {
548+
// Grub entries are sorted by their filename in reverse order
549+
Bootloader::Grub => Some("0".into()),
550+
Bootloader::Systemd => Some("1".into()),
551+
};
544552

545553
// This will be atomically renamed to 'loader/entries' on shutdown/reboot
546554
(

0 commit comments

Comments
 (0)