aboutsummaryrefslogtreecommitdiff
path: root/revdep
diff options
context:
space:
mode:
authoremmett1 <emmett1.2miligrams@protonmail.com>2024-03-26 00:32:56 +0800
committeremmett1 <emmett1.2miligrams@protonmail.com>2024-03-26 00:32:56 +0800
commitcf41ee19b9776b02b814dfde6bcd5051481d04c2 (patch)
treed8b54aae6f53958af36f27f12143f088ae09b55d /revdep
parent84ec73d5575ac42c88394b49507e09e3af99715a (diff)
downloadautils-cf41ee19b9776b02b814dfde6bcd5051481d04c2.tar.gz
autils-cf41ee19b9776b02b814dfde6bcd5051481d04c2.zip
scripts added
Diffstat (limited to 'revdep')
-rwxr-xr-xrevdep33
1 files changed, 33 insertions, 0 deletions
diff --git a/revdep b/revdep
new file mode 100755
index 0000000..eb6d056
--- /dev/null
+++ b/revdep
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+SEARCH_DIRS="/bin /usr/bin /sbin /usr/sbin /lib /usr/lib /usr/libexec"
+TMPFILE=$(mktemp)
+
+trap 'rm -f $TMPFILE; printf "\033[0K"; exit 1' 1 2 3 15
+
+find $SEARCH_DIRS -type f \( -perm /+u+x -o -name '*.so' -o -name '*.so.*' \) -print 2> /dev/null | sort -u > $TMPFILE
+total=$(wc -l $TMPFILE | awk '{print $1}')
+count=0
+while read -r line; do
+ count=$(( count + 1 ))
+ libname=${line##*/}
+ printf " $(( 100*count/total ))%% $libname\033[0K\r"
+ case "$(file -bi "$line")" in
+ *application/x-sharedlib* | *application/x-executable* | *application/x-pie-executable*)
+ missinglib=$(ldd /$line 2>&1 | grep "Error loading shared library" | awk '{print $5}' | sed 's/://' | sort | uniq)
+ if [ "$missinglib" ]; then
+ for i in $missinglib; do
+ objdump -p /$line | grep NEEDED | awk '{print $2}' | grep -qx $i && {
+ ownby=$(spm -o $line | tail -n+2 | head -n1 | awk '{print $1}')
+ [ "$ownby" ] || continue
+ echo " $ownby: $line (requires $i)"
+ }
+ done
+ fi;;
+ esac
+done < $TMPFILE
+printf "\033[0K"
+
+rm -f $TMPFILE
+
+exit 0