#! /bin/sh
# postrm script cedarview-drm
#
# see: dh_installdeb(1)
#
# Copyright (C) 2007 Mario Limonciello
# Copyright (C) 2009-2011 Canonical Ltd.

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see /usr/share/doc/packaging-manual/

BLACKLIST_FILE=/etc/modprobe.d/cedarview-drm.conf

case "$1" in
    remove|purge)
        # Remove blacklist file
        rm -f $BLACKLIST_FILE

        # Restore the default lightdm.conf, if any
        if dpkg-divert --list /etc/lightdm/lightdm.conf | grep 'cedarview-drm' > /dev/null ; then
            rm -f /etc/lightdm/lightdm.conf
            dpkg-divert --remove --rename --package cedarview-drm --divert /etc/lightdm/lightdm.conf.cedarview-drm /etc/lightdm/lightdm.conf > /dev/null
        fi

        # Update initramfs, in case we were loaded into it
        update-initramfs -u

        if which update-grub-gfxpayload >/dev/null 2>&1; then
            update-grub-gfxpayload
        fi
        ;;

    upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
        ;;

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

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#
