Skip to content

Commit 387f495

Browse files
committed
reset: Mark reset deployment dir with .bootc-factory-reset
This is currently used to signal to `bootc status` that the deployment is a factory reset and doesn't support soft reboot. Otherwise, the soft reboot code will throw an exception due to mismatched kargs. Signed-off-by: ckyrouac <[email protected]>
1 parent 553c5b8 commit 387f495

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

crates/lib/src/deploy.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,16 @@ async fn deploy(
634634
let ostree = sysroot.get_ostree()?;
635635
let staged = ostree.staged_deployment().unwrap();
636636
assert_eq!(staged.index(), r);
637+
638+
// This file is used to signal to other CLI commands that this deployment is a factory reset
639+
// (e.g. bootc status)
640+
if matches!(from, MergeState::Reset { .. }) {
641+
let deployment_dir = ostree.deployment_dirpath(&staged);
642+
let deployment_dir = std::path::Path::new(deployment_dir.as_str());
643+
let marker_path = deployment_dir.join(".bootc-factory-reset");
644+
std::fs::write(&marker_path, b"")?;
645+
}
646+
637647
Ok(staged)
638648
}
639649

crates/lib/src/status.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,19 @@ impl From<ImageReference> for OstreeImageReference {
9292

9393
/// Check if a deployment has soft reboot capability
9494
fn has_soft_reboot_capability(sysroot: &SysrootLock, deployment: &ostree::Deployment) -> bool {
95-
ostree_ext::systemd_has_soft_reboot() && sysroot.deployment_can_soft_reboot(deployment)
95+
let deployment_dir = sysroot.deployment_dirpath(deployment);
96+
let deployment_dir = std::path::Path::new(deployment_dir.as_str());
97+
let is_factory_reset = deployment_dir.join(".bootc-factory-reset").exists();
98+
99+
if is_factory_reset {
100+
// Factory reset deployments don't support soft reboots
101+
// this is primarily because the kargs validation will fail when checking for soft reboot
102+
// compatibility in the ostree code, which will cause bootc status and upgrade to fail.
103+
// (see ostree_sysroot_deployment_can_soft_reboot in ostree)
104+
false
105+
} else {
106+
ostree_ext::systemd_has_soft_reboot() && sysroot.deployment_can_soft_reboot(deployment)
107+
}
96108
}
97109

98110
/// Parse an ostree origin file (a keyfile) and extract the targeted

0 commit comments

Comments
 (0)