@@ -453,16 +453,18 @@ impl Component for Efi {
453
453
fn generate_update_metadata ( & self , sysroot : & str ) -> Result < ContentMetadata > {
454
454
let sysroot_path = Utf8Path :: new ( sysroot) ;
455
455
456
- // copy EFI files to updates dir from usr/lib/efi
457
456
let efilib_path = sysroot_path. join ( EFILIB ) ;
458
- let meta = if efilib_path. exists ( ) {
457
+ let efi_comps = if efilib_path. exists ( ) {
458
+ get_efi_component_from_usr ( & sysroot_path, EFILIB ) ?
459
+ } else {
460
+ None
461
+ } ;
462
+
463
+ // copy EFI files to updates dir from usr/lib/efi
464
+ let meta = if let Some ( efi_components) = efi_comps {
459
465
let mut packages = Vec :: new ( ) ;
460
466
let mut modules_vec: Vec < Module > = vec ! [ ] ;
461
467
let sysroot_dir = Dir :: open_ambient_dir ( sysroot_path, cap_std:: ambient_authority ( ) ) ?;
462
- let efi_components = get_efi_component_from_usr ( & sysroot_path, EFILIB ) ?;
463
- if efi_components. len ( ) == 0 {
464
- bail ! ( "Failed to find EFI components from {efilib_path}" ) ;
465
- }
466
468
for efi in efi_components {
467
469
Command :: new ( "cp" )
468
470
. args ( [ "-rp" , "--reflink=auto" ] )
@@ -734,7 +736,7 @@ pub struct EFIComponent {
734
736
fn get_efi_component_from_usr < ' a > (
735
737
sysroot : & ' a Utf8Path ,
736
738
usr_path : & ' a str ,
737
- ) -> Result < Vec < EFIComponent > > {
739
+ ) -> Result < Option < Vec < EFIComponent > > > {
738
740
let efilib_path = sysroot. join ( usr_path) ;
739
741
let skip_count = Utf8Path :: new ( usr_path) . components ( ) . count ( ) ;
740
742
@@ -765,9 +767,12 @@ fn get_efi_component_from_usr<'a>(
765
767
} )
766
768
. collect ( ) ;
767
769
770
+ if components. len ( ) == 0 {
771
+ return Ok ( None ) ;
772
+ }
768
773
components. sort_by ( |a, b| a. name . cmp ( & b. name ) ) ;
769
774
770
- Ok ( components)
775
+ Ok ( Some ( components) )
771
776
}
772
777
773
778
#[ cfg( test) ]
@@ -904,7 +909,7 @@ Boot0003* test";
904
909
let efi_comps = get_efi_component_from_usr ( utf8_tpath, EFILIB ) ?;
905
910
assert_eq ! (
906
911
efi_comps,
907
- vec![
912
+ Some ( vec![
908
913
EFIComponent {
909
914
name: "BAR" . to_string( ) ,
910
915
version: "1.1" . to_string( ) ,
@@ -915,12 +920,12 @@ Boot0003* test";
915
920
version: "1.1" . to_string( ) ,
916
921
path: Utf8PathBuf :: from( "usr/lib/efi/FOO/1.1/EFI" ) ,
917
922
} ,
918
- ]
923
+ ] )
919
924
) ;
920
925
std:: fs:: remove_dir_all ( efi_path. join ( "BAR/1.1/EFI" ) ) ?;
921
926
std:: fs:: remove_dir_all ( efi_path. join ( "FOO/1.1/EFI" ) ) ?;
922
927
let efi_comps = get_efi_component_from_usr ( utf8_tpath, EFILIB ) ?;
923
- assert_eq ! ( efi_comps, [ ] ) ;
928
+ assert_eq ! ( efi_comps, None ) ;
924
929
Ok ( ( ) )
925
930
}
926
931
}
0 commit comments