crux-musl

Unnamed repository; edit this file 'description' to name the repository.
git clone https://codeberg.org/emmett1/crux-musl
Log | Files | Refs | README | LICENSE

revdep-musl (1431B)


      1 #!/bin/sh
      2 
      3 helpmsg() {
      4 	echo "usage: $0 [-v|-h]"
      5 	echo "  -v   be verbose"
      6 	echo "  -h   print this help message"
      7 	exit 0
      8 }
      9 
     10 SEARCH_DIRS="/bin /usr/bin /sbin /usr/sbin /lib /usr/lib /usr/libexec"
     11 TMPFILE=$(mktemp)
     12 
     13 trap 'rm -f $TMPFILE; printf "\033[0K"; exit 1' 1 2 3 15
     14 
     15 while [ "$1" ]; do
     16 	case $1 in
     17 		-v) verbose=1;;
     18 		-h) helpmsg;;
     19 	esac
     20 	shift
     21 done
     22 
     23 find $SEARCH_DIRS -type f \( -perm /+u+x -o -name '*.so' -o -name '*.so.*' \) -print 2> /dev/null | sort -u > $TMPFILE
     24 total=$(wc -l $TMPFILE | awk '{print $1}')
     25 count=0
     26 while read -r line; do
     27 	count=$(( count + 1 ))
     28 	libname=${line##*/}
     29 	if [ "$verbose" ]; then
     30 		printf " $(( 100*count/total ))%% $libname\033[0K\r"
     31 	fi
     32 	case "$(file -bi "$line")" in
     33 		*application/x-sharedlib* | *application/x-executable* | *application/x-pie-executable*)
     34 			missinglib=$(ldd /$line 2>&1 | grep "Error loading shared library" | awk '{print $5}' | sed 's/://' | sort | uniq)
     35 			if [ "$missinglib" ]; then
     36 				for i in $missinglib; do
     37 					objdump -p /$line | grep NEEDED | awk '{print $2}' | grep -qx $i && {
     38 						ownby=$(pkginfo -o $line | tail -n1 | awk '{print $1}')
     39 						[ "$ownby" ] || continue
     40 						if [ "$verbose" ]; then
     41 							echo " $ownby: $line (requires $i)"
     42 						else
     43 							echo "$p" | tr ' ' '\n' | grep -xq $ownby || {
     44 								echo $ownby
     45 								p="$p $ownby"
     46 							}
     47 						fi
     48 					}
     49 				done
     50 			fi;;
     51 	esac
     52 done < $TMPFILE
     53 printf "\033[0K"
     54 
     55 rm -f $TMPFILE
     56 
     57 exit 0