2006-08-15 23:25:14 +02:00
|
|
|
if test -z "$out"; then
|
|
|
|
out="$OUT"
|
|
|
|
initialPath="$INITIALPATH"
|
2006-08-17 02:54:32 +02:00
|
|
|
shell="$SHELL"
|
2006-08-15 23:25:14 +02:00
|
|
|
fi
|
|
|
|
|
2006-08-15 16:46:41 +02:00
|
|
|
setupPath=
|
|
|
|
for i in $initialPath; do
|
|
|
|
setupPath=$setupPath${setupPath:+:}$i
|
|
|
|
done
|
|
|
|
|
|
|
|
PATH=$setupPath
|
2006-08-15 23:25:14 +02:00
|
|
|
export PATH
|
2006-08-15 16:46:41 +02:00
|
|
|
|
|
|
|
mkdir $out
|
2006-08-15 23:25:14 +02:00
|
|
|
|
2006-08-15 16:46:41 +02:00
|
|
|
cat > $out/setup <<EOF
|
|
|
|
PATH=$setupPath
|
|
|
|
export PATH
|
|
|
|
|
|
|
|
SHELL=$shell
|
|
|
|
export SHELL
|
|
|
|
|
|
|
|
# make fetchurl usable
|
|
|
|
header() {
|
|
|
|
echo "\$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
stopNest() {
|
|
|
|
echo "Nothing to do"
|
|
|
|
}
|
2006-12-31 20:07:33 +01:00
|
|
|
|
|
|
|
# !!! Awful copy&paste.
|
|
|
|
substitute() {
|
|
|
|
local input="\$1"
|
|
|
|
local output="\$2"
|
|
|
|
|
|
|
|
local -a params=("\$@")
|
|
|
|
|
|
|
|
local sedScript=\$NIX_BUILD_TOP/.sedargs
|
|
|
|
rm -f \$sedScript
|
|
|
|
touch \$sedScript
|
|
|
|
|
|
|
|
local n p pattern replacement varName
|
|
|
|
|
|
|
|
for ((n = 2; n < \${#params[*]}; n += 1)); do
|
|
|
|
p=\${params[\$n]}
|
|
|
|
|
|
|
|
if test "\$p" = "--replace"; then
|
|
|
|
pattern=\${params[\$((n + 1))]}
|
|
|
|
replacement=\${params[\$((n + 2))]}
|
|
|
|
n=\$((n + 2))
|
|
|
|
echo "s^\$pattern^\$replacement^g" >> \$sedScript
|
|
|
|
sedArgs=("\${sedArgs[@]}" "-e" )
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "\$p" = "--subst-var"; then
|
|
|
|
varName=\${params[\$((n + 1))]}
|
|
|
|
n=\$((n + 1))
|
|
|
|
echo "s^@\${varName}@^\${!varName}^g" >> \$sedScript
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test "\$p" = "--subst-var-by"; then
|
|
|
|
varName=\${params[\$((n + 1))]}
|
|
|
|
replacement=\${params[\$((n + 2))]}
|
|
|
|
n=\$((n + 2))
|
|
|
|
echo "s^@\${varName}@^\$replacement^g" >> \$sedScript
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
sed -f \$sedScript < "\$input" > "\$output".tmp
|
|
|
|
if test -x "\$output"; then
|
|
|
|
chmod +x "\$output".tmp
|
|
|
|
fi
|
|
|
|
mv -f "\$output".tmp "\$output"
|
|
|
|
}
|
2006-08-15 16:46:41 +02:00
|
|
|
EOF
|
2006-08-15 23:25:14 +02:00
|
|
|
|
2006-08-15 16:46:41 +02:00
|
|
|
chmod +x $out/setup
|