Skip to content

Commit 3af4186

Browse files
committed
chore: copy loader.conf to /boot/loader/ if present in bootupd config dir
1 parent bfd1cd4 commit 3af4186

File tree

3 files changed

+23
-51
lines changed

3 files changed

+23
-51
lines changed

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ mod model_legacy;
4646
mod ostreeutil;
4747
mod packagesystem;
4848
mod sha512string;
49-
mod util;
5049
mod systemd_boot_configs;
50+
mod util;
5151

5252
use clap::crate_name;
5353

src/systemd_boot_configs.rs

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1+
use std::path::Path;
2+
13
use anyhow::{bail, Context, Result};
24
use fn_error_context::context;
35
use 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-
// }

tmp/Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RUN dnf install -y \
77
tree
88

99
COPY bootupctl /usr/bin/bootupctl
10+
# COPY loader.conf /usr/lib/bootupd/systemd-boot/loader.conf
1011

1112
RUN set -x && \
1213
KVER=$(rpm -q --qf '%{version}-%{release}.%{arch}\n' kernel | head -n 1) && \

0 commit comments

Comments
 (0)