ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / ca / cargo-bisect-rustc / 0001-dynamically-patchelf-binaries.patch
blob3df226835ab914474fccdfb249af580295f24e94
1 diff --git a/src/toolchains.rs b/src/toolchains.rs
2 index 53a7ddb..795a711 100644
3 --- a/src/toolchains.rs
4 +++ b/src/toolchains.rs
5 @@ -206,6 +206,8 @@ impl Toolchain {
6 })?;
9 + nix_patchelf(tmpdir.path().to_path_buf())
10 + .expect("failed to patch toolchain for NixOS");
11 fs::rename(tmpdir.into_path(), dest).map_err(InstallError::Move)
14 @@ -533,3 +535,42 @@ fn download_tarball(
15 res => res,
19 +fn nix_patchelf(mut toolchain_path: PathBuf) -> io::Result<()> {
20 + toolchain_path.push("bin");
22 + for entry in toolchain_path.read_dir()? {
23 + let entry = entry?;
24 + if !entry.file_type()?.is_file() {
25 + continue;
26 + }
28 + eprintln!("info: you seem to be running NixOS. Attempting to patch {}",
29 + entry.path().to_str().unwrap());
30 + let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
31 + .arg("--set-interpreter")
32 + .arg("@dynamicLinker@")
33 + .arg(entry.path())
34 + .output();
35 + }
37 + toolchain_path.pop();
38 + toolchain_path.push("lib");
40 + for entry in toolchain_path.read_dir()? {
41 + let entry = entry?;
42 + if !entry.file_type()?.is_file() {
43 + continue;
44 + }
46 + eprintln!("info: you seem to be running NixOS. Attempting to patch {}",
47 + entry.path().to_str().unwrap());
48 + let _ = ::std::process::Command::new("@patchelf@/bin/patchelf")
49 + .arg("--set-rpath")
50 + .arg("@libPath@")
51 + .arg(entry.path())
52 + .output();
53 + }
55 + Ok(())