diff options
author | wsnipex <wsnipex@a1.net> | 2023-03-19 18:00:16 +0100 |
---|---|---|
committer | wsnipex <wsnipex@a1.net> | 2023-03-19 18:02:01 +0100 |
commit | 4c3c625db6fbd0280f07105e7a7c3f25ef54407c (patch) | |
tree | 7400e115d4efe33a5b52ba51ef10d7e2f63b4b5d /tools | |
parent | 506ac609febfda2ea422ed33010c103a7f83f60d (diff) |
webos: dynamically package missing dependency libraries
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/webOS/verify-symbols.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/webOS/verify-symbols.sh b/tools/webOS/verify-symbols.sh new file mode 100755 index 0000000000..6123e09a49 --- /dev/null +++ b/tools/webOS/verify-symbols.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# found on https://github.com/webosbrew/dev-utils/tree/main/scripts + +EXE="$1" + +if [ ! -f "${EXE}" ]; then + echo "Usage: $0 executable" + exit 1 +fi + +if [ ! -d "${WEBOS_ROOTFS}" ]; then + echo 'WEBOS_ROOTFS is not a directory' + exit 1 +fi + +lib_search_paths="$(objdump -p ${EXE} | grep RUNPATH | tr -s ' ' | cut -d ' ' -f 3)" +lib_search_paths="${lib_search_paths}:${WEBOS_ROOTFS}/lib:${WEBOS_ROOTFS}/usr/lib:${WEBOS_LD_LIBRARY_PATH}" + +required_syms=$(nm --dynamic --extern-only --undefined-only "${EXE}" | grep ' [U] ' | tr -s ' ' | cut -d ' ' -f 3) + +needed_libs=$(objdump -p "${EXE}" | grep NEEDED | tr -s ' ' | cut -d ' ' -f 3) +found_libs="" +has_missing=0 + +for lib in ${needed_libs}; do + lib_found=0 + OLDIFS=$IFS + IFS=: + for path in ${lib_search_paths}; do + lib_path="${path}/${lib}" + if [ -f "${lib_path}" ]; then + lib_found=1 + found_libs="${found_libs} ${lib_path}" + fi + done + IFS=$OLDIFS + if [ ${lib_found} = 0 ]; then + has_missing=1 + echo "Missing library: ${lib}" + fi +done + +# shellcheck disable=SC2086 +lib_syms=$(nm --dynamic --extern-only --defined-only ${found_libs} | grep ' [a-zA-Z] ' | cut -d ' ' -f 3 | tr -s '@') + +for sym in ${required_syms}; do + if ! echo "${lib_syms}" | grep -q "${sym}"; then + has_missing=1 + sym_name=$(echo "${sym}" | cut -d '@' -f 1 | c++filt) + if echo "${sym}" | grep -q '@'; then + sym_ver="@$(echo ${sym} | cut -d '@' -f 2)" + fi + echo "Missing symbol: ${sym_name}${sym_ver}" + fi +done + +if [ ${has_missing} = 0 ]; then + echo "All OK." +fi + +return $has_missing |