PDA

Visualizza la versione completa : nuova versione script dipendenze


pierluigi p
18-04-2003, 13:48
Allura quello che segue e' uno script per controllare se le dipendenze in una macchina slackware sono soddisfatte...in soldoni se tutte le lib linkate dinamicamente ci sono. (errori di seg fault ecc)
funge pure su altre distro ma chiaramente non suggerisce pacchetti mancanti.
La nuova versione aggiunge:
i colori :-)

per slack la scelta della versione del cd (8.x,9.x)

la scelta del path da verificare (tutto il sistema, /usr/bin, /tua/dir, etc)
per slack le eventuali inconsistenze nel /etc/ld.so.conf, cioe' se le lib ci sono e il pacchetto e' installato ma dovete aggiungere il path affinche' il sistema lo sappia

vari fix e migliorie che non ricordo....



#!/bin/bash
#Script to check if all the dependencies are ok in the whole system or just
#a part of it.
#It is written for Slackware Linux but will work on others distro...hope so ;-)
#but not for the Slackware install cd check code part.
#Coded by Pierluigi Previtali slack@slack.z00.it .
#inspired by Cameron Kerr cameron.kerr@paradise.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
#17/04/2003 mods for 9.x compatibility, addedd colors, path choice,already
#installed packages check, various fix....enjoy.

#declare vars
BLUE="\033[0;34m"
GREEN="\033[0;32m"
RED="\033[0;31m"
YLW="\033[1;33m"
N_C="\033[0m"
LD_CONF="/etc/ld.so.conf"
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"
TMP_PKG="$TMP_DIR/tmp_pkg_files"
#start script
if [ "$UID" != "0" ]; then
echo -e "${RED} Sorry you are not ROOT....${N_C}"
exit
fi

#obtain various infos
#start with version
echo -e "${YLW}Please choose your version$N_C"
echo ""
OPT="8.x 9.x quit"
select opt in $OPT;do
if [ "$opt" = "8.x" ];then
SLACK_MANIFEST="/mnt/cdrom/slackware/MANIFEST.gz"
CMD="gunzip"
EXT=".gz"
break
elif [ "$opt" = "9.x" ];then
SLACK_MANIFEST="/mnt/cdrom/slackware/MANIFEST.bz2"
CMD="bunzip2"
EXT=".bz2"
break
elif [ "$opt" = "quit" ];then
echo "Quitting...."
exit
else
echo -e "${RED}Possible options are ${YLW}\n(1)\n(2)\n(3)$N_C"

fi
done

#now the path
echo " "
echo -e "${YLW}Please choose your path $N_C"
echo " "
select opt in "Check the whole fs [/]" "Check a certain path \
[/your/path/here/]" "quit";do
if [ "$opt" = "Check the whole fs [/]" ];then
break
elif [ "$opt" = "Check a certain path [/your/path/here/]" ];then
echo -n -e "${YLW}Path: ${N_C}"
read NEW_PATH
if [ -d "$NEW_PATH" ];then
CHECK_PATH=${NEW_PATH}
echo " "
echo -e "The start path is ${YLW}$CHECK_PATH"
break
else
echo " "
echo -e "${RED}The dir ${YLW}[${NEW_PATH}] ${RED}seems to be missing${N_C}"
echo -e "${RED}Assuming default ${YLW}[/]${N_C}"
sleep 2
break
fi
elif [ "$opt" = "quit" ];then
echo "Quitting...."
exit
else
echo -e "${RED}Possible options are ${YLW}\n(1)\n(2)\n(3)$N_C"

fi
done

#cleanup
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 "$TMP_PKG" ]; then
rm "$TMP_PKG"
fi

#check for MANIFEST
if [ -f "$SLACK_MANIFEST" ]; then
echo " "
echo -e "${GREEN}The file $SLACK_MANIFEST is present...$N_C"
else
echo " "
echo -e "${RED}Can't find the file $SLACK_MANIFEST ${N_C}"
echo " "
echo "Insert the disk and mount it on /mnt/cdrom please otherwise"
echo "the script will not be able to check if the required libs are in"
echo "the standard packages. Anyway the results without the suggested"
echo "packages will be displayed in the following file:"
echo -e "${YLW}$DEF_RESULT${N_C}"
echo "You can exit now pressing Control-C"
echo "Wait for 10 second since now...."
sleep 10
fi
echo " "
echo "Your $LD_CONF have the following entries: "
echo -e -n "${YLW}"
cat $LD_CONF
echo -e "\n${N_C}Updating the lib cache.... "
ldconfig
echo "Done.... "
echo "Starting search....this may take several minutes...."
sleep 1
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 " "
echo $i
output="`ldd \"$i\" 2> /dev/null | grep ' => not found$' | \
cut -d' ' -f1 | sed -e 's/^[[:space:]*]//'`"
if [ "$output" ]; then
echo -e "${RED}Warning missing libraries ${N_C} "
echo "${output}" >> "$TMP_LDD"
echo "${i}" >> "$TMP_FILES"
make_list="1"
#sleep 1
else
echo -e "${GREEN}Dependencies checked OK ${N_C}"
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 -e "\nGuilty files:\n">>"$DEF_RESULT"
cat "$TMP_FILES" >> "$DEF_RESULT"
clear
echo -e " Results are in ${YLW}$DEF_RESULT${N_C}\n"
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"
${CMD} ${TMP_DIR}/MANIFEST${EXT}
echo -e "\nSuggested packages:\n">>"$DEF_RESULT"
for i in `cat $DEF_LDD`;do
echo " "
echo -e "Searching ${YLW}$i${N_C} ...."
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 >>"$TMP_PKG"
done
cat $TMP_PKG | sort | uniq >> $DEF_RESULT
echo -e "\nCheck for inconsistences in ${YLW}$LD_CONF"
for i in `cat $TMP_PKG | sort | uniq`;do
pkg_name=`basename $i |sed 's/.tgz$//g'`
pkg_found=`ls /var/log/packages/* | grep $pkg_name`
if [ "$pkg_found" ];then
echo -e "${RED}Inconsistences found ${N_C}about ${YLW}$i${N_C}"
echo -e "\nThe package $i is installed but the libs path is not properly set in $LD_CONF ? " >> $DEF_RESULT
fi
done
echo -e "\nOk....finished read the report in ${YLW}$DEF_RESULT${N_C}\n"

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 "$TMP_PKG" ]; then
rm "$TMP_PKG"
fi
else
echo -e "\n${RED}Can't find the file $SLACK_MANIFEST ${N_C}...insert the 8.1"
echo "disk and mount it on /mnt/cdrom please and yes...restart the script :-)"
echo "Anyway the results are in the following file:"
echo -e "${YLW}$DEF_RESULT${N_C}"
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 -e "${GREEN}All libraries are presents ${N_C}"
fi




enjoy...pierluigi

Ilmalcom
18-04-2003, 15:01
Complimenti :D

pierluigi p
18-04-2003, 20:02
;) 'azie && up

pierluigi

andy caps
18-04-2003, 20:09
:quipy: mi ha fatto tornare la voglia di slak ... sto scaricando

andy caps
07-11-2004, 02:52
.

Loading