From 48a9fd81943482621e0745a03abc5be811a88da4 Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 1 Feb 2018 17:10:45 +0100 Subject: 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 --- pkgs/games/build-support/setup-hooks/auto-patchelf.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'pkgs/games/build-support') 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 } -- cgit 1.4.1