deb: wipe the staged tree when overlay staging falls back to a copy

On a resumed session whose overlay mount fails (no overlayfs, mount
error, non-overlay driver), the fallback used to copy the host tree
into the staged tree of the previous attempt: a merge that keeps the
old build stamps and resurrects files deleted on the host — a
silently half-stale build, exactly what resume must never produce.
The driver now reports the failure instead of copying, and the
caller wipes the staged build root and re-stages a fresh copy
(environment resumable, build artifacts discarded).
This commit is contained in:
2026-09-27 23:32:16 +02:00
parent 318bcea341
commit 961f6bc234
3 changed files with 89 additions and 37 deletions
+14 -5
View File
@@ -361,9 +361,12 @@ async fn build_binary_package_impl(
}
let staged_path = if let Some(s) = &session {
// Re-mount the session's persistent upperdir over the host
// tree; a driver without overlay support (or a failed mount)
// falls back to a fresh copy — still environment-resumable,
// just not artifact-resumable.
// tree. If overlay staging is unavailable (no overlayfs, mount
// failure, non-overlay driver), wipe the staged tree and
// re-stage a fresh copy: copying over the previous attempt's
// tree would merge stale build artifacts and resurrect
// host-deleted files into the build. Still environment-
// resumable, just not artifact-resumable.
let staging = match build_ctx.ensure_available_with_overlay(
&parent_dir,
&build_root,
@@ -371,14 +374,20 @@ async fn build_binary_package_impl(
&s.work_dir(),
) {
Ok(staging) => staging,
Err(e) if e.kind() == std::io::ErrorKind::Unsupported => {
Err(e) => {
log::info!(
"Overlay staging unavailable ({}): the staged tree is \
re-staged from scratch, build artifacts are discarded",
e
);
s.wipe_staged_tree()?;
let path = build_ctx.ensure_available(&parent_dir, &build_root)?;
build_resume = false;
crate::context::OverlayStaging {
path,
overlay: false,
}
}
Err(e) => return Err(e.into()),
};
if !staging.overlay {
// Copy fallback: the staged tree is fresh, there is nothing