svn path=/nixpkgs/trunk/; revision=9347

This commit is contained in:
Michael Raskin 2007-09-20 18:25:43 +00:00
parent b67ce21440
commit de45e0e929
1 changed files with 72 additions and 67 deletions

View File

@ -4,6 +4,15 @@ rec {
setStrictMode = noDepEntry "set -e;"; setStrictMode = noDepEntry "set -e;";
setNixGcc = noDepEntry "test -z \$NIX_GCC && NIX_GCC=@gcc@;"; setNixGcc = noDepEntry "test -z \$NIX_GCC && NIX_GCC=@gcc@;";
setPathDelimiter = noDepEntry "
if [ -z ${system##*cygwin*} ]; then
PATH_DELIMITER=;
else
PATH_DELIMITER=;
fi
" ;
initPath = noDepEntry "# Set up the initial path. initPath = noDepEntry "# Set up the initial path.
PATH= PATH=
for i in \$NIX_GCC @initialPath@; do for i in \$NIX_GCC @initialPath@; do
@ -28,18 +37,18 @@ param5=@param5@
if test -n \"@preHook@\"; then if test -n \"@preHook@\"; then
source @preHook@ source @preHook@
fi fi
" [initPath]; " [];
checkShellEnv = FullDepEntry "# Check that the pre-hook initialised SHELL. checkShellEnv = FullDepEntry "# Check that the pre-hook initialised SHELL.
if test -z \"\$SHELL\"; then echo \"SHELL not set\"; exit 1; fi if test -z \"\$SHELL\"; then echo \"SHELL not set\"; exit 1; fi
" [execPreHook]; " [];
gccSetupHook = FullDepEntry "# Hack: run gcc's setup hook. gccSetupHook = FullDepEntry "# Hack: run gcc's setup hook.
envHooks=() envHooks=()
if test -f \$NIX_GCC/nix-support/setup-hook; then if test -f \$NIX_GCC/nix-support/setup-hook; then
source \$NIX_GCC/nix-support/setup-hook source \$NIX_GCC/nix-support/setup-hook
fi fi
" [setNixGcc initPath execPreHook]; " [setNixGcc];
defEnsureDir = FullDepEntry "# Ensure that the given directories exists. defEnsureDir = FullDepEntry "# Ensure that the given directories exists.
@ -49,7 +58,25 @@ ensureDir() {
if ! test -x \"\$dir\"; then mkdir -p \"\$dir\"; fi if ! test -x \"\$dir\"; then mkdir -p \"\$dir\"; fi
done done
} }
" [initPath]; " [];
defInstallBin = FullDepEntry "
installBin() {
ensureDir $out/bin
cp "$@" $out/bin
}
" [];
defAssertEnvExists = FullDepEntry "
assertEnvExists(){
if test -z "${!1}"; then
msg=${2:-error: assertion failed: env var $1 is required}
echo $msg >&2; exit 1
fi
}
" [];
defFail = FullDepEntry "# Called when some build action fails. If \$succeedOnFailure is set, defFail = FullDepEntry "# Called when some build action fails. If \$succeedOnFailure is set,
# create the file `\$out/nix-support/failed' to signal failure, and # create the file `\$out/nix-support/failed' to signal failure, and
@ -64,13 +91,13 @@ fail() {
exit \$? exit \$?
fi fi
} }
" [initPath]; " [];
runAddInputsHook = FullDepEntry "# Allow the caller to augment buildInputs (it's not always possible to runAddInputsHook = FullDepEntry "# Allow the caller to augment buildInputs (it's not always possible to
# do this before the call to setup.sh, since the PATH is empty at that # do this before the call to setup.sh, since the PATH is empty at that
# point; here we have a basic Unix environment). # point; here we have a basic Unix environment).
eval \"\$addInputsHook\" eval \"\$addInputsHook\"
" [initPath gccSetupHook defFail]; " [defFail];
defFindInputs = FullDepEntry "# Recursively find all build inputs. defFindInputs = FullDepEntry "# Recursively find all build inputs.
findInputs() findInputs()
@ -95,7 +122,7 @@ findInputs()
done done
fi fi
} }
" [initPath]; " [];
getInputs = FullDepEntry "pkgs=\"\" getInputs = FullDepEntry "pkgs=\"\"
if test -n \"\$buildinputs\"; then if test -n \"\$buildinputs\"; then
@ -104,7 +131,7 @@ fi
for i in \$buildInputs \$propagatedBuildInputs; do for i in \$buildInputs \$propagatedBuildInputs; do
findInputs \$i findInputs \$i
done done
" [defFindInputs runAddInputsHook]; " [defFindInputs];
defAddToEnv = FullDepEntry "# Set the relevant environment variables to point to the build inputs defAddToEnv = FullDepEntry "# Set the relevant environment variables to point to the build inputs
# found above. # found above.
@ -727,84 +754,62 @@ installPhase() {
defFixupW = FullDepEntry " defFixupW = FullDepEntry "
# The fixup phase performs generic, package-independent, Nix-related # The fixup phase performs generic, package-independent, Nix-related
# stuff, like running patchelf and setting the # stuff, like running patchelf and setting the
# propagated-build-inputs. It should rarely be overriden. # propagated-build-inputs. It should rarely be overriden.
fixupW() { fixupW() {
if test -n \"\$fixupPhase\"; then if test -n "$fixupPhase"; then
eval \"\$fixupPhase\" eval "$fixupPhase"
return return
fi fi
eval \"\$preFixup\" eval "$preFixup"
forceShare=\${forceShare:=man doc info} forceShare=${forceShare:=man doc info}
if test -n \"\$forceShare\"; then if test -n "$forceShare"; then
for d in \$forceShare; do for d in $forceShare; do
if test -d \"\$prefix/\$d\"; then if test -d "$prefix/$d"; then
if test -d \"\$prefix/share/\$d\"; then if test -d "$prefix/share/$d"; then
echo \"Both \$d/ and share/\$d/ exists, aborting\" echo "Both $d/ and share/$d/ exists!"
else else
ensureDir \$prefix/share echo Fixing location of $dir/ subdirectory
if test -w \$prefix/share; then ensureDir $prefix/share
mv -v \$prefix/\$d \$prefix/share if test -w $prefix/share; then
ln -sv share/\$d \$prefix mv -v $prefix/$d $prefix/share
ln -sv share/$d $prefix
fi fi
fi fi
else
echo "No $d/ subdirectory, skipping."
fi fi
done; done;
fi 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
test -d \"\$prefix/lib\" && stripDebug=\"\$prefix/lib\" echo "Stripping debuging symbols from files in"
stripDirs "${stripDebugList:-lib}" -S
if test -n \"\$stripDebug\"; then echo "Stripping all symbols from files in"
find \"\$stripDebug\" -type f -print0 | stripDirs "${stripAllList:-bin sbin}" -s
xargs -0 strip --strip-debug --verbose || true
fi
test -d \"\$prefix/bin\" && stripAll=\"\$prefix/bin\"
test -d \"\$prefix/sbin\" && stripAll=\"\${stripAll} \$prefix/sbin\"
if test -n \"\$stripAll\"; then
find \"\$prefix/bin\" \"\$prefix/sbin\" -type f -print0 |
xargs -0 strip --strip-all --verbose || true
fi
fi fi
if test -z \"\$dontFixupShare\"; then if test "$havePatchELF" = 1 -a -z "$dontPatchELF"; then
for dir in doc info man; do patchELF "$prefix"
if test -d \"\$prefix/\$dir\"; then fi
if test -d \"\$prefix/share/\$dir\"; then
echo Both \"\$prefix/\$dir\" and \"\$prefix/share/\$dir\" exists! if test -n "$propagatedBuildInputs"; then
else ensureDir "$out/nix-support"
echo Fixing location of \$dir/ subdirectory echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
ensureDir \"\$prefix/share\" fi
if test -w \$prefix/share; then
mv -v \"\$prefix/\$dir\" \"\$prefix/share\" if test -n "$setupHook"; then
ln -sv \"share/\$dir\" \"\$prefix\" ensureDir "$out/nix-support"
fi substituteAll "$setupHook" "$out/nix-support/setup-hook"
fi
fi
done
fi fi
if test \"\$havePatchELF\" = 1 -a -z \"\$dontPatchELF\"; then eval "$postFixup"
patchELF \"\$prefix\"
fi
if test -n \"\$propagatedBuildInputs\"; then
ensureDir \"\$out/nix-support\"
echo \"\$propagatedBuildInputs\" > \"\$out/nix-support/propagated-build-inputs\"
fi
if test -n \"\$setupHook\"; then
ensureDir \"\$out/nix-support\"
substituteAll \"\$setupHook\" \"\$out/nix-support/setup-hook\"
fi
eval \"\$postFixup\"
} }
" [defPatchElf initPath]; " [defPatchElf initPath];