1
1
diff --git a/src/dist/component/package.rs b/src/dist/component/package.rs
2
- index 4b432785..fa45e87e 100644
2
+ index 3beddf54..0f859b8d 100644
3
3
--- a/src/dist/component/package.rs
4
4
+++ b/src/dist/component/package.rs
5
- @@ -109,10 +109,11 @@ impl Package for DirectoryPackage {
6
- match &*part.0 {
7
- "file" => {
8
- if self.copy {
9
- - builder.copy_file(path.clone(), &src_path)?
10
- + builder.copy_file(path.clone(), &src_path)?;
5
+ @@ -113,6 +113,7 @@ impl Package for DirectoryPackage {
11
6
} else {
12
- - builder.move_file(path.clone(), &src_path)?
13
- + builder.move_file(path.clone(), &src_path)?;
7
+ builder.move_file(path.clone(), &src_path)?
14
8
}
15
9
+ nix_patchelf_if_needed(&target.prefix().path().join(path.clone()), &src_path)
16
10
}
17
11
"dir" => {
18
12
if self.copy {
19
- @@ -135,6 +136,22 @@ impl Package for DirectoryPackage {
13
+ @@ -135,6 +136,29 @@ impl Package for DirectoryPackage {
20
14
}
21
15
}
22
16
23
17
+ fn nix_patchelf_if_needed(dest_path: &Path, src_path: &Path) {
24
- + let is_bin = if let Some(p) = src_path.parent() {
25
- + p.ends_with("bin")
18
+ + let ( is_bin, is_lib) = if let Some(p) = src_path.parent() {
19
+ + ( p.ends_with("bin"), p.ends_with("lib") )
26
20
+ } else {
27
- + false
21
+ + ( false, false)
28
22
+ };
29
23
+
30
24
+ if is_bin {
@@ -34,6 +28,13 @@ index 4b432785..fa45e87e 100644
34
28
+ .arg(dest_path)
35
29
+ .output();
36
30
+ }
31
+ + else if is_lib {
32
+ + let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
33
+ + .arg("--set-rpath")
34
+ + .arg("@libPath@")
35
+ + .arg(dest_path)
36
+ + .output();
37
+ + }
37
38
+ }
38
39
+
39
40
#[derive(Debug)]
0 commit comments