1
+ use std:: path:: Path ;
2
+
1
3
use anyhow:: { bail, Context , Result } ;
2
4
use fn_error_context:: context;
3
5
use log:: warn;
4
6
5
7
/// Install the systemd-boot entry files
6
8
#[ 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" ) ?;
11
11
let status = std:: process:: Command :: new ( "bootctl" )
12
12
. args ( [
13
13
"install" ,
14
14
"--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" ) ?,
16
16
] )
17
17
. status ( )
18
18
. context ( "running install" ) ?;
@@ -21,50 +21,21 @@ pub(crate) fn install(
21
21
bail ! ( "bootctl install failed with status: {}" , status) ;
22
22
}
23
23
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
+
24
40
Ok ( ( ) )
25
41
}
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