#!/bin/sh -
# perl-5.005-base.prerm - called by dpkg before deleting
# written by Darren Stalder (whooptidoo!)
# $Id: base.prerm,v 1.2 1999/07/06 14:19:45 torin Exp torin $
#

set -e

# remove compatibility symlink for the move from FSSTD to FHS
if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/perl-5.005-base ];
then
        rm -f /usr/doc/perl-5.005-base
fi

case "$1" in
    # Change the alternatives & remove the binary only when removing
    remove)
        ver=`perl -e 'print $]'`
	linkit=
	# if this is the preferred version of perl, don't let it be gone after update-alternatives is done
	if [ "$ver" = "5.00503" ]; then
	  linkit="yes"
        fi
	(cd /usr/bin; test -f perl-5.005.dist || ln perl-5.005 perl-5.005.dist)
	update-alternatives --remove perl /usr/bin/perl-5.005
	if [ "$linkit" = "yes" ]; then
	  # Keep it as /usr/bin/perl if needed
	  (cd /usr/bin; test -f perl || ln -s perl-5.005 perl)
	else
	  # Remove it completely
	  rm -f /usr/bin/perl-5.005
	fi
    ;;

    failed-upgrade|upgrade|deconfigure)
    ;;

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

exit 0

#
# end of perl-5.005-base.prerm
