All pastes #155191 Raw Edit

Miscellany

public text v1 · immutable
#155191 ·published 2006-08-30 22:06 UTC
rendered paste body
#!/bin/sh

#################################################################
# This script is a very basic method of testing the libraries
# and executables installed in certain locations for missing 
# libraries / dependencies
# This is totally amatuer, but maybe useful.  As a result of
# running this script I found one or two issues on my machine 
# which had been running its O/S for 18mths and having had 
# loads of packages installed from source over that time.
#################################################################


# Set the locations of the files to contain the search results
# ldd1 is a staging area eg /tmp/ldd1.txt
# ldd2 is the actual results eg /tmp/ldd2.txt
# EDIT THIS
ldd1="/tmp/ldd1.txt"
ldd2="/tmp/ldd2.txt"

# Firefox.bin is run from firefox which exports the lib path
# For ldd to work correctly the same thing needs to happen.
# Thanks to Pat Volkerding for pointing this out :)
# Add any other exports needed below
# EDIT THIS
LD_LIBRARY_PATH=/usr/lib/firefox
export LD_LIBRARY_PATH


##################################################################
# Should not need to edit the below for it to work.

# No debugging
set +x

# Reset the counter
count=0

echo
echo "This may take several minutes..."
echo

# Remove old files if they exist
if [ -e $ldd1 ]
  then
    rm $ldd1
fi

if [ -e $ldd2 ]
  then
    rm $ldd2
fi

# Loop through system directories, test files to see if they are executable or directories.
# If they are directories, then cd to them.
# If they are executable then ldd them and send the output to $ldd1
for i in /bin/* /lib/* /sbin/* /usr/lib/* /usr/sbin/* /usr/local/bin/* /usr/local/lib/* /usr/local/sbin/* /usr/X11R6/bin/* /usr/X11R6/lib/* /opt/kde/bin/* /opt/kde/lib/*; do
if [ -d $i ]
  then
    cd $i;
    for ii in *; do 
    if [ -x $ii -a -f $ii ]
      then
      echo $ii >> $ldd1; ldd $ii | grep "not found" >> $ldd1;
      ((count=count+1));
      printf "\r%d " $count;
    fi; done
  elif [ -x $i -a -f $i ]
    then
      echo $i >> $ldd1; ldd $i | grep "not found" >> $ldd1;
      ((count=count+1));
      printf "\r%d " $count;
fi; done

# Export the result to screen along with suggestions
echo
cat $ldd1 | grep -B1 "not found" >> $ldd2
echo
cat $ldd2
echo
echo "Done, results stored in $ldd2 and displayed above"
echo
echo "You may want to search the installed packages to find where a file has come from"
echo "for i in /var/log/packages/*; do cat \$1 | grep filename; done"
echo