* Don't use the "replace-literal" command in stdenv; instead use
bash's pattern replacement feature. "replace-literal" is an uncommon command so it was a headache during the bootstrap. svn path=/nixpkgs/branches/stdenv-updates/; revision=31681
This commit is contained in:
parent
fc89eefa50
commit
0e6fa321bb
@ -11,6 +11,5 @@
|
|||||||
pkgs.gnumake
|
pkgs.gnumake
|
||||||
pkgs.bash
|
pkgs.bash
|
||||||
pkgs.patch
|
pkgs.patch
|
||||||
pkgs.replace
|
|
||||||
pkgs.xz
|
pkgs.xz
|
||||||
]
|
]
|
||||||
|
@ -16,8 +16,6 @@ done
|
|||||||
|
|
||||||
mkdir $out
|
mkdir $out
|
||||||
|
|
||||||
# Can't use substitute() here, because replace may not have been
|
|
||||||
# built yet (in the bootstrap).
|
|
||||||
sed \
|
sed \
|
||||||
-e "s^@preHook@^$_preHook^g" \
|
-e "s^@preHook@^$_preHook^g" \
|
||||||
-e "s^@postHook@^$_postHook^g" \
|
-e "s^@postHook@^$_postHook^g" \
|
||||||
|
@ -315,43 +315,39 @@ substitute() {
|
|||||||
local output="$2"
|
local output="$2"
|
||||||
|
|
||||||
local -a params=("$@")
|
local -a params=("$@")
|
||||||
local -a args=()
|
|
||||||
|
|
||||||
local n p pattern replacement varName
|
local n p pattern replacement varName
|
||||||
|
|
||||||
|
local content="$(cat $input)"
|
||||||
|
|
||||||
for ((n = 2; n < ${#params[*]}; n += 1)); do
|
for ((n = 2; n < ${#params[*]}; n += 1)); do
|
||||||
p=${params[$n]}
|
p=${params[$n]}
|
||||||
|
|
||||||
if test "$p" = "--replace"; then
|
if [ "$p" = --replace ]; then
|
||||||
pattern="${params[$((n + 1))]}"
|
pattern="${params[$((n + 1))]}"
|
||||||
replacement="${params[$((n + 2))]}"
|
replacement="${params[$((n + 2))]}"
|
||||||
n=$((n + 2))
|
n=$((n + 2))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$p" = "--subst-var"; then
|
if [ "$p" = --subst-var ]; then
|
||||||
varName="${params[$((n + 1))]}"
|
varName="${params[$((n + 1))]}"
|
||||||
pattern="@$varName@"
|
pattern="@$varName@"
|
||||||
replacement="${!varName}"
|
replacement="${!varName}"
|
||||||
n=$((n + 1))
|
n=$((n + 1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$p" = "--subst-var-by"; then
|
if [ "$p" = --subst-var-by ]; then
|
||||||
pattern="@${params[$((n + 1))]}@"
|
pattern="@${params[$((n + 1))]}@"
|
||||||
replacement="${params[$((n + 2))]}"
|
replacement="${params[$((n + 2))]}"
|
||||||
n=$((n + 2))
|
n=$((n + 2))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test ${#args[@]} != 0; then
|
content="${content//"$pattern"/$replacement}"
|
||||||
args[${#args[@]}]="-a"
|
|
||||||
fi
|
|
||||||
args[${#args[@]}]="$pattern"
|
|
||||||
args[${#args[@]}]="$replacement"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
replace-literal -e -s -- "${args[@]}" < "$input" > "$output".tmp
|
# !!! This doesn't work properly if $content is "-n".
|
||||||
if test -x "$output"; then
|
echo -n "$content" > "$output".tmp
|
||||||
chmod +x "$output".tmp
|
if [ -x "$output" ]; then chmod +x "$output".tmp; fi
|
||||||
fi
|
|
||||||
mv -f "$output".tmp "$output"
|
mv -f "$output".tmp "$output"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,6 @@ rec {
|
|||||||
cp -d ${gnumake}/bin/* $out/bin
|
cp -d ${gnumake}/bin/* $out/bin
|
||||||
cp -d ${patch}/bin/* $out/bin
|
cp -d ${patch}/bin/* $out/bin
|
||||||
cp ${patchelf}/bin/* $out/bin
|
cp ${patchelf}/bin/* $out/bin
|
||||||
cp ${replace}/bin/* $out/bin
|
|
||||||
|
|
||||||
cp -d ${gnugrep.pcre}/lib/libpcre*.so* $out/lib # needed by grep
|
cp -d ${gnugrep.pcre}/lib/libpcre*.so* $out/lib # needed by grep
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user