summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xfind-sodeps.sh38
-rwxr-xr-xfind-soprovides.sh39
2 files changed, 77 insertions, 0 deletions
diff --git a/find-sodeps.sh b/find-sodeps.sh
new file mode 100755
index 0000000..8836906
--- /dev/null
+++ b/find-sodeps.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+if [[ -z $1 ]]; then
+ echo "$(basename "$0") <package file>"
+ exit 1
+fi
+
+tmpdir=$(mktemp -d /tmp/find-sodeps.XXXXXXX)
+trap "rm -rf '$tmpdir'" EXIT INT TERM
+
+tar -C $tmpdir -xf "$1"
+
+cd $tmpdir
+
+in_array() {
+ local needle=$1; shift
+ [[ -z $1 ]] && return 1 # Not Found
+ local item
+ for item in "$@"; do
+ [[ $item = $needle ]] && return 0 # Found
+ done
+ return 1 # Not Found
+}
+
+
+find . -type f | while read filename
+do
+ soarch=$(objdump -a "$filename" 2>/dev/null | sed -rn 's/.* file format (.*)$/\1/p' | tr - _)
+ [ -n "$soarch" ] || continue
+ for sofile in $(readelf -d "$filename" 2> /dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p')
+ do
+ soname=$(sed -rn 's/(.*)\.so.*/\1.so/p' <<< "$sofile")
+ if ! in_array "${soname}" ${sodepends[@]}; then
+ echo "${soname}"
+ sodepends=(${sodepends[@]} "${soname}")
+ fi
+ done
+done
diff --git a/find-soprovides.sh b/find-soprovides.sh
new file mode 100755
index 0000000..dee1078
--- /dev/null
+++ b/find-soprovides.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+if [[ -z $1 ]]; then
+ echo "$(basename "$0") <package file>"
+ exit 1
+fi
+
+tmpdir=$(mktemp -d /tmp/find-sodeps.XXXXXXX)
+trap "rm -rf '$tmpdir'" EXIT INT TERM
+
+tar -C $tmpdir -xf "$1"
+
+cd $tmpdir
+
+in_array() {
+ local needle=$1; shift
+ [[ -z $1 ]] && return 1 # Not Found
+ local item
+ for item in "$@"; do
+ [[ $item = $needle ]] && return 0 # Found
+ done
+ return 1 # Not Found
+}
+
+find . -type f -name \*.so\* | while read filename
+do
+ if readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
+ soarch=$(objdump -a "$filename" 2>/dev/null | sed -rn 's/.* file format (.*)$/\1/p' | tr - _)
+ sofile=$(readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Library soname: \[(.*)\].*/\1/p')
+ [ -z "$sofile" ] && sofile="$(basename "$filename")"
+
+ soname=$(sed -rn 's/(.*)\.so.*/\1.so/p' <<< "$sofile")
+ if ! in_array "${soname}" ${soprovides[@]}; then
+ echo "${soname}"
+ soprovides=(${soprovides[@]} "${soname}")
+ fi
+ fi
+done
+