sandbox,deb,test: run builds through the Sandbox trait

Build and test code now takes Arc<dyn Sandbox>. Context implements the
trait as a bridge for the unshare driver, so the callers move in one
commit without rewriting the driver first.

Staging goes through stage_tree with explicit ReuseState upper and work
paths. The sources backup writes its copy explicitly, and is_host keeps
the keyring cache ownership check on the host only.
This commit is contained in:
vhaudiquet committed 2026-11-24 18:35:17 +01:00
1 parent f1a21e0923
commit 483e532baf
16 files changed
+362 -109

No files matched your search

+7 -7
View File
@@ -2,7 +2,7 @@
//! production for binary-only builds (`pkh deb`), the equivalent of
//! `dpkg-genbuildinfo -b` + `dpkg-genchanges -b`.
//!
//! All tree/database access goes through a [`Context`] so the generation can
//! All tree/database access goes through a [`Sandbox`] so the generation can
//! run against a build tree living in a local directory, an ephemeral
//! chroot or a remote host. Artifact digests are computed inside the context
//! with coreutils (`md5sum`, `sha1sum`, `sha256sum`, `stat`), keeping the
@@ -13,8 +13,8 @@ use std::error::Error;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use crate::context::Context;
use crate::debian::{ChecksumEntry, ControlInfo, FileChecksums, FilesList};
use crate::sandbox::{Sandbox, SandboxExt};
/// Digests of one artifact.
#[derive(Debug, Clone, Default)]
@@ -57,7 +57,7 @@ pub struct BinaryMetadataOptions {
/// registration in `debian/files`, and binary-NMU handling (`Source:
/// pkg (prev)` + `Binary-Only-Changes`, with no source files distributed).
pub fn generate_binary_metadata(
ctx: &Arc<Context>,
ctx: &Arc<dyn Sandbox>,
package_dir: &Path,
upload_dir: &Path,
opts: &BinaryMetadataOptions,
@@ -330,7 +330,7 @@ pub fn generate_binary_metadata(
/// Compute md5/sha1/sha256 digests and sizes for the named files inside the
/// context directory `dir`, using coreutils.
fn hashes_in_context(
ctx: &Arc<Context>,
ctx: &Arc<dyn Sandbox>,
dir: &Path,
names: &[String],
) -> Result<BTreeMap<String, ArtifactHashes>, Box<dyn Error>> {
@@ -488,7 +488,7 @@ Description: test package
std::fs::write(base.path().join("hello_1.0-1+b1_all.deb"), "deb payload")
.expect("write deb");
let ctx = Arc::new(
let ctx: Arc<dyn Sandbox> = Arc::new(
crate::context::Context::new(crate::context::ContextConfig::Local).expect("context"),
);
let opts = BinaryMetadataOptions {
@@ -547,7 +547,7 @@ Description: test package
.expect("chmod files");
}
let ctx = Arc::new(
let ctx: Arc<dyn Sandbox> = Arc::new(
crate::context::Context::new(crate::context::ContextConfig::Local).expect("context"),
);
let opts = BinaryMetadataOptions {
@@ -622,7 +622,7 @@ Description: test package
std::fs::write(base.path().join("hello_1.0.orig.tar.xz"), "tarball bytes")
.expect("write previous tarball");
let ctx = Arc::new(
let ctx: Arc<dyn Sandbox> = Arc::new(
crate::context::Context::new(crate::context::ContextConfig::Local).expect("context"),
);
let opts = BinaryMetadataOptions {