summary refs log tree commit diff
path: root/nixos/modules/system/boot/stage-1.nix
diff options
context:
space:
mode:
authorThomas Tuegel <ttuegel@gmail.com>2016-08-08 09:45:45 -0500
committerThomas Tuegel <ttuegel@gmail.com>2016-08-08 09:45:45 -0500
commit68922e3f7407c5aecd8cc9cc3d22d753269b3f31 (patch)
treebcc57e2e1725bb0f6f7d3c7b8d5675a079c93407 /nixos/modules/system/boot/stage-1.nix
parentee36bb85886e4a6be1b172f5ec692727a8fe5893 (diff)
downloadnixlib-68922e3f7407c5aecd8cc9cc3d22d753269b3f31.tar
nixlib-68922e3f7407c5aecd8cc9cc3d22d753269b3f31.tar.gz
nixlib-68922e3f7407c5aecd8cc9cc3d22d753269b3f31.tar.bz2
nixlib-68922e3f7407c5aecd8cc9cc3d22d753269b3f31.tar.lz
nixlib-68922e3f7407c5aecd8cc9cc3d22d753269b3f31.tar.xz
nixlib-68922e3f7407c5aecd8cc9cc3d22d753269b3f31.tar.zst
nixlib-68922e3f7407c5aecd8cc9cc3d22d753269b3f31.zip
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.
Diffstat (limited to 'nixos/modules/system/boot/stage-1.nix')
-rw-r--r--nixos/modules/system/boot/stage-1.nix14
1 files changed, 5 insertions, 9 deletions
diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix
index a74cfafdd37f..70429e9c0a22 100644
--- a/nixos/modules/system/boot/stage-1.nix
+++ b/nixos/modules/system/boot/stage-1.nix
@@ -87,15 +87,11 @@ let
         LDD="$(ldd $BIN)" || continue
         LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')"
         for LIB in $LIBS; do
-          [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib
-          while [ "$(readlink $LIB)" != "" ]; do
-            LINK="$(readlink $LIB)"
-            if [ "''${LINK:0:1}" != "/" ]; then
-              LINK="$(dirname $LIB)/$LINK"
-            fi
-            LIB="$LINK"
-            [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib
-          done
+          TGT="$out/lib/$(basename $LIB)"
+          if [ ! -f "$TGT" ]; then
+            SRC="$(readlink -e $LIB)"
+            cp -pdv "$SRC" "$TGT"
+          fi
         done
       done