@@ -262,13 +262,6 @@ fn run() -> Result<()> {
262262 }
263263 }
264264
265- // If no entries were the default, pick the first entry as the default entry.
266- if entries. iter ( ) . all ( |entry| !entry. is_default ( ) )
267- && let Some ( entry) = entries. first_mut ( )
268- {
269- entry. mark_default ( ) ;
270- }
271-
272265 // Tell the bootloader interface what entries are available.
273266 BootloaderInterface :: set_entries ( entries. iter ( ) . map ( |entry| entry. name ( ) ) )
274267 . context ( "unable to set entries in bootloader interface" ) ?;
@@ -280,8 +273,16 @@ fn run() -> Result<()> {
280273 let bootloader_interface_timeout =
281274 BootloaderInterface :: get_timeout ( ) . context ( "unable to get bootloader interface timeout" ) ?;
282275
276+ // Acquire the default entry from the bootloader interface.
277+ let bootloader_interface_default_entry = BootloaderInterface :: get_default_entry ( )
278+ . context ( "unable to get bootloader interface default entry" ) ?;
279+
280+ // Acquire the oneshot entry from the bootloader interface.
281+ let bootloader_interface_oneshot_entry = BootloaderInterface :: get_oneshot_entry ( )
282+ . context ( "unable to get bootloader interface oneshot entry" ) ?;
283+
283284 // If --boot is specified, boot that entry immediately.
284- let force_boot_entry = context. root ( ) . options ( ) . boot . as_ref ( ) ;
285+ let mut force_boot_entry = context. root ( ) . options ( ) . boot . clone ( ) ;
285286 // If --force-menu is specified, show the boot menu regardless of the value of --boot.
286287 let mut force_boot_menu = context. root ( ) . options ( ) . force_menu ;
287288
@@ -320,6 +321,33 @@ fn run() -> Result<()> {
320321 }
321322 }
322323
324+ // Apply bootloader interface default entry settings.
325+ if let Some ( ref bootloader_interface_default_entry) = bootloader_interface_default_entry {
326+ // Iterate over all the entries and mark the default entry as the one specified.
327+ for entry in & mut entries {
328+ // Mark the entry as the default entry if it matches the specified entry.
329+ // If the entry does not match the specified entry, unmark it as the default entry.
330+ if entry. is_match ( bootloader_interface_default_entry) {
331+ entry. mark_default ( ) ;
332+ } else {
333+ entry. unmark_default ( ) ;
334+ }
335+ }
336+ }
337+
338+ // Apply bootloader interface oneshot entry settings.
339+ // If set, we will force booting the oneshot entry.
340+ if let Some ( ref bootloader_interface_oneshot_entry) = bootloader_interface_oneshot_entry {
341+ force_boot_entry = Some ( bootloader_interface_oneshot_entry. clone ( ) ) ;
342+ }
343+
344+ // If no entries were the default, pick the first entry as the default entry.
345+ if entries. iter ( ) . all ( |entry| !entry. is_default ( ) )
346+ && let Some ( entry) = entries. first_mut ( )
347+ {
348+ entry. mark_default ( ) ;
349+ }
350+
323351 // Convert the menu timeout to a duration.
324352 let menu_timeout = Duration :: from_secs ( menu_timeout) ;
325353
0 commit comments