From 99c6f63cd410ed586a6df3fdf3a94fb1eafd1269 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Fri, 25 Sep 2026 20:53:02 +0200 Subject: [PATCH] deb: pin the cross variant choice of M-A:same build-deps in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An unqualified Multi-Arch: same build-dependency resolves to the host-architecture variant only, even when a build-architecture candidate exists: that is what dpkg's checker accepts (KnownFacts accepts foreign, host and all instances) and what sbuild installs, whose dummy package carries the parsed Build-Depends unqualified and whose sbuild-cross-resolver only filters foreign M-A:foreign and Essential packages out of the apt universe — verified by resolving a sbuild-style dummy:arm64 against the resolute/stonking indexes, which yields libelf-dev:arm64 & co and never the amd64 variants. The build-architecture side of such a library is only ever installed through an explicit :native declaration. Pin both rules so a resolver regression towards dual-installing unqualified dependencies cannot reappear unnoticed. --- src/deb/local.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/deb/local.rs b/src/deb/local.rs index be678a4..2c436ae 100644 --- a/src/deb/local.rs +++ b/src/deb/local.rs @@ -1154,6 +1154,39 @@ mod tests { assert_eq!(spec, "t:amd64"); } + /// Cross parity with dpkg's checker and sbuild's apt-resolved dummy + /// package: an unqualified Multi-Arch: same name resolves to the + /// host-architecture variant even when a build-architecture candidate + /// exists — the build-architecture side is only ever installed + /// through an explicit `:native` declaration (or a pkh quirk + /// injecting one), never alongside the host variant. + #[test] + fn install_spec_unqualified_same_package_never_dual_installs() { + let host = "arm64"; + let build = "amd64"; + + let spec = install_spec_for( + &rel("t"), + &[cand("amd64", "same"), cand("arm64", "same")], + build, + host, + ) + .unwrap(); + assert_eq!(spec, "t:arm64"); + + // The build-architecture side comes from `:native` declarations: + // the co-installable build-arch variant of the same source + // package. + let spec = install_spec_for( + &rel("t:native"), + &[cand("amd64", "same"), cand("arm64", "same")], + build, + host, + ) + .unwrap(); + assert_eq!(spec, "t:amd64"); + } + /// Qualified dependencies install exactly the variant their qualifier /// selects per dpkg semantics; virtual names (no candidates) pass /// through unqualified for apt to resolve a provider.