summaryrefslogtreecommitdiffstats
path: root/tests/shims.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 11:17:27 +0000
committeraur-build <aur-build@localhost>2026-11-19 11:17:27 +0000
commitbc8f069d18c5de3dee04ae303227a255248efc1e (patch)
tree35143f64346a2a555672789ae33cbf0905bffc0b /tests/shims.rs
parent99ad2034be8fc5b107205199e19da831596a6791 (diff)
downloadaur-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/shims.rs')
-rw-r--r--tests/shims.rs48
1 files changed, 48 insertions, 0 deletions
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");