build/binary: native .buildinfo/.changes for binary builds (pkh deb)

Extend the metadata writers to binary-only uploads and wire them into
the 'pkh deb' flow:

- build/binary.rs generates <pkg>_<ver>_<arch>.buildinfo/.changes
  through any Context: debian/files consumption, encounter-order
  Architecture accumulation (sorted in .buildinfo like dpkg-genbuildinfo),
  sorted Binary lists, dpkg-formatted Description lines with udeb
  suffixes, Installed-Build-Depends closure over the context status DB,
  and binNMU handling (Source: pkg (prev), Binary-Only-Changes, previous
  .dsc redistribution);
- artifact digests are computed inside the context via coreutils
  (md5sum/sha1sum/sha256sum/stat) so chrooted/remote trees work;
- deb/local.rs runs the generation after 'rules binary', exports
  SOURCE_DATE_EPOCH from the changelog (reproducibility), and resolves
  vendor/profiles inside the context; deb/mod.rs retrieves the new
  artifacts alongside the debs;
- reusable helpers added: FilesList::parse/render,
  parse_changelog_entry_from_str, parse_previous_version_from_str,
  installed_build_depends_from_content.

Differential gate: same tree built with real 'dpkg-buildpackage -b' and
with the pkh flow; .changes/.buildinfo compared field-by-field modulo
machine-dependent fields, artifact checksums included.
This commit is contained in:
2026-08-24 11:58:19 +02:00
parent dfaab0606a
commit 42fcfc2dfa
9 changed files with 808 additions and 45 deletions
+23 -4
View File
@@ -115,7 +115,8 @@ Exit codes matter: e.g. unsatisfied build-deps ⇒ exit 3.
| `dpkg-architecture` | arch ↔ triplet tables, multiarch tuple, env dump | **Low-medium** — embed cputable/ostable/tupletable/abitable data (stable for years) | **Replaced** (§11, [`debian/arch.rs`](../src/debian/arch.rs)) |
| `dpkg-checkbuilddeps` | deps vs installed status | **Medium**`Dpkg::Deps` grammar (alternatives, arch qualifiers, `<profiles>` restrictions, versioned Provides subtleties, Multi-Arch facts) + status-file scan | **Replaced** (§11, [`debian/deps.rs`](../src/debian/deps.rs); wired into the pipeline behind `-D`, source-only builds skip it like dpkg-buildpackage) |
| `dpkg-genbuildinfo` | `.buildinfo` | **Medium** — deb822 emit + status snapshot + checksums | Native (see §11, [`buildinfo.rs`](../src/build/buildinfo.rs)) |
| `dpkg-genchanges` | `.changes` | **Medium** — deb822 emit + `debian/files` consumption + `.deb` control extraction (ar+tar, trivial with crates) | Native for source uploads (§11, [`changes.rs`](../src/build/changes.rs)); binary aggregation next |
| `dpkg-genchanges` | `.changes` | **Medium** — deb822 emit + `debian/files` consumption + `.deb` control extraction (ar+tar, trivial with crates) | **Replaced** for source (§11) and binary uploads (§11, [`build/binary.rs`](../src/build/binary.rs)) |
| `dpkg-genbuildinfo` (binary) | `.buildinfo` for `-b` builds | **Medium** — deb822 emit + in-context artifact hashing | **Replaced** (§11, [`build/binary.rs`](../src/build/binary.rs), wired into [`deb/local.rs`](../src/deb/local.rs)) |
| `dpkg-distaddfile`/`debian/files` protocol | build outputs registry | **Trivial** — one append-only line format | Native ([`files.rs`](../src/build/files.rs)) |
| OpenPGP signing | inline clearsign of dsc/buildinfo/changes | **Low**`gpgme` (already a dependency) supports clearsigning | Native ([`sign.rs`](../src/build/sign.rs)) |
| `dpkg-source` | orig tarball, debian diff, patches, `.dsc` | **Very high** — V1/V2/quilt/native formats, byte-exact tar normalization, quilt bookkeeping, `--include-binaries`, hundreds of validation warnings | **Keep as subprocess** (see §6) |
@@ -304,6 +305,24 @@ correct for quilt formats.
`Environment` field, vendor default profiles approximated
(`derivative.ubuntu noudeb` for Ubuntu).
**Next steps**: binary-build adoption of the same pipeline inside ephemeral
contexts (`.changes`/`.buildinfo` generation for `pkh deb`, replacing the
manual quilt step), then Phase 2 satellite replacement.
## 12. Implementation status (Phase 2 — satellite tools)
All four satellite replacements landed, each gated by differential tests
against the real tool:
| Work item | Module | Differential gate |
|---|---|---|
| WI-1 `dpkg-architecture` | [`debian/arch.rs`](../src/debian/arch.rs) (tables + lookups), wired into [`build/env.rs`](../src/build/env.rs) | `arch_env(Some(a))` equals real `dpkg-architecture -f -a a` key-for-key for **every** arch from `dpkg-architecture -L`, plus native (`build/mod.rs::diff_arch_env_*`) |
| WI-2 version compare | [`debian/version.rs`](../src/debian/version.rs) (`Ord`, `compare`, `later_than`) | all vectors from dpkg `scripts/t/Dpkg_Version.t` + Ubuntu-flavored cases, cross-checked against `dpkg --compare-versions` for `<< <= = >= >>` (`diff_version_compare_against_dpkg`) |
| WI-3 `dpkg-checkbuilddeps` | [`debian/deps.rs`](../src/debian/deps.rs) (grammar, restriction reduction, KnownFacts evaluation, `check_build_depends`) | 24 scenarios vs real `dpkg-checkbuilddeps` (alternatives, versions, arch/profile restrictions, Multi-Arch, versioned Provides, conflicts, `-A`/`-B`) comparing exit status + diagnostics (`diff_checkbuilddeps_matrix`); unit tests port the `Dpkg_Deps.t` reduction matrices. Wired into `run_source_build` behind `-D` parity: source-only builds skip the check like `dpkg-buildpackage`, unsatisfied deps exit 3 |
| WI-4 binary `.buildinfo`/`.changes` | [`build/binary.rs`](../src/build/binary.rs) (context-generic generation), wired into [`deb/local.rs`](../src/deb/local.rs); artifact retrieval extended in [`deb/mod.rs`](../src/deb/mod.rs) | same tree built with real `dpkg-buildpackage -b` and with the pkh flow (rules build/binary + native metadata through a local context): `.changes`/`.buildinfo` compared field-by-field modulo machine-dependent fields, artifact checksums included (`diff_binary_build_metadata`) |
Binary-flow notes: `SOURCE_DATE_EPOCH` is now exported to the rules
environment (reproducibility); digests are computed inside the context via
coreutils so remote/chrooted trees work; binNMU binary builds set
`Source: pkg (prev)` / `Binary-Only-Changes` and redistribute the previous
`.dsc` when present; `Architecture` is encounter-ordered in `.changes`
(sorted in `.buildinfo`, matching dpkg).
Still delegated to subprocesses: `dpkg-source` and `debian/rules` (by
design, see §5 Scope C).