Skip to content

Commit

Permalink
Check multiarch lib dir earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Jan 15, 2025
1 parent 3ae48be commit 63ec807
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<String>> {
pub(crate) fn resolve_with_dpkg(path: &Path, lib_dir_search_path: Option<&Path>) -> CDResult<Vec<String>> {
let temp_folder = tempfile::tempdir()?;
let debian_folder = temp_folder.path().join("debian");
let control_file_path = debian_folder.join("control");
Expand All @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 63ec807

Please sign in to comment.