3
0
Fork 0
forked from mirrors/nixpkgs

Provide a hook for per-output fixup

This commit is contained in:
Eelco Dolstra 2014-06-25 16:47:58 +02:00
parent b0f2d3419c
commit 37889e2b5e

View file

@ -1,3 +1,6 @@
: ${outputs:=out}
###################################################################### ######################################################################
# Hook handling. # Hook handling.
@ -784,14 +787,16 @@ installPhase() {
} }
# The fixup phase performs generic, package-independent, Nix-related # The fixup phase performs generic, package-independent stuff, like
# stuff, like running patchelf and setting the # stripping binaries, running patchelf and setting
# propagated-build-inputs. It should rarely be overriden. # propagated-build-inputs.
fixupPhase() { fixupPhase() {
runHook preFixup
# Make sure everything is writable so "strip" et al. work. # Make sure everything is writable so "strip" et al. work.
if [ -e "$prefix" ]; then chmod -R u+w "$prefix"; fi for output in $outputs; do
if [ -e "$output" ]; then chmod -R u+w "$output"; fi
done
runHook preFixup
# Put man/doc/info under $out/share. # Put man/doc/info under $out/share.
forceShare=${forceShare:=man doc info} forceShare=${forceShare:=man doc info}
@ -812,10 +817,42 @@ fixupPhase() {
done; done;
fi fi
# Apply fixup to each output.
local output
for output in $outputs; do
prefix=${!output} runHook fixupOutput
done
if [ -n "$propagatedBuildInputs" ]; then
mkdir -p "$out/nix-support"
echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
fi
if [ -n "$propagatedNativeBuildInputs" ]; then
mkdir -p "$out/nix-support"
echo "$propagatedNativeBuildInputs" > "$out/nix-support/propagated-native-build-inputs"
fi
if [ -n "$propagatedUserEnvPkgs" ]; then
mkdir -p "$out/nix-support"
echo "$propagatedUserEnvPkgs" > "$out/nix-support/propagated-user-env-packages"
fi
if [ -n "$setupHook" ]; then
mkdir -p "$out/nix-support"
substituteAll "$setupHook" "$out/nix-support/setup-hook"
fi
runHook postFixup
}
addHook fixupOutput _defaultFixupOutput
_defaultFixupOutput() {
if [ -z "$dontGzipMan" ]; then if [ -z "$dontGzipMan" ]; then
echo "gzipping man pages" echo "gzipping man pages"
GLOBIGNORE=.:..:*.gz:*.bz2 GLOBIGNORE=.:..:*.gz:*.bz2
for f in "$out"/share/man/*/* "$out"/share/man/*/*/*; do for f in "$prefix"/share/man/*/* "$prefix"/share/man/*/*/*; do
if [ -f "$f" -a ! -L "$f" ]; then if [ -f "$f" -a ! -L "$f" ]; then
if gzip -c -n "$f" > "$f".gz; then if gzip -c -n "$f" > "$f".gz; then
rm "$f" rm "$f"
@ -824,7 +861,7 @@ fixupPhase() {
fi fi
fi fi
done done
for f in "$out"/share/man/*/* "$out"/share/man/*/*/*; do for f in "$prefix"/share/man/*/* "$prefix"/share/man/*/*/*; do
if [ -L "$f" -a -f `readlink -f "$f"`.gz ]; then if [ -L "$f" -a -f `readlink -f "$f"`.gz ]; then
ln -sf `readlink "$f"`.gz "$f".gz && rm "$f" ln -sf `readlink "$f"`.gz "$f".gz && rm "$f"
fi fi
@ -852,28 +889,6 @@ fixupPhase() {
if [ -z "$dontPatchShebangs" ]; then if [ -z "$dontPatchShebangs" ]; then
patchShebangs "$prefix" patchShebangs "$prefix"
fi fi
if [ -n "$propagatedBuildInputs" ]; then
mkdir -p "$out/nix-support"
echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs"
fi
if [ -n "$propagatedNativeBuildInputs" ]; then
mkdir -p "$out/nix-support"
echo "$propagatedNativeBuildInputs" > "$out/nix-support/propagated-native-build-inputs"
fi
if [ -n "$propagatedUserEnvPkgs" ]; then
mkdir -p "$out/nix-support"
echo "$propagatedUserEnvPkgs" > "$out/nix-support/propagated-user-env-packages"
fi
if [ -n "$setupHook" ]; then
mkdir -p "$out/nix-support"
substituteAll "$setupHook" "$out/nix-support/setup-hook"
fi
runHook postFixup
} }