Skip to content

Commit dbae495

Browse files
committed
install: Allow install with existing non-booted stateroot dirs
This modifies the existing check for an extant stateroot dir to check if the pending stateroot is the same as the booted deployment. Also only run init_osname if there is not an existing stateroot dir. fixes #1246 Signed-off-by: ckyrouac <[email protected]>
1 parent 6648d6c commit dbae495

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/src/install.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -678,17 +678,25 @@ async fn initialize_ostree_root(
678678
ostree_ext::fsverity::ensure_verity(repo).await?;
679679
}
680680

681-
let stateroot_exists = rootfs_dir.try_exists(format!("ostree/deploy/{stateroot}"))?;
682-
ensure!(
683-
!stateroot_exists,
684-
"Cannot redeploy over extant stateroot {stateroot}"
685-
);
686-
sysroot
687-
.init_osname(stateroot, cancellable)
688-
.context("initializing stateroot")?;
681+
if let Some(booted) = sysroot.booted_deployment() {
682+
if stateroot == booted.stateroot() {
683+
anyhow::bail!("Cannot redeploy over booted stateroot {stateroot}");
684+
}
685+
}
689686

690687
let sysroot_dir = crate::utils::sysroot_dir(&sysroot)?;
691688

689+
// init_osname fails when ostree/deploy/{stateroot} already exists
690+
// the stateroot directory can be left over after a failed install attempt,
691+
// so only create it via init_osname if it doesn't exist
692+
// (ideally this would be handled by init_osname)
693+
let stateroot_path = format!("ostree/deploy/{stateroot}");
694+
if !sysroot_dir.try_exists(stateroot_path)? {
695+
sysroot
696+
.init_osname(stateroot, cancellable)
697+
.context("initializing stateroot")?;
698+
}
699+
692700
state.tempdir.create_dir("temp-run")?;
693701
let temp_run = state.tempdir.open_dir("temp-run")?;
694702

0 commit comments

Comments
 (0)