2020-04-24 23:36:52 +00:00
|
|
|
diff --git a/src/dist/component/package.rs b/src/dist/component/package.rs
|
2022-08-12 12:06:08 +00:00
|
|
|
index 73a533b5..408ab815 100644
|
2020-04-24 23:36:52 +00:00
|
|
|
--- a/src/dist/component/package.rs
|
|
|
|
+++ b/src/dist/component/package.rs
|
2022-08-12 12:06:08 +00:00
|
|
|
@@ -113,6 +113,7 @@ fn install<'a>(
|
2020-04-24 23:36:52 +00:00
|
|
|
} else {
|
2020-07-18 16:06:22 +00:00
|
|
|
builder.move_file(path.clone(), &src_path)?
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
|
|
|
+ nix_patchelf_if_needed(&target.prefix().path().join(path.clone()), &src_path)
|
|
|
|
}
|
|
|
|
"dir" => {
|
|
|
|
if self.copy {
|
2022-08-12 12:06:08 +00:00
|
|
|
@@ -135,6 +136,29 @@ fn components(&self) -> Vec<String> {
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+fn nix_patchelf_if_needed(dest_path: &Path, src_path: &Path) {
|
2020-07-18 16:06:22 +00:00
|
|
|
+ let (is_bin, is_lib) = if let Some(p) = src_path.parent() {
|
2022-08-12 12:06:08 +00:00
|
|
|
+ (p.ends_with("bin") || p.ends_with("libexec"), p.ends_with("lib"))
|
2020-04-24 23:36:52 +00:00
|
|
|
+ } else {
|
2020-07-18 16:06:22 +00:00
|
|
|
+ (false, false)
|
2020-04-24 23:36:52 +00:00
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if is_bin {
|
|
|
|
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
|
|
|
|
+ .arg("--set-interpreter")
|
|
|
|
+ .arg("@dynamicLinker@")
|
|
|
|
+ .arg(dest_path)
|
|
|
|
+ .output();
|
|
|
|
+ }
|
2020-07-18 16:06:22 +00:00
|
|
|
+ else if is_lib {
|
|
|
|
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
|
|
|
|
+ .arg("--set-rpath")
|
|
|
|
+ .arg("@libPath@")
|
|
|
|
+ .arg(dest_path)
|
|
|
|
+ .output();
|
|
|
|
+ }
|
2020-04-24 23:36:52 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
#[derive(Debug)]
|
2022-08-12 12:06:08 +00:00
|
|
|
pub(crate) struct TarPackage<'a>(DirectoryPackage, temp::Dir<'a>);
|
2020-04-24 23:36:52 +00:00
|
|
|
|