diff options
author | aszlig <aszlig@nix.build> | 2018-11-25 16:17:14 +0100 |
---|---|---|
committer | aszlig <aszlig@nix.build> | 2018-11-25 16:22:32 +0100 |
commit | 2faf905f98eeb9f674ef845ae9bf9fd7f1279d1e (patch) | |
tree | 01d2034f0d26dd4bac437339bb28f6d25c03ffba /pkgs/build-support/setup-hooks | |
parent | 503b41b9b2d726f10372e3daac713cc2042b8cf0 (diff) | |
download | nixpkgs-2faf905f98eeb9f674ef845ae9bf9fd7f1279d1e.tar nixpkgs-2faf905f98eeb9f674ef845ae9bf9fd7f1279d1e.tar.gz nixpkgs-2faf905f98eeb9f674ef845ae9bf9fd7f1279d1e.tar.bz2 nixpkgs-2faf905f98eeb9f674ef845ae9bf9fd7f1279d1e.tar.lz nixpkgs-2faf905f98eeb9f674ef845ae9bf9fd7f1279d1e.tar.xz nixpkgs-2faf905f98eeb9f674ef845ae9bf9fd7f1279d1e.tar.zst nixpkgs-2faf905f98eeb9f674ef845ae9bf9fd7f1279d1e.zip |
autoPatchelfHook: Add addAutoPatchelfSearchPath
This function is useful if autoPatchelf is invoked during some of the phases of a build and allows to add arbitrary shared objects to the search path. So far the same functionality was in autoPatchelf itself, but not available as a separate function, so when adding shared objects to the dependency cache one would have to do so manually. The function also has the --no-recurse flag, which prevents recursing into subdirectories. Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/build-support/setup-hooks')
-rw-r--r-- | pkgs/build-support/setup-hooks/auto-patchelf.sh | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 43b1679670d..61bdafa88c3 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -147,14 +147,39 @@ autoPatchelfFile() { fi } -autoPatchelf() { +# Can be used to manually add additional directories with shared object files +# to be included for the next autoPatchelf invocation. +addAutoPatchelfSearchPath() { local -a findOpts=() + # XXX: Somewhat similar to the one in the autoPatchelf function, maybe make + # it DRY someday... while [ $# -gt 0 ]; do case "$1" in --) shift; break;; --no-recurse) shift; findOpts+=("-maxdepth" 1);; --*) + echo "addAutoPatchelfSearchPath: ERROR: Invalid command line" \ + "argument: $1" >&2 + return 1;; + *) break;; + esac + done + + cachedDependencies+=( + $(find "$@" "${findOpts[@]}" \! -type d \ + \( -name '*.so' -o -name '*.so.*' \)) + ) +} + +autoPatchelf() { + local -a norecurse= + + while [ $# -gt 0 ]; do + case "$1" in + --) shift; break;; + --no-recurse) shift; norecurse=1;; + --*) echo "autoPatchelf: ERROR: Invalid command line" \ "argument: $1" >&2 return 1;; @@ -171,11 +196,7 @@ autoPatchelf() { # Add all shared objects of the current output path to the start of # cachedDependencies so that it's choosen first in findDependency. - cachedDependencies+=( - $(find "$@" "${findOpts[@]}" \! -type d \ - \( -name '*.so' -o -name '*.so.*' \)) - ) - local elffile + addAutoPatchelfSearchPath ${norecurse:+--no-recurse} -- "$@" # Here we actually have a subshell, which also means that # $cachedDependencies is final at this point, so whenever we want to run @@ -189,7 +210,7 @@ autoPatchelf() { LANG=C readelf -l "$file" | grep -q "^ *INTERP\\>" || continue fi autoPatchelfFile "$file" - done < <(find "$@" "${findOpts[@]}" -type f -print0) + done < <(find "$@" ${norecurse:+-maxdepth 1} -type f -print0) } # XXX: This should ultimately use fixupOutputHooks but we currently don't have |