nixpkgs/pkgs/development/tools/rust/rustup/0001-dynamically-patchelf-binaries.patch

42 lines
1.4 KiB
Diff
Raw Normal View History

2019-04-23 16:37:44 +01:00
diff --git a/src/dist/component/package.rs b/src/dist/component/package.rs
2019-09-13 17:33:24 +01:00
index 4b432785..fa45e87e 100644
2019-04-23 16:37:44 +01:00
--- a/src/dist/component/package.rs
+++ b/src/dist/component/package.rs
2019-09-13 17:33:24 +01:00
@@ -109,10 +109,11 @@ impl Package for DirectoryPackage {
match &*part.0 {
2019-04-23 16:37:44 +01:00
"file" => {
if self.copy {
- builder.copy_file(path.clone(), &src_path)?
+ builder.copy_file(path.clone(), &src_path)?;
} else {
- builder.move_file(path.clone(), &src_path)?
+ builder.move_file(path.clone(), &src_path)?;
}
2018-07-22 10:27:06 +01:00
+ nix_patchelf_if_needed(&target.prefix().path().join(path.clone()), &src_path)
2019-04-23 16:37:44 +01:00
}
"dir" => {
if self.copy {
2019-09-13 17:33:24 +01:00
@@ -135,6 +136,22 @@ impl Package for DirectoryPackage {
}
}
2019-09-13 17:33:24 +01:00
+fn nix_patchelf_if_needed(dest_path: &Path, src_path: &Path) {
+ let is_bin = if let Some(p) = src_path.parent() {
+ p.ends_with("bin")
+ } else {
+ false
+ };
+
+ if is_bin {
+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
+ .arg("--set-interpreter")
+ .arg("@dynamicLinker@")
+ .arg(dest_path)
+ .output();
+ }
+}
+
2019-09-13 17:33:24 +01:00
#[derive(Debug)]
pub struct TarPackage<'a>(DirectoryPackage, temp::Dir<'a>);