diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 11:17:27 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 11:17:27 +0000 |
| commit | bc8f069d18c5de3dee04ae303227a255248efc1e (patch) | |
| tree | 35143f64346a2a555672789ae33cbf0905bffc0b /tests | |
| parent | 99ad2034be8fc5b107205199e19da831596a6791 (diff) | |
| download | aur-build-bc8f069d18c5de3dee04ae303227a255248efc1e.tar.gz aur-build-bc8f069d18c5de3dee04ae303227a255248efc1e.zip | |
pipeline: replace the devtools chroot with pinned pacman -U provisioning
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.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/crash.rs | 20 | ||||
| -rw-r--r-- | tests/dispatch.rs | 8 | ||||
| -rw-r--r-- | tests/invariants.rs | 4 | ||||
| -rw-r--r-- | tests/pipeline.rs | 57 | ||||
| -rw-r--r-- | tests/shims.rs | 48 |
5 files changed, 118 insertions, 19 deletions
diff --git a/tests/crash.rs b/tests/crash.rs index ca58a04..e1f856f 100644 --- a/tests/crash.rs +++ b/tests/crash.rs @@ -45,8 +45,8 @@ fn run_cli(env: &Env, args: &[&str]) -> std::process::Output { fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work() { let (mut env, _fx) = env_with_fixture("plain-make"); let id = queued(&env, "plain-make"); - // The child will be murdered the moment it invokes makechrootpkg. - env.cfg.hooks.shim_kill_parent = Some("makechrootpkg".into()); + // The child will be murdered the moment it invokes makepkg. + env.cfg.hooks.shim_kill_parent = Some("makepkg".into()); env.cfg.save().unwrap(); let out = run_cli(&env, &["run", &id]); @@ -71,10 +71,10 @@ fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work Some(StepState::Running), "the step that was running should be recorded as running" ); - assert_eq!( - builds::step_status(&env.db, &id, "chroot").unwrap(), - Some(StepState::Succeeded), - "the completed step before the crash must be checkpointed" + let chroot_status = builds::step_status(&env.db, &id, "chroot").unwrap(); + assert!( + chroot_status.is_some_and(|s| s.is_done()), + "the completed step before the crash must be checkpointed: {chroot_status:?}" ); assert!(db::accepted_release(&env.db, "plain-make").unwrap().is_none(), "nothing was published"); @@ -97,11 +97,11 @@ fn a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work let shim = env.cfg.hooks.shim_dir.clone().unwrap(); assert_eq!( aur_build::shims::called_with(&shim, "mkarchroot", ""), - 1, - "the chroot step was checkpointed as done and must not run again" + 0, + "the provisioning model never calls devtools, before or after a crash" ); assert_eq!( - aur_build::shims::called_with(&shim, "makechrootpkg", ""), + aur_build::shims::called_with(&shim, "makepkg", ""), 2, "exactly one rebuild: the crashed attempt and the resumed one" ); @@ -147,7 +147,7 @@ fn a_failed_build_leaves_the_index_serving_the_old_version_and_says_so() { // v2 is approved and its build fails deterministically. fx.bump(&[("pkgver", "2.0")]); - env.set_shim_fail("makechrootpkg"); + env.set_shim_fail("makepkg"); let c2 = approved(&env, "plain-make"); let id2 = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c2).unwrap(); let out = pipeline::run(&env.cfg, &env.db, &id2).unwrap(); diff --git a/tests/dispatch.rs b/tests/dispatch.rs index 8c0e4ff..5f65b6f 100644 --- a/tests/dispatch.rs +++ b/tests/dispatch.rs @@ -178,13 +178,13 @@ fn a_transient_failure_is_retried_up_to_the_cap() { #[test] fn a_missing_toolchain_is_not_retried() { - // m-14: this used to be the transient test. A missing `makechrootpkg` + // m-14: this used to be the transient test. A missing `makepkg` // surfaces as an `Io` error, and `Io` used to mean "retry" — so a // misconfigured host or a full disk burned every attempt and then went // quiet. It is deterministic: the tool is not going to appear. let (mut env, _fx) = env_with_fixture("plain-make"); let id = queued_build(&env, "plain-make"); - env.cfg.makechrootpkg_bin = "/nonexistent/makechrootpkg-for-test".into(); + env.cfg.makepkg_bin = "/nonexistent/makepkg-for-test".into(); env.cfg.max_transient_attempts = 3; env.cfg.dispatch_tick_secs = 0; let pool = dispatch::Pool::spawn(Arc::new(env.cfg.clone()), env.db.clone()); @@ -231,7 +231,7 @@ fn a_reaped_build_resumes_at_the_next_incomplete_step_with_no_duplicate_work() { pipeline::run(&env.cfg, &env.db, &id).unwrap(), pipeline::Outcome::Failed { .. } )); - let builds_before = aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makechrootpkg", ""); + let builds_before = aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makepkg", ""); // The worker "died" at publish: the row is leased with a lease nobody will // extend. A fresh dispatcher reaps it and a worker finishes from the @@ -252,7 +252,7 @@ fn a_reaped_build_resumes_at_the_next_incomplete_step_with_no_duplicate_work() { assert_eq!(state, BuildState::Succeeded, "the resumed build did not finish"); 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_before, "I5: resuming must not rebuild" ); diff --git a/tests/invariants.rs b/tests/invariants.rs index 1f6f7f2..770966f 100644 --- a/tests/invariants.rs +++ b/tests/invariants.rs @@ -159,7 +159,7 @@ fn i5_resume_after_a_crash_repeats_no_completed_step() { pipeline::Outcome::Failed { .. } )); let shim = env.cfg.hooks.shim_dir.clone().unwrap(); - let builds_before = aur_build::shims::called_with(&shim, "makechrootpkg", ""); + let builds_before = aur_build::shims::called_with(&shim, "makepkg", ""); assert_eq!(builds_before, 2, "one build per attempted publish"); // "Restart" the worker on the same build row. @@ -169,7 +169,7 @@ fn i5_resume_after_a_crash_repeats_no_completed_step() { other => panic!("{other:?}"), } assert_eq!( - aur_build::shims::called_with(&shim, "makechrootpkg", ""), + aur_build::shims::called_with(&shim, "makepkg", ""), builds_before, "I5: resuming re-ran the build step" ); diff --git a/tests/pipeline.rs b/tests/pipeline.rs index 878c193..d4ef724 100644 --- a/tests/pipeline.rs +++ b/tests/pipeline.rs @@ -118,6 +118,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"); let c = approve_fixture(&env, "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"), diff --git a/tests/shims.rs b/tests/shims.rs index 3422500..b21efab 100644 --- a/tests/shims.rs +++ b/tests/shims.rs @@ -175,6 +175,54 @@ fn repo_add_writes_a_pacman_database() { } #[test] +fn pacman_u_verifies_digests_and_q_reports_the_world() { + // The provisioning step's fail-closed world check runs against this fake: + // `-U` must refuse bytes that do not hash to the digest their name claims, + // and `-Q` must report exactly what landed. + let tmp = tempfile::tempdir().unwrap(); + let log = tmp.path().join("shimlog"); + std::fs::create_dir_all(&log).unwrap(); + let build = tmp.path().join("build"); + std::fs::create_dir_all(&build).unwrap(); + std::fs::write(build.join("PKGBUILD"), common::pkgbuild("plain-make", "1.0", "1", "")).unwrap(); + shim( + "makepkg", + &build, + &[("AUR_SHIM_MANIFEST", &fixture_manifest("plain-make")), ("AUR_SHIM_DIR", &log)], + &["-c", "-f"], + ); + let pkg = build.join("plain-make-1.0-1-x86_64.pkg.tar.zst"); + let bytes = std::fs::read(&pkg).unwrap(); + let blob = tmp.path().join(aur_build::hash::hex(&bytes)); + std::fs::write(&blob, &bytes).unwrap(); + + let (code, _, err) = shim( + "pacman", + tmp.path(), + &[("AUR_SHIM_DIR", &log)], + &["-U", "--noconfirm", &blob.display().to_string()], + ); + assert_eq!(code, 0, "{err}"); + + let (code, out, _) = shim("pacman", tmp.path(), &[("AUR_SHIM_DIR", &log)], &["-Q"]); + assert_eq!(code, 0); + assert!(out.contains("plain-make 1.0-1"), "the world check reads -Q: {out}"); + + // A blob whose bytes do not match the digest its name claims is refused + // like a bad signature: name it with some other digest's hex. + let bad = tmp.path().join(aur_build::hash::hex(b"some other artifact")); + std::fs::write(&bad, b"tampered").unwrap(); + let (code, _, err) = shim( + "pacman", + tmp.path(), + &[("AUR_SHIM_DIR", &log)], + &["-U", &bad.display().to_string()], + ); + assert_ne!(code, 0, "a digest mismatch must fail closed"); + assert!(err.contains("hash"), "{err}"); +} + +#[test] fn gpg_writes_a_detached_signature() { let tmp = tempfile::tempdir().unwrap(); let f = tmp.path().join("thing.pkg.tar.zst"); |
