checksums: add SHA-512 and a Checksums-* field parser
The checksum model only carried md5/sha1/sha256 while deb-buildinfo(5) defines Checksums-Sha512, and there was no way to parse a Checksums-* field body back into entries. Add ChecksumKind::Sha512 (computed alongside the others), a field parser validating the '<hex> <size> <name>' grammar, and an only-if-populated Checksums-Sha512 emission in .buildinfo — deliberately dormant in the dpkg-parity flows, which never emit it, and .dsc/.changes untouched.
This commit is contained in:
@@ -110,6 +110,9 @@ pub fn generate_binary_metadata(
|
||||
let entry_hashes = hashes
|
||||
.remove(name)
|
||||
.ok_or_else(|| format!("artifact '{name}' listed in debian/files but not found"))?;
|
||||
// SHA-512 stays unknown here: like dpkg-genbuildinfo, no SHA-512
|
||||
// digest is computed for the artifacts, and an empty digest keeps
|
||||
// the `Checksums-Sha512` field of the `.buildinfo` omitted.
|
||||
checksums.insert_entry(
|
||||
name,
|
||||
ChecksumEntry {
|
||||
@@ -117,6 +120,7 @@ pub fn generate_binary_metadata(
|
||||
md5: entry_hashes.md5,
|
||||
sha1: entry_hashes.sha1,
|
||||
sha256: entry_hashes.sha256,
|
||||
sha512: String::new(),
|
||||
},
|
||||
);
|
||||
// Architecture accumulation in encounter order (dpkg-genchanges).
|
||||
@@ -285,6 +289,9 @@ pub fn generate_binary_metadata(
|
||||
md5: h.md5.clone(),
|
||||
sha1: h.sha1.clone(),
|
||||
sha256: h.sha256.clone(),
|
||||
// No SHA-512 digest available (see above); keeps the
|
||||
// `Checksums-Sha512` `.buildinfo` field omitted.
|
||||
sha512: String::new(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -457,6 +464,8 @@ fn include_dsc_artifacts(
|
||||
md5: h.md5.clone(),
|
||||
sha1: h.sha1.clone(),
|
||||
sha256: h.sha256.clone(),
|
||||
// No SHA-512 digest available (see above).
|
||||
sha512: String::new(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -474,6 +483,9 @@ fn include_dsc_artifacts(
|
||||
md5: p.md5.clone().unwrap_or_default(),
|
||||
sha1: p.sha1.clone().unwrap_or_default(),
|
||||
sha256: p.sha256.clone().unwrap_or_default(),
|
||||
// The `.dsc` records no SHA-512 (dpkg only writes
|
||||
// sha1/sha256 there).
|
||||
sha512: String::new(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user