#!/bin/sh -e

set -e

if [ "$1" = "configure" ]; then
	# Version 1.0-10 moved the man page, so if upgrading from before that
	# version, then delete the old alternatives.

	if [ "$2" ]; then
		if dpkg --compare-versions 1.0-10 gt $2; then
			update-alternatives --remove w /usr/bin/w.bassman
		fi
	fi

	# Version 1.0-1 of the package lacked the alternatives. If upgrading
	# from that version, then add them. Also add them if installing for the
	# first time, or if upgrading from before 1.0-10. Otherwise, don't, so
	# changes to the priority will persist accross upgrades.

	if [ -z "$2" ] || dpkg --compare-versions 1.0-10 gt "$2"; then
		update-alternatives --install /usr/bin/w w /usr/bin/w.bassman 25 \
			--slave /usr/share/man/man1/w.1.gz w.1.gz /usr/share/man/man1/w.bassman.1.gz
	fi
fi

#DEBHELPER#
