diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 09:12:28 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 09:12:28 +0000 |
| commit | d9c8402180749df4452dc37febace4d933b8407d (patch) | |
| tree | 377a7b89203c266d00a714845b50d27febbda4c7 /src/shims/mod.rs | |
| parent | 4cb2f4c7b68dceaed8f7ffbd8f0db3cfbf3f1ddc (diff) | |
| download | aur-build-d9c8402180749df4452dc37febace4d933b8407d.tar.gz aur-build-d9c8402180749df4452dc37febace4d933b8407d.zip | |
pkginfo: .PKGINFO/.BUILDINFO parsing gets a real home, and a parser bug fix (§10.1)
Ingest decides what the index claims about a package and what the world
snapshot records by reading two text files out of a tar inside a zstd stream.
That code was living in src/shims — the test harness — which meant production
depended on the harness for its view of a package's own metadata. Moved to
src/pkginfo.rs, with the shim now delegating to it so the harness and the
production path cannot disagree about what a package says about itself.
Still no libalpm: tar + zstd + eighty lines of key = value parsing. Unknown keys
are ignored rather than rejected, because makepkg adds fields over time and a new
one must not stop us publishing.
**The parser had a real bug.** A .BUILDINFO installed block puts its first entry
on the same line as the key:
installed = glibc 2.39-1 x86_64 -
gmp 6.3.0-1 x86_64 -
The old code skipped the header line, so the first dependency was silently
dropped from every snapshot — exactly the kind of gap that makes staleness
quietly wrong. The header line is parsed now.
tests/world.rs builds real .pkg.tar.zst files and asserts the fields come out of
the archive: repeated keys stay lists, an archive with no .PKGINFO is refused
rather than defaulted from the filename, and the world snapshot contains our own
packages and none of glibc/pacman/binutils. The empty-snapshot case for a first
build is asserted too — nothing of ours existed yet, and recording that honestly
beats inventing a world.
Split pkgbases produce one approval, one release and N index rows each with its
own artifact, asserted directly here. 143 tests pass, clippy clean.
Diffstat (limited to 'src/shims/mod.rs')
| -rw-r--r-- | src/shims/mod.rs | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/src/shims/mod.rs b/src/shims/mod.rs index 5560aa3..754bbb4 100644 --- a/src/shims/mod.rs +++ b/src/shims/mod.rs @@ -542,38 +542,16 @@ pub fn repo_add(args: &[String], _m: &Manifest) -> Result<i32, String> { Ok(0) } -/// Pull `.PKGINFO` out of a `.pkg.tar.zst` (§10.1: plain text in a tar, no -/// libalpm needed). +/// Pull `.PKGINFO` out of a `.pkg.tar.zst`. The real parsing lives in +/// `crate::pkginfo`, which the pipeline also uses — the shim and the production +/// path must agree about what a package says about itself, or a test that passes +/// here would not mean anything. pub fn read_pkginfo(pkg_bytes: &[u8]) -> Result<String, String> { - let dec = zstd::Decoder::new(std::io::Cursor::new(pkg_bytes)).map_err(|e| e.to_string())?; - let mut ar = tar::Archive::new(dec); - for e in ar.entries().map_err(|e| e.to_string())? { - let mut e = e.map_err(|e| e.to_string())?; - let name = e.path_bytes().to_vec(); - if name.ends_with(b".PKGINFO") { - use std::io::Read; - let mut s = String::new(); - e.read_to_string(&mut s).map_err(|e| e.to_string())?; - return Ok(s); - } - } - Err("no .PKGINFO in package".into()) + crate::pkginfo::pkginfo_text(pkg_bytes) } pub fn read_buildinfo(pkg_bytes: &[u8]) -> Result<String, String> { - let dec = zstd::Decoder::new(std::io::Cursor::new(pkg_bytes)).map_err(|e| e.to_string())?; - let mut ar = tar::Archive::new(dec); - for e in ar.entries().map_err(|e| e.to_string())? { - let mut e = e.map_err(|e| e.to_string())?; - let name = e.path_bytes().to_vec(); - if name.ends_with(b".BUILDINFO") { - use std::io::Read; - let mut s = String::new(); - e.read_to_string(&mut s).map_err(|e| e.to_string())?; - return Ok(s); - } - } - Err("no .BUILDINFO in package".into()) + crate::pkginfo::buildinfo_text(pkg_bytes) } fn parse_pkginfo(s: &str) -> (String, String, String, String) { |
