diff options
Diffstat (limited to 'src/pipeline/steps.rs')
| -rw-r--r-- | src/pipeline/steps.rs | 73 |
1 files changed, 3 insertions, 70 deletions
diff --git a/src/pipeline/steps.rs b/src/pipeline/steps.rs index c19ac6b..061593b 100644 --- a/src/pipeline/steps.rs +++ b/src/pipeline/steps.rs @@ -23,9 +23,6 @@ pub fn run_step(ctx: &Ctx, step: &str) -> Result<StepResult> { } } -/// Step 0 — materialize from the local mirror only, never the network, and -/// re-hash what we got. This is the `aur_commit` pin doing its job: there is no -/// path from "AUR moved since the review" to "we built it anyway". fn materialize(ctx: &Ctx) -> Result<StepResult> { let mirror = ctx .pb @@ -62,14 +59,10 @@ fn materialize(ctx: &Ctx) -> Result<StepResult> { Ok(StepResult::Done(Some(computed))) } -/// A display-safe prefix; hashes are 64 hex chars but world digests can be tiny. fn short(s: &str) -> String { s.chars().take(12).collect() } -/// Step 1 — resolve dependencies against the current accepted index and compute -/// the intended world. Unresolvable means "a pkgbase we subscribe to that we have -/// not published yet": block and wait, do not fail (§10.4). fn plan(ctx: &Ctx) -> Result<StepResult> { let recipe = recipe_at(&ctx.srcdir)?; let mut wanted: Vec<String> = Vec::new(); @@ -84,9 +77,8 @@ fn plan(ctx: &Ctx) -> Result<StepResult> { let mut official = 0; for dep in &wanted { if ours.contains(dep) || ctx.pb.name == *dep || recipe.pkgnames.contains(dep) { - continue; // satisfied by our own index, or by this very build + continue; } - // Anything else is only a problem if we are supposed to be publishing it. if db::get_subscription(&ctx.db, dep)?.is_some() || db::get_pkgbase(&ctx.db, dep)?.is_some() { missing.push(dep.clone()); } else { @@ -108,16 +100,6 @@ fn plan(ctx: &Ctx) -> Result<StepResult> { Ok(StepResult::Done(Some(hash))) } -/// Step 2 — provision the sandbox with the pinned lease set. -/// -/// The devtools chroot is gone: the sandbox boots from a base that already carries -/// the official packages, and everything *we* publish arrives as blobs installed -/// with `pacman -U`. The step id stays `chroot` so existing checkpoint rows are -/// not stranded. -/// -/// Nothing is resolved at build time: the lease manifest is the plan, every blob -/// is re-hashed before it is staged, and the sandbox's own `pacman -Q` must confirm -/// the pinned world landed. fn provision(ctx: &Ctx) -> Result<StepResult> { let lease = lease_manifest(ctx)?; if lease.is_empty() { @@ -129,8 +111,6 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { }; for e in &lease { let path = ctx.cfg.store_path(&e.digest); - // The hub hashes what it sends: store corruption is caught here, not - // discovered by a confused package manager inside the sandbox. let (digest, _) = crate::hash::digest_file(&path)?; if digest != e.digest { return Err(Error::fail_closed(format!( @@ -145,15 +125,12 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { argv.extend(lease.iter().map(|e| format!("blob:{}", e.digest))); let out = sbx.run(&Cmd::new(argv), &mut |_| {})?; if !out.success() { - // A refused `-U` is almost always an incomplete closure — "the sandbox lied - // about its world", not "the sandbox broke". return Err(Error::world_mismatch(format!( "{} -U refused the lease set: {}", ctx.cfg.pacman_bin, tail(&out.stderr) ))); } - // Fail-closed world check: the world we approved is the world we build in. let q = sbx.run(&Cmd::new(vec![ctx.cfg.pacman_bin.clone(), "-Q".into()]), &mut |_| {})?; if !q.success() { return Err(Error::fail_closed(format!( @@ -187,8 +164,6 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { Ok(StepResult::Done(Some(crate::hash::canonical_json(&world)?))) } -/// Lease a sandbox for a step, or report that the pool cannot fit one. A full -/// pool blocks the build rather than failing it (§10.4). fn sandbox_or_wait( ctx: &Ctx, ) -> Result<Option<std::sync::Arc<dyn crate::sandbox::Sandbox>>> { @@ -202,7 +177,6 @@ fn sandbox_or_wait( } } -/// One pinned entry of the lease manifest. #[derive(Debug, Clone)] struct LeasePkg { name: String, @@ -210,10 +184,6 @@ struct LeasePkg { digest: String, } -/// The lease manifest: every dependency this build needs that we publish, -/// pinned to the exact version and digest of the artifact we serve. Official -/// packages arrive with the sandbox; anything unresolvable here would have been -/// `plan()`'s problem. fn lease_manifest(ctx: &Ctx) -> Result<Vec<LeasePkg>> { let recipe = recipe_at(&ctx.srcdir)?; let mut wanted: Vec<String> = Vec::new(); @@ -225,7 +195,7 @@ fn lease_manifest(ctx: &Ctx) -> Result<Vec<LeasePkg>> { let mut out = Vec::new(); for dep in wanted { if dep == ctx.pb.name || recipe.pkgnames.contains(&dep) { - continue; // this build's own output is not its own dependency + continue; } if let Some((version, digest)) = db::index_artifact(&ctx.db, &dep)? { out.push(LeasePkg { name: dep, version, digest }); @@ -234,18 +204,12 @@ fn lease_manifest(ctx: &Ctx) -> Result<Vec<LeasePkg>> { Ok(out) } -/// Step 3 — make sure every source we reviewed is on disk and hashes to what the -/// candidate recorded. For a `SKIP` source this is the only verification that -/// exists (§8.1). fn sources(ctx: &Ctx) -> Result<StepResult> { let digests: Vec<SourceDigest> = serde_json::from_str(&ctx.src.source_digests_json).unwrap_or_default(); let mut verified = 0; for d in &digests { match d.kind.as_str() { - // Already materialized from the mirror at the pinned commit. "local" => verified += 1, - // VCS kinds (git/svn/hg/bzr): honouring upstream_pins at build time - // is deferred to P1 (§20); the pkgver assertion is the interim guard. "vcs" | "git" | "svn" | "hg" | "bzr" => verified += 1, _ => { let (digest, _size) = match cached_path(&ctx.db, &d.url, &d.digest) { @@ -268,8 +232,6 @@ fn sources(ctx: &Ctx) -> Result<StepResult> { )))) } -/// Step 4 — the belt-and-braces assertion that what we build is what was approved. -/// If upstream moved between approval and build, fail with both versions (§8.1). fn pkgver(ctx: &Ctx) -> Result<StepResult> { let recipe = recipe_at(&ctx.srcdir)?; let has_vcs = recipe.source_entries.iter().any(|s| s.is_vcs()); @@ -308,18 +270,12 @@ fn pkgver(ctx: &Ctx) -> Result<StepResult> { Ok(StepResult::Done(Some(text))) } -/// Step 5 — `makepkg -c -f` in the provisioned sandbox, with the log going to -/// the file the SSE tail reads. No `-s`: the lease set is already installed, and -/// resolving dependencies at build time is what the pinning model forbids. No -/// `-si`: the sandbox never holds the signing key. fn build(ctx: &Ctx) -> Result<StepResult> { let argv = vec![ctx.cfg.makepkg_bin.clone(), "-c".into(), "-f".into()]; let sbx = match sandbox_or_wait(ctx)? { Some(s) => s, None => return Ok(StepResult::Blocked(vec!["sandbox-pool".into()])), }; - // The sandbox streams the child's output here as it arrives; the SSE tail - // reads the same file. if let Some(parent) = ctx.log.parent() { let _ = std::fs::create_dir_all(parent); } @@ -331,7 +287,7 @@ fn build(ctx: &Ctx) -> Result<StepResult> { } }; let out = sbx.run(&Cmd::new(argv).in_dir(&ctx.srcdir), &mut on_log)?; - drop(on_log); // closes the log file before the outcome is recorded + drop(on_log); if !out.success() { return Err(Error::Subprocess { cmd: ctx.cfg.makepkg_bin.clone(), @@ -350,8 +306,6 @@ fn tail(b: &[u8]) -> String { lines[lines.len().saturating_sub(6)..].join(" | ") } -/// Step 6 — parse `.PKGINFO`/`.BUILDINFO` out of the produced artifacts (§10.1: -/// plain text in a tar, no libalpm needed). fn collect(ctx: &Ctx) -> Result<StepResult> { let mut pkgs = Vec::new(); let mut entries: Vec<PathBuf> = std::fs::read_dir(&ctx.srcdir)? @@ -360,11 +314,6 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { .filter(|p| p.to_string_lossy().ends_with(".pkg.tar.zst")) .collect(); entries.sort(); - // I9: the build is untrusted, and the control plane must not *depend* on the - // sandbox for its own safety. Everything below takes a path a PKGBUILD could - // have arranged to exist in the srcdir, and the next step copies whatever it - // points at into the store, from where we serve and sign it. So: no symlinks, - // and the resolved target must live inside this build's staging directory. let staging_root = ctx.staging.canonicalize()?;; for path in entries { if std::fs::symlink_metadata(&path).map(|m| m.file_type().is_symlink()).unwrap_or(true) { @@ -383,13 +332,9 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { let path = resolved; let bytes = std::fs::read(&path)?; let (digest, size) = crate::hash::digest_file(&path)?; - // Read what the package says about itself out of the archive, rather - // than trusting what the build claimed on stdout (§10.1). let pkginfo = crate::pkginfo::pkginfo_text(&bytes) .map_err(|e| Error::invalid(format!("{}: {e}", path.display())))?; let meta = crate::pkginfo::parse_pkginfo(&pkginfo); - // `.BUILDINFO` is what the world snapshot is built from. Absent is not - // fatal; present-but-unparseable would be a lie we should not swallow. let buildinfo = crate::pkginfo::buildinfo_text(&bytes).unwrap_or_default(); let sig = path.with_extension("pkg.tar.zst.sig"); pkgs.push(CollectedPkg { @@ -419,8 +364,6 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { Ok(StepResult::Done(Some(crate::hash::hex_str(&serde_json::to_string(&pkgs)?)))) } -/// Step 7 — dependencies satisfiable, no downgrade. Signature checking is not -/// here: the sandbox never sees the key, so the signature is made at ingest. fn verify(ctx: &Ctx) -> Result<StepResult> { let collect = Collect::load(&ctx.collect_path)?; let ours = db::our_package_names(&ctx.db)?; @@ -429,7 +372,6 @@ fn verify(ctx: &Ctx) -> Result<StepResult> { &db::index_version(&ctx.db, &p.name)?.unwrap_or_else(|| "0".into()), &p.version, ) { - // Downgrades are allowed but flagged (§16); the review already shows it. ctx.log_line(&format!(" note: {} is a downgrade from what we serve", p.name)); } let mut provided: std::collections::BTreeSet<String> = ours.clone(); @@ -449,8 +391,6 @@ fn verify(ctx: &Ctx) -> Result<StepResult> { )?)))) } -/// Step 8 — move artifacts into the content-addressed store and record rows. -/// Staging stays disposable; a GC pass sweeps abandoned directories (§8.2). fn ingest(ctx: &Ctx) -> Result<StepResult> { let mut collect = Collect::load(&ctx.collect_path)?; for p in &mut collect.packages { @@ -463,8 +403,6 @@ fn ingest(ctx: &Ctx) -> Result<StepResult> { std::fs::copy(from, &dest)?; } p.path = dest.display().to_string(); - // Hub-side signing: over the exact bytes that just entered the store. A - // gpg failure fails the build closed. if !ctx.cfg.signing_key_id.is_empty() { let sigdest = ctx.cfg.store_path(&format!("{}-sig", p.digest)); if !sigdest.exists() { @@ -498,9 +436,6 @@ fn ingest(ctx: &Ctx) -> Result<StepResult> { Ok(()) })?; - // §10.1: the world snapshot is the build's installed set INTERSECTED with our - // own packages, filtered at ingest time. Left unfiltered, every package would - // be permanently stale because Arch never stops moving. let ours = db::our_package_names(&ctx.db)?; let mut members: Vec<WorldMember> = Vec::new(); for p in &collect.packages { @@ -519,7 +454,6 @@ fn ingest(ctx: &Ctx) -> Result<StepResult> { ))))) } -/// Step 9 — the only externally visible step, serialized per repo (§9). fn publish(ctx: &Ctx) -> Result<StepResult> { let release_id = crate::pipeline::publish::publish(ctx)?; Ok(StepResult::Done(Some(format!("release:{release_id}")))) @@ -529,7 +463,6 @@ fn publish(ctx: &Ctx) -> Result<StepResult> { use std::path::PathBuf; -/// Read the recipe from a materialized tree, preferring `.SRCINFO`. pub(crate) fn recipe_at(dir: &Path) -> Result<Recipe> { let mut files = std::collections::BTreeMap::new(); for entry in walkdir::WalkDir::new(dir).max_depth(2).into_iter().filter_map(|e| e.ok()) { |
