From aab2c4ada483ec940b731b6117cf045f686e451e Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 13 Nov 2024 14:58:57 +0000 Subject: [PATCH] bootloader: Pass source root --- lib/src/bootloader.rs | 10 +++++++++- lib/src/install.rs | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/src/bootloader.rs b/lib/src/bootloader.rs index 2a696f1fd..d185485ec 100644 --- a/lib/src/bootloader.rs +++ b/lib/src/bootloader.rs @@ -1,5 +1,6 @@ use anyhow::{anyhow, bail, Context, Result}; use camino::{Utf8Path, Utf8PathBuf}; +use cap_std_ext::cap_std::fs::Dir; use fn_error_context::context; use crate::blockdev::PartitionTable; @@ -37,6 +38,7 @@ fn get_bootupd_device(device: &PartitionTable) -> Result { #[context("Installing bootloader")] pub(crate) fn install_via_bootupd( device: &PartitionTable, + src_root: &Dir, rootfs: &Utf8Path, configopts: &crate::install::InstallConfigOpts, ) -> Result<()> { @@ -49,9 +51,15 @@ pub(crate) fn install_via_bootupd( .into_iter() .chain(verbose) .chain(bootupd_opts.iter().copied().flatten()) - .chain(["--device", devpath.as_str(), rootfs.as_str()]); + .chain([ + "--src-root=.", + "--device", + devpath.as_str(), + rootfs.as_str(), + ]); Task::new("Running bootupctl to install bootloader", "bootupctl") .args(args) + .cwd(src_root)? .verbose() .run() } diff --git a/lib/src/install.rs b/lib/src/install.rs index 55f04f7c8..abd5a92ac 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -673,7 +673,7 @@ async fn install_container( state: &State, root_setup: &RootSetup, sysroot: &ostree::Sysroot, -) -> Result<(ostree::Deployment, InstallAleph)> { +) -> Result<(ostree::Deployment, Dir, InstallAleph)> { let sepolicy = state.load_policy()?; let sepolicy = sepolicy.as_ref(); let stateroot = state.stateroot(); @@ -837,7 +837,7 @@ async fn install_container( selinux: state.selinux_state.to_aleph().to_string(), }; - Ok((deployment, aleph)) + Ok((deployment, root, aleph)) } /// Run a command in the host mount namespace @@ -1314,7 +1314,7 @@ async fn install_with_sysroot( ) -> Result<()> { // And actually set up the container in that root, returning a deployment and // the aleph state (see below). - let (_deployment, aleph) = install_container(state, rootfs, &sysroot).await?; + let (deployment, deployment_root, aleph) = install_container(state, rootfs, &sysroot).await?; // Write the aleph data that captures the system state at the time of provisioning for aid in future debugging. rootfs .rootfs_fd @@ -1330,6 +1330,7 @@ async fn install_with_sysroot( } else { crate::bootloader::install_via_bootupd( &rootfs.device_info, + &deployment_root, &rootfs.rootfs, &state.config_opts, )?;