1+ use std:: path:: Path ;
2+
13use anyhow:: { bail, Context , Result } ;
24use fn_error_context:: context;
35use log:: warn;
46
57/// Install the systemd-boot entry files
68#[ context( "Installing systemd-boot entries" ) ]
7- pub ( crate ) fn install (
8- target_root : & openat:: Dir , // This should be mounted ESP root dir (not /boot inside ESP)
9- _write_uuid : bool ,
10- ) -> Result < ( ) > {
9+ pub ( crate ) fn install ( esp_path : & openat:: Dir , _write_uuid : bool ) -> Result < ( ) > {
10+ let esp_path = esp_path. recover_path ( ) . context ( "ESP path is not valid" ) ?;
1111 let status = std:: process:: Command :: new ( "bootctl" )
1212 . args ( [
1313 "install" ,
1414 "--esp-path" ,
15- target_root . recover_path ( ) ? . to_str ( ) . context ( "ESP path is not valid UTF-8" ) ?,
15+ esp_path . to_str ( ) . context ( "ESP path is not valid UTF-8" ) ?,
1616 ] )
1717 . status ( )
1818 . context ( "running install" ) ?;
@@ -21,50 +21,21 @@ pub(crate) fn install(
2121 bail ! ( "bootctl install failed with status: {}" , status) ;
2222 }
2323
24+ // If loader.conf is present in /usr/lib/bootupd/systemd-boot/loader.conf, copy it over
25+ let src_loader_conf = "/usr/lib/bootupd/systemd-boot/loader.conf" ;
26+ let dst_loader_conf = Path :: new ( & esp_path) . join ( "loader/loader.conf" ) ;
27+ if Path :: new ( src_loader_conf) . exists ( ) {
28+ std:: fs:: copy ( src_loader_conf, & dst_loader_conf) . context ( format ! (
29+ "Copying {} to {}" ,
30+ src_loader_conf,
31+ dst_loader_conf. display( )
32+ ) ) ?;
33+ warn ! (
34+ "Copied \" {}\" to \" {}\" ." ,
35+ src_loader_conf,
36+ dst_loader_conf. display( )
37+ ) ;
38+ }
39+
2440 Ok ( ( ) )
2541}
26-
27- // use anyhow::{Context, Result};
28- // use fn_error_context::context;
29- // use log::warn;
30- // use std::fs;
31- // use std::path::Path;
32-
33- // /// Install the systemd-boot entry files
34- // #[context("Installing systemd-boot entries")]
35- // pub(crate) fn install(
36- // target_root: &openat::Dir, // This should be mounted ESP root dir (not /boot inside ESP)
37- // _write_uuid: bool,
38- // ) -> Result<()> {
39- // let esp_path = target_root.recover_path()?.to_str().context("ESP path is not valid UTF-8")?.to_string();
40-
41- // let dirs = [
42- // "EFI/systemd",
43- // "EFI/BOOT",
44- // "loader",
45- // "loader/keys",
46- // "loader/entries",
47- // "EFI/Linux",
48- // ];
49- // for dir in dirs.iter() {
50- // let full_path = Path::new(&esp_path).join(dir);
51- // if !full_path.exists() {
52- // fs::create_dir_all(&full_path).context(format!("Creating {}", full_path.display()))?;
53- // warn!("Created \"{}\".", full_path.display());
54- // }
55- // }
56-
57- // let src_efi = "/usr/lib/systemd/boot/efi/systemd-bootx64.efi";
58- // let dst_systemd = Path::new(&esp_path).join("EFI/systemd/systemd-bootx64.efi");
59- // let dst_boot = Path::new(&esp_path).join("EFI/BOOT/BOOTX64.EFI");
60-
61- // fs::copy(src_efi, &dst_systemd)
62- // .context(format!("Copying {} to {}", src_efi, dst_systemd.display()))?;
63- // warn!("Copied \"{}\" to \"{}\".", src_efi, dst_systemd.display());
64-
65- // fs::copy(src_efi, &dst_boot)
66- // .context(format!("Copying {} to {}", src_efi, dst_boot.display()))?;
67- // warn!("Copied \"{}\" to \"{}\".", src_efi, dst_boot.display());
68-
69- // Ok(())
70- // }
0 commit comments