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 concatTo ignoreMissingDepsArray autoPatchelfIgnoreMissingDeps
57 concatTo appendRunpathsArray appendRunpaths
58 concatTo runtimeDependenciesArray runtimeDependencies
59 concatTo patchelfFlagsArray patchelfFlags
60 concatTo autoPatchelfFlagsArray autoPatchelfFlags
62 # Check if ignoreMissingDepsArray contains "1" and if so, replace it with
63 # "*", printing a deprecation warning.
64 for dep
in "${ignoreMissingDepsArray[@]}"; do
65 if [ "$dep" == "1" ]; then
66 echo "autoPatchelf: WARNING: setting 'autoPatchelfIgnoreMissingDeps" \
67 "= true;' is deprecated and will be removed in a future release." \
68 "Use 'autoPatchelfIgnoreMissingDeps = [ \"*\" ];' instead." >&2
69 ignoreMissingDepsArray
=( "*" )
75 ${norecurse:+--no-recurse} \
76 --ignore-missing "${ignoreMissingDepsArray[@]}" \
78 --libs "${autoPatchelfLibs[@]}" \
79 "${extraAutoPatchelfLibs[@]}" \
80 --runtime-dependencies "${runtimeDependenciesArray[@]/%//lib}" \
81 --append-rpaths "${appendRunpathsArray[@]}" \
82 "${autoPatchelfFlagsArray[@]}" \
83 --extra-args "${patchelfFlagsArray[@]}"
86 autoPatchelfPostFixup
() {
87 # XXX: This should ultimately use fixupOutputHooks but we currently don't have
88 # a way to enforce the order. If we have $runtimeDependencies set, the setup
89 # hook of patchelf is going to ruin everything and strip out those additional
92 # So what we do here is basically run in postFixup and emulate the same
93 # behaviour as fixupOutputHooks because the setup hook for patchelf is run in
94 # fixupOutput and the postFixup hook runs later.
95 if [[ -z "${dontAutoPatchelf-}" ]]; then
96 autoPatchelf
-- $
(for output
in $
(getAllOutputNames
); do
97 [ -e "${!output}" ] ||
continue
103 postFixupHooks
+=(autoPatchelfPostFixup
)