#!/bin/sh

set -e

case "$1" in
    (configure)
        :
    ;;
    (abort-upgrade|abort-remove|abort-deconfigure)
	exit 0
    ;;
    (*)
	echo "postinst called with unknown argument \`$1'" >&2
	exit 0
    ;;
esac


for conffile in zlogin zlogout zprofile zshenv zshrc; do
    dpkg-maintscript-helper rm_conffile /etc/zsh-beta/$conffile 5 -- "$@"
done
if [ -d /etc/zsh-beta ]; then
    rmdir /etc/zsh-beta || true
fi

update-alternatives --remove zsh-beta /usr/bin/zsh
update-alternatives --remove zsh-beta /bin/zsh4
update-alternatives --remove zsh-beta /bin/zsh5

# Replace documentation directory with symlink
docdir="/usr/share/doc/zsh-beta"
if [ -d $docdir -a ! -L $docdir ]; then
    if rmdir $docdir 2>/dev/null; then
        ln -sf zsh-common $docdir
    fi
fi

#DEBHELPER#

exit 0
