#!/bin/bash #Script to check if all the dependencies are ok in a Linux system. #It is written for Slackware Linux but will work on others distro...hope so ;-) #but not for the Slackware install cd check code. #Coded by Pierluigi Previtali slack@NOSPAMslack.z00.it . #inspired by Cameron Kerr cameron.kerr@NOSPAMparadise.net.nz . #read the report in /tmp/ldd_report . #This script will search binary files and test with the ldd command #if the dependencies are ok and will make a report. #Code released under GPL2 #06/12/2002 if [ "$UID" != "0" ]; then echo "Sorry you are not ROOT...." exit fi SLACK_MANIFEST="/cdrom/slackware/MANIFEST.gz" CHECK_PATH="/" TMP_DIR="/tmp" UNCOMPRESSED_MANIFEST="$TMP_DIR/MANIFEST" DEF_LDD="$TMP_DIR/def_ldd_result" TMP_LDD="$TMP_DIR/tmp_ldd_result" DEF_RESULT="$TMP_DIR/ldd_report" TMP_FILES="$TMP_DIR/tmp_ldd_files" if [ -f "$DEF_LDD" ]; then rm "$DEF_LDD" fi if [ -f "$TMP_LDD" ]; then rm "$TMP_LDD" fi if [ -f "$TMP_FILES" ]; then rm "$TMP_FILES" fi if [ -f "$UNCOMPRESSED_MANIFEST" ]; then rm "$UNCOMPRESSED_MANIFEST" fi if [ -f "$DEF_RESULT" ]; then rm "$DEF_RESULT" fi if [ -f "$SLACK_MANIFEST" ]; then echo "The file $SLACK_MANIFEST is present..." else echo "Can't find the file $SLACK_MANIFEST ...insert the 8.1" echo "disk and mount it on /cdrom please otherwise" echo "it will not be able to check if the required libs are in" echo "the standard packages. Anyway the results will be " echo "displayed in the following file:" echo "$DEF_RESULT" echo "You can exit now pressing Control-C" echo "Wait for 10 second since now...." sleep 10 fi echo "Starting search....this may take several minutes...." RESULTS="`find $CHECK_PATH -type f -perm +111 -xdev -print| \ xargs file |grep ELF|awk '{print $1 }'|sed 's/://g'`" echo "Ok search finished...now checking libraries" sleep 1 for i in $RESULTS do echo $i output="`ldd \"$i\" 2> /dev/null | grep ' => not found$' | \ cut -d' ' -f1 | sed -e 's/^[[:space:]*]//'`" if [ "$output" ]; then echo "|---------------------------|" echo "| Warning missing libraries | " echo "|---------------------------| " echo "${output}" >> "$TMP_LDD" echo "${i}" >> "$TMP_FILES" make_list="1" sleep 1 else echo " Dependencies checked OK " fi done if [ "$make_list" ]; then cat "$TMP_LDD" | sort | uniq > "$DEF_LDD" echo "Missing libs">>"$DEF_RESULT" echo "************">>"$DEF_RESULT" cat "$DEF_LDD" >> "$DEF_RESULT" echo "Guilty files">>"$DEF_RESULT" echo "************">>"$DEF_RESULT" cat "$TMP_FILES" >> "$DEF_RESULT" clear echo "|---------------------------------|" echo " Read the file $DEF_RESULT" echo "|---------------------------------| " echo " Searching missing libraries in Slackware Packages" echo " this may take a while...." echo " you can always press Control-C and simply read the file:" echo " $DEF_RESULT ,without the section about the suggested packages" echo " to install" if [ -f "$SLACK_MANIFEST" ]; then cp "$SLACK_MANIFEST" "$TMP_DIR" gzip -d "$TMP_DIR"/MANIFEST.gz echo "Suggested packages">>"$DEF_RESULT" echo "******************">>"$DEF_RESULT" for i in `cat $DEF_LDD`;do echo "Searching $i ...." cat "$TMP_DIR"/MANIFEST | awk ' BEGIN { starting = 1 } /^\|\| Package: / { if( starting == 1 ) starting = 0 else printf( "\n" ) printf( "%s ", $3 ) } /^[-bcdlps][-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT][[:space:]]/ { printf( "%s ", $6 ) } END { printf( "\n" ) } ' | fgrep "${i}" | cut -d' ' -f1 >>"$DEF_RESULT" done if [ -f "$DEF_LDD" ]; then rm "$DEF_LDD" fi if [ -f "$TMP_LDD" ]; then rm "$TMP_LDD" fi if [ -f "$TMP_FILES" ]; then rm "$TMP_FILES" fi if [ -f "$UNCOMPRESSED_MANIFEST" ]; then rm "$UNCOMPRESSED_MANIFEST" fi else echo "Can't find the file $SLACK_MANIFEST ...insert the 8.1" echo "disk and mount it on /cdrom please and yes...restart the script :-)" echo "Anyway the results are in the following file:" echo "$DEF_RESULT" if [ -f "$DEF_LDD" ]; then rm "$DEF_LDD" fi if [ -f "$TMP_LDD" ]; then rm "$TMP_LDD" fi if [ -f "$TMP_FILES" ]; then rm "$TMP_FILES" fi exit fi else echo " All libraries are presents " fi