Skip to content

Commit

Permalink
Merge pull request #143 from cgwalters/more-errcontext
Browse files Browse the repository at this point in the history
More errcontext
  • Loading branch information
cgwalters authored Oct 13, 2023
2 parents ea68e1b + fc2de6b commit 6e0b3b9
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/src/bootloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const STATIC_GRUB_CFG_EFI: &str = include_str!("grub-efi.cfg");
/// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel)
pub(crate) const EFI_DIR: &str = "efi";

#[context("Installing grub2 EFI")]
fn install_grub2_efi(efidir: &Dir, uuid: &str) -> Result<()> {
let mut vendordir = None;
let efidir = efidir.open_dir("EFI").context("Opening EFI/")?;
Expand Down Expand Up @@ -56,31 +57,30 @@ pub(crate) fn install_via_bootupd(
rootfs: &Utf8Path,
boot_uuid: &str,
) -> Result<()> {
Task::new_and_run(
"Running bootupctl to install bootloader",
"bootupctl",
[
"backend",
"install",
"--src-root",
"/",
"--device",
device.as_str(),
rootfs.as_str(),
],
)?;
let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv");
let args = ["backend", "install"].into_iter().chain(verbose).chain([
"--src-root",
"/",
"--device",
device.as_str(),
rootfs.as_str(),
]);
Task::new_and_run("Running bootupctl to install bootloader", "bootupctl", args)?;

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

let bootfs = &rootfs.join("boot");
let bootfs = Dir::open_ambient_dir(bootfs, cap_std::ambient_authority())?;
let bootfs =
Dir::open_ambient_dir(bootfs, cap_std::ambient_authority()).context("Opening boot")?;

if super::install::ARCH_USES_EFI {
let efidir = bootfs.open_dir("efi")?;
let efidir = bootfs.open_dir("efi").context("Opening efi")?;
install_grub2_efi(&efidir, &grub2_uuid_contents)?;
}

bootfs.ensure_dir_with("grub2", &DirBuilder::new())?;
bootfs
.ensure_dir_with("grub2", &DirBuilder::new())
.context("Creating boot/grub2")?;
let grub2 = bootfs.open_dir("grub2")?;

// Mode 0700 to support passwords etc.
Expand Down

0 comments on commit 6e0b3b9

Please sign in to comment.