How to fix common problems due to missing or corrupt packages
When your system behaves weird or applications don't work as they should or not at all, you maybe messed up your system. Now you could just reinstall your system from scratch and that might even be the best solution. But I recommend trying these two scripts first, as they are able to fix the one or other problem. If this doesn't fix your problem, either ask for help on the forums, Jabber or IRC channel or reinstall your system from scratch.
Checking for missing dependencies
This script can be useful when some of your application lacks one or multiple dependencies. No matter whether you removed them, didn't install them in the first place or the dependency information in the repository has been updated. As this script usually doesn't do match you may even consider running it from time to time to catch dependency information updates of already installed packages or to prevent dependency problems in general.
The script works by simulating a reinstallation of all packages with slapt-get and extracts the information about new packages, i.e. those not yet installed but required by some installed package.
Save the following code to a file named install-missing-deps and make it executable (e.g. chmod +x install-missing-deps). Now call it as root e.g. with su -c './install-missing-deps.
#!/bin/sh unset TMP new newpkgs line quit() { rm -rf $TMP exit $@ } trap 'echo "Killed by signal"; quit 2' INT TERM TMP=`mktemp -d` || quit 1 # list of installed, (still) available pkgs LANG=C slapt-get --available | grep 'inst=yes' | awk '{ print $1 }' >$TMP/reinst if egrep -q '^ *$' $TMP/reinst; then echo "Nothing to install" quit fi # missing deps will be listed as new pkgs if ! LANG=C slapt-get -s --reinstall -i $(cat $TMP/reinst) >$TMP/sget && \ ! egrep -q "^You don't have enough free space in " $TMP/sget; then quit 1 fi # extract new pkgs while read line; do if echo $line | egrep -q "^The following .*packages will be"; then new="false" fi if [ "x$new" == "xtrue" ]; then newpkgs="$newpkgs$line " fi if [ "x$line" == "xThe following NEW packages will be installed:" ]; then new="true" fi done <$TMP/sget if echo "$newpkgs" | egrep -q '^ *$'; then echo "Nothing to install" quit fi # install new pkgs (i.e. missing deps) slapt-get -p -i $newpkgs || quit 1 quit
Reinstall all packages
This script just reinstalls every package on your system. Unless you accidentally deleted /var/log/packages, this can e.g. fix problems because of deleted files. Better try other solutions before like Installing missing deps mentioned before, as this script is really time- and traffic-intensive. Although you basically reinstall your system completely, but all packages, settings and user files are retained. You should check for dotnew files afterwards.
Also if you're using lilo (or any other bootloader that uses blocklists to access the kernel), you should reinstall the bootloader with lilo -v (or whatever command your bootloader needs) after running the script. Otherwise your system could very well become unbootable as the kernel package is also reinstalled. It doesn't matter whether the version number of the package changed or not. For grub/grub2 this should be no problem.
Save the following code to a file named reinstall-everything and make it executable (e.g. chmod +x reinstall-everything). Now call it as root e.g. with su -c './reinstall-everything.
#!/bin/sh unset TMP quit() { rm -rf $TMP exit $@ } trap 'echo "Killed by signal"; quit 2' INT TERM TMP=`mktemp -d` || quit 1 # generate list of installed, (still) available pkgs LANG=C slapt-get --available | grep 'inst=yes' | awk '{ print $1 }' >$TMP/reinst if egrep -q '^ *$' $TMP/reinst; then echo "Nothing to install" quit fi # reinstall installed, available pkgs slapt-get --reinstall -p -i $(cat $TMP/reinst) || quit 1 quit