From bc8f069d18c5de3dee04ae303227a255248efc1e Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 11:17:27 +0000 Subject: pipeline: replace the devtools chroot with pinned pacman -U provisioning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The chroot step existed to run mkarchroot/makechrootpkg, whose sudo requirement was the whole reason a build had to run on the hub under root-adjacent rules. The sandbox model makes the chroot redundant: the sandbox boots from a base that already carries the official packages, and step 2 now provisions it with a lease manifest instead — every dependency we publish, pinned to the exact version and digest of the artifact the index serves. The hub re-hashes every blob before staging it, installs with pacman -U (no -Sy, no live resolution, no mirror at build time), and the sandbox's own pacman -Q must confirm the pinned world landed before a build may start. A byte that hashes differently, or a world that drifted, fails closed. The build step is now plain makepkg -c -f: no -s (dependencies arrive installed; resolving at build time is what the pinning model forbids) and no -si (ingest signs). mkarchroot/makechrootpkg are gone from the pipeline and the config; their shims stay as stand-ins for the real devtools so the shim protocol itself remains exercised. The shim pacman grew a real fake installed-database: -U refuses bytes that do not hash to the digest their name claims, -Q reports what landed, so the world check is a test and not a no-op. --- tests/pipeline.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'tests/pipeline.rs') diff --git a/tests/pipeline.rs b/tests/pipeline.rs index 878c193..d4ef724 100644 --- a/tests/pipeline.rs +++ b/tests/pipeline.rs @@ -117,6 +117,57 @@ fn the_build_never_signs_ingest_does() { ); } +#[test] +fn a_tampered_store_artifact_fails_the_lease_closed() { + // dep-client depends on plain-make, so its lease pins plain-make's exact + // artifact. Corrupt the store bytes after publication: provisioning + // re-hashes everything it stages and must refuse, not build against bytes + // that are not what the index — and the review behind it — approved. + let (env, _plain, _client) = env_with_two_fixtures("plain-make", "dep-client"); + let c = approve_fixture(&env, "plain-make"); + assert!(matches!(run_for(&env, &c), pipeline::Outcome::Succeeded { .. })); + + let c2 = approve_fixture(&env, "dep-client"); + let id2 = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c2).unwrap(); + + let (digest, path): (String, String) = env + .db + .read(|c| { + Ok(c.query_row("SELECT digest, path FROM artifact LIMIT 1", [], |r| { + Ok((r.get(0)?, r.get(1)?)) + })?) + }) + .unwrap(); + let original = std::fs::read(&path).unwrap(); + let mut tampered = original.clone(); + tampered[16] ^= 0xFF; + std::fs::write(&path, &tampered).unwrap(); + + match pipeline::run(&env.cfg, &env.db, &id2).unwrap() { + pipeline::Outcome::Failed { step, error, transient } => { + assert_eq!(step, "chroot", "provisioning is where the lie gets caught"); + assert!(error.contains("hash") && error.contains(&digest), "{error}"); + assert!(!transient, "a corrupt store is not a network hiccup"); + } + other => panic!("{other:?}"), + } + + // Restore the bytes and resume: the lease verifies, the sandbox's own + // `pacman -Q` confirms the pinned world landed, and the build completes — + // which is the happy provisioning path proven end to end as well. + std::fs::write(&path, &original).unwrap(); + assert!( + matches!(pipeline::run(&env.cfg, &env.db, &id2).unwrap(), pipeline::Outcome::Succeeded { .. }), + "the resumed build failed" + ); + assert!(in_index(&env).iter().any(|(n, _)| n == "dep-client")); + let shimlog = env.cfg.hooks.shim_dir.clone().unwrap(); + assert!( + aur_build::shims::called_with(&shimlog, "pacman", "-U") > 0, + "the dependency arrived as a pinned blob through pacman -U, not a live mirror" + ); +} + #[test] fn i1_no_index_entry_without_an_approval() { let (env, _fx) = env_with_fixture("plain-make"); @@ -256,7 +307,7 @@ fn i5_a_restarted_build_resumes_at_the_next_incomplete_step() { pipeline::Outcome::Failed { .. } )); let builds_after_crash = - aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makechrootpkg", ""); + aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makepkg", ""); assert_eq!(builds_after_crash, 2, "one real build before the crash"); // "Restart": same build row, no fault. Steps 0-8 are checkpointed as @@ -267,7 +318,7 @@ fn i5_a_restarted_build_resumes_at_the_next_incomplete_step() { other => panic!("{other:?}"), } assert_eq!( - aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makechrootpkg", ""), + aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makepkg", ""), builds_after_crash, "I5: resuming must not rebuild" ); @@ -301,7 +352,7 @@ fn a_failed_build_leaves_the_previous_version_serving() { fx.bump(&[("pkgver", "1.0.1")]); let c2 = approve_pending(&env, "plain-make"); // The build itself fails this time. - env.set_shim_fail("makechrootpkg"); + env.set_shim_fail("makepkg"); let out = run_for(&env, &c2); match out { pipeline::Outcome::Failed { step, .. } => assert_eq!(step, "build"), -- cgit v1.2.3