* 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:
Eelco Dolstra 2012-01-19 13:47:26 +00:00
parent fc89eefa50
commit 0e6fa321bb
4 changed files with 9 additions and 17 deletions

View file

@ -11,6 +11,5 @@
pkgs.gnumake
pkgs.bash
pkgs.patch
pkgs.replace
pkgs.xz
]

View file

@ -16,8 +16,6 @@ done
mkdir $out
# Can't use substitute() here, because replace may not have been
# built yet (in the bootstrap).
sed \
-e "s^@preHook@^$_preHook^g" \
-e "s^@postHook@^$_postHook^g" \

View file

@ -315,43 +315,39 @@ substitute() {
local output="$2"
local -a params=("$@")
local -a args=()
local n p pattern replacement varName
local content="$(cat $input)"
for ((n = 2; n < ${#params[*]}; n += 1)); do
p=${params[$n]}
if test "$p" = "--replace"; then
if [ "$p" = --replace ]; then
pattern="${params[$((n + 1))]}"
replacement="${params[$((n + 2))]}"
n=$((n + 2))
fi
if test "$p" = "--subst-var"; then
if [ "$p" = --subst-var ]; then
varName="${params[$((n + 1))]}"
pattern="@$varName@"
replacement="${!varName}"
n=$((n + 1))
fi
if test "$p" = "--subst-var-by"; then
if [ "$p" = --subst-var-by ]; then
pattern="@${params[$((n + 1))]}@"
replacement="${params[$((n + 2))]}"
n=$((n + 2))
fi
if test ${#args[@]} != 0; then
args[${#args[@]}]="-a"
fi
args[${#args[@]}]="$pattern"
args[${#args[@]}]="$replacement"
content="${content//"$pattern"/$replacement}"
done
replace-literal -e -s -- "${args[@]}" < "$input" > "$output".tmp
if test -x "$output"; then
chmod +x "$output".tmp
fi
# !!! This doesn't work properly if $content is "-n".
echo -n "$content" > "$output".tmp
if [ -x "$output" ]; then chmod +x "$output".tmp; fi
mv -f "$output".tmp "$output"
}

View file

@ -133,7 +133,6 @@ rec {
cp -d ${gnumake}/bin/* $out/bin
cp -d ${patch}/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