@@ -7,7 +7,7 @@ use fn_error_context::context;
7
7
8
8
use crate :: {
9
9
bootc_composefs:: boot:: { get_esp_partition, get_sysroot_parent_dev, BootType } ,
10
- composefs_consts:: { BOOT_LOADER_ENTRIES , COMPOSEFS_CMDLINE , USER_CFG } ,
10
+ composefs_consts:: { COMPOSEFS_CMDLINE , TYPE1_ENT_PATH , USER_CFG } ,
11
11
parsers:: {
12
12
bls_config:: { parse_bls_config, BLSConfig , BLSConfigType } ,
13
13
grub_menuconfig:: { parse_grub_menuentry_file, MenuEntry } ,
@@ -91,14 +91,14 @@ pub(crate) fn get_sorted_uki_boot_entries<'a>(
91
91
parse_grub_menuentry_file ( str)
92
92
}
93
93
94
- #[ context( "Getting sorted BLS entries" ) ]
95
- pub ( crate ) fn get_sorted_bls_boot_entries (
94
+ #[ context( "Getting sorted Type1 boot entries" ) ]
95
+ pub ( crate ) fn get_sorted_type1_boot_entries (
96
96
boot_dir : & Dir ,
97
97
ascending : bool ,
98
98
) -> Result < Vec < BLSConfig > > {
99
99
let mut all_configs = vec ! [ ] ;
100
100
101
- for entry in boot_dir. read_dir ( format ! ( "loader/{BOOT_LOADER_ENTRIES}" ) ) ? {
101
+ for entry in boot_dir. read_dir ( TYPE1_ENT_PATH ) ? {
102
102
let entry = entry?;
103
103
104
104
let file_name = entry. file_name ( ) ;
@@ -374,41 +374,63 @@ pub(crate) async fn composefs_deployment_status() -> Result<Host> {
374
374
}
375
375
} ;
376
376
377
- match boot_type {
378
- BootType :: Bls => {
379
- let bls_config = get_sorted_bls_boot_entries ( & boot_dir, false ) ?;
380
- let bls_config = bls_config
381
- . first ( )
382
- . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?;
383
-
384
- match & bls_config. cfg_type {
385
- BLSConfigType :: EFI { efi } => {
386
- host. status . rollback_queued = efi. contains ( composefs_digest. as_ref ( ) ) ;
387
- }
377
+ let is_rollback_queued = match booted. bootloader {
378
+ Bootloader :: Grub => match boot_type {
379
+ BootType :: Bls => {
380
+ let bls_config = get_sorted_type1_boot_entries ( & boot_dir, false ) ?;
381
+ let bls_config = bls_config
382
+ . first ( )
383
+ . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?;
388
384
389
- BLSConfigType :: NonEFI { options , .. } => {
390
- host . status . rollback_queued = !options
385
+ match & bls_config . cfg_type {
386
+ BLSConfigType :: NonEFI { options , .. } => !options
391
387
. as_ref ( )
392
388
. ok_or ( anyhow:: anyhow!( "options key not found in bls config" ) ) ?
393
- . contains ( composefs_digest. as_ref ( ) ) ;
389
+ . contains ( composefs_digest. as_ref ( ) ) ,
390
+
391
+ BLSConfigType :: EFI { .. } => {
392
+ anyhow:: bail!( "Found 'efi' field in Type1 boot entry" )
393
+ }
394
+ BLSConfigType :: Unknown => anyhow:: bail!( "Unknown BLS Config Type" ) ,
394
395
}
396
+ }
395
397
396
- BLSConfigType :: Unknown => todo ! ( ) ,
397
- } ;
398
- }
398
+ BootType :: Uki => {
399
+ let mut s = String :: new ( ) ;
399
400
400
- BootType :: Uki => {
401
- let mut s = String :: new ( ) ;
401
+ !get_sorted_uki_boot_entries ( & boot_dir, & mut s) ?
402
+ . first ( )
403
+ . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?
404
+ . body
405
+ . chainloader
406
+ . contains ( composefs_digest. as_ref ( ) )
407
+ }
408
+ } ,
402
409
403
- host. status . rollback_queued = !get_sorted_uki_boot_entries ( & boot_dir, & mut s) ?
410
+ // We will have BLS stuff and the UKI stuff in the same DIR
411
+ Bootloader :: Systemd => {
412
+ let bls_config = get_sorted_type1_boot_entries ( & boot_dir, false ) ?;
413
+ let bls_config = bls_config
404
414
. first ( )
405
- . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?
406
- . body
407
- . chainloader
408
- . contains ( composefs_digest. as_ref ( ) )
415
+ . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?;
416
+
417
+ match & bls_config. cfg_type {
418
+ // For UKI boot
419
+ BLSConfigType :: EFI { efi } => efi. contains ( composefs_digest. as_ref ( ) ) ,
420
+
421
+ // For boot entry Type1
422
+ BLSConfigType :: NonEFI { options, .. } => !options
423
+ . as_ref ( )
424
+ . ok_or ( anyhow:: anyhow!( "options key not found in bls config" ) ) ?
425
+ . contains ( composefs_digest. as_ref ( ) ) ,
426
+
427
+ BLSConfigType :: Unknown => anyhow:: bail!( "Unknown BLS Config Type" ) ,
428
+ }
409
429
}
410
430
} ;
411
431
432
+ host. status . rollback_queued = is_rollback_queued;
433
+
412
434
if host. status . rollback_queued {
413
435
host. spec . boot_order = BootOrder :: Rollback
414
436
} ;
@@ -465,7 +487,7 @@ mod tests {
465
487
tempdir. atomic_write ( "loader/entries/entry1.conf" , entry1) ?;
466
488
tempdir. atomic_write ( "loader/entries/entry2.conf" , entry2) ?;
467
489
468
- let result = get_sorted_bls_boot_entries ( & tempdir, true ) . unwrap ( ) ;
490
+ let result = get_sorted_type1_boot_entries ( & tempdir, true ) . unwrap ( ) ;
469
491
470
492
let mut config1 = BLSConfig :: default ( ) ;
471
493
config1. title = Some ( "Fedora 42.20250623.3.1 (CoreOS)" . into ( ) ) ;
@@ -488,7 +510,7 @@ mod tests {
488
510
assert_eq ! ( result[ 0 ] . sort_key. as_ref( ) . unwrap( ) , "1" ) ;
489
511
assert_eq ! ( result[ 1 ] . sort_key. as_ref( ) . unwrap( ) , "2" ) ;
490
512
491
- let result = get_sorted_bls_boot_entries ( & tempdir, false ) . unwrap ( ) ;
513
+ let result = get_sorted_type1_boot_entries ( & tempdir, false ) . unwrap ( ) ;
492
514
assert_eq ! ( result[ 0 ] . sort_key. as_ref( ) . unwrap( ) , "2" ) ;
493
515
assert_eq ! ( result[ 1 ] . sort_key. as_ref( ) . unwrap( ) , "1" ) ;
494
516
0 commit comments