nixos stage-1: recursively process binaries and libraries

This commit is contained in:
Nikolay Amiantov 2016-07-06 22:56:21 +03:00
parent 90ad879753
commit bd0ab027c1

View File

@ -81,9 +81,9 @@ let
# Copy ld manually since it isn't detected correctly # Copy ld manually since it isn't detected correctly
cp -pv ${pkgs.glibc.out}/lib/ld*.so.? $out/lib cp -pv ${pkgs.glibc.out}/lib/ld*.so.? $out/lib
# Copy all of the needed libraries for the binaries # Copy all of the needed libraries
for BIN in $(find $out/{bin,sbin} -type f); do find $out/bin $out/lib -type f | while read BIN; do
echo "Copying libs for bin $BIN" echo "Copying libs for executable $BIN"
LDD="$(ldd $BIN)" || continue LDD="$(ldd $BIN)" || continue
LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')" LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')"
for LIB in $LIBS; do for LIB in $LIBS; do
@ -104,13 +104,17 @@ let
stripDirs "lib bin" "-s" stripDirs "lib bin" "-s"
# Run patchelf to make the programs refer to the copied libraries. # Run patchelf to make the programs refer to the copied libraries.
for i in $out/bin/* $out/lib/*; do if ! test -L $i; then nuke-refs -e $out $i; fi; done find $out/bin $out/lib -type f | while read i; do
if ! test -L $i; then
nuke-refs -e $out $i
fi
done
for i in $out/bin/*; do find $out/bin -type f | while read i; do
if ! test -L $i; then if ! test -L $i; then
echo "patching $i..." echo "patching $i..."
patchelf --set-interpreter $out/lib/ld*.so.? --set-rpath $out/lib $i || true patchelf --set-interpreter $out/lib/ld*.so.? --set-rpath $out/lib $i || true
fi fi
done done
# Make sure that the patchelf'ed binaries still work. # Make sure that the patchelf'ed binaries still work.