freebsd-ports/lang/perl5.16/files/use.perl.in
Mathieu Arnold 398dca09df To ease up with future upgrades, move PERL_VERSION into a separate file.
While there, remove 8.4 support, and do some cleanup.

Sponsored by:	Absolight
2015-08-31 13:17:48 +00:00

52 lines
1.4 KiB
Bash

#!/bin/sh
# $FreeBSD$
LINK_USRBIN="%%LINK_USRBIN%%"
: ${OSVERSION:=`/sbin/sysctl -n kern.osreldate`};
PERL_VERSION="%%PERL_VERSION%%"
special_link_list="perl perl5"
do_remove_links()
{
for binary in ${special_link_list} ; do
if [ -L "/usr/bin/${binary}" ] ; then
/bin/rm -f "/usr/bin/${binary}"
fi
done
bins=`/bin/ls /usr/bin/*perl*5.* ${PKG_PREFIX}/bin/*perl*5.* 2>/dev/null`
for binary in ${bins} ; do
if [ -L "${binary}" ] ; then
echo "use.perl: Removing ${binary} installed by an older perl port"
/bin/rm -f "${binary}"
fi
done
}
do_create_links()
{
for binary in ${special_link_list} ; do
if [ -f "/usr/bin/${binary}" ] ; then
echo "use.perl: Backing up /usr/bin/${binary} as /usr/bin/${binary}.freebsd"
/bin/mv -f "/usr/bin/${binary}" "/usr/bin/${binary}.freebsd"
fi
if [ -e "/usr/bin/${binary}" ] ; then
echo "use.perl: /usr/bin/${binary} is still there, which should not happen"
elif [ -e "${PKG_PREFIX}/bin/perl${PERL_VERSION}" ] ; then
/bin/ln -sf "${PKG_PREFIX}/bin/perl${PERL_VERSION}" "/usr/bin/${binary}"
else
echo "use.perl: ${PKG_PREFIX}/bin/perl${PERL_VERSION} is not there, a symlink won't do any good"
fi
done
}
if [ "$2" = "POST-INSTALL" ] ; then
if [ ${LINK_USRBIN} = yes ] ; then
do_remove_links
do_create_links
fi
elif [ "$2" = "POST-DEINSTALL" ] ; then
[ ${LINK_USRBIN} = yes ] && do_remove_links
fi
exit 0