#!/bin/bash # Make a list of libraries that the files mentioned in the supplied file link to. source `which ttPM-funcs` 2>/dev/null || exit 1 if [ $# = 0 ] then printMsg warning "Usage: `basename [-l] $0` file" printmsg warning "-l uses ldd instead of readelf to find linked libs" exit 1 fi USE_LDD=false if [ "$1" = "-l" ] then USE_LDD=true shift fi if [ ! -f $1 ] then printMsg warning "Given file does not exist" exit 1 fi TMPFILE1=`mktemp` TMPFILE2=`mktemp` # Create a list of all linked libraries for F in `cat ${1}` do if [ "$USE_LDD" = "true" ] then ldd ${F} 2>/dev/null | grep = >> $TMPFILE1 2>/dev/null else readelf -d $F 2>/dev/null | grep NEEDED >> $TMPFILE1 fi done if [ "$USE_LDD" = "true" ] then cat $TMPFILE1 | grep -v "not found" | grep -v "linux-gate.so.1" | cut -f 3 -d " " | sort | uniq else cat $TMPFILE1 | cut -d "[" -f 2,2 | sed -e "s@]@@g" | sort | uniq > $TMPFILE2 for i in $(cat $TMPFILE2) do if [ -f /lib/$i ] then echo /lib/$i elif [ -f /usr/lib/$i ] then echo /usr/lib/$i else # We don't care for libs that are not in the std libpath #echo $i : fi done fi # Clean the tmp file rm -f $TMPFILE1 $TMPFILE2