Skip to content

Commit 5a0b50d

Browse files
committed
install: Change helper to return deployment too
Prep for further changes. Signed-off-by: Colin Walters <[email protected]>
1 parent 53550fc commit 5a0b50d

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

lib/src/install.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ async fn install_container(
609609
state: &State,
610610
root_setup: &RootSetup,
611611
sysroot: &ostree::Sysroot,
612-
) -> Result<InstallAleph> {
612+
) -> Result<(ostree::Deployment, InstallAleph)> {
613613
let sepolicy = state.load_policy()?;
614614
let sepolicy = sepolicy.as_ref();
615615
let stateroot = STATEROOT_DEFAULT;
@@ -766,7 +766,7 @@ async fn install_container(
766766
selinux: state.selinux_state.to_aleph().to_string(),
767767
};
768768

769-
Ok(aleph)
769+
Ok((deployment, aleph))
770770
}
771771

772772
/// Run a command in the host mount namespace
@@ -1235,18 +1235,19 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
12351235
.ok_or_else(|| anyhow!("No uuid for boot/root"))?;
12361236
tracing::debug!("boot uuid={boot_uuid}");
12371237

1238-
// Write the aleph data that captures the system state at the time of provisioning for aid in future debugging.
1238+
// Initialize the ostree sysroot (repo, stateroot, etc.)
12391239
let sysroot = initialize_ostree_root(state, rootfs).await?;
1240-
{
1241-
let aleph = install_container(state, rootfs, &sysroot).await?;
1242-
rootfs
1243-
.rootfs_fd
1244-
.atomic_replace_with(BOOTC_ALEPH_PATH, |f| {
1245-
serde_json::to_writer(f, &aleph)?;
1246-
anyhow::Ok(())
1247-
})
1248-
.context("Writing aleph version")?;
1249-
}
1240+
// And actually set up the container in that root, returning a deployment and
1241+
// the aleph state (see below).
1242+
let (deployment, aleph) = install_container(state, rootfs, &sysroot).await?;
1243+
// Write the aleph data that captures the system state at the time of provisioning for aid in future debugging.
1244+
rootfs
1245+
.rootfs_fd
1246+
.atomic_replace_with(BOOTC_ALEPH_PATH, |f| {
1247+
serde_json::to_writer(f, &aleph)?;
1248+
anyhow::Ok(())
1249+
})
1250+
.context("Writing aleph version")?;
12501251
if cfg!(target_arch = "s390x") {
12511252
// TODO: Integrate s390x support into install_via_bootupd
12521253
crate::bootloader::install_via_zipl(&rootfs.device_info, boot_uuid)?;
@@ -1258,6 +1259,10 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
12581259
)?;
12591260
}
12601261

1262+
// After this point, we need to drop all open references to the filesystem
1263+
drop(deployment);
1264+
drop(sysroot);
1265+
12611266
tracing::debug!("Installed bootloader");
12621267

12631268
// Finalize mounted filesystems

0 commit comments

Comments
 (0)