#!/bin/sh
# preinst script for gujin
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    install|upgrade)
	# If gujin is already installed (upgrade or re-install), try to remove the
	# previous install if possible (impossible if installed in B.E.E.R. area),
	# so next uninstall of current package will re-install the initial bootloader:
	# Do not remove anything if /boot/gujin.[bios|idechs|idelba|idel48] is installed.
	if [ -f /boot/gujin.ebios ] ;
		then if gujin --force --remove /boot/gujin.ebios ;
			then echo "Previous Gujin removed"; fi ; fi
	# if failed, move away /boot/gujin.ebios, it may be linked to the partition
	# boot record, or /boot reside on a partition not on the first disk:
	# (then, two uninstall are needed to get back to Grub)
	if [ -f /boot/gujin.ebios ] ; then \
		mv /boot/gujin.ebios /boot/gujin-`date -u +%Y-%m-%d-%0k-%0M`.ebios ; fi
    ;;

    abort-upgrade)
    ;;

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

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

#DEBHELPER#

exit 0


