#!/bin/sh -e
# This script can be called in the following ways:
#
# After the package was removed:
#	<postrm> remove
#
# After the package was purged:
#	<postrm> purge
#
# After the package was upgraded:
#	<old-postrm> upgrade <new-version>
# if that fails:
#	<new-postrm> failed-upgrade <old-version>
#
#
# After all of the packages files have been replaced:
#	<postrm> disappear <overwriting-package> <version>
#
#
# If preinst fails during install:
#	<new-postrm> abort-install
#
# If preinst fails during upgrade of removed package:
#	<new-postrm> abort-install <old-version>
#
# If preinst fails during upgrade:
#	<new-postrm> abort-upgrade <old-version>

# Enable udevadm again
enable_udevadm()
{
    rm -f /sbin/udevadm
    dpkg-divert --package fake-udev --rename --divert /sbin/udevadm.upgrade \
    		--remove /sbin/udevadm
}


# Remove configuration and log files
purge_files()
{
    if [ -f /etc/iftab ]; then
	rm -f /etc/iftab || true
    fi

    if [ -f /var/log/udev ]; then
	rm -f /var/log/udev || true
    fi
}


case "$1" in
    remove)
	;;

    purge)
	purge_files
	;;

    upgrade|failed-upgrade|disappear)
	;;

    abort-install|abort-upgrade)
	enable_udevadm
	;;

    *)
	echo "$0 called with unknown argument \`$1'" 1>&2
	exit 1
	;;
esac


exit 0
