From ac690371116ef7a1147fbde54855dda4472b1636 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sat, 26 Sep 2026 20:15:09 -0700 Subject: [PATCH] fix(entries): stamp the sort key of entries The sort-key of an entry was compared as written, without stamping the values into it. Autoconfigured Linux entries all use "$kernel" as the sort key, so they compared equal and kept the order the filesystem listed them in, which made the default kernel arbitrary instead of the newest one. Stamp the sort key along with the title. --- crates/boot/src/entries.rs | 10 ++++++++++ crates/boot/src/main.rs | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/boot/src/entries.rs b/crates/boot/src/entries.rs index 903669e..88ad5a1 100644 --- a/crates/boot/src/entries.rs +++ b/crates/boot/src/entries.rs @@ -74,6 +74,16 @@ impl BootableEntry { self.title = self.context.stamp(&self.title); } + /// Restamp the declared sort key with the current context. + /// A sort key that was set on this entry directly is left as is. + pub fn restamp_sort_key(&mut self) { + if self.sort_key.is_none() + && let Some(ref sort_key) = self.declaration.sort_key + { + self.sort_key = Some(self.context.stamp(sort_key)); + } + } + /// Mark this entry as the default entry. pub fn mark_default(&mut self) { self.default = true; diff --git a/crates/boot/src/main.rs b/crates/boot/src/main.rs index bfed7f3..730906a 100644 --- a/crates/boot/src/main.rs +++ b/crates/boot/src/main.rs @@ -271,8 +271,9 @@ fn run() -> Result<()> { .freeze(); // Provide the new context to the bootable entry. entry.swap_context(context); - // Restamp the title with any values. + // Restamp the title and sort key with any values. entry.restamp_title(); + entry.restamp_sort_key(); // Mark this entry as the default entry if it is declared as such. if let Some(ref default_entry) = config.options.default_entry {