summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2019-03-22 12:54:00 (EDT)
committer P. J. McDermott <pj@pehjota.net>2019-03-22 12:54:00 (EDT)
commit8595ada6ead613afd47c815045a7d1b2c425a351 (patch)
treed10aaa3e2bdca0328190cfd716c7eb4232d3ba68
parentfa0ed86cbefd4a45d190f2ce1b2594e46addef2d (diff)
oh-shlibdeps: Use readelf instead of ldd
-rw-r--r--locale/en_US.sh1
-rw-r--r--src/oh-shlibdeps.sh59
2 files changed, 50 insertions, 10 deletions
diff --git a/locale/en_US.sh b/locale/en_US.sh
index 1323689..db39953 100644
--- a/locale/en_US.sh
+++ b/locale/en_US.sh
@@ -30,4 +30,5 @@ msg_opkhelper_chmod_man='Setting mode of manual files...'
msg_opkhelper_chmod_bin='Setting mode of program files in "%s"...'
msg_opkhelper_no_capable_build_sys='No capable build system found'
msg_opkhelper_no_capable_host_arch='No capable build system host architecture found'
+msg_opkhelper_shlib_no_lib='Library "%s" not found'
msg_opkhelper_shlib_no_pkg='No package found containing library "%s"'
diff --git a/src/oh-shlibdeps.sh b/src/oh-shlibdeps.sh
index cf5473e..8077166 100644
--- a/src/oh-shlibdeps.sh
+++ b/src/oh-shlibdeps.sh
@@ -21,24 +21,63 @@
. '@pkgdatadir@/load.sm'
+LIBRARY_PATH='@library_path@'
+READELF_NEEDED_SED='s/^ 0x[0-9a-f]* (NEEDED) *Shared library: \[\(.*\)\]$/\1/p'
+
+find_lib()
+{
+ local lib="${1}"
+ shift 1
+ local pkg=
+ local dir=
+
+ # Check just-built packages.
+ for pkg in *.data/; do
+ IFS=':'
+ for dir in ${LIBRARY_PATH}; do
+ unset IFS
+ if [ -r "${pkg}/${dir}/${lib}" ]; then
+ printf '%s,\n' "${pkg%.data/}"
+ return 0
+ fi
+ done
+ unset IFS
+ done
+
+ # Check installed packages.
+ IFS=':'
+ for dir in ${LIBRARY_PATH}; do
+ unset IFS
+ if [ -r "${dir}/${lib}" ]; then
+ lib="${dir}/${lib}"
+ pkg="$('@OPKG@' search "${lib}" | sed 's/ - .*$//')"
+ if [ -n "${pkg}" ]; then
+ printf '%s,\n' "${pkg}"
+ return 0
+ else
+ oh_warn "$(oh_get_msg 'shlib_no_pkg')" "${lib}"
+ return 0
+ fi
+ fi
+ done
+ unset IFS
+
+ oh_warn "$(oh_get_msg 'shlib_no_lib')" "${lib}"
+ return 0
+}
+
find_needed()
{
local elf="${1}"
shift 1
while IFS='' read -r lib; do
- pkg="$('@OPKG@' search "${lib}" | sed 's/ - .*$//')"
- if [ -z "${pkg}" ]; then
- oh_warn "$(oh_msg 'shlib_no_pkg')" "${lib}"
- else
- printf '%s,\n' "${pkg}"
- fi
+ find_lib "${lib}"
done <<-EOF
- $('@LDD@' "${elf}" | sed -n 's/^\t.* => \(.*\) (.*)$/\1/p' \
- 2>/dev/null)
+ $('@READELF@' -d "${elf}" | sed -n "${READELF_NEEDED_SED}")
EOF
- # The above ldd's stderr is redirected to /dev/null to hide glibc ldd's
- # "you do not have execution permission" warning.
+
+ return 0
}
find_elves()