Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cgwalters committed Oct 22, 2023
1 parent 00bd61b commit 50a496e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/src/bootloader.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::os::unix::prelude::PermissionsExt;
use std::path::Path;

use anyhow::{Context, Result};
use camino::Utf8Path;
Expand Down Expand Up @@ -51,11 +52,16 @@ fn install_grub2_efi(efidir: &Dir, uuid: &str) -> Result<()> {
Ok(())
}

pub(crate) fn is_efi_booted() -> Result<bool> {
Path::new("/sys/firmware/efi").try_exists().map_err(Into::into)
}

#[context("Installing bootloader")]
pub(crate) fn install_via_bootupd(
device: &Utf8Path,
rootfs: &Utf8Path,
boot_uuid: &str,
is_alongside: bool
) -> Result<()> {
let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv");
let args = ["backend", "install"].into_iter().chain(verbose).chain([
Expand All @@ -73,7 +79,8 @@ pub(crate) fn install_via_bootupd(
let bootfs =
Dir::open_ambient_dir(bootfs, cap_std::ambient_authority()).context("Opening boot")?;

if super::install::ARCH_USES_EFI {
let use_efi = super::install::ARCH_USES_EFI && (is_efi_booted() || !is_alongside)
if use_efi {
let efidir = bootfs.open_dir("efi").context("Opening efi")?;
install_grub2_efi(&efidir, &grub2_uuid_contents)?;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
.get_boot_uuid()?
.or(rootfs.rootfs_uuid.as_deref())
.ok_or_else(|| anyhow!("No uuid for boot/root"))?;
crate::bootloader::install_via_bootupd(&rootfs.device, &rootfs.rootfs, boot_uuid)?;
crate::bootloader::install_via_bootupd(&rootfs.device, &rootfs.rootfs, boot_uuid, rootfs.is_alongside)?;
tracing::debug!("Installed bootloader");

// If Ignition is specified, enable it
Expand Down

0 comments on commit 50a496e

Please sign in to comment.