@@ -24,7 +24,8 @@ use ostree_ext::ostree;
24
24
use tokio:: io:: AsyncReadExt ;
25
25
26
26
use crate :: cli:: OutputFormat ;
27
- use crate :: deploy:: get_sorted_boot_entries;
27
+ use crate :: deploy:: get_sorted_bls_boot_entries;
28
+ use crate :: deploy:: get_sorted_uki_boot_entries;
28
29
use crate :: install:: BootType ;
29
30
use crate :: install:: ORIGIN_KEY_BOOT ;
30
31
use crate :: install:: ORIGIN_KEY_BOOT_TYPE ;
@@ -422,6 +423,9 @@ pub(crate) async fn composefs_deployment_status() -> Result<Host> {
422
423
Err ( e) => Err ( e) ,
423
424
} ?;
424
425
426
+ // NOTE: This cannot work if we support both BLS and UKI at the same time
427
+ let mut boot_type: Option < BootType > = None ;
428
+
425
429
for depl in deployments {
426
430
let depl = depl?;
427
431
@@ -441,6 +445,21 @@ pub(crate) async fn composefs_deployment_status() -> Result<Host> {
441
445
let boot_entry =
442
446
boot_entry_from_composefs_deployment ( ini, depl_file_name. to_string ( ) ) . await ?;
443
447
448
+ // SAFETY: boot_entry.composefs will always be present
449
+ let boot_type_from_origin = boot_entry. composefs . as_ref ( ) . unwrap ( ) . boot_type ;
450
+
451
+ match boot_type {
452
+ Some ( current_type) => {
453
+ if current_type != boot_type_from_origin {
454
+ anyhow:: bail!( "Conflicting boot types" )
455
+ }
456
+ }
457
+
458
+ None => {
459
+ boot_type = Some ( boot_type_from_origin) ;
460
+ }
461
+ } ;
462
+
444
463
if depl. file_name ( ) == booted_image_verity {
445
464
host. spec . image = boot_entry. image . as_ref ( ) . map ( |x| x. image . clone ( ) ) ;
446
465
host. status . booted = Some ( boot_entry) ;
@@ -457,11 +476,31 @@ pub(crate) async fn composefs_deployment_status() -> Result<Host> {
457
476
host. status . rollback = Some ( boot_entry) ;
458
477
}
459
478
460
- host. status . rollback_queued = !get_sorted_boot_entries ( false ) ?
461
- . first ( )
462
- . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?
463
- . options
464
- . contains ( booted_image_verity) ;
479
+ // Shouldn't really happen, but for sanity nonetheless
480
+ let Some ( boot_type) = boot_type else {
481
+ anyhow:: bail!( "Could not determine boot type" ) ;
482
+ } ;
483
+
484
+ match boot_type {
485
+ BootType :: Bls => {
486
+ host. status . rollback_queued = !get_sorted_bls_boot_entries ( false ) ?
487
+ . first ( )
488
+ . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?
489
+ . options
490
+ . contains ( booted_image_verity) ;
491
+ }
492
+
493
+ BootType :: Uki => {
494
+ let mut s = String :: new ( ) ;
495
+
496
+ host. status . rollback_queued = !get_sorted_uki_boot_entries ( & mut s) ?
497
+ . first ( )
498
+ . ok_or ( anyhow:: anyhow!( "First boot entry not found" ) ) ?
499
+ . body
500
+ . chainloader
501
+ . contains ( booted_image_verity) ;
502
+ }
503
+ } ;
465
504
466
505
if host. status . rollback_queued {
467
506
host. spec . boot_order = BootOrder :: Rollback
0 commit comments