diff options
author | Michael Raskin <7c6f434c@mail.ru> | 2008-06-12 07:17:37 +0000 |
---|---|---|
committer | Michael Raskin <7c6f434c@mail.ru> | 2008-06-12 07:17:37 +0000 |
commit | 7be33e7fd15311382bf807d0f109869ab4d4ec0a (patch) | |
tree | 4e529625e4f51dfb585ded3299ee6fc665f65ba4 /pkgs/top-level/builder-defs.nix | |
parent | e8e0d1665ca18214ad751171d4920893400fa472 (diff) | |
download | nixlib-7be33e7fd15311382bf807d0f109869ab4d4ec0a.tar nixlib-7be33e7fd15311382bf807d0f109869ab4d4ec0a.tar.gz nixlib-7be33e7fd15311382bf807d0f109869ab4d4ec0a.tar.bz2 nixlib-7be33e7fd15311382bf807d0f109869ab4d4ec0a.tar.lz nixlib-7be33e7fd15311382bf807d0f109869ab4d4ec0a.tar.xz nixlib-7be33e7fd15311382bf807d0f109869ab4d4ec0a.tar.zst nixlib-7be33e7fd15311382bf807d0f109869ab4d4ec0a.zip |
Ported fixSheBang from stdenv-updates to builder-defs.nix, tested on Metasploit.
No other rebuilds caused. svn path=/nixpkgs/trunk/; revision=12047
Diffstat (limited to 'pkgs/top-level/builder-defs.nix')
-rw-r--r-- | pkgs/top-level/builder-defs.nix | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pkgs/top-level/builder-defs.nix b/pkgs/top-level/builder-defs.nix index e01699767685..f59f916575a8 100644 --- a/pkgs/top-level/builder-defs.nix +++ b/pkgs/top-level/builder-defs.nix @@ -485,4 +485,26 @@ args: with args; with stringsWithDeps; with lib; cp -r . $out/share/${shareName} '') ["doUnpack" "defEnsureDir"]; + doPatchShebangs = dir: FullDepEntry ('' + patchShebangFun() { + # Rewrite all script interpreter file names (`#! /path') under the + # specified directory tree to paths found in $PATH. E.g., + # /bin/sh will be rewritten to /nix/store/<hash>-some-bash/bin/sh. + # Interpreters that are already in the store are left untouched. + header "patching script interpreter paths" + local f + for f in $(find "${dir}" -type f -perm +0100); do + local oldPath=$(sed -ne '1 s,^#![ ]*\([^ ]*\).*$,\1,p' "$f") + if test -n "$oldPath" -a "''${oldPath:0:''${#NIX_STORE}}" != "$NIX_STORE"; then + local newPath=$(type -P $(basename $oldPath) || true) + if test -n "$newPath" -a "$newPath" != "$oldPath"; then + echo "$f: interpreter changed from $oldPath to $newPath" + sed -i "1 s,$oldPath,$newPath," "$f" + fi + fi + done + } + patchShebangFun; + '') ["minInit"]; + }) // args |