2017-10-29 21:32:40 +01:00
|
|
|
From c21cc756b69a5f33c8a7758b746a816f40f55932 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Leon Isenberg <ljli@users.noreply.github.com>
|
|
|
|
Date: Sat, 28 Oct 2017 17:58:17 +0200
|
|
|
|
Subject: [PATCH] nix customization: patchelf installed binaries
|
|
|
|
|
|
|
|
---
|
2018-07-22 11:27:06 +02:00
|
|
|
src/rustup-dist/src/component/package.rs | 21 ++++++++++++++++++++-
|
|
|
|
1 file changed, 20 insertions(+), 1 deletion(-)
|
2017-10-29 21:32:40 +01:00
|
|
|
|
|
|
|
diff --git a/src/rustup-dist/src/component/package.rs b/src/rustup-dist/src/component/package.rs
|
2018-07-22 11:27:06 +02:00
|
|
|
index 70c54dcd..f0318986 100644
|
2017-10-29 21:32:40 +01:00
|
|
|
--- a/src/rustup-dist/src/component/package.rs
|
|
|
|
+++ b/src/rustup-dist/src/component/package.rs
|
2018-07-22 11:27:06 +02:00
|
|
|
@@ -100,7 +100,10 @@ impl Package for DirectoryPackage {
|
2017-10-29 21:32:40 +01:00
|
|
|
let src_path = root.join(&path);
|
|
|
|
|
|
|
|
match &*part.0 {
|
2018-07-22 11:27:06 +02:00
|
|
|
- "file" => builder.copy_file(path.clone(), &src_path)?,
|
2017-10-29 21:32:40 +01:00
|
|
|
+ "file" => {
|
2018-07-22 11:27:06 +02:00
|
|
|
+ builder.copy_file(path.clone(), &src_path)?;
|
|
|
|
+ nix_patchelf_if_needed(&target.prefix().path().join(path.clone()), &src_path)
|
2017-10-29 21:32:40 +01:00
|
|
|
+ }
|
2018-07-22 11:27:06 +02:00
|
|
|
"dir" => builder.copy_dir(path.clone(), &src_path)?,
|
2017-10-29 21:32:40 +01:00
|
|
|
_ => return Err(ErrorKind::CorruptComponent(name.to_owned()).into()),
|
|
|
|
}
|
2018-07-22 11:27:06 +02:00
|
|
|
@@ -118,6 +121,22 @@ impl Package for DirectoryPackage {
|
2017-10-29 21:32:40 +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();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
// On Unix we need to set up the file permissions correctly so
|
|
|
|
// binaries are executable and directories readable. This shouldn't be
|
|
|
|
// necessary: the source files *should* have the right permissions,
|
|
|
|
--
|
2018-07-22 11:27:06 +02:00
|
|
|
2.17.1
|
2017-10-29 21:32:40 +01:00
|
|
|
|