@@ -349,8 +349,6 @@ impl Component for Efi {
349
349
anyhow:: bail!( "No update metadata for component {} found" , self . name( ) ) ;
350
350
} ;
351
351
log:: debug!( "Found metadata {}" , meta. version) ;
352
- let srcdir_name = component_updatedirname ( self ) ;
353
- let ft = crate :: filetree:: FileTree :: new_from_dir ( & src_dir. sub_dir ( & srcdir_name) ?) ?;
354
352
355
353
// Let's attempt to use an already mounted ESP at the target
356
354
// dest_root if one is already mounted there in a known ESP location.
@@ -371,16 +369,35 @@ impl Component for Efi {
371
369
. with_context ( || format ! ( "opening dest dir {}" , destpath. display( ) ) ) ?;
372
370
validate_esp_fstype ( destd) ?;
373
371
374
- // TODO - add some sort of API that allows directly setting the working
375
- // directory to a file descriptor.
376
- std:: process:: Command :: new ( "cp" )
377
- . args ( [ "-rp" , "--reflink=auto" ] )
378
- . arg ( & srcdir_name)
379
- . arg ( destpath)
380
- . current_dir ( format ! ( "/proc/self/fd/{}" , src_dir. as_raw_fd( ) ) )
381
- . run ( ) ?;
372
+ let src_path = Utf8Path :: new ( src_root) ;
373
+ let efilib_path = src_path. join ( EFILIB ) ;
374
+ let efi_comps = if efilib_path. exists ( ) {
375
+ get_efi_component_from_usr ( & src_path, EFILIB ) ?
376
+ } else {
377
+ None
378
+ } ;
379
+
380
+ let vendor_path = if let Some ( efi_components) = efi_comps {
381
+ for efi in efi_components {
382
+ log:: trace!( "Copy {} to {}" , efi. path, destpath. display( ) ) ;
383
+ util:: copy_in_fd ( & src_dir, & efi. path , & destpath) ?;
384
+ }
385
+ efilib_path
386
+ } else {
387
+ let updates = Utf8PathBuf :: from_path_buf ( component_updatedirname ( self ) )
388
+ . expect ( "Invalide UTF-8 path" ) ;
389
+
390
+ util:: copy_in_fd ( & src_dir, & updates, & destpath) ?;
391
+ updates
392
+ } ;
393
+
394
+ let ft =
395
+ crate :: filetree:: FileTree :: new_from_dir ( & src_dir. sub_dir ( vendor_path. as_std_path ( ) ) ?) ?;
396
+
382
397
if update_firmware {
383
- if let Some ( vendordir) = self . get_efi_vendor ( & Path :: new ( src_root) ) ? {
398
+ if let Some ( vendordir) =
399
+ self . get_efi_vendor ( src_path. join ( vendor_path) . as_std_path ( ) ) ?
400
+ {
384
401
self . update_firmware ( device, destd, & vendordir) ?
385
402
}
386
403
}
@@ -449,12 +466,7 @@ impl Component for Efi {
449
466
let mut packages = Vec :: new ( ) ;
450
467
let sysroot_dir = Dir :: open_ambient_dir ( sysroot_path, cap_std:: ambient_authority ( ) ) ?;
451
468
for efi in efi_components {
452
- Command :: new ( "cp" )
453
- . args ( [ "-rp" , "--reflink=auto" ] )
454
- . arg ( & efi. path )
455
- . arg ( crate :: model:: BOOTUPD_UPDATES_DIR )
456
- . current_dir ( format ! ( "/proc/self/fd/{}" , sysroot_dir. as_raw_fd( ) ) )
457
- . run ( ) ?;
469
+ util:: copy_in_fd ( & sysroot_dir, & efi. path , crate :: model:: BOOTUPD_UPDATES_DIR ) ?;
458
470
packages. push ( format ! ( "{}-{}" , efi. name, efi. version) ) ;
459
471
}
460
472
0 commit comments