1 # shellcheck shell=bash
3 declare -a autoPatchelfLibs
4 declare -a extraAutoPatchelfLibs
7 autoPatchelfLibs
+=("$1/lib")
10 # shellcheck disable=SC2154
11 # (targetOffset is referenced but not assigned.)
12 addEnvHooks
"$targetOffset" gatherLibraries
14 # Can be used to manually add additional directories with shared object files
15 # to be included for the next autoPatchelf invocation.
16 addAutoPatchelfSearchPath
() {
19 while [ $# -gt 0 ]; do
22 --no-recurse) shift; findOpts
+=("-maxdepth" 1);;
24 echo "addAutoPatchelfSearchPath: ERROR: Invalid command line" \
32 while IFS
= read -r -d '' dir
; do
33 extraAutoPatchelfLibs
+=("$dir")
34 done < <(find "$@" "${findOpts[@]}" \
! -type d \
35 \
( -name '*.so' -o -name '*.so.*' \
) -print0 \
36 |
sed -z 's#/[^/]*$##' \
44 while [ $# -gt 0 ]; do
47 --no-recurse) shift; norecurse
=1;;
49 echo "autoPatchelf: ERROR: Invalid command line" \
56 readarray
-td' ' ignoreMissingDepsArray
< <(echo -n "$autoPatchelfIgnoreMissingDeps")
57 if [ "$autoPatchelfIgnoreMissingDeps" == "1" ]; then
58 echo "autoPatchelf: WARNING: setting 'autoPatchelfIgnoreMissingDeps" \
59 "= true;' is deprecated and will be removed in a future release." \
60 "Use 'autoPatchelfIgnoreMissingDeps = [ \"*\" ];' instead." >&2
61 ignoreMissingDepsArray
=( "*" )
64 local appendRunpathsArray
=($appendRunpaths)
65 local runtimeDependenciesArray
=($runtimeDependencies)
66 local patchelfFlagsArray
=($patchelfFlags)
67 @pythonInterpreter@ @autoPatchelfScript@ \
68 ${norecurse:+--no-recurse} \
69 --ignore-missing "${ignoreMissingDepsArray[@]}" \
71 --libs "${autoPatchelfLibs[@]}" \
72 "${extraAutoPatchelfLibs[@]}" \
73 --runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}" \
74 --append-rpaths "${appendRunpathsArray[@]}" \
75 --extra-args "${patchelfFlagsArray[@]}"
78 # XXX: This should ultimately use fixupOutputHooks but we currently don't have
79 # a way to enforce the order. If we have $runtimeDependencies set, the setup
80 # hook of patchelf is going to ruin everything and strip out those additional
83 # So what we do here is basically run in postFixup and emulate the same
84 # behaviour as fixupOutputHooks because the setup hook for patchelf is run in
85 # fixupOutput and the postFixup hook runs later.
87 # shellcheck disable=SC2016
88 # (Expressions don't expand in single quotes, use double quotes for that.)
90 if [ -z "${dontAutoPatchelf-}" ]; then
91 autoPatchelf -- $(for output in $(getAllOutputNames); do
92 [ -e "${!output}" ] || continue