[Pkg-nagios-devel] Bug#396173: nagios2-common: removed logrotate file still left around

Marc Haber mh+debian-packages at zugschlus.de
Mon Oct 30 12:38:38 CET 2006


On Mon, Oct 30, 2006 at 11:22:24AM +0100, Marc Haber wrote:
> We need to take local care about removing the file. I do not have a
> clue about how to do this in a policy conformant way.

Possibly ugly code to do this:
# Remove a no-longer used conffile
rm_conffile() {
    CONFFILE="$1"
    if [ -e "$CONFFILE" ]; then
        md5sum="$(md5sum \"$CONFFILE\" | sed -e \"s/ .*//\")"
        old_md5sum="$(sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\'
               $CONFFILE'{s/.* //;p}}\" /var/lib/dpkg/status)"
        if [ "$md5sum" != "$old_md5sum" ]; then
            echo "Obsolete conffile $CONFFILE has been modified."
            echo "Saving as $CONFFILE.dpkg-bak ..."
            mv -f "$CONFFILE" "$CONFFILE".bak
        else
            echo "Removing obsolete conffile $CONFFILE ..."
            rm -f "$CONFFILE"
        fi
    fi
}

preinst code:
case "$1" in install|upgrade)
        if dpkg --compare-versions "$2" lt "2.5-3"; then
                rm_conffile "<filename>"
        fi
        ;;
esac



-- 
-----------------------------------------------------------------------------
Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
Mannheim, Germany  |  lose things."    Winona Ryder | Fon: *49 621 72739834
Nordisch by Nature |  How to make an American Quilt | Fax: *49 621 72739835




More information about the Pkg-nagios-devel mailing list