* substitute() in stdenv: use the replace program instead of awful
sed hackery. * Some indentation fixes in setup.sh. svn path=/nixpkgs/branches/stdenv-updates/; revision=10658
This commit is contained in:
parent
3db3e079af
commit
5f45fb3ae9
@ -50,14 +50,17 @@ fi
|
||||
doSubstitute() {
|
||||
local src=$1
|
||||
local dst=$2
|
||||
substitute "$src" "$dst" \
|
||||
--subst-var "out" \
|
||||
--subst-var "shell" \
|
||||
--subst-var "gcc" \
|
||||
--subst-var "gccProg" \
|
||||
--subst-var "binutils" \
|
||||
--subst-var "libc" \
|
||||
--subst-var-by "ld" "$ldPath/ld"
|
||||
# Can't use substitute() here, because replace may not have been
|
||||
# built yet (in the bootstrap).
|
||||
sed \
|
||||
-e "s^@out@^$out^" \
|
||||
-e "s^@shell@^$shell^" \
|
||||
-e "s^@gcc@^$gcc^" \
|
||||
-e "s^@gccProg@^$gccProg^" \
|
||||
-e "s^@binutils@^$binutils^" \
|
||||
-e "s^@libc@^$libc^" \
|
||||
-e "s^@ld@^$ldPath/ld^" \
|
||||
< "$src" > "$dst"
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,8 +12,9 @@ preConfigure=preConfigure
|
||||
preConfigure() {
|
||||
|
||||
for i in configure io/ftwtest-sh; do
|
||||
substituteInPlace "$i" \
|
||||
--replace "@PWD@" "pwd"
|
||||
# Can't use substituteInPlace here because replace hasn't been
|
||||
# built yet in the bootstrap.
|
||||
sed -i "$i" -e "s^/bin/pwd^$(type -tP pwd)^"
|
||||
done
|
||||
|
||||
# In the glibc 2.6/2.7 tarballs C-translit.h is a little bit older
|
||||
|
@ -12,8 +12,6 @@ stdenv.mkDerivation {
|
||||
sha256 = "06j5q20l11x8kcrl9bg15xgb1pw0w82pazikxf4zvq2fmhiaa922";
|
||||
};
|
||||
|
||||
patches = [ ./glibc-pwd.patch ./glibc-getcwd-param-MAX.patch ];
|
||||
|
||||
inherit kernelHeaders installLocales;
|
||||
|
||||
inherit (stdenv) is64bit;
|
||||
|
@ -1,14 +0,0 @@
|
||||
2006-06-18 Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
* sysdeps/unix/sysv/linux/getcwd.c: Include sys/param.h.
|
||||
|
||||
--- glibc-old/sysdeps/unix/sysv/linux/getcwd.c
|
||||
+++ glibc-new/sysdeps/unix/sysv/linux/getcwd.c
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
+#include <sys/param.h>
|
||||
|
||||
#include <sysdep.h>
|
||||
#include <sys/syscall.h>
|
@ -1,74 +0,0 @@
|
||||
diff -ruN glibc-20050110/configure glibc-20050110.patched/configure
|
||||
--- glibc-20050110/configure 2005-01-05 10:39:53.000000000 +0100
|
||||
+++ glibc-20050110.patched/configure 2005-01-18 13:33:01.000000000 +0100
|
||||
@@ -1393,7 +1393,7 @@
|
||||
ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
|
||||
|
||||
|
||||
-if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then
|
||||
+if test "`cd $srcdir; @PWD@`" = "`@PWD@`"; then
|
||||
{ { echo "$as_me:$LINENO: error: you must configure in a separate build directory" >&5
|
||||
echo "$as_me: error: you must configure in a separate build directory" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
diff -ruN glibc-20050110/io/ftwtest-sh glibc-20050110.patched/io/ftwtest-sh
|
||||
--- glibc-20050110/io/ftwtest-sh 2004-02-09 21:12:23.000000000 +0100
|
||||
+++ glibc-20050110.patched/io/ftwtest-sh 2005-01-18 13:33:15.000000000 +0100
|
||||
@@ -120,7 +120,7 @@
|
||||
sort > $testout
|
||||
|
||||
# perhaps $tmp involves some symlinks...
|
||||
-tmpreal=`cd $tmp; /bin/pwd 2>/dev/null || /usr/bin/pwd`
|
||||
+tmpreal=`cd $tmp; @PWD@ 2>/dev/null || /usr/bin/pwd`
|
||||
|
||||
cat <<EOF | cmp $testout - || exit 1
|
||||
base = "$tmp/", file = "ftwtest.d", flag = FTW_D, cwd = $tmpreal, level = 0
|
||||
@@ -138,7 +138,7 @@
|
||||
EOF
|
||||
rm $testout
|
||||
|
||||
-curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
|
||||
+curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
|
||||
cd "$tmp"
|
||||
LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d |
|
||||
sort > $testout
|
||||
@@ -160,7 +160,7 @@
|
||||
EOF
|
||||
rm $testout
|
||||
|
||||
-curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
|
||||
+curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
|
||||
cd "$tmp"
|
||||
LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/. |
|
||||
sort > $testout
|
||||
@@ -182,7 +182,7 @@
|
||||
EOF
|
||||
rm $testout
|
||||
|
||||
-curwd=`/bin/pwd 2>/dev/null || /usr/bin/pwd`
|
||||
+curwd=`@PWD@ 2>/dev/null || /usr/bin/pwd`
|
||||
cd "$tmp"
|
||||
LD_LIBRARY_PATH=$objpfx $ldso $testprogram --chdir ftwtest.d/foo/lvl1/link@1 |
|
||||
sort > $testout
|
||||
diff -ruN glibc-20050110/scripts/rellns-sh glibc-20050110.patched/scripts/rellns-sh
|
||||
--- glibc-20050110/scripts/rellns-sh 1999-12-19 00:40:25.000000000 +0100
|
||||
+++ glibc-20050110.patched/scripts/rellns-sh 2005-01-18 13:35:53.245937423 +0100
|
||||
@@ -22,13 +22,13 @@
|
||||
exit 1
|
||||
fi
|
||||
|
||||
-if test -x /bin/pwd; then
|
||||
- pwd=/bin/pwd
|
||||
-elif test -x /usr/bin/pwd; then
|
||||
- pwd=/usr/bin/pwd
|
||||
-else
|
||||
+#if test -x /bin/pwd; then
|
||||
+# pwd=/bin/pwd
|
||||
+#elif test -x /usr/bin/pwd; then
|
||||
+# pwd=/usr/bin/pwd
|
||||
+#else
|
||||
pwd='pwd'
|
||||
-fi
|
||||
+#fi
|
||||
|
||||
# Make both paths absolute.
|
||||
if test -d $1; then
|
@ -11,4 +11,5 @@
|
||||
pkgs.gnumake
|
||||
pkgs.bash
|
||||
pkgs.patch
|
||||
pkgs.replace
|
||||
]
|
||||
|
@ -3,3 +3,5 @@ export NIX_ENFORCE_PURITY=
|
||||
if test -z "$cygwinConfigureEnableShared"; then
|
||||
export configureFlags="$configureFlags --disable-shared"
|
||||
fi
|
||||
|
||||
PATH_DELIMITER=';'
|
||||
|
@ -8,14 +8,17 @@ source $stdenv/setup
|
||||
|
||||
mkdir $out
|
||||
|
||||
substitute "$setup" "$out/setup" \
|
||||
--subst-var preHook \
|
||||
--subst-var postHook \
|
||||
--subst-var initialPath \
|
||||
--subst-var gcc \
|
||||
--subst-var shell \
|
||||
--subst-var-by param1 "$p1" \
|
||||
--subst-var-by param2 "$p2" \
|
||||
--subst-var-by param3 "$p3" \
|
||||
--subst-var-by param4 "$p4" \
|
||||
--subst-var-by param5 "$p5"
|
||||
# Can't use substitute() here, because replace may not have been
|
||||
# built yet (in the bootstrap).
|
||||
sed \
|
||||
-e "s^@preHook@^$preHook^" \
|
||||
-e "s^@postHook@^$postHook^" \
|
||||
-e "s^@initialPath@^$initialPath^" \
|
||||
-e "s^@gcc@^$gcc^" \
|
||||
-e "s^@shell@^$shell^" \
|
||||
-e "s^@param1@^$p1^" \
|
||||
-e "s^@param2@^$p2^" \
|
||||
-e "s^@param3@^$p3^" \
|
||||
-e "s^@param4@^$p4^" \
|
||||
-e "s^@param5@^$p5^" \
|
||||
< "$setup" > "$out/setup"
|
||||
|
@ -2,11 +2,9 @@ set -e
|
||||
|
||||
test -z $NIX_GCC && NIX_GCC=@gcc@
|
||||
|
||||
if [ -z ${system##*cygwin*} ]; then
|
||||
PATH_DELIMITER=';'
|
||||
else
|
||||
PATH_DELIMITER=':'
|
||||
fi
|
||||
|
||||
# Helper functions that might be useful in setup hooks.
|
||||
|
||||
|
||||
addToSearchPathWithCustomDelimiter() {
|
||||
local delimiter=$1
|
||||
@ -28,6 +26,7 @@ addToSearchPath()
|
||||
addToSearchPathWithCustomDelimiter "${PATH_DELIMITER}" "$@"
|
||||
}
|
||||
|
||||
|
||||
# Set up the initial path.
|
||||
PATH=
|
||||
for i in $NIX_GCC @initialPath@; do
|
||||
@ -41,6 +40,7 @@ fi
|
||||
|
||||
# Execute the pre-hook.
|
||||
export SHELL=@shell@
|
||||
PATH_DELIMITER=':'
|
||||
if test -z "$shell"; then
|
||||
export shell=@shell@
|
||||
fi
|
||||
@ -234,27 +234,17 @@ stripDirs() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
######################################################################
|
||||
# Textual substitution functions.
|
||||
|
||||
|
||||
# Some disgusting hackery to escape replacements in Sed substitutions.
|
||||
# We should really have a tool that replaces literal values by other
|
||||
# literal values, without any need for escaping.
|
||||
escapeSed() {
|
||||
local s="$1"
|
||||
# The `tr' hack is to escape newlines. Sed handles newlines very
|
||||
# badly, so we just replace newlines with the magic character 0xff
|
||||
# (377 octal). So don't use that character in replacements :-P
|
||||
echo -n "$1" | tr '\012' '\377' | sed -e 's^\\^\\\\^g' -e 's^\xff^\\n^g' -e 's/\^/\\^/g' -e 's/&/\\&/g'
|
||||
}
|
||||
|
||||
|
||||
substitute() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
|
||||
local -a params=("$@")
|
||||
local -a args=()
|
||||
|
||||
local sedScript=$NIX_BUILD_TOP/.sedargs
|
||||
rm -f $sedScript
|
||||
@ -284,12 +274,14 @@ substitute() {
|
||||
n=$((n + 2))
|
||||
fi
|
||||
|
||||
replacement="$(escapeSed "$replacement")"
|
||||
|
||||
echo "s^$pattern^$replacement^g" >> $sedScript
|
||||
if test ${#args[@]} != 0; then
|
||||
args[${#args[@]}]="-a"
|
||||
fi
|
||||
args[${#args[@]}]="$pattern"
|
||||
args[${#args[@]}]="$replacement"
|
||||
done
|
||||
|
||||
sed -f $sedScript < "$input" > "$output".tmp
|
||||
replace -e -s "${args[@]}" < "$input" > "$output".tmp
|
||||
if test -x "$output"; then
|
||||
chmod +x "$output".tmp
|
||||
fi
|
||||
@ -537,7 +529,7 @@ unpackW() {
|
||||
|
||||
|
||||
unpackPhase() {
|
||||
sourceRoot=. # don't change to user dir homeless shelter if custom unpackSource does'nt set sourceRoot
|
||||
sourceRoot=. # don't change to user dir homeless shelter if custom unpackSource doesn't set sourceRoot
|
||||
header "unpacking sources"
|
||||
startLog "unpack"
|
||||
unpackW
|
||||
@ -751,28 +743,26 @@ fixupW() {
|
||||
|
||||
eval "$preFixup"
|
||||
|
||||
forceShare=${forceShare:=man doc info}
|
||||
if test -n "$forceShare"; then
|
||||
for d in $forceShare; do
|
||||
if test -d "$prefix/$d"; then
|
||||
if test -d "$prefix/share/$d"; then
|
||||
echo "Both $d/ and share/$d/ exists!"
|
||||
else
|
||||
# Put man/doc/info under $out/share.
|
||||
forceShare=${forceShare:=man doc info}
|
||||
if test -n "$forceShare"; then
|
||||
for d in $forceShare; do
|
||||
if test -d "$prefix/$d"; then
|
||||
if test -d "$prefix/share/$d"; then
|
||||
echo "Both $d/ and share/$d/ exists!"
|
||||
else
|
||||
echo Fixing location of $d/ subdirectory
|
||||
ensureDir $prefix/share
|
||||
ensureDir $prefix/share
|
||||
if test -w $prefix/share; then
|
||||
mv -v $prefix/$d $prefix/share
|
||||
ln -sv share/$d $prefix
|
||||
mv -v $prefix/$d $prefix/share
|
||||
ln -sv share/$d $prefix
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "No $d/ subdirectory, skipping."
|
||||
fi
|
||||
done;
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done;
|
||||
fi
|
||||
|
||||
|
||||
# TODO : strip _only_ ELF executables, and return || fail here...
|
||||
# TODO: strip _only_ ELF executables, and return || fail here...
|
||||
if test -z "$dontStrip"; then
|
||||
echo "Stripping debuging symbols from files in"
|
||||
stripDirs "${stripDebugList:-lib}" -S
|
||||
|
@ -1,4 +1,5 @@
|
||||
{stdenv, fetchurl}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "replace-2.24";
|
||||
|
||||
@ -7,14 +8,10 @@ stdenv.mkDerivation {
|
||||
sha256 = "1c2nkxx83vmlh1v3ib6r2xqh121gdb1rharwsimcb2h0xwc558dm";
|
||||
};
|
||||
|
||||
buildInputs = [];
|
||||
makeFlags = " TREE=\$(out) ";
|
||||
|
||||
postInstall = "mv \$out/bin/replace \$out/bin/replace-literal";
|
||||
makeFlags = "TREE=\$(out)";
|
||||
|
||||
meta = {
|
||||
description = "
|
||||
Replace verbatim strings. Sed is not fit to do it. Replace is.
|
||||
";
|
||||
homepage = http://replace.richardlloyd.org.uk/;
|
||||
description = "A tool to replace verbatim strings";
|
||||
};
|
||||
}
|
||||
|
@ -321,6 +321,7 @@ rec {
|
||||
nukeReferences = import ../build-support/nuke-references/default.nix {
|
||||
inherit stdenv;
|
||||
};
|
||||
|
||||
|
||||
### TOOLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user