summary refs log tree commit diff
path: root/pkgs/tools/networking/edgedb/0001-dynamically-patchelf-binaries.patch
blob: ec2dccfc359a99a7593b0658a9afa91e4debdafc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/src/portable/install.rs b/src/portable/install.rs
index dc0d932..5394fc1 100644
--- a/src/portable/install.rs
+++ b/src/portable/install.rs
@@ -133,8 +133,16 @@ fn unpack_package(cache_file: &Path, target_dir: &Path)
     for entry in arch.entries()? {
         let mut entry = entry?;
         let path = entry.path()?;
+        let is_inside_bin = {
+            let mut path_iter = path.iter();
+            path_iter.next(); // discards first folder
+            path_iter.as_path().starts_with("bin")
+        };
         if let Some(path) = build_path(&target_dir, &*path)? {
-            entry.unpack(path)?;
+            entry.unpack(&path)?;
+            if is_inside_bin {
+                nix_patchelf_if_needed(&path);
+            }
         }
     }
     bar.finish_and_clear();
@@ -203,3 +211,11 @@ pub fn package(pkg_info: &PackageInfo) -> anyhow::Result<InstallInfo> {
 
     Ok(info)
 }
+
+fn nix_patchelf_if_needed(dest_path: &Path) {
+    let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
+        .arg("--set-interpreter")
+        .arg("@dynamicLinker@")
+        .arg(dest_path)
+        .output();
+}