#!/bin/sh -e

# Automatically added by dh_installdocs
if [ "$1" = "configure" ]; then
	if [ -d /usr/doc -a ! -e /usr/doc/perl-5.005-base -a -d /usr/share/doc/perl-5.005-base ]; then
		ln -sf ../share/doc/perl-5.005-base /usr/doc/perl-5.005-base
	fi
fi
# End automatically added section


if [ "$1" = configure ]
then
    # clean up stray binary (dpkg doesn't know about perl-5.005 as it
    # was packaged as perl-5.005.dist and renamed in the postinst).
    rm -f /usr/bin/perl-5.005

    # more cruft, we don't ship this anymore
    rm -f /usr/bin/patchls

    # the old packages could remove /usr/local/lib in some cases
    if [ -w /usr/local ]
    then
	if [ ! -e /usr/local/lib ]
	then
	    mkdir /usr/local/lib
	    chown root:staff /usr/local/lib
	    chmod 2775 /usr/local/lib
	fi
    fi

    # see if we need to bother messing with alternatives
    [ -L /etc/alternatives/perl ] || exit 0

    # update-alternatives is currently a perl program
    if [ ! -x /usr/bin/perl ]
    then
	echo "Error: no /usr/bin/perl, can't clean up old alternatives."
	exit 0
    fi

    # u-a may destroy the target
    preserve=/usr/bin/perl.preserve-during-upgrade
    ln /usr/bin/perl $preserve

    $preserve -S update-alternatives --auto perl
    $preserve -S update-alternatives --remove perl /usr/bin/perl-5.005

    # restore
    rm -f /usr/bin/perl
    mv $preserve /usr/bin/perl
fi

exit 0
