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:
1 parent
f1a21e0923
commit
483e532baf
16 files changed
+362
-109
No files matched your search
+21
-8
@@ -84,6 +84,11 @@ pub trait Sandbox: Send + Sync {
|
||||
/// A fresh temporary directory inside the environment.
|
||||
fn create_temp_dir(&self) -> io::Result<String>;
|
||||
|
||||
/// Whether this sandbox is the host machine. Defaults to `false`.
|
||||
fn is_host(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// Release mounts, devices or guest state and apply the teardown
|
||||
/// policy. Idempotent. `outcome` is `None` when the owner did not
|
||||
/// report one. Defaults to a no-op.
|
||||
@@ -179,9 +184,16 @@ The trait has three transfer primitives:
|
||||
`put` takes the copy policies the backend needs to apply:
|
||||
|
||||
```rust
|
||||
pub struct ReuseState {
|
||||
/// Overlay upper directory.
|
||||
pub upper: PathBuf,
|
||||
/// Overlay work directory.
|
||||
pub work: PathBuf,
|
||||
}
|
||||
|
||||
pub struct PutOptions {
|
||||
/// Backend state to reuse for a resumable tree copy.
|
||||
pub reuse: Option<PathBuf>,
|
||||
pub reuse: Option<ReuseState>,
|
||||
/// Directory names to skip at any depth.
|
||||
pub skip_dirs: Vec<OsString>,
|
||||
}
|
||||
@@ -204,7 +216,7 @@ directory. The caller builds the final name.
|
||||
```rust
|
||||
pub struct StageOptions {
|
||||
/// Backend state to reuse for a resumable tree copy.
|
||||
pub reuse: Option<PathBuf>,
|
||||
pub reuse: Option<ReuseState>,
|
||||
/// Remove VCS metadata from the staged tree.
|
||||
pub prune_vcs: bool,
|
||||
}
|
||||
@@ -479,8 +491,8 @@ The commit scopes follow `AGENTS.md`: add `sandbox`, `build_profile` and
|
||||
2. Staging and `--incremental`. Host-side overlayfs is specific to the unshare
|
||||
backend. The `put` and `stage_tree` API must be settled before `Ecrou`, or
|
||||
the Ecrou backend will not support incremental builds.
|
||||
3. Trait size. The trait has 11 methods, and every backend must implement all
|
||||
of them. One trait keeps `Arc<dyn Sandbox>` simple. If it grows, split
|
||||
3. Trait size. The trait has 11 required methods and one provided capability
|
||||
method (`is_host`), and every backend implement the required ones. One trait keeps `Arc<dyn Sandbox>` simple. If it grows, split
|
||||
it into `CommandRunner` and `FileSystem` supertraits rather than adding
|
||||
optional methods.
|
||||
4. Per-call cost over a microVM channel. A file read is cheap on the host and a
|
||||
@@ -510,10 +522,11 @@ The commit scopes follow `AGENTS.md`: add `sandbox`, `build_profile` and
|
||||
state fields. Pruning and the `--incremental` base check also assume a
|
||||
tarball; the microVM image identity has to replace or extend that check. Add
|
||||
the backend tag before the Ecrou work, not after.
|
||||
11. Resume state shape. `PutOptions.reuse` is a host `PathBuf` because
|
||||
`Unshare` keeps its upper and work layers on the host. An Ecrou overlay may
|
||||
live inside the guest. Decide whether `reuse` becomes an opaque token
|
||||
before Ecrou, or whether Ecrou also keeps its resume state on the host.
|
||||
11. Resume state shape. `PutOptions.reuse` is a `ReuseState` holding host
|
||||
paths because `Unshare` keeps its upper and work layers on the host. An
|
||||
Ecrou overlay may live inside the guest. Decide whether `reuse` becomes an
|
||||
opaque token before Ecrou, or whether Ecrou also keeps its resume state on
|
||||
the host.
|
||||
|
||||
## Testing
|
||||
|
||||
|
||||
Reference in new issue
Block a user