mirror of
https://github.com/edera-dev/sprout.git
synced 2026-11-04 16:42:20 +00:00
fix(main): use the boot menu when the entry to boot can't be found
An entry from --boot or LoaderEntryOneShot that didn't match any entry aborted boot, which happens when the one-shot entry was removed or misspelled. Log a warning and use the boot menu instead.
This commit is contained in:
1 parent
20ca279fca
commit
8fce1738f2
1 file changed
+22
-7
+22
-7
@@ -379,14 +379,29 @@ fn run() -> Result<()> {
|
||||
.menu_style
|
||||
.unwrap_or(config.options.menu_style);
|
||||
|
||||
// Use the forced boot entry if possible, otherwise pick the first entry using a boot menu.
|
||||
let entry = if !force_boot_menu && let Some(ref force_boot_entry) = force_boot_entry {
|
||||
BootableEntry::find(force_boot_entry, entries.iter())
|
||||
.context(format!("unable to find entry: {force_boot_entry}"))?
|
||||
} else {
|
||||
// Find the forced boot entry, unless the boot menu is forced.
|
||||
// If the forced boot entry can't be found, such as when it was removed,
|
||||
// the boot menu is used instead.
|
||||
let forced_entry = force_boot_entry
|
||||
.as_ref()
|
||||
.filter(|_| !force_boot_menu)
|
||||
.and_then(|force_boot_entry| {
|
||||
let entry = BootableEntry::find(force_boot_entry, entries.iter());
|
||||
if entry.is_none() {
|
||||
warn!(
|
||||
"unable to find entry '{}', using the boot menu",
|
||||
force_boot_entry
|
||||
);
|
||||
}
|
||||
entry
|
||||
});
|
||||
|
||||
// Use the forced boot entry if possible, otherwise pick an entry using a boot menu.
|
||||
let entry = match forced_entry {
|
||||
Some(entry) => entry,
|
||||
// Delegate to the menu to select an entry to boot.
|
||||
menu::select(&timer, menu_timeout, menu_style, &entries)
|
||||
.context("unable to select entry via boot menu")?
|
||||
None => menu::select(&timer, menu_timeout, menu_style, &entries)
|
||||
.context("unable to select entry via boot menu")?,
|
||||
};
|
||||
|
||||
// Tell the bootloader interface what the selected entry is.
|
||||
|
||||
Reference in new issue
Block a user