deb: install build-deps per dpkg cross semantics
Replace the apt-get build-dep passes with a native resolver: the Build-* clauses are evaluated against the context's package state by crate::debian::deps (the dpkg-checkbuilddeps equivalent), and the unsatisfied ones install through explicitly architecture-qualified names. apt's --host-architecture build-dep resolution is coarser than the checker it feeds: unqualified Multi-Arch: same libraries only ever get the host-architecture variant, and there is no way to also satisfy the build-architecture needs of a cross build without a native re-resolution pass — which installs co-install partners that break unpacking for -dev packages whose variants conflict on arch-differing files (curl-config; the libcurl4-gnutls-dev regression). The resolver now applies the same dpkg rules as the checker, preferring the runnable build-architecture variant of Multi-Arch: foreign tools, and passes virtual names through to apt. Build-Conflicts are now checked before anything installs, which the build-dep passes never did, and a failed dose3 diagnosis no longer masks the resolver error (a latent flaw of the passes: binary-only builds have no .dsc for dose-builddebcheck to read). An end-to-end test pins the expected failure: a cross build whose build-dependencies cannot satisfy dpkg's cross semantics aborts, naming the dependency.
This commit is contained in:
@@ -739,4 +739,74 @@ mod tests {
|
||||
"arch-independant .deb not produced, got: {deb_files:?}"
|
||||
);
|
||||
}
|
||||
|
||||
/// A cross build whose build-dependencies cannot be satisfied under
|
||||
/// dpkg's cross semantics must abort at the install step, naming the
|
||||
/// unsatisfied dependency: the expected-failure counterpart of the
|
||||
/// cross builds above.
|
||||
#[tokio::test]
|
||||
#[test_log::test]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
async fn test_deb_cross_unsatisfiable_build_dep_fails_end_to_end() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let pkg_dir = temp_dir.path().join("pkh-crosstest");
|
||||
std::fs::create_dir_all(pkg_dir.join("debian/source")).unwrap();
|
||||
|
||||
std::fs::write(
|
||||
pkg_dir.join("debian/changelog"),
|
||||
"pkh-crosstest (1.0) noble; urgency=medium\n\n \
|
||||
* Synthetic package declaring an unsatisfiable build-dependency.\n\n \
|
||||
-- pkh tests <pkh@example.com> Tue, 15 Sep 2026 08:00:00 +0000\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(
|
||||
pkg_dir.join("debian/control"),
|
||||
"Source: pkh-crosstest\n\
|
||||
Section: devel\n\
|
||||
Priority: optional\n\
|
||||
Maintainer: pkh tests <pkh@example.com>\n\
|
||||
Standards-Version: 4.7.4\n\
|
||||
Build-Depends: pkh-no-such-package-xyz\n\
|
||||
Architecture: any\n\
|
||||
\n\
|
||||
Package: pkh-crosstest\n\
|
||||
Architecture: any\n\
|
||||
Depends: ${misc:Depends}, ${shlibs:Depends}\n\
|
||||
Description: Cross-build negative regression package\n \
|
||||
Declares a build-dependency absent from the archive.\n",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
std::fs::write(
|
||||
pkg_dir.join("debian/rules"),
|
||||
"#!/usr/bin/make -f\n%:\n\tdh $@\n",
|
||||
)
|
||||
.unwrap();
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let rules = pkg_dir.join("debian/rules");
|
||||
let mut perms = std::fs::metadata(&rules).unwrap().permissions();
|
||||
perms.set_mode(0o755);
|
||||
std::fs::set_permissions(&rules, perms).unwrap();
|
||||
|
||||
std::fs::write(pkg_dir.join("debian/source/format"), "3.0 (native)\n").unwrap();
|
||||
|
||||
let ctx = Arc::new(Context::new(crate::context::ContextConfig::Local).unwrap());
|
||||
|
||||
let err = crate::deb::build_binary_package(DebBuildOptions {
|
||||
arch: Some("arm64".to_string()),
|
||||
series: Some("noble".to_string()),
|
||||
cwd: Some(pkg_dir),
|
||||
cross: true,
|
||||
ctx: Some(ctx),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.expect_err("an unsatisfiable build-dependency must fail the cross build");
|
||||
|
||||
assert!(
|
||||
err.to_string().contains("pkh-no-such-package-xyz"),
|
||||
"error should name the unsatisfied dependency: {err}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user