@@ -16,13 +16,10 @@ use cap_std::fs::Dir;
16
16
use cap_std_ext:: cap_std;
17
17
use chrono:: prelude:: * ;
18
18
use fn_error_context:: context;
19
- use log:: { info, warn} ;
20
19
use openat_ext:: OpenatDirExt ;
21
20
use os_release:: OsRelease ;
22
- use std:: io:: Write ;
23
21
use rustix:: fd:: BorrowedFd ;
24
22
use walkdir:: WalkDir ;
25
- use widestring:: U16CString ;
26
23
27
24
use crate :: bootupd:: RootContext ;
28
25
use crate :: freezethaw:: fsfreeze_thaw_cycle;
@@ -151,35 +148,6 @@ impl Efi {
151
148
clear_efi_target ( & product_name) ?;
152
149
create_efi_boot_entry ( device, espdir, vendordir, & product_name)
153
150
}
154
-
155
- /// Find a kernel and optional initramfs/uki file in the update directory for systemd-boot
156
- fn find_kernel_and_initrd ( dir : & openat:: Dir ) -> Result < ( String , Option < String > ) > {
157
- let mut kernel: Option < String > = None ;
158
- let mut initrd: Option < String > = None ;
159
- log:: warn!( "Searching for kernel and initrd in update dir: {:?}" , dir. recover_path( ) ) ;
160
- for entry in dir. list_dir ( "." ) ? {
161
- log:: warn!( "Found entry: {:?}" , entry) ;
162
- let entry = entry?;
163
- let fname = entry. file_name ( ) . to_string_lossy ( ) ;
164
- if fname. starts_with ( "vmlinuz" ) || fname. ends_with ( ".efi" ) || fname. ends_with ( ".uki" ) {
165
- log:: warn!( "Found kernel/UKI file: {}" , fname) ;
166
- if kernel. is_some ( ) {
167
- log:: warn!( "Multiple kernel/UKI files found in update dir" ) ;
168
- bail ! ( "Multiple kernel/UKI files found in update dir" ) ;
169
- }
170
- kernel = Some ( fname. to_string ( ) ) ;
171
- } else if fname. starts_with ( "initrd" ) || fname. ends_with ( ".img" ) || fname. ends_with ( ".cpio.gz" ) {
172
- log:: warn!( "Found initramfs file: {}" , fname) ;
173
- if initrd. is_some ( ) {
174
- log:: warn!( "Multiple initramfs files found in update dir" ) ;
175
- bail ! ( "Multiple initramfs files found in update dir" ) ;
176
- }
177
- initrd = Some ( fname. to_string ( ) ) ;
178
- }
179
- }
180
- let kernel = kernel. ok_or_else ( || anyhow:: anyhow!( "No kernel or UKI file found in update dir" ) ) ?;
181
- Ok ( ( kernel, initrd) )
182
- }
183
151
}
184
152
185
153
#[ context( "Get product name" ) ]
@@ -207,11 +175,6 @@ impl Component for Efi {
207
175
return Ok ( None ) ;
208
176
} ;
209
177
210
- // // Don't adopt if the system is booted with systemd-boot or
211
- // // systemd-stub since those will be managed with bootctl.
212
- // if skip_systemd_bootloaders() {
213
- // return Ok(None);
214
- // }
215
178
crate :: component:: query_adopt_state ( )
216
179
}
217
180
@@ -306,11 +269,10 @@ impl Component for Efi {
306
269
device : & str ,
307
270
update_firmware : bool ,
308
271
) -> Result < InstalledContent > {
309
- log:: warn!( "Installing component: {}" , self . name( ) ) ;
310
272
let Some ( meta) = get_component_update ( src_root, self ) ? else {
311
273
anyhow:: bail!( "No update metadata for component {} found" , self . name( ) ) ;
312
274
} ;
313
- log:: warn !( "Found metadata {}" , meta. version) ;
275
+ log:: debug !( "Found metadata {}" , meta. version) ;
314
276
let srcdir_name = component_updatedirname ( self ) ;
315
277
let ft = crate :: filetree:: FileTree :: new_from_dir ( & src_root. sub_dir ( & srcdir_name) ?) ?;
316
278
@@ -329,15 +291,10 @@ impl Component for Efi {
329
291
self . mount_esp_device ( Path :: new ( dest_root) , Path :: new ( & esp_device) ) ?
330
292
} ;
331
293
332
- let destpath_clone = destpath. clone ( ) ;
333
-
334
294
let destd = & openat:: Dir :: open ( & destpath)
335
295
. with_context ( || format ! ( "opening dest dir {}" , destpath. display( ) ) ) ?;
336
296
validate_esp_fstype ( destd) ?;
337
297
338
- // let using_systemd_boot = skip_systemd_bootloaders();
339
- let using_systemd_boot = true ;
340
-
341
298
// TODO - add some sort of API that allows directly setting the working
342
299
// directory to a file descriptor.
343
300
std:: process:: Command :: new ( "cp" )
@@ -347,71 +304,7 @@ impl Component for Efi {
347
304
. current_dir ( format ! ( "/proc/self/fd/{}" , src_root. as_raw_fd( ) ) )
348
305
. run ( ) ?;
349
306
350
- // Configure systemd-boot loader config/entry
351
- if using_systemd_boot {
352
- let loader_dir = destpath. join ( "loader" ) ;
353
- if !loader_dir. exists ( ) {
354
- log:: warn!( "Creating systemd-boot loader directory at {}" , loader_dir. display( ) ) ;
355
- std:: fs:: create_dir_all ( & loader_dir)
356
- . with_context ( || format ! ( "creating systemd-boot loader directory {}" , loader_dir. display( ) ) ) ?;
357
- }
358
- let entries_dir = loader_dir. join ( "entries" ) ;
359
- log:: warn!( "Using systemd-boot, creating entries dir at {}" , entries_dir. display( ) ) ;
360
- std:: fs:: create_dir_all ( & entries_dir)
361
- . with_context ( || format ! ( "creating entries dir {}" , entries_dir. display( ) ) ) ?;
362
- log:: warn!( "Installing systemd-boot entry in {}/bootupd.conf" , entries_dir. display( ) ) ;
363
- // Write loader.conf if it doesn't exist
364
- let loader_conf_path = loader_dir. join ( "loader.conf" ) ;
365
- if !loader_conf_path. exists ( ) {
366
- let mut loader_conf = std:: fs:: File :: create ( & loader_conf_path)
367
- . with_context ( || format ! ( "creating loader.conf at {}" , loader_conf_path. display( ) ) ) ?;
368
- writeln ! ( loader_conf, "default auto" ) ?;
369
- writeln ! ( loader_conf, "timeout 20" ) ?;
370
- writeln ! ( loader_conf, "editor no" ) ?;
371
- }
372
- log:: warn!( "Installed: {}/bootupd.conf" , entries_dir. display( ) ) ;
373
-
374
- // let sysroot = Dir::open_ambient_dir("/", cap_std::ambient_authority())?;
375
- // let product_name = get_product_name(&sysroot).unwrap_or("Unknown Product".to_string());
376
- // log::warn!("Get product name: '{product_name}'");
377
-
378
- // Find the kernel/UKI and optional initramfs in the update dir
379
- log:: warn!(
380
- "Searching for kernel and initrd in update dir: {:?}" ,
381
- crate :: model:: BOOTUPD_UPDATES_DIR
382
- ) ;
383
- let update_dir = src_root. sub_dir ( & srcdir_name)
384
- . context ( "opening update dir" ) ?;
385
- log:: debug!( "Searching for kernel and initrd in update dir: {:?}" , update_dir. recover_path( ) ) ;
386
- let ( kernel_file, initrd_file) = Self :: find_kernel_and_initrd ( & update_dir) ?;
387
-
388
- log:: warn!(
389
- "Installing systemd-boot entry for kernel: {}, initrd: {:?}" ,
390
- kernel_file, initrd_file
391
- ) ;
392
- crate :: systemd_boot_configs:: install (
393
- & destd,
394
- true ,
395
- "Unknown Product" ,
396
- & kernel_file,
397
- initrd_file. as_deref ( ) ,
398
- ) . context ( "installing systemd-boot entry" ) ?;
399
- }
400
-
401
- // If using systemd-boot, run `bootctl install` to set up the bootloader.
402
- if using_systemd_boot {
403
- log:: warn!( "Using systemd-boot, running bootctl install" ) ;
404
- let status = std:: process:: Command :: new ( "bootctl" )
405
- . args ( [ "install" , "--esp-path" , destpath_clone. to_str ( ) . unwrap ( ) ] )
406
- . status ( )
407
- . context ( "running bootctl install" ) ?;
408
- log:: warn!( "bootctl install status: {}" , status) ;
409
- if !status. success ( ) {
410
- bail ! ( "bootctl install failed with status: {}" , status) ;
411
- }
412
- }
413
-
414
- if update_firmware && !using_systemd_boot {
307
+ if update_firmware {
415
308
if let Some ( vendordir) = self . get_efi_vendor ( & src_root) ? {
416
309
self . update_firmware ( device, destd, & vendordir) ?
417
310
}
@@ -750,12 +643,9 @@ fn get_efi_component_from_usr<'a>(
750
643
. filter_map ( |entry| {
751
644
let entry = entry. ok ( ) ?;
752
645
if !entry. file_type ( ) . is_dir ( ) || entry. file_name ( ) != "EFI" {
753
- info ! ( "Skipping non-directory or non-EFI entry: {}" , entry. path( ) . display( ) ) ;
754
646
return None ;
755
647
}
756
648
757
- info ! ( "Found EFI component at {}" , entry. path( ) . display( ) ) ;
758
-
759
649
let abs_path = entry. path ( ) ;
760
650
let rel_path = abs_path. strip_prefix ( sysroot) . ok ( ) ?;
761
651
let utf8_rel_path = Utf8PathBuf :: from_path_buf ( rel_path. to_path_buf ( ) ) . ok ( ) ?;
0 commit comments