On Sat, Jan 15, 2011 at 11:52:34PM -0800, Mike Bird wrote: > Some people have expressed interested in obsolete config files > associated with currently installed packages. > > Here's a (slow) script for finding them, plus the merged results > of running the script on a dozen servers and workstations - mostly > Lenny and a few Squeeze. > > Output is space delimited, four fields: > debian-release package-name package-version obsolete-conffile The main problem with this script is that all it does is spit out the available information. It doesn't actually check if the user modified one of the conffiles. An example is attached. Modifying it to automatically purge "safe" packages where the user made no modifications would be fairly trivial. -- .''`. Roger Leigh : :' : Debian GNU/Linux http://people.debian.org/~rleigh/ `. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/ `- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
#!/bin/sh # # Check if a package may safely be purged. A package is considered # safe to purge if none of its conffiles have been changed from the # default (i.e. its MD5SUMS match the original). # # Copyright © 2011 Roger Leigh <rleigh@debian.org> # ################################################################################ set -e dpkg --get-selections | grep 'deinstall$' | awk '{print $1}' | while read pkg do echo "Checking $pkg..." (dpkg-query -W -f '${Conffiles}' "$pkg"; echo '') | while read line do if [ -n "$line" ]; then FILE="$(echo "$line" | sed -e 's/^[[:space:]]*\([[:print:]][[:print:]]*\)[[:space:]][[:space:]]*\([0-9a-f][0-9a-f]*\).*/\1/')" OLDMD5="$(echo "$line" | sed -e 's/^[[:space:]]*\([[:print:]][[:print:]]*\)[[:space:]][[:space:]]*\([0-9a-f][0-9a-f]*\).*/\2/')" NEWMD5="$(md5sum "$FILE" | sed -e 's/^\([0-9a-f][0-9a-f]*\)[[:space:]][[:space:]]*\([[:print:]][[:print:]]*\)$/\1/')" echo -n "$FILE" if [ "$OLDMD5" != "$NEWMD5" ]; then echo ' keep' else echo ' purge' fi fi done done
Attachment:
signature.asc
Description: Digital signature