* 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() {
|
doSubstitute() {
|
||||||
local src=$1
|
local src=$1
|
||||||
local dst=$2
|
local dst=$2
|
||||||
substitute "$src" "$dst" \
|
# Can't use substitute() here, because replace may not have been
|
||||||
--subst-var "out" \
|
# built yet (in the bootstrap).
|
||||||
--subst-var "shell" \
|
sed \
|
||||||
--subst-var "gcc" \
|
-e "s^@out@^$out^" \
|
||||||
--subst-var "gccProg" \
|
-e "s^@shell@^$shell^" \
|
||||||
--subst-var "binutils" \
|
-e "s^@gcc@^$gcc^" \
|
||||||
--subst-var "libc" \
|
-e "s^@gccProg@^$gccProg^" \
|
||||||
--subst-var-by "ld" "$ldPath/ld"
|
-e "s^@binutils@^$binutils^" \
|
||||||
|
-e "s^@libc@^$libc^" \
|
||||||
|
-e "s^@ld@^$ldPath/ld^" \
|
||||||
|
< "$src" > "$dst"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,8 +12,9 @@ preConfigure=preConfigure
|
|||||||
preConfigure() {
|
preConfigure() {
|
||||||
|
|
||||||
for i in configure io/ftwtest-sh; do
|
for i in configure io/ftwtest-sh; do
|
||||||
substituteInPlace "$i" \
|
# Can't use substituteInPlace here because replace hasn't been
|
||||||
--replace "@PWD@" "pwd"
|
# built yet in the bootstrap.
|
||||||
|
sed -i "$i" -e "s^/bin/pwd^$(type -tP pwd)^"
|
||||||
done
|
done
|
||||||
|
|
||||||
# In the glibc 2.6/2.7 tarballs C-translit.h is a little bit older
|
# In the glibc 2.6/2.7 tarballs C-translit.h is a little bit older
|
||||||
|
@ -12,8 +12,6 @@ stdenv.mkDerivation {
|
|||||||
sha256 = "06j5q20l11x8kcrl9bg15xgb1pw0w82pazikxf4zvq2fmhiaa922";
|
sha256 = "06j5q20l11x8kcrl9bg15xgb1pw0w82pazikxf4zvq2fmhiaa922";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [ ./glibc-pwd.patch ./glibc-getcwd-param-MAX.patch ];
|
|
||||||
|
|
||||||
inherit kernelHeaders installLocales;
|
inherit kernelHeaders installLocales;
|
||||||
|
|
||||||
inherit (stdenv) is64bit;
|
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.gnumake
|
||||||
pkgs.bash
|
pkgs.bash
|
||||||
pkgs.patch
|
pkgs.patch
|
||||||
|
pkgs.replace
|
||||||
]
|
]
|
||||||
|
@ -3,3 +3,5 @@ export NIX_ENFORCE_PURITY=
|
|||||||
if test -z "$cygwinConfigureEnableShared"; then
|
if test -z "$cygwinConfigureEnableShared"; then
|
||||||
export configureFlags="$configureFlags --disable-shared"
|
export configureFlags="$configureFlags --disable-shared"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PATH_DELIMITER=';'
|
||||||
|
@ -8,14 +8,17 @@ source $stdenv/setup
|
|||||||
|
|
||||||
mkdir $out
|
mkdir $out
|
||||||
|
|
||||||
substitute "$setup" "$out/setup" \
|
# Can't use substitute() here, because replace may not have been
|
||||||
--subst-var preHook \
|
# built yet (in the bootstrap).
|
||||||
--subst-var postHook \
|
sed \
|
||||||
--subst-var initialPath \
|
-e "s^@preHook@^$preHook^" \
|
||||||
--subst-var gcc \
|
-e "s^@postHook@^$postHook^" \
|
||||||
--subst-var shell \
|
-e "s^@initialPath@^$initialPath^" \
|
||||||
--subst-var-by param1 "$p1" \
|
-e "s^@gcc@^$gcc^" \
|
||||||
--subst-var-by param2 "$p2" \
|
-e "s^@shell@^$shell^" \
|
||||||
--subst-var-by param3 "$p3" \
|
-e "s^@param1@^$p1^" \
|
||||||
--subst-var-by param4 "$p4" \
|
-e "s^@param2@^$p2^" \
|
||||||
--subst-var-by param5 "$p5"
|
-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@
|
test -z $NIX_GCC && NIX_GCC=@gcc@
|
||||||
|
|
||||||
if [ -z ${system##*cygwin*} ]; then
|
|
||||||
PATH_DELIMITER=';'
|
# Helper functions that might be useful in setup hooks.
|
||||||
else
|
|
||||||
PATH_DELIMITER=':'
|
|
||||||
fi
|
|
||||||
|
|
||||||
addToSearchPathWithCustomDelimiter() {
|
addToSearchPathWithCustomDelimiter() {
|
||||||
local delimiter=$1
|
local delimiter=$1
|
||||||
@ -28,6 +26,7 @@ addToSearchPath()
|
|||||||
addToSearchPathWithCustomDelimiter "${PATH_DELIMITER}" "$@"
|
addToSearchPathWithCustomDelimiter "${PATH_DELIMITER}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Set up the initial path.
|
# Set up the initial path.
|
||||||
PATH=
|
PATH=
|
||||||
for i in $NIX_GCC @initialPath@; do
|
for i in $NIX_GCC @initialPath@; do
|
||||||
@ -41,6 +40,7 @@ fi
|
|||||||
|
|
||||||
# Execute the pre-hook.
|
# Execute the pre-hook.
|
||||||
export SHELL=@shell@
|
export SHELL=@shell@
|
||||||
|
PATH_DELIMITER=':'
|
||||||
if test -z "$shell"; then
|
if test -z "$shell"; then
|
||||||
export shell=@shell@
|
export shell=@shell@
|
||||||
fi
|
fi
|
||||||
@ -234,27 +234,17 @@ stripDirs() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Textual substitution functions.
|
# 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() {
|
substitute() {
|
||||||
local input="$1"
|
local input="$1"
|
||||||
local output="$2"
|
local output="$2"
|
||||||
|
|
||||||
local -a params=("$@")
|
local -a params=("$@")
|
||||||
|
local -a args=()
|
||||||
|
|
||||||
local sedScript=$NIX_BUILD_TOP/.sedargs
|
local sedScript=$NIX_BUILD_TOP/.sedargs
|
||||||
rm -f $sedScript
|
rm -f $sedScript
|
||||||
@ -284,12 +274,14 @@ substitute() {
|
|||||||
n=$((n + 2))
|
n=$((n + 2))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
replacement="$(escapeSed "$replacement")"
|
if test ${#args[@]} != 0; then
|
||||||
|
args[${#args[@]}]="-a"
|
||||||
echo "s^$pattern^$replacement^g" >> $sedScript
|
fi
|
||||||
|
args[${#args[@]}]="$pattern"
|
||||||
|
args[${#args[@]}]="$replacement"
|
||||||
done
|
done
|
||||||
|
|
||||||
sed -f $sedScript < "$input" > "$output".tmp
|
replace -e -s "${args[@]}" < "$input" > "$output".tmp
|
||||||
if test -x "$output"; then
|
if test -x "$output"; then
|
||||||
chmod +x "$output".tmp
|
chmod +x "$output".tmp
|
||||||
fi
|
fi
|
||||||
@ -537,7 +529,7 @@ unpackW() {
|
|||||||
|
|
||||||
|
|
||||||
unpackPhase() {
|
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"
|
header "unpacking sources"
|
||||||
startLog "unpack"
|
startLog "unpack"
|
||||||
unpackW
|
unpackW
|
||||||
@ -751,28 +743,26 @@ fixupW() {
|
|||||||
|
|
||||||
eval "$preFixup"
|
eval "$preFixup"
|
||||||
|
|
||||||
forceShare=${forceShare:=man doc info}
|
# Put man/doc/info under $out/share.
|
||||||
if test -n "$forceShare"; then
|
forceShare=${forceShare:=man doc info}
|
||||||
for d in $forceShare; do
|
if test -n "$forceShare"; then
|
||||||
if test -d "$prefix/$d"; then
|
for d in $forceShare; do
|
||||||
if test -d "$prefix/share/$d"; then
|
if test -d "$prefix/$d"; then
|
||||||
echo "Both $d/ and share/$d/ exists!"
|
if test -d "$prefix/share/$d"; then
|
||||||
else
|
echo "Both $d/ and share/$d/ exists!"
|
||||||
|
else
|
||||||
echo Fixing location of $d/ subdirectory
|
echo Fixing location of $d/ subdirectory
|
||||||
ensureDir $prefix/share
|
ensureDir $prefix/share
|
||||||
if test -w $prefix/share; then
|
if test -w $prefix/share; then
|
||||||
mv -v $prefix/$d $prefix/share
|
mv -v $prefix/$d $prefix/share
|
||||||
ln -sv share/$d $prefix
|
ln -sv share/$d $prefix
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
fi
|
||||||
echo "No $d/ subdirectory, skipping."
|
done;
|
||||||
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
|
if test -z "$dontStrip"; then
|
||||||
echo "Stripping debuging symbols from files in"
|
echo "Stripping debuging symbols from files in"
|
||||||
stripDirs "${stripDebugList:-lib}" -S
|
stripDirs "${stripDebugList:-lib}" -S
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{stdenv, fetchurl}:
|
{stdenv, fetchurl}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "replace-2.24";
|
name = "replace-2.24";
|
||||||
|
|
||||||
@ -7,14 +8,10 @@ stdenv.mkDerivation {
|
|||||||
sha256 = "1c2nkxx83vmlh1v3ib6r2xqh121gdb1rharwsimcb2h0xwc558dm";
|
sha256 = "1c2nkxx83vmlh1v3ib6r2xqh121gdb1rharwsimcb2h0xwc558dm";
|
||||||
};
|
};
|
||||||
|
|
||||||
buildInputs = [];
|
makeFlags = "TREE=\$(out)";
|
||||||
makeFlags = " TREE=\$(out) ";
|
|
||||||
|
|
||||||
postInstall = "mv \$out/bin/replace \$out/bin/replace-literal";
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "
|
homepage = http://replace.richardlloyd.org.uk/;
|
||||||
Replace verbatim strings. Sed is not fit to do it. Replace is.
|
description = "A tool to replace verbatim strings";
|
||||||
";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -321,6 +321,7 @@ rec {
|
|||||||
nukeReferences = import ../build-support/nuke-references/default.nix {
|
nukeReferences = import ../build-support/nuke-references/default.nix {
|
||||||
inherit stdenv;
|
inherit stdenv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
### TOOLS
|
### TOOLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user