@@ -365,8 +365,6 @@ impl Component for Efi {
365
365
anyhow:: bail!( "No update metadata for component {} found" , self . name( ) ) ;
366
366
} ;
367
367
log:: debug!( "Found metadata {}" , meta. version) ;
368
- let srcdir_name = component_updatedirname ( self ) ;
369
- let ft = crate :: filetree:: FileTree :: new_from_dir ( & src_dir. sub_dir ( & srcdir_name) ?) ?;
370
368
371
369
// Let's attempt to use an already mounted ESP at the target
372
370
// dest_root if one is already mounted there in a known ESP location.
@@ -387,16 +385,30 @@ impl Component for Efi {
387
385
. with_context ( || format ! ( "opening dest dir {}" , destpath. display( ) ) ) ?;
388
386
validate_esp_fstype ( destd) ?;
389
387
390
- // TODO - add some sort of API that allows directly setting the working
391
- // directory to a file descriptor.
392
- std:: process:: Command :: new ( "cp" )
393
- . args ( [ "-rp" , "--reflink=auto" ] )
394
- . arg ( & srcdir_name)
395
- . arg ( destpath)
396
- . current_dir ( format ! ( "/proc/self/fd/{}" , src_dir. as_raw_fd( ) ) )
397
- . run ( ) ?;
388
+ let src_path = Path :: new ( src_root) ;
389
+ let efilib_path = src_path. join ( EFILIB ) ;
390
+ let efi_comps = if efilib_path. exists ( ) {
391
+ get_efi_component_from_usr ( & Utf8Path :: new ( src_root) , EFILIB ) ?
392
+ } else {
393
+ None
394
+ } ;
395
+
396
+ let efi_path = if let Some ( efi_components) = efi_comps {
397
+ for efi in efi_components {
398
+ log:: trace!( "Copy {} to {}" , efi. path, destpath. display( ) ) ;
399
+ util:: copy_in_fd ( & src_dir, & efi. path , & destpath) ?;
400
+ }
401
+ PathBuf :: from ( EFILIB )
402
+ } else {
403
+ let updates = component_updatedirname ( self ) ;
404
+ util:: copy_in_fd ( & src_dir, & updates, & destpath) ?;
405
+ updates
406
+ } ;
407
+
408
+ let ft = crate :: filetree:: FileTree :: new_from_dir ( & src_dir. sub_dir ( & efi_path) ?) ?;
409
+
398
410
if update_firmware {
399
- if let Some ( vendordir) = self . get_efi_vendor ( & Path :: new ( src_root ) ) ? {
411
+ if let Some ( vendordir) = self . get_efi_vendor ( & src_path . join ( efi_path ) ) ? {
400
412
self . update_firmware ( device, destd, & vendordir) ?
401
413
}
402
414
}
@@ -466,12 +478,7 @@ impl Component for Efi {
466
478
let mut modules_vec: Vec < Module > = vec ! [ ] ;
467
479
let sysroot_dir = Dir :: open_ambient_dir ( sysroot_path, cap_std:: ambient_authority ( ) ) ?;
468
480
for efi in efi_components {
469
- Command :: new ( "cp" )
470
- . args ( [ "-rp" , "--reflink=auto" ] )
471
- . arg ( & efi. path )
472
- . arg ( crate :: model:: BOOTUPD_UPDATES_DIR )
473
- . current_dir ( format ! ( "/proc/self/fd/{}" , sysroot_dir. as_raw_fd( ) ) )
474
- . run ( ) ?;
481
+ util:: copy_in_fd ( & sysroot_dir, & efi. path , crate :: model:: BOOTUPD_UPDATES_DIR ) ?;
475
482
packages. push ( format ! ( "{}-{}" , efi. name, efi. version) ) ;
476
483
modules_vec. push ( Module {
477
484
name : efi. name ,
0 commit comments