Skip to content

Commit 3d9404e

Browse files
committed
bootloader: Switch to using bootupd to do BIOS
This means we now get unified management. Signed-off-by: Colin Walters <[email protected]>
1 parent 21c87b4 commit 3d9404e

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

lib/src/bootloader.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use camino::Utf8Path;
55
use cap_std::fs::Dir;
66
use cap_std::fs::Permissions;
77
use cap_std_ext::cap_std;
8+
use cap_std_ext::cap_std::fs::DirBuilder;
89
use cap_std_ext::prelude::*;
910
use fn_error_context::context;
1011

@@ -58,21 +59,30 @@ pub(crate) fn install_via_bootupd(
5859
Task::new_and_run(
5960
"Running bootupctl to install bootloader",
6061
"bootupctl",
61-
["backend", "install", "--src-root", "/", rootfs.as_str()],
62+
[
63+
"backend",
64+
"install",
65+
"--src-root",
66+
"/",
67+
"--device",
68+
device.as_str(),
69+
rootfs.as_str(),
70+
],
6271
)?;
6372

6473
let grub2_uuid_contents = format!("set BOOT_UUID=\"{boot_uuid}\"\n");
6574

6675
let bootfs = &rootfs.join("boot");
76+
let bootfs = Dir::open_ambient_dir(bootfs, cap_std::ambient_authority())?;
6777

6878
{
69-
let efidir = Dir::open_ambient_dir(bootfs.join("efi"), cap_std::ambient_authority())?;
79+
let efidir = bootfs.open_dir("efi")?;
7080
install_grub2_efi(&efidir, &grub2_uuid_contents)?;
7181
}
7282

73-
let grub2 = &bootfs.join("grub2");
74-
std::fs::create_dir(grub2).context("creating boot/grub2")?;
75-
let grub2 = Dir::open_ambient_dir(grub2, cap_std::ambient_authority())?;
83+
bootfs.ensure_dir_with("grub2", &DirBuilder::new())?;
84+
let grub2 = bootfs.open_dir("grub2")?;
85+
7686
// Mode 0700 to support passwords etc.
7787
grub2.set_permissions(".", Permissions::from_mode(0o700))?;
7888
grub2
@@ -91,17 +101,5 @@ pub(crate) fn install_via_bootupd(
91101
)
92102
.with_context(|| format!("Writing {GRUB_BOOT_UUID_FILE}"))?;
93103

94-
Task::new("Installing BIOS grub2", "grub2-install")
95-
.args([
96-
"--target",
97-
"i386-pc",
98-
"--boot-directory",
99-
bootfs.as_str(),
100-
"--modules",
101-
"mdraid1x",
102-
device.as_str(),
103-
])
104-
.run()?;
105-
106104
Ok(())
107105
}

0 commit comments

Comments
 (0)