Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-18.03 54 lines 2.0 kB view raw
1From c21cc756b69a5f33c8a7758b746a816f40f55932 Mon Sep 17 00:00:00 2001 2From: Leon Isenberg <ljli@users.noreply.github.com> 3Date: Sat, 28 Oct 2017 17:58:17 +0200 4Subject: [PATCH] nix customization: patchelf installed binaries 5 6--- 7 src/rustup-dist/src/component/package.rs | 24 +++++++++++++++++++++++- 8 1 file changed, 23 insertions(+), 1 deletion(-) 9 10diff --git a/src/rustup-dist/src/component/package.rs b/src/rustup-dist/src/component/package.rs 11index 8aa63db9..4d219826 100644 12--- a/src/rustup-dist/src/component/package.rs 13+++ b/src/rustup-dist/src/component/package.rs 14@@ -99,7 +99,13 @@ impl Package for DirectoryPackage { 15 let src_path = root.join(&path); 16 17 match &*part.0 { 18- "file" => try!(builder.copy_file(path.clone(), &src_path)), 19+ "file" => { 20+ try!(builder.copy_file(path.clone(), &src_path)); 21+ nix_patchelf_if_needed( 22+ &target.prefix().path().join(path.clone()), 23+ &src_path, 24+ ) 25+ } 26 "dir" => try!(builder.copy_dir(path.clone(), &src_path)), 27 _ => return Err(ErrorKind::CorruptComponent(name.to_owned()).into()), 28 } 29@@ -117,6 +123,22 @@ impl Package for DirectoryPackage { 30 } 31 } 32 33+fn nix_patchelf_if_needed(dest_path: &Path, src_path: &Path) { 34+ let is_bin = if let Some(p) = src_path.parent() { 35+ p.ends_with("bin") 36+ } else { 37+ false 38+ }; 39+ 40+ if is_bin { 41+ let _ = ::std::process::Command::new("@patchelf@/bin/patchelf") 42+ .arg("--set-interpreter") 43+ .arg("@dynamicLinker@") 44+ .arg(dest_path) 45+ .output(); 46+ } 47+} 48+ 49 // On Unix we need to set up the file permissions correctly so 50 // binaries are executable and directories readable. This shouldn't be 51 // necessary: the source files *should* have the right permissions, 52-- 532.14.1 54