···11+# Helper functions for deepin packaging22+33+searchHardCodedPaths() {44+ # looks for ocurrences of hard coded paths in given (current)55+ # directory and command invocations for the purpose of debugging a66+ # derivation77+88+ local dir=$199+1010+ echo ----------- looking for command invocations1111+ grep --color=always -r -E '\<(ExecStart|Exec|startDetached|execute|exec\.(Command|LookPath))\>' $dir || true1212+1313+ echo ----------- looking for hard coded paths1414+ grep --color=always -r -E '/(usr|bin|sbin|etc|var|opt)\>' $dir || true1515+1616+ echo ----------- done1717+}1818+1919+fixPath() {2020+ # Usage:2121+ #2222+ # fixPath <parent dir> <path> <files>2323+ #2424+ # replaces occurences of <path> by <parent_dir><path> in <files>2525+ # removing /usr from the start of <path> if present2626+2727+ local parentdir=$12828+ local path=$22929+ local newpath=$parentdir$(echo $path | sed "s,^/usr,,")3030+ local files=("${@:3}")3131+ echo ======= grep --color=always "${path}" "${files[@]}"3232+ grep --color=always "${path}" "${files[@]}"3333+ echo +++++++ sed -i -e "s,$path,$newpath,g" "${files[@]}"3434+ sed -i -e "s,$path,$newpath,g" "${files[@]}"3535+}3636+3737+searchForUnresolvedDLL() {3838+ # Usage:3939+ #4040+ # searchForUnresolvedDLL <dir>4141+ #4242+ # looks in <dir> for executables with unresolved dynamic library paths4343+4444+ local dir="$1"4545+ echo ======= Looking for executables with unresolved dynamic library dependencies4646+ echo $dir4747+ for f in $(find -L "$dir" -type f -executable); do4848+ if (ldd $f | grep -q "not found"); then4949+ echo $f5050+ ldd $f | grep --color=always "not found"5151+ fi5252+ done5353+}