diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 15:33:32 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 15:33:32 +0000 |
| commit | 753e05a4f588d3e8a3ea0b88b2e03d74f9f00be8 (patch) | |
| tree | 9a9d73297e81716a398adcb6dd069735dcf91827 /src/pipeline/publish.rs | |
| parent | 933c637de34095f1ea1ab88b02626bbf22eec7f4 (diff) | |
| download | aur-build-753e05a4f588d3e8a3ea0b88b2e03d74f9f00be8.tar.gz aur-build-753e05a4f588d3e8a3ea0b88b2e03d74f9f00be8.zip | |
pipeline: the name we publish comes from the real .PKGINFO parser, and the shims are test-only
`publish.rs::package_name` — the function that decides which package a built
artifact is, and therefore what the index says — called into the test harness
(`shims::read_pkginfo`) to read it. Worse, the shim module carried its own
`.PKGINFO` field parser alongside the real one in `pkginfo.rs`. Two parsers
that can drift is a supply-chain-shaped foot-gun in a system whose whole job
is provenance: the bytes we sign and the bytes the tests believed in would be
interpreted by different code, and a green shim test would not have meant the
pipeline read the package the same way.
There is now one parser. `package_name` uses `pkginfo::pkginfo_text` and
`pkginfo::parse_pkginfo`; the shim's `repo-add` renders its `DESC` entry from
the same `PkgInfo` the production code parses, so the fake tool and the real
pipeline cannot disagree about what a package calls itself. The duplicate
parser and the two wrapper functions are deleted, and the harness test reads
its artifact with `pkginfo` too.
The module itself is now test-only in the way the review asked for. `pub(crate)`
was not available — the shim binaries are separate crates that link the
library — so the equivalent enforcement is used instead: `shims` is compiled
out unless the `test-support` feature is on, and every shim binary declares
`required-features = ["test-support"]`. A production `cargo build --release`
neither builds the fakes nor links their code; `cargo build --bin makepkg`
says so out loud. `tests/production_surface.rs` covers the half the compiler
cannot see: no module in `src/` outside the harness may name `shims::`, and the
binaries must keep declaring the feature.
Diffstat (limited to 'src/pipeline/publish.rs')
| -rw-r--r-- | src/pipeline/publish.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/pipeline/publish.rs b/src/pipeline/publish.rs index ab0cb87..40048c3 100644 --- a/src/pipeline/publish.rs +++ b/src/pipeline/publish.rs @@ -321,15 +321,21 @@ fn dedupe_by_name(paths: Vec<PathBuf>) -> Vec<PathBuf> { out } +/// The package name a built artifact declares, read from its own `.PKGINFO`. +/// +/// This is the real parser in `crate::pkginfo`, not the shim harness's: the +/// name that goes into the index must come from the same read of the bytes that +/// the pipeline signs, and a second parser in the test scaffolding is one +/// refactor away from disagreeing about what a package calls itself (§6 M-4). fn package_name(path: &Path) -> Option<String> { let bytes = std::fs::read(path).ok()?; - let info = crate::shims::read_pkginfo(&bytes).ok()?; - for line in info.lines() { - if let Some(v) = line.strip_prefix("pkgname =") { - return Some(v.trim().to_string()); - } + let info = crate::pkginfo::pkginfo_text(&bytes).ok()?; + let name = crate::pkginfo::parse_pkginfo(&info).name; + if name.is_empty() { + None + } else { + Some(name) } - None } /// Re-materialize the served index from the DB. Run at startup: if a crash left |
