@@ -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 ( ) ;
@@ -358,41 +358,63 @@ pub(crate) async fn composefs_deployment_status() -> Result<Host> {
358
358
}
359
359
} ;
360
360
361
- match boot_type {
362
- BootType :: Bls => {
363
- let bls_config = get_sorted_bls_boot_entries ( & boot_dir, false ) ?;
364
- let bls_config = bls_config
365
- . first ( )
366
- . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?;
367
-
368
- match & bls_config. cfg_type {
369
- BLSConfigType :: EFI { efi } => {
370
- host. status . rollback_queued = efi. contains ( composefs_digest. as_ref ( ) ) ;
371
- }
361
+ let is_rollback_queued = match booted. bootloader {
362
+ Bootloader :: Grub => match boot_type {
363
+ BootType :: Bls => {
364
+ let bls_config = get_sorted_type1_boot_entries ( & boot_dir, false ) ?;
365
+ let bls_config = bls_config
366
+ . first ( )
367
+ . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?;
372
368
373
- BLSConfigType :: NonEFI { options , .. } => {
374
- host . status . rollback_queued = !options
369
+ match & bls_config . cfg_type {
370
+ BLSConfigType :: NonEFI { options , .. } => !options
375
371
. as_ref ( )
376
372
. ok_or ( anyhow:: anyhow!( "options key not found in bls config" ) ) ?
377
- . contains ( composefs_digest. as_ref ( ) ) ;
373
+ . contains ( composefs_digest. as_ref ( ) ) ,
374
+
375
+ BLSConfigType :: EFI { .. } => {
376
+ anyhow:: bail!( "Found 'efi' field in Type1 boot entry" )
377
+ }
378
+ BLSConfigType :: Unknown => anyhow:: bail!( "Unknown BLS Config Type" ) ,
378
379
}
380
+ }
379
381
380
- BLSConfigType :: Unknown => todo ! ( ) ,
381
- } ;
382
- }
382
+ BootType :: Uki => {
383
+ let mut s = String :: new ( ) ;
383
384
384
- BootType :: Uki => {
385
- let mut s = String :: new ( ) ;
385
+ !get_sorted_uki_boot_entries ( & boot_dir, & mut s) ?
386
+ . first ( )
387
+ . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?
388
+ . body
389
+ . chainloader
390
+ . contains ( composefs_digest. as_ref ( ) )
391
+ }
392
+ } ,
386
393
387
- host. status . rollback_queued = !get_sorted_uki_boot_entries ( & boot_dir, & mut s) ?
394
+ // We will have BLS stuff and the UKI stuff in the same DIR
395
+ Bootloader :: Systemd => {
396
+ let bls_config = get_sorted_type1_boot_entries ( & boot_dir, false ) ?;
397
+ let bls_config = bls_config
388
398
. first ( )
389
- . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?
390
- . body
391
- . chainloader
392
- . contains ( composefs_digest. as_ref ( ) )
399
+ . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?;
400
+
401
+ match & bls_config. cfg_type {
402
+ // For UKI boot
403
+ BLSConfigType :: EFI { efi } => efi. contains ( composefs_digest. as_ref ( ) ) ,
404
+
405
+ // For boot entry Type1
406
+ BLSConfigType :: NonEFI { options, .. } => !options
407
+ . as_ref ( )
408
+ . ok_or ( anyhow:: anyhow!( "options key not found in bls config" ) ) ?
409
+ . contains ( composefs_digest. as_ref ( ) ) ,
410
+
411
+ BLSConfigType :: Unknown => anyhow:: bail!( "Unknown BLS Config Type" ) ,
412
+ }
393
413
}
394
414
} ;
395
415
416
+ host. status . rollback_queued = is_rollback_queued;
417
+
396
418
if host. status . rollback_queued {
397
419
host. spec . boot_order = BootOrder :: Rollback
398
420
} ;
@@ -449,7 +471,7 @@ mod tests {
449
471
tempdir. atomic_write ( "loader/entries/entry1.conf" , entry1) ?;
450
472
tempdir. atomic_write ( "loader/entries/entry2.conf" , entry2) ?;
451
473
452
- let result = get_sorted_bls_boot_entries ( & tempdir, true ) . unwrap ( ) ;
474
+ let result = get_sorted_type1_boot_entries ( & tempdir, true ) . unwrap ( ) ;
453
475
454
476
let mut config1 = BLSConfig :: default ( ) ;
455
477
config1. title = Some ( "Fedora 42.20250623.3.1 (CoreOS)" . into ( ) ) ;
@@ -472,7 +494,7 @@ mod tests {
472
494
assert_eq ! ( result[ 0 ] . sort_key. as_ref( ) . unwrap( ) , "1" ) ;
473
495
assert_eq ! ( result[ 1 ] . sort_key. as_ref( ) . unwrap( ) , "2" ) ;
474
496
475
- let result = get_sorted_bls_boot_entries ( & tempdir, false ) . unwrap ( ) ;
497
+ let result = get_sorted_type1_boot_entries ( & tempdir, false ) . unwrap ( ) ;
476
498
assert_eq ! ( result[ 0 ] . sort_key. as_ref( ) . unwrap( ) , "2" ) ;
477
499
assert_eq ! ( result[ 1 ] . sort_key. as_ref( ) . unwrap( ) , "1" ) ;
478
500
0 commit comments