about summary refs log tree commit diff
path: root/pkgs/games/build-support/setup-hooks
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2017-09-13 06:04:38 +0200
committeraszlig <aszlig@redmoonstudios.org>2017-09-13 15:26:33 +0200
commite273773c4e66c2e553e1cbf0c453fc225fe808e3 (patch)
tree80a9b690daab736d0b28677a1ce4ffe5bc993aca /pkgs/games/build-support/setup-hooks
parentef6c66560175e4b5a798bd09caa31cd5ebad8127 (diff)
pkgs/build-game: Add runtimeDependencies attribute
This allows us to add libraries to the RPATH despite being required by
the respective game. By default there is only PulseAudio at the moment.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'pkgs/games/build-support/setup-hooks')
-rw-r--r--pkgs/games/build-support/setup-hooks/auto-patchelf.sh17
1 files changed, 10 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 b0982a45..33408533 100644
--- a/pkgs/games/build-support/setup-hooks/auto-patchelf.sh
+++ b/pkgs/games/build-support/setup-hooks/auto-patchelf.sh
@@ -51,7 +51,6 @@ checkElfDep() {
 populateCacheWithRecursiveDeps() {
     local so found foundso
     for so in "${cachedDependencies[@]}"; do
-        local IFS=$'\n'
         for found in $(getDepsFromSo "$so"); do
             local libdir="${found%/*}"
             local base="${found##*/}"
@@ -91,21 +90,23 @@ findDependency() {
 }
 
 autoPatchelfFile() {
-    local toPatch="$1"
-    local dep
+    local dep rpath="" toPatch="$1"
 
     local interpreter="$(cat $NIX_CC/nix-support/dynamic-linker)"
     if isExecutable "$toPatch"; then
         patchelf --set-interpreter "$interpreter" "$toPatch"
+        if [ -n "$runtimeDependencies" ]; then
+            for dep in $runtimeDependencies; do
+                rpath="$rpath${rpath:+:}$dep/lib"
+            done
+        fi
     fi
 
     patchelf --remove-rpath "$toPatch"
 
-    local rpath=""
     local missing="$(
         ldd "$toPatch" | sed -n -e 's/^[\t ]*\([^ ]\+\) => not found.*/\1/p'
     )"
-    local IFS=$'\n'
     for dep in $missing; do
         echo -n "searching for dependency $dep..." >&2
         if findDependency "$dep"; then
@@ -125,11 +126,13 @@ autoPatchelfFile() {
 autoPatchelf() {
     echo "automatically fixing dependencies for ELF files" >&2
 
-    local i IFS=$'\n'
     cachedDependencies+=(
         $(find "$out" \! -type d \( -name '*.so' -o -name '*.so.*' \))
     )
-    for i in $(findElfs "$prefix"); do autoPatchelfFile "$i"; done
+    local elffile
+    findElfs "$prefix" | while read -r elffile; do
+        autoPatchelfFile "$elffile"
+    done
 }
 
 postInstallHooks+=(autoPatchelf)