diff options
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) { |
