#! /bin/sh -e

if [ "${BASEDIR:=/}" = "/" ]; then
    BASEDIR=""
fi

# dpkg triggers support for update-mime
if [ "$1" = "triggered" ]; then
    test -x $BASEDIR/usr/sbin/update-mime && $BASEDIR/usr/sbin/update-mime --triggered
    exit 0
fi


# Remove the old status directory (and any orphaned install-mime program)
rm -fr $BASEDIR/var/lib/mime
rm -f  $BASEDIR/usr/sbin/install-mime


# Remove the "see" as alternative for "view"
# Closes: #623384
# This command can be removed after the Jessie release
update-alternatives \
    --altdir $BASEDIR/etc/alternatives \
    --admindir $BASEDIR/var/lib/dpkg/alternatives \
	--remove view /usr/bin/see


# Run the update program
if [ -x $BASEDIR/usr/sbin/update-mime ]; then
    $BASEDIR/usr/sbin/update-mime --triggered
fi
