about summary refs log tree commit diff
path: root/pkgs/games/build-support
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-02-01 17:10:45 +0100
committeraszlig <aszlig@nix.build>2018-02-01 22:28:22 +0100
commit48a9fd81943482621e0745a03abc5be811a88da4 (patch)
treee28e8f3336e8c6318b14bb6cf07f6de4b2bba88e /pkgs/games/build-support
parentad0dd95bac65bbb84feb9db118dde303344b7618 (diff)
auto-patchelf: Clean up a bit
This makes sure that ldd doesn't print warnings like if the file isn't
executable and also makes the status messages a bit more clear.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games/build-support')
-rw-r--r--pkgs/games/build-support/setup-hooks/auto-patchelf.sh18
1 files changed, 11 insertions, 7 deletions
diff --git a/pkgs/games/build-support/setup-hooks/auto-patchelf.sh b/pkgs/games/build-support/setup-hooks/auto-patchelf.sh
index 501aacbf..99ce3be4 100644
--- a/pkgs/games/build-support/setup-hooks/auto-patchelf.sh
+++ b/pkgs/games/build-support/setup-hooks/auto-patchelf.sh
@@ -42,7 +42,7 @@ getDepsFromSo() {
 }
 
 checkElfDep() {
-    local errors ldout="$(ldd "$1")"
+    local errors ldout="$(ldd "$1" 2> /dev/null)"
     if errors="$(echo "$ldout" | grep -F "not found")"; then
         echo -e "Library dependencies missing for $1:\n$errors"
     fi
@@ -92,7 +92,7 @@ findDependency() {
 autoPatchelfFile() {
     local dep rpath="" toPatch="$1"
 
-    local interpreter="$(cat $NIX_CC/nix-support/dynamic-linker)"
+    local interpreter="$(< "$NIX_CC/nix-support/dynamic-linker")"
     if isExecutable "$toPatch"; then
         patchelf --set-interpreter "$interpreter" "$toPatch"
         if [ -n "$runtimeDependencies" ]; then
@@ -102,23 +102,27 @@ autoPatchelfFile() {
         fi
     fi
 
+    echo "searching for dependencies of $toPatch:" >&2
+
     patchelf --remove-rpath "$toPatch"
 
     local missing="$(
-        ldd "$toPatch" | sed -n -e 's/^[\t ]*\([^ ]\+\) => not found.*/\1/p'
+        ldd "$toPatch" 2> /dev/null | \
+            sed -n -e 's/^[\t ]*\([^ ]\+\) => not found.*/\1/p'
     )"
+
     for dep in $missing; do
-        echo -n "searching for dependency $dep..." >&2
+        echo -n "  $dep -> " >&2
         if findDependency "$dep"; then
             rpath="$rpath${rpath:+:}${foundDependency%/*}"
-            echo " found: $foundDependency" >&2
+            echo "found: $foundDependency" >&2
         else
-            echo " not found" >&2
+            echo "not found!" >&2
         fi
     done
 
     if [ -n "$rpath" ]; then
-        echo "setting RPATH of $toPatch to $rpath" >&2
+        echo "setting RPATH to: $rpath" >&2
         patchelf --set-rpath "$rpath" "$toPatch"
     fi
 }