From 63ec807b483fe78eeacb8fd7e66219fcc2ebdb8c Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 15 Jan 2025 18:28:24 +0100 Subject: [PATCH] Check multiarch lib dir earlier --- src/dependencies.rs | 10 +++------- src/lib.rs | 11 ++++++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/dependencies.rs b/src/dependencies.rs index c2e8f30..078a2f2 100644 --- a/src/dependencies.rs +++ b/src/dependencies.rs @@ -5,7 +5,7 @@ use std::process::Command; const DPKG_SHLIBDEPS_COMMAND: &str = "dpkg-shlibdeps"; /// Resolves the dependencies based on the output of dpkg-shlibdeps on the binary. -pub(crate) fn resolve_with_dpkg(path: &Path, mut lib_dir_search_path: Option<&Path>) -> CDResult> { +pub(crate) fn resolve_with_dpkg(path: &Path, lib_dir_search_path: Option<&Path>) -> CDResult> { let temp_folder = tempfile::tempdir()?; let debian_folder = temp_folder.path().join("debian"); let control_file_path = debian_folder.join("control"); @@ -19,12 +19,8 @@ pub(crate) fn resolve_with_dpkg(path: &Path, mut lib_dir_search_path: Option<&Pa cmd.arg("-O"); // determine library search path from target if let Some(dir) = lib_dir_search_path { - if dir.is_dir() { - cmd.args(["-l".as_ref(), dir.as_os_str()]); - } else { - log::debug!("lib dir doesn't exist: {}", dir.display()); - lib_dir_search_path = None; - } + debug_assert!(dir.exists()); + cmd.args(["-l".as_ref(), dir.as_os_str()]); } let output = cmd .arg(path) diff --git a/src/lib.rs b/src/lib.rs index 5de2dfa..18e2182 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -128,7 +128,14 @@ impl CargoDeb { package_deb.resolve_assets()?; // When cross-compiling, resolve dependencies using libs for the target platform (where multiarch is supported) - let lib_search_path = config.rust_target_triple.as_deref().map(|triple| package_deb.multiarch_lib_dir(triple)); + let mut lib_search_path = config.rust_target_triple.as_deref().map(|triple| package_deb.multiarch_lib_dir(triple)); + if let Some(dir) = lib_search_path.as_deref() { + if !dir.exists() { + log::debug!("lib dir doesn't exist: {}", dir.display()); + lib_search_path = None; + } + } + package_deb.resolve_binary_dependencies(lib_search_path.as_deref(), listener)?; compress_assets(&mut package_deb, listener)?; @@ -399,6 +406,8 @@ pub(crate) fn debian_architecture_from_rust_triple(rust_target_triple: &str) -> #[test] fn ensure_all_rust_targets_map_to_debian_targets() { + assert_eq!(debian_triple_from_rust_triple("armv7-unknown-linux-gnueabihf"), "arm-linux-gnueabihf"); + const DEB_ARCHS: &[&str] = &["alpha", "amd64", "arc", "arm", "arm64", "arm64ilp32", "armel", "armhf", "hppa", "hurd-i386", "hurd-amd64", "i386", "ia64", "kfreebsd-amd64", "kfreebsd-i386", "loong64", "m68k", "mips", "mipsel", "mips64", "mips64el",