git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/stage-1: use `readlink -e` in builder

The builder has this convoluted `while` loop which just replicates `readlink -e`. I'm sure there was a reason at one point, because the loop has been there since time immemorial. It kept getting copied around, I suspect because nobody bothered to understand what it actually did. Incidentally, this fixes #17513, but I have no idea why.

commit68922e3f7407c5aecd8cc9cc3d22d753269b3f31 authorThomas Tuegel <ttuegel@gmail.com> dateMon 8 Aug 2016, 09:45 (10 years ago) parentee36bb8
1 file changed+5−9
nixos/modules/system/boot/stage-1.nix+5−9
nixos/modules/system/boot/stage-1.nix+5−9
@@ -87,15 +87,11 @@ let
8787 LDD="$(ldd $BIN)" || continue
8888 LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')"
8989 for LIB in $LIBS; do
90− [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib
91− while [ "$(readlink $LIB)" != "" ]; do
92− LINK="$(readlink $LIB)"
93− if [ "''${LINK:0:1}" != "/" ]; then
94− LINK="$(dirname $LIB)/$LINK"
95− fi
96− LIB="$LINK"
97− [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib
98− done
90+ TGT="$out/lib/$(basename $LIB)"
91+ if [ ! -f "$TGT" ]; then
92+ SRC="$(readlink -e $LIB)"
93+ cp -pdv "$SRC" "$TGT"
94+ fi
9995 done
10096 done
10197