mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 14:41:17 +00:00
* Automatically patch shebang paths ("#! /interpreter") to store
paths. E.g. /usr/bin/perl is rewritten to /nix/store/<whatever Perl is in $PATH>. Paths in the Nix store are left unchanged. Contributed by Nicolas Pierron. svn path=/nixpkgs/branches/stdenv-updates/; revision=12036
This commit is contained in:
parent
5d6247cb96
commit
1000662377
|
@ -688,6 +688,28 @@ patchELF() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
patchShebangs() {
|
||||||
|
# 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 dir="$1"
|
||||||
|
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
|
||||||
|
stopNest
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
installPhase() {
|
installPhase() {
|
||||||
if test -n "$installPhase"; then
|
if test -n "$installPhase"; then
|
||||||
eval "$installPhase"
|
eval "$installPhase"
|
||||||
|
@ -761,6 +783,10 @@ fixupPhase() {
|
||||||
patchELF "$prefix"
|
patchELF "$prefix"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test -z "$dontPatchShebangs"; then
|
||||||
|
patchShebangs "$prefix"
|
||||||
|
fi
|
||||||
|
|
||||||
if test -n "$propagatedBuildInputs"; then
|
if test -n "$propagatedBuildInputs"; then
|
||||||
ensureDir "$out/nix-support"
|
ensureDir "$out/nix-support"
|
||||||
echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
|
echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
|
||||||
|
|
Loading…
Reference in a new issue