ports/55760: [patch] make Perl versions coexist

Sergey Matveychuk sem at ciam.ru
Wed Aug 20 09:42:19 UTC 2003


>Number:         55760
>Category:       ports
>Synopsis:       [patch] make Perl versions coexist
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 20 02:41:34 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Sergey Matveychuk
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD sem-home.ciam.ru 5.1-CURRENT FreeBSD 5.1-CURRENT #4: Thu Jul 31 11:50:58 MSD 2003 root at sem-home.ciam.ru:/usr/obj/usr/src/sys/SEM-HOME i386


	
>Description:
	
	These patches for perl5 and perl5.8 ports allow all Perl versions
	coexist. You can set Perl as active with use.perl <version> or
	use.perl (system for 4.x). Active perl is /usr/bin/perl and
	/usr/local/bin/perl.
	But you can use all Perls you have installed any time.
>How-To-Repeat:
	
>Fix:

	

--- perl5.patch begins here ---
diff -ruN perl5.orig/Makefile perl5/Makefile
--- perl5.orig/Makefile	Sat Aug 16 17:23:01 2003
+++ perl5/Makefile	Tue Aug 19 22:05:16 2003
@@ -7,7 +7,7 @@
 
 PORTNAME=	perl
 PORTVERSION=	${PERL_VER}
-PORTREVISION=	13
+PORTREVISION=	14
 CATEGORIES=	lang devel perl5
 MASTER_SITES=	${MASTER_SITE_PERL_CPAN} \
 		${MASTER_SITE_LOCAL:S/$/:local/}
@@ -28,10 +28,12 @@
 CONFIGURE_ARGS=	-sde -Dprefix=${PREFIX} \
 	-Darchlib=${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH} \
 	-Dprivlib=${PREFIX}/lib/perl5/${PERL_VER} \
+	-Dman1dir=${PREFIX}/lib/perl5/${PERL_VER}/man/man1 \
 	-Dman3dir=${PREFIX}/lib/perl5/${PERL_VER}/man/man3 \
 	-Dsitearch=${PREFIX}/lib/perl5/site_perl/${PERL_VER}/${PERL_ARCH} \
 	-Dsitelib=${PREFIX}/lib/perl5/site_perl/${PERL_VER} \
-	-Dscriptdir=${PREFIX}/bin \
+	-Dbin=${PREFIX}/bin/perl-${PERL_VER} \
+	-Dscriptdir=${PREFIX}/bin/perl-${PERL_VER} \
 	-Dcc="${CC}" \
 	-Ui_malloc -Ui_iconv -Dccflags=-DAPPLLIB_EXP=\"${BSDPAN_DEST}\"
 INSTALLS_SHLIB=	yes
@@ -51,6 +53,11 @@
 CONFIGURE_ARGS+=	-Dusemymalloc=n
 .endif
 
+PLIST_SUB+=		PERL_VERSION=${PERL_VERSION} \
+			PERL_VER=${PERL_VER} \
+			PERL_ARCH=${PERL_ARCH} \
+			SITE_PERL=${SITE_PERL:S|^${LOCALBASE}/||}
+
 INCLUDEDIR=	/usr/include
 
 .ifdef USE_PERL5
@@ -59,7 +66,9 @@
 
 .include <bsd.port.pre.mk>
 
-.if ${OSVERSION} >= 500043
+.if defined(INACTIVE)
+PKGMESSAGE=	${WRKDIR}/pkg-message
+.else
 PKGMESSAGE=	${PKGDIR}/.not-here
 .endif
 
@@ -138,6 +147,7 @@
 MAN3+=	GDBM_File.3
 .endif
 
+MAN1PREFIX=	${PREFIX}/lib/perl5/${PERL_VER}
 MAN3PREFIX=	${PREFIX}/lib/perl5/${PERL_VER}
 
 test:
@@ -150,28 +160,57 @@
 BSDPAN_REVISION=1
 
 post-patch:
-	${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
+	@${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
+		${FILESDIR}/use.perl \
+		> ${WRKDIR}/use.perl
+	@${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
 		-e 's|%%PERL_VER%%|${PERL_VER}|g;' \
 		-e 's|%%PERL_VERSION%%|${PERL_VERSION}|g;' \
 		-e 's|%%PERL_ARCH%%|${PERL_ARCH}|g;' \
-		${FILESDIR}/use.perl \
-		> ${WRKDIR}/use.perl
+		${FILESDIR}/set.perl \
+		> ${WRKDIR}/set.perl
+.if defined(INACTIVE)
+	@${SED} -e 's|%%PERL_VER%%|${PERL_VER}|g;' \
+		${PKGDIR}/pkg-message \
+		> ${PKGMESSAGE}
+.if ${OSVERSION} < 500043
+	@${ECHO} >> ${PKGMESSAGE}
+	@${ECHO} >> ${PKGMESSAGE}
+	@${ECHO} "At any time you can also type" >> ${PKGMESSAGE}
+	@${ECHO} >> ${PKGMESSAGE}
+	@${ECHO} "  use.perl system" >> ${PKGMESSAGE}
+	@${ECHO} >> ${PKGMESSAGE}
+	@${ECHO} "if you wish to revert back to the system version of perl." >> ${PKGMESSAGE}
+.endif
+.endif
+
+pre-install:
+	@if [ -e ${PREFIX}/bin/perl -a ! -L ${PREFIX}/bin/perl ]; then \
+		${ECHO_MSG} "===>  You have old-style perl port installed in ${PREFIX}/bin"; \
+		${ECHO_MSG} "      Deinstall it first and try again."; \
+		exit 1; \
+	fi
 
 post-install:
-	@strip ${PREFIX}/bin/perl ${PREFIX}/bin/suidperl
-	@${LN} -sf ${PREFIX}/bin/perl ${PREFIX}/bin/perl5
-	@${LN} -sf ${PREFIX}/bin/perl ${PREFIX}/bin/perl${PERL_VER}
-	${INSTALL_SCRIPT} ${WRKDIR}/use.perl ${PREFIX}/bin/use.perl
+	@${STRIP_CMD} ${PREFIX}/bin/perl-${PERL_VER}/perl ${PREFIX}/bin/perl-${PERL_VER}/suidperl
 .for file in ${BSDPAN_FILES}
 	${MKDIR} ${BSDPAN_DEST}/${file:H}
 	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
 		${BSDPAN_WRKSRC}/${file} ${BSDPAN_DEST}/${file}
 .endfor
-	@(cd ${INCLUDEDIR} && ${PREFIX}/bin/h2ph *.h machine/*.h sys/*.h)
-.if ${OSVERSION} < 500043
+	@(cd ${INCLUDEDIR} && ${PREFIX}/bin/perl-${PERL_VER}/h2ph *.h machine/*.h sys/*.h)
+	${INSTALL_SCRIPT} ${WRKDIR}/use.perl ${PREFIX}/bin
+	${INSTALL_SCRIPT} ${WRKDIR}/use.perl ${PREFIX}/bin/perl-${PERL_VER}
+	${INSTALL_SCRIPT} ${WRKDIR}/set.perl ${PREFIX}/bin/perl-${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/set.perl ${PREFIX}/bin/set.perl${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/perl ${PREFIX}/bin/perl${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/perl /usr/bin/perl${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/sperl${PERL_VER} ${PREFIX}/bin/sperl${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/sperl${PERL_VER} /usr/bin/sperl${PERL_VER}
+.if defined(INACTIVE)
 	@fmt ${PKGMESSAGE}
 .else
-	@${PREFIX}/bin/use.perl port
+	@${PREFIX}/bin/use.perl ${PERL_VER}
 .endif
 
 .include <bsd.port.post.mk>
diff -ruN perl5.orig/files/set.perl perl5/files/set.perl
--- perl5.orig/files/set.perl	Thu Jan  1 03:00:00 1970
+++ perl5/files/set.perl	Tue Aug 19 22:05:16 2003
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+PREFIX="%%PREFIX%%"
+current_date=`date`
+msg_line="# -- use.perl generated line -- #"
+man_line="OPTIONAL_MANPATH	%%PREFIX%%/lib/perl5/%%PERL_VERSION%%/man"
+files_to_perform=`find ${PREFIX}/bin/perl-%%PERL_VER%% -type f ! -name perl%%PERL_VER%% ! -name sperl%%PERL_VER%% ! -name use.perl ! -name set.perl`
+
+if [ "x$1" = "xactive" ]; then
+	ln -sf ${PREFIX}/bin/perl-%%PERL_VER%%/perl /usr/bin/perl
+	ln -sf ${PREFIX}/bin/perl-%%PERL_VER%%/perl /usr/bin/perl5
+	ln -sf ${PREFIX}/bin/perl-%%PERL_VER%%/sperl /usr/bin/sperl5
+	ln -sf ${PREFIX}/bin/perl-%%PERL_VER%%/suidperl /usr/bin/suidperl
+	for f in ${files_to_perform}
+	do
+		ln -sf $f ${PREFIX}/bin/`basename $f`
+	done
+
+	cat << EOM >> /etc/make.conf
+# -- use.perl generated deltas -- #
+# Created: ${current_date}
+# Setting to use base perl from ports:
+PERL_VER=%%PERL_VER%%
+PERL_VERSION=%%PERL_VERSION%%
+PERL_ARCH=%%PERL_ARCH%%
+NOPERL=yo
+NO_PERL=yo
+NO_PERL_WRAPPER=yo
+EOM
+
+	if ! grep -q "$man_line" /etc/manpath.config; then
+		echo "$msg_line" >> /etc/manpath.config
+		echo "$man_line" >> /etc/manpath.config
+	fi
+	exit 0;
+
+fi
+
+if [ "x$1" = "xinactive" ]; then
+	rm -f /usr/bin/perl
+	rm -f /usr/bin/perl5
+	rm -f /usr/bin/sperl5
+	rm -f /usr/bin/suidperl
+	for f in ${files_to_perform}
+	do
+		rm -f ${PREFIX}/bin/`basename $f`
+	done
+
+	cat << EOM >> /etc/make.conf
+# -- use.perl generated deltas -- #
+# Created: ${current_date}
+# Setting to use base system perl:
+.undef PERL_VER
+.undef PERL_VERSION
+.undef PERL_ARCH
+.undef NOPERL
+.undef NO_PERL
+EOM
+
+	man_line=`echo "$man_line"|sed -e 's#/#\\\\/#g'`
+	sed -e "/$msg_line/d;/$man_line/d" /etc/manpath.config > /etc/manpath.config.new
+	mv -f /etc/manpath.config /etc/manpath.config.bak
+	mv -f /etc/manpath.config.new /etc/manpath.config
+fi
diff -ruN perl5.orig/files/use.perl perl5/files/use.perl
--- perl5.orig/files/use.perl	Sat Aug 16 17:23:01 2003
+++ perl5/files/use.perl	Tue Aug 19 22:05:16 2003
@@ -1,140 +1,89 @@
-#! %%PREFIX%%/bin/perl -w
-# $FreeBSD: ports/lang/perl5/files/use.perl,v 1.6 2002/12/04 16:50:04 bmah Exp $
-use strict;
-
-# XXX what to do with perldoc, pelbug, perlcc ??
-
-sub usage
-{
-	print STDERR <<EOF;
-Usage:
-  $0 port       -> /usr/bin/perl is the perl5 port
-  $0 system     -> /usr/bin/perl is the system perl
-EOF
-	exit 2;
-}
-
-my $port_perl = '%%PREFIX%%/bin/perl';
-$port_perl =~ tr|/|/|s;
-
- at ARGV == 1 or usage();
-if ($ARGV[0] eq 'port') {
-	switch_to_port();
-} elsif ($ARGV[0] eq 'system') {
-	switch_to_system();
-} else {
-	usage();
-}
-exit 0;
-
-# Both functions depend on the idea that switch_to_port leaves
-# perl5 alone.  If the wrapper is installed on a -current system,
-# /usr/bin/perl5 will also be the wrapper.
-
-sub switch_to_system
-{
-	# protect against cases where people use PREFIX=/usr
-	if ($port_perl ne '/usr/bin/perl') {
-		unlink '/usr/bin/perl', '/usr/bin/suidperl',
-			'/usr/bin/perl%%PERL_VERSION%%';
-
-		link '/usr/bin/perl5', '/usr/bin/perl';
-		link '/usr/bin/perl5', '/usr/bin/perl%%PERL_VERSION%%';
-
-		my $ident = `/usr/bin/ident -q /usr/bin/perl5`;
-		if ($ident =~ m#src/usr.bin/perl/perl.c#) {
-			link '/usr/bin/perl5', '/usr/bin/suidperl';
-		} else {
-			link '/usr/bin/sperl5', '/usr/bin/suidperl';
-		}
-	}
-
-	open MK, ">> /etc/make.conf" or die "/etc/make.conf: $!";
-	print MK <<EOF;
-# -- use.perl generated deltas -- #
-# Created: @{[scalar localtime]}
-# Setting to use base system perl:
-.undef PERL_VER
-.undef PERL_VERSION
-.undef PERL_ARCH
-.undef NOPERL
-.undef NO_PERL
-
-EOF
-	close MK;
-
-	open MPOLD, "< /etc/manpath.config" or die "/etc/manpath.config: $!";
-	open MPNEW, "> /etc/manpath.config.new" or die "/etc/manpath.config.new: $!";
-	while (<MPOLD>) {
-		next if m|use.perl generated line|;
-		next if m|^\s*OPTIONAL_MANPATH\s+\S+/lib/perl5/%%PERL_VERSION%%/man\s*$|;
-		print MPNEW;
-	}
-	close MPNEW;
-	close MPOLD;
-	rename '/etc/manpath.config', '/etc/manpath.config.bak';
-	rename '/etc/manpath.config.new', '/etc/manpath.config';
-}
-
-sub switch_to_port
-{
-	# protect against cases where people use PREFIX=/usr
-	if ($port_perl ne '/usr/bin/perl') {
-
-		my $need_perl5_link;
-		if (-e "/usr/bin/perl5" && !-l "/usr/bin/perl5") {
-			my $ident = `/usr/bin/ident -q /usr/bin/perl5`;
-			if ($ident =~ m#src/usr.bin/perl/perl.c#) {
-				rename '/usr/bin/perl', '/usr/bin/perl-wrapper';
-			} else {
-				unlink '/usr/bin/perl';
-			}
-		} else {
-			unlink "/usr/bin/perl5";
-			$need_perl5_link = 1;
-		}
-
-		unlink '/usr/bin/suidperl', '/usr/bin/perl%%PERL_VERSION%%';
-
-		symlink '%%PREFIX%%/bin/perl', '/usr/bin/perl';
-		symlink '%%PREFIX%%/bin/suidperl', '/usr/bin/suidperl';
-		symlink '%%PREFIX%%/bin/perl', '/usr/bin/perl%%PERL_VERSION%%';
-		symlink '%%PREFIX%%/bin/perl', '/usr/bin/perl5' if $need_perl5_link;
-	}
-
-	open MK, ">> /etc/make.conf" or die "/etc/make.conf: $!";
-	print MK <<EOF;
-# -- use.perl generated deltas -- #
-# Created: @{[scalar localtime]}
-# Setting to use base perl from ports:
-PERL_VER=%%PERL_VER%%
-PERL_VERSION=%%PERL_VERSION%%
-PERL_ARCH=%%PERL_ARCH%%
-NOPERL=yo
-NO_PERL=yo
-NO_PERL_WRAPPER=yo
-
-EOF
-	close MK;
-
-	my $perl_port_manpath = <<EOF;
-# -- use.perl generated line -- #
-OPTIONAL_MANPATH	%%PREFIX%%/lib/perl5/%%PERL_VERSION%%/man
-EOF
-
-	open MPOLD, "< /etc/manpath.config" or die "/etc/manpath.config: $!";
-	open MPNEW, "> /etc/manpath.config.new" or die "/etc/manpath.config.new: $!";
-	my $modified = 0;
-	while (<MPOLD>) {
-		if (!$modified && m|^\s*OPTIONAL_MANPATH\s+\S+/lib/perl5/\S+/man\s*$|) {
-			print MPNEW $perl_port_manpath;
-			$modified = 1;
-		}
-		print MPNEW;
-	}
-	print MPNEW $perl_port_manpath unless $modified;
-	close MPNEW;
-	close MPOLD;
-	rename '/etc/manpath.config', '/etc/manpath.config.bak';
-	rename '/etc/manpath.config.new', '/etc/manpath.config';
-}
+#!/bin/sh
+
+PREFIX="%%PREFIX%%"
+preserve_system="a2p c2ph find2perl h2ph h2xs perlbug perlcc perldoc pl2pm \
+		 pod2html pod2latex pod2man pod2text s2p splain"
+
+if [ -f /sbin/sysctl -a -x /sbin/sysctl ] ; then
+	osreldate=`/sbin/sysctl -n kern.osreldate`
+else
+	osreldate=`/usr/sbin/sysctl -n kern.osreldate`
+fi
+
+if [ "x$1" = "x" ]; then
+	echo "Usage:"
+	echo -n "$0 <version>"
+	if [ $osreldate -lt 500043 ] ; then
+		echo -n "|system"
+	fi
+	echo "<version>	- set perl version as active perl"
+	if [ $osreldate -lt 500043 ] ; then
+		echo "system		- set system perl as active"
+	fi
+	exit 2
+fi
+
+# Runned for a first time - there is no active perl yet
+if [ "$1" != "system" -a ! -e /usr/bin/perl ]; then
+	${PREFIX}/bin/set.perl$1 active
+	exit 0
+fi
+
+if [ -e ${PREFIX}/bin/perl -a ! -L ${PREFIX}/bin/perl ]; then
+	echo "FATAL: ${PREFIX}/bin/perl is not symlink."
+	echo "You have old style perl port installed. Reinstall it."
+	exit 1
+fi
+
+# Get current active perl version
+if [ -L ${PREFIX}/bin/perl ]; then
+	active_version=`realpath ${PREFIX}/bin/perl|sed -e 's#.*perl-\(.*\)/perl#\1#'`
+fi
+
+if [ "x${active_version}" = "x$1" ]; then
+	echo "perl $1 is already active"
+	exit 0
+fi
+if [ "$1" = "system" -a -e /usr/bin/perl -a ! -L /usr/bin/perl ]; then
+	echo "system perl is already active"
+	exit 0
+fi
+
+if [ "$1" != "system" -a ! -f ${PREFIX}/bin/set.perl$1 ]; then
+	echo "perl version $1 is not installed"
+	exit 1
+fi
+
+# There is no system perl on 5.x
+if [ $osreldate -ge 500043 -a $1 = "system" ]; then
+	exit 1
+fi
+
+if [ "$1" != "system" -a "x${active_version}" != "x" -a ! -x ${PREFIX}/bin/set.perl${active_version} ]; then
+	echo "FATAL: can't find ${PREFIX}/bin/set.perl${active_version} script"
+	echo 1
+fi
+
+# Deactivate active perl
+if [ -e /usr/bin/perl -a ! -L /usr/bin/perl ]; then
+	for f in ${preserve_system}; do
+		mv /usr/bin/$f /usr/bin/${f}.sys
+	done
+else
+	if [ -e /usr/bin/perl ]; then
+		${PREFIX}/bin/set.perl${active_version} inactive
+	fi
+fi
+
+if [ $osreldate -lt 500043 -a $1 = "system" ]; then
+	ln -f /usr/bin/perl5.005* /usr/bin/perl
+	ln -f /usr/bin/perl5.005* /usr/bin/perl5
+	ln -f /usr/bin/sperl5.005* /usr/bin/sperl5
+	ln -f /usr/bin/sperl5.005* /usr/bin/suidperl
+	for f in ${preserve_system}; do
+		mv /usr/bin/${f}.sys /usr/bin/$f
+	done
+	exit 0
+fi
+
+${PREFIX}/bin/set.perl$1 active
diff -ruN perl5.orig/pkg-deinstall perl5/pkg-deinstall
--- perl5.orig/pkg-deinstall	Thu Jan  1 03:00:00 1970
+++ perl5/pkg-deinstall	Tue Aug 19 22:05:16 2003
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if [ -f /sbin/sysctl -a -x /sbin/sysctl ] ; then
+	osreldate=`/sbin/sysctl -n kern.osreldate`
+else
+	osreldate=`/usr/sbin/sysctl -n kern.osreldate`
+fi
+
+if [ "$2" = POST-DEINSTALL ] ; then
+	if [ ! -e /usr/bin/perl ]; then
+		if [ $osreldate -lt 500043 ] ; then
+			${PKG_PREFIX}/bin/use.perl system
+		elif [ -d ${PKG_PREFIX}/bin/perl-* ]; then
+			${PKG_PREFIX}/bin/use.perl `ls -d ${PKG_PREFIX}/bin/perl-* | sed -e "s#${PKG_PREFIX}/bin/perl-##"`
+		fi
+	fi
+	if [ ! -d ${PKG_PREFIX}/bin/perl-* ]; then
+		rm -f ${PKG_PREFIX}/bin/use.perl
+	fi
+	exit 0
+fi
+
+PERL_VER=`echo $1|sed -e 's/perl-\(.*\)_.*/\1/'`
+
+active_version=`ls -l ${PKG_PREFIX}/bin/perl 2>/dev/null|awk '{print $11}'|sed -e 's#.*perl-\(.*\)/perl#\1#'`
+if [ "x${active_version}" = "x${PERL_VER}" ]; then
+	${PKG_PREFIX}/bin/set.perl${PERL_VER} inactive
+fi
+
+exit 0
diff -ruN perl5.orig/pkg-install perl5/pkg-install
--- perl5.orig/pkg-install	Sat Aug 16 17:23:01 2003
+++ perl5/pkg-install	Tue Aug 19 22:05:16 2003
@@ -1,22 +1,29 @@
 #!/bin/sh
 
-if [ "$2" != POST-INSTALL ] ; then
-	exit 0
-fi
+PERL_VER=`echo $1|sed -e 's/perl-\(.*\)_.*/\1/'`
 
 INCLUDEDIR=/usr/include
 
-install -d ${PKG_PREFIX}/lib/perl5/site_perl/5.6.1/mach
-cd ${INCLUDEDIR} && ${PKG_PREFIX}/bin/h2ph *.h machine/*.h sys/*.h
+if [ "$2" = POST-INSTALL ] ; then
+	install -d ${PKG_PREFIX}/lib/perl5/site_perl/${PERL_VER}/mach
+	cd ${INCLUDEDIR} && ${PKG_PREFIX}/bin/perl-${PERL_VER}/h2ph *.h machine/*.h sys/*.h
 
-if [ -f /sbin/sysctl -a -x /sbin/sysctl ] ; then
-	osreldate=`/sbin/sysctl -n kern.osreldate`
-else
-	osreldate=`/usr/sbin/sysctl -n kern.osreldate`
+	cp -f ${PKG_PREFIX}/bin/perl-${PERL_VER}/use.perl ${PKG_PREFIX}/bin
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/set.perl ${PKG_PREFIX}/bin/set.perl${PERL_VER}
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/perl ${PKG_PREFIX}/bin/perl${PERL_VER}
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/perl /usr/bin/perl${PERL_VER}
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/sperl${PERL_VER} ${PKG_PREFIX}/bin/sperl${PERL_VER}
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/sperl${PERL_VER} /usr/bin/sperl${PERL_VER}
+
+	${PKG_PREFIX}/bin/use.perl ${PERL_VER}
+	exit 0
 fi
 
-if [ $osreldate -ge 500043 ] ; then
-	${PKG_PREFIX}/bin/use.perl port
+# PRE-INSTALL
+if [ -e ${PKG_PREFIX}/bin/perl -a ! -L ${PKG_PREFIX}/bin/perl ]; then
+	echo "===>  You have old-style perl port installed in ${PKG_PREFIX}/bin"
+	echo "      Deinstall it first and try again."
+	exit 1
 fi
 
 exit 0
diff -ruN perl5.orig/pkg-message perl5/pkg-message
--- perl5.orig/pkg-message	Sat Aug 16 17:23:01 2003
+++ perl5/pkg-message	Tue Aug 19 22:05:16 2003
@@ -1,10 +1,9 @@
-Installation of Perl distribution is finished.  Please note, that since
-Perl is also in the base system, this distribution will not be used by
-default.
+Installation of Perl distribution is finished.  Please note, that this 
+distribution will not be used by default.
 
 If you want this version of Perl to be used by default, please type
 
-  use.perl port
+  use.perl %%PERL_VER%%
 
 Assuming that use.perl script (which was installed with the rest of the
 Perl distribution) can be found in your PATH (you might have to type
@@ -14,9 +13,3 @@
 also put some variables into your /etc/make.conf file, so that newly
 installed ports (not packages!) will use new version of perl, and the
 system upgrades from the source will not overwrite the changes made.
-
-At any time you can also type
-
-  use.perl system
-
-if you wish to revert back to the system version of perl.
diff -ruN perl5.orig/pkg-plist perl5/pkg-plist
--- perl5.orig/pkg-plist	Sat Aug 16 17:23:01 2003
+++ perl5/pkg-plist	Tue Aug 19 22:05:16 2003
@@ -1,32 +1,39 @@
-bin/perl
- at exec ln -fs %D/%F %B/perl%%PERL_VER%%
- at exec ln -fs %D/%F %B/perl5
- at unexec rm %B/perl%%PERL_VER%%
- at unexec rm %B/perl5
-bin/sperl%%PERL_VER%%
+bin/set.perl%%PERL_VER%%
+bin/perl-%%PERL_VER%%/set.perl
+bin/perl-%%PERL_VER%%/use.perl
+bin/perl-%%PERL_VER%%/perl
+bin/perl-%%PERL_VER%%/perl%%PERL_VER%%
+ at exec ln -fs %D/%F %D/bin/perl%%PERL_VER%%
+ at unexec rm %D/bin/perl%%PERL_VER%%
+ at exec ln -fs %D/%F /usr/bin/perl%%PERL_VER%%
+ at unexec rm /usr/bin/perl%%PERL_VER%%
+bin/perl-%%PERL_VER%%/sperl%%PERL_VER%%
 @exec ln -fs %D/%F %B/suidperl
 @unexec rm %B/suidperl
-bin/a2p
-bin/c2ph
-bin/dprofpp
-bin/find2perl
-bin/h2ph
-bin/h2xs
-bin/perlbug
-bin/perlcc
-bin/perldoc
-bin/pl2pm
-bin/pod2html
-bin/pod2latex
-bin/pod2man
-bin/pod2text
-bin/pod2usage
-bin/podchecker
-bin/podselect
-bin/pstruct
-bin/s2p
-bin/splain
-bin/use.perl
+ at exec ln -fs %D/%F %D/bin/sperl%%PERL_VER%%
+ at unexec rm %D/bin/sperl%%PERL_VER%%
+ at exec ln -fs %D/%F /usr/bin/sperl%%PERL_VER%%
+ at unexec rm /usr/bin/sperl%%PERL_VER%%
+bin/perl-%%PERL_VER%%/a2p
+bin/perl-%%PERL_VER%%/c2ph
+bin/perl-%%PERL_VER%%/dprofpp
+bin/perl-%%PERL_VER%%/find2perl
+bin/perl-%%PERL_VER%%/h2ph
+bin/perl-%%PERL_VER%%/h2xs
+bin/perl-%%PERL_VER%%/perlbug
+bin/perl-%%PERL_VER%%/perlcc
+bin/perl-%%PERL_VER%%/perldoc
+bin/perl-%%PERL_VER%%/pl2pm
+bin/perl-%%PERL_VER%%/pod2html
+bin/perl-%%PERL_VER%%/pod2latex
+bin/perl-%%PERL_VER%%/pod2man
+bin/perl-%%PERL_VER%%/pod2text
+bin/perl-%%PERL_VER%%/pod2usage
+bin/perl-%%PERL_VER%%/podchecker
+bin/perl-%%PERL_VER%%/podselect
+bin/perl-%%PERL_VER%%/pstruct
+bin/perl-%%PERL_VER%%/s2p
+bin/perl-%%PERL_VER%%/splain
 lib/perl5/%%PERL_VER%%/AnyDBM_File.pm
 lib/perl5/%%PERL_VER%%/AutoLoader.pm
 lib/perl5/%%PERL_VER%%/AutoSplit.pm
@@ -977,9 +984,11 @@
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/CPAN 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/pod 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/man/man3 2>/dev/null || true
+ at unexec rmdir %D/lib/perl5/%%PERL_VER%%/man/man1 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/man 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/BSDPAN/BSDPAN 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/BSDPAN/ExtUtils 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/BSDPAN 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%% 2>/dev/null || true
 @unexec rmdir %D/lib/perl5 2>/dev/null || true
+ at unexec rmdir %D/bin/perl-%%PERL_VER%% 2>/dev/null || true
--- perl5.patch ends here ---

--- perl5.8.patch begins here ---
diff -ruN perl5.8.orig/Makefile perl5.8/Makefile
--- perl5.8.orig/Makefile	Sat Aug 16 17:23:05 2003
+++ perl5.8/Makefile	Tue Aug 19 22:05:20 2003
@@ -7,7 +7,7 @@
 
 PORTNAME=	perl
 PORTVERSION=	${PERL_VER}
-PORTREVISION=	7
+PORTREVISION=	8
 CATEGORIES=	lang devel perl5
 MASTER_SITES=	${MASTER_SITE_PERL_CPAN} \
 		${MASTER_SITE_LOCAL:S/$/:local/} \
@@ -29,10 +29,12 @@
 CONFIGURE_ARGS=	-sde -Dprefix=${PREFIX} \
 	-Darchlib=${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH} \
 	-Dprivlib=${PREFIX}/lib/perl5/${PERL_VER} \
+	-Dman1dir=${PREFIX}/lib/perl5/${PERL_VER}/man/man1 \
 	-Dman3dir=${PREFIX}/lib/perl5/${PERL_VER}/man/man3 \
 	-Dsitearch=${PREFIX}/lib/perl5/site_perl/${PERL_VER}/${PERL_ARCH} \
 	-Dsitelib=${PREFIX}/lib/perl5/site_perl/${PERL_VER} \
-	-Dscriptdir=${PREFIX}/bin \
+	-Dbin=${PREFIX}/bin/perl-${PERL_VER} \
+	-Dscriptdir=${PREFIX}/bin/perl-${PERL_VER} \
 	-Ui_malloc -Ui_iconv -Uinstallusrbinperl \
 	-Dcc="${CC}" \
 	-Dccflags=-DAPPLLIB_EXP=\"${BSDPAN_DEST}\"
@@ -60,9 +62,20 @@
 CONFIGURE_ARGS+=	-Dusethreads=n
 .endif
 
+PLIST_SUB+=		PERL_VERSION=${PERL_VERSION} \
+			PERL_VER=${PERL_VER} \
+			PERL_ARCH=${PERL_ARCH} \
+			SITE_PERL=${SITE_PERL:S|^${LOCALBASE}/||}
+
 INCLUDEDIR=	/usr/include
 
 .include <bsd.port.pre.mk>
+.if defined(INACTIVE)
+PKGMESSAGE=	${WRKDIR}/pkg-message
+.else
+PKGMESSAGE=	${PKGDIR}/.not-here
+.endif
+
 
 MAN1=	a2p.1 c2ph.1 dprofpp.1 enc2xs.1 find2perl.1 h2ph.1 h2xs.1 \
 	libnetcfg.1 perl.1 perl5004delta.1 perl5005delta.1 \
@@ -180,6 +193,8 @@
 .if defined(WITH_GDBM)
 MAN3+=	GDBM_File.3
 .endif
+
+MAN1PREFIX=	${PREFIX}/lib/perl5/${PERL_VER}
 MAN3PREFIX=	${PREFIX}/lib/perl5/${PERL_VER}
 
 LATEST_LINK=	perl5.8
@@ -194,24 +209,57 @@
 BSDPAN_REVISION=1
 
 post-patch:
-	${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
+	@${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
+		${FILESDIR}/use.perl \
+		> ${WRKDIR}/use.perl
+	@${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
 		-e 's|%%PERL_VER%%|${PERL_VER}|g;' \
 		-e 's|%%PERL_VERSION%%|${PERL_VERSION}|g;' \
 		-e 's|%%PERL_ARCH%%|${PERL_ARCH}|g;' \
-		${FILESDIR}/use.perl \
-		> ${WRKDIR}/use.perl
+		${FILESDIR}/set.perl \
+		> ${WRKDIR}/set.perl
+.if defined(INACTIVE)
+	@${SED} -e 's|%%PERL_VER%%|${PERL_VER}|g;' \
+		${PKGDIR}/pkg-message \
+		> ${PKGMESSAGE}
+.if ${OSVERSION} < 500043
+	@${ECHO} >> ${PKGMESSAGE}
+	@${ECHO} >> ${PKGMESSAGE}
+	@${ECHO} "At any time you can also type" >> ${PKGMESSAGE}
+	@${ECHO} >> ${PKGMESSAGE}
+	@${ECHO} "  use.perl system" >> ${PKGMESSAGE}
+	@${ECHO} >> ${PKGMESSAGE}
+	@${ECHO} "if you wish to revert back to the system version of perl." >> ${PKGMESSAGE}
+.endif
+.endif
+
+pre-install:
+	@if [ -e ${PREFIX}/bin/perl -a ! -L ${PREFIX}/bin/perl ]; then \
+		${ECHO_MSG} "===>  You have old-style perl port installed in ${PREFIX}/bin"; \
+		${ECHO_MSG} "      Deinstall it first and try again."; \
+		exit 1; \
+	fi
 
 post-install:
-	@strip ${PREFIX}/bin/perl ${PREFIX}/bin/suidperl
-	@${LN} -sf ${PREFIX}/bin/perl ${PREFIX}/bin/perl5
-	@${LN} -sf ${PREFIX}/bin/perl ${PREFIX}/bin/perl${PERL_VER}
-	${INSTALL_SCRIPT} ${WRKDIR}/use.perl ${PREFIX}/bin/use.perl
+	@${STRIP_CMD} ${PREFIX}/bin/perl-${PERL_VER}/perl ${PREFIX}/bin/perl-${PERL_VER}/suidperl
 .for file in ${BSDPAN_FILES}
 	${MKDIR} ${BSDPAN_DEST}/${file:H}
 	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
 		${BSDPAN_WRKSRC}/${file} ${BSDPAN_DEST}/${file}
 .endfor
-	@(cd ${INCLUDEDIR} && ${PREFIX}/bin/h2ph *.h machine/*.h sys/*.h)
+	@(cd ${INCLUDEDIR} && ${PREFIX}/bin/perl-${PERL_VER}/h2ph *.h machine/*.h sys/*.h)
+	${INSTALL_SCRIPT} ${WRKDIR}/use.perl ${PREFIX}/bin
+	${INSTALL_SCRIPT} ${WRKDIR}/use.perl ${PREFIX}/bin/perl-${PERL_VER}
+	${INSTALL_SCRIPT} ${WRKDIR}/set.perl ${PREFIX}/bin/perl-${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/set.perl ${PREFIX}/bin/set.perl${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/perl ${PREFIX}/bin/perl${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/perl /usr/bin/perl${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/sperl${PERL_VER} ${PREFIX}/bin/sperl${PERL_VER}
+	${LN} -sf ${PREFIX}/bin/perl-${PERL_VER}/sperl${PERL_VER} /usr/bin/sperl${PERL_VER}
+.if defined(INACTIVE)
 	@fmt ${PKGMESSAGE}
+.else
+	@${PREFIX}/bin/use.perl ${PERL_VER}
+.endif
 
 .include <bsd.port.post.mk>
diff -ruN perl5.8.orig/files/set.perl perl5.8/files/set.perl
--- perl5.8.orig/files/set.perl	Thu Jan  1 03:00:00 1970
+++ perl5.8/files/set.perl	Tue Aug 19 22:05:20 2003
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+PREFIX="%%PREFIX%%"
+current_date=`date`
+msg_line="# -- use.perl generated line -- #"
+man_line="OPTIONAL_MANPATH	%%PREFIX%%/lib/perl5/%%PERL_VERSION%%/man"
+files_to_perform=`find ${PREFIX}/bin/perl-%%PERL_VER%% -type f ! -name perl%%PERL_VER%% ! -name sperl%%PERL_VER%% ! -name use.perl ! -name set.perl`
+
+if [ "x$1" = "xactive" ]; then
+	ln -sf ${PREFIX}/bin/perl-%%PERL_VER%%/perl /usr/bin/perl
+	ln -sf ${PREFIX}/bin/perl-%%PERL_VER%%/perl /usr/bin/perl5
+	ln -sf ${PREFIX}/bin/perl-%%PERL_VER%%/sperl /usr/bin/sperl5
+	ln -sf ${PREFIX}/bin/perl-%%PERL_VER%%/suidperl /usr/bin/suidperl
+	for f in ${files_to_perform}
+	do
+		ln -sf $f ${PREFIX}/bin/`basename $f`
+	done
+
+	cat << EOM >> /etc/make.conf
+# -- use.perl generated deltas -- #
+# Created: ${current_date}
+# Setting to use base perl from ports:
+PERL_VER=%%PERL_VER%%
+PERL_VERSION=%%PERL_VERSION%%
+PERL_ARCH=%%PERL_ARCH%%
+NOPERL=yo
+NO_PERL=yo
+NO_PERL_WRAPPER=yo
+EOM
+
+	if ! grep -q "$man_line" /etc/manpath.config; then
+		echo "$msg_line" >> /etc/manpath.config
+		echo "$man_line" >> /etc/manpath.config
+	fi
+	exit 0;
+
+fi
+
+if [ "x$1" = "xinactive" ]; then
+	rm -f /usr/bin/perl
+	rm -f /usr/bin/perl5
+	rm -f /usr/bin/sperl5
+	rm -f /usr/bin/suidperl
+	for f in ${files_to_perform}
+	do
+		rm -f ${PREFIX}/bin/`basename $f`
+	done
+
+	cat << EOM >> /etc/make.conf
+# -- use.perl generated deltas -- #
+# Created: ${current_date}
+# Setting to use base system perl:
+.undef PERL_VER
+.undef PERL_VERSION
+.undef PERL_ARCH
+.undef NOPERL
+.undef NO_PERL
+EOM
+
+	man_line=`echo "$man_line"|sed -e 's#/#\\\\/#g'`
+	sed -e "/$msg_line/d;/$man_line/d" /etc/manpath.config > /etc/manpath.config.new
+	mv -f /etc/manpath.config /etc/manpath.config.bak
+	mv -f /etc/manpath.config.new /etc/manpath.config
+fi
diff -ruN perl5.8.orig/files/use.perl perl5.8/files/use.perl
--- perl5.8.orig/files/use.perl	Sat Aug 16 17:23:05 2003
+++ perl5.8/files/use.perl	Tue Aug 19 22:05:20 2003
@@ -1,132 +1,89 @@
-#! %%PREFIX%%/bin/perl -w
-# $FreeBSD: ports/lang/perl5.8/files/use.perl,v 1.6 2002/07/21 17:09:12 tobez Exp $
-use strict;
-
-# XXX what to do with perldoc, pelbug, perlcc ??
-
-sub usage
-{
-	print STDERR <<EOF;
-Usage:
-  $0 port       -> /usr/bin/perl is the perl5 port
-  $0 system     -> /usr/bin/perl is the system perl
-EOF
-	exit 2;
-}
-
-my $port_perl = '%%PREFIX%%/bin/perl';
-$port_perl =~ tr|/|/|s;
-
-my $ident = `/usr/bin/ident -q /usr/bin/perl5`;
-
- at ARGV == 1 or usage();
-if ($ARGV[0] eq 'port') {
-	switch_to_port();
-} elsif ($ARGV[0] eq 'system') {
-	switch_to_system();
-} else {
-	usage();
-}
-exit 0;
-
-# Both functions depend on the idea that switch_to_port leaves
-# perl5 alone.  If the wrapper is installed on a -current system,
-# /usr/bin/perl5 will also be the wrapper.
-
-sub switch_to_system
-{
-	# protect against cases where people use PREFIX=/usr
-	if ($port_perl ne '/usr/bin/perl') {
-		unlink '/usr/bin/perl', '/usr/bin/suidperl',
-			'/usr/bin/perl%%PERL_VERSION%%';
-
-		link '/usr/bin/perl5', '/usr/bin/perl';
-		link '/usr/bin/perl5', '/usr/bin/perl%%PERL_VERSION%%';
-
-		if ($ident =~ m#src/usr.bin/perl/perl.c#) {
-			link '/usr/bin/perl5', '/usr/bin/suidperl';
-		} else {
-			link '/usr/bin/sperl5', '/usr/bin/suidperl';
-		}
-	}
-
-	open MK, ">> /etc/make.conf" or die "/etc/make.conf: $!";
-	print MK <<EOF;
-# -- use.perl generated deltas -- #
-# Created: @{[scalar localtime]}
-# Setting to use base system perl:
-.undef PERL_VER
-.undef PERL_VERSION
-.undef PERL_ARCH
-.undef NOPERL
-.undef NO_PERL
-
-EOF
-	close MK;
-
-	open MPOLD, "< /etc/manpath.config" or die "/etc/manpath.config: $!";
-	open MPNEW, "> /etc/manpath.config.new" or die "/etc/manpath.config.new: $!";
-	while (<MPOLD>) {
-		next if m|use.perl generated line|;
-		next if m|^\s*OPTIONAL_MANPATH\s+\S+/lib/perl5/%%PERL_VERSION%%/man\s*$|;
-		print MPNEW;
-	}
-	close MPNEW;
-	close MPOLD;
-	rename '/etc/manpath.config', '/etc/manpath.config.bak';
-	rename '/etc/manpath.config.new', '/etc/manpath.config';
-}
-
-sub switch_to_port
-{
-	# protect against cases where people use PREFIX=/usr
-	if ($port_perl ne '/usr/bin/perl') {
-		if ($ident =~ m#src/usr.bin/perl/perl.c#) {
-			rename '/usr/bin/perl', '/usr/bin/perl-wrapper';
-		} else {
-			unlink '/usr/bin/perl';
-		}
-
-		unlink '/usr/bin/suidperl', '/usr/bin/perl%%PERL_VERSION%%';
-
-		symlink '%%PREFIX%%/bin/perl', '/usr/bin/perl';
-		symlink '%%PREFIX%%/bin/suidperl', '/usr/bin/suidperl';
-		symlink '%%PREFIX%%/bin/perl', '/usr/bin/perl%%PERL_VERSION%%';
-	}
-
-	open MK, ">> /etc/make.conf" or die "/etc/make.conf: $!";
-	print MK <<EOF;
-# -- use.perl generated deltas -- #
-# Created: @{[scalar localtime]}
-# Setting to use base perl from ports:
-PERL_VER=%%PERL_VER%%
-PERL_VERSION=%%PERL_VERSION%%
-PERL_ARCH=%%PERL_ARCH%%
-NOPERL=yo
-NO_PERL=yo
-NO_PERL_WRAPPER=yo
-
-EOF
-	close MK;
-
-	my $perl_port_manpath = <<EOF;
-# -- use.perl generated line -- #
-OPTIONAL_MANPATH	%%PREFIX%%/lib/perl5/%%PERL_VERSION%%/man
-EOF
-
-	open MPOLD, "< /etc/manpath.config" or die "/etc/manpath.config: $!";
-	open MPNEW, "> /etc/manpath.config.new" or die "/etc/manpath.config.new: $!";
-	my $modified = 0;
-	while (<MPOLD>) {
-		if (!$modified && m|^\s*OPTIONAL_MANPATH\s+\S+/lib/perl5/\S+/man\s*$|) {
-			print MPNEW $perl_port_manpath;
-			$modified = 1;
-		}
-		print MPNEW;
-	}
-	print MPNEW $perl_port_manpath unless $modified;
-	close MPNEW;
-	close MPOLD;
-	rename '/etc/manpath.config', '/etc/manpath.config.bak';
-	rename '/etc/manpath.config.new', '/etc/manpath.config';
-}
+#!/bin/sh
+
+PREFIX="%%PREFIX%%"
+preserve_system="a2p c2ph find2perl h2ph h2xs perlbug perlcc perldoc pl2pm \
+		 pod2html pod2latex pod2man pod2text s2p splain"
+
+if [ -f /sbin/sysctl -a -x /sbin/sysctl ] ; then
+	osreldate=`/sbin/sysctl -n kern.osreldate`
+else
+	osreldate=`/usr/sbin/sysctl -n kern.osreldate`
+fi
+
+if [ "x$1" = "x" ]; then
+	echo "Usage:"
+	echo -n "$0 <version>"
+	if [ $osreldate -lt 500043 ] ; then
+		echo -n "|system"
+	fi
+	echo "<version>	- set perl version as active perl"
+	if [ $osreldate -lt 500043 ] ; then
+		echo "system		- set system perl as active"
+	fi
+	exit 2
+fi
+
+# Runned for a first time - there is no active perl yet
+if [ "$1" != "system" -a ! -e /usr/bin/perl ]; then
+	${PREFIX}/bin/set.perl$1 active
+	exit 0
+fi
+
+if [ -e ${PREFIX}/bin/perl -a ! -L ${PREFIX}/bin/perl ]; then
+	echo "FATAL: ${PREFIX}/bin/perl is not symlink."
+	echo "You have old style perl port installed. Reinstall it."
+	exit 1
+fi
+
+# Get current active perl version
+if [ -L ${PREFIX}/bin/perl ]; then
+	active_version=`realpath ${PREFIX}/bin/perl|sed -e 's#.*perl-\(.*\)/perl#\1#'`
+fi
+
+if [ "x${active_version}" = "x$1" ]; then
+	echo "perl $1 is already active"
+	exit 0
+fi
+if [ "$1" = "system" -a -e /usr/bin/perl -a ! -L /usr/bin/perl ]; then
+	echo "system perl is already active"
+	exit 0
+fi
+
+if [ "$1" != "system" -a ! -f ${PREFIX}/bin/set.perl$1 ]; then
+	echo "perl version $1 is not installed"
+	exit 1
+fi
+
+# There is no system perl on 5.x
+if [ $osreldate -ge 500043 -a $1 = "system" ]; then
+	exit 1
+fi
+
+if [ "$1" != "system" -a "x${active_version}" != "x" -a ! -x ${PREFIX}/bin/set.perl${active_version} ]; then
+	echo "FATAL: can't find ${PREFIX}/bin/set.perl${active_version} script"
+	echo 1
+fi
+
+# Deactivate active perl
+if [ -e /usr/bin/perl -a ! -L /usr/bin/perl ]; then
+	for f in ${preserve_system}; do
+		mv /usr/bin/$f /usr/bin/${f}.sys
+	done
+else
+	if [ -e /usr/bin/perl ]; then
+		${PREFIX}/bin/set.perl${active_version} inactive
+	fi
+fi
+
+if [ $osreldate -lt 500043 -a $1 = "system" ]; then
+	ln -f /usr/bin/perl5.005* /usr/bin/perl
+	ln -f /usr/bin/perl5.005* /usr/bin/perl5
+	ln -f /usr/bin/sperl5.005* /usr/bin/sperl5
+	ln -f /usr/bin/sperl5.005* /usr/bin/suidperl
+	for f in ${preserve_system}; do
+		mv /usr/bin/${f}.sys /usr/bin/$f
+	done
+	exit 0
+fi
+
+${PREFIX}/bin/set.perl$1 active
diff -ruN perl5.8.orig/pkg-deinstall perl5.8/pkg-deinstall
--- perl5.8.orig/pkg-deinstall	Thu Jan  1 03:00:00 1970
+++ perl5.8/pkg-deinstall	Tue Aug 19 22:05:20 2003
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if [ -f /sbin/sysctl -a -x /sbin/sysctl ] ; then
+	osreldate=`/sbin/sysctl -n kern.osreldate`
+else
+	osreldate=`/usr/sbin/sysctl -n kern.osreldate`
+fi
+
+if [ "$2" = POST-DEINSTALL ] ; then
+	if [ ! -e /usr/bin/perl ]; then
+		if [ $osreldate -lt 500043 ] ; then
+			${PKG_PREFIX}/bin/use.perl system
+		elif [ -d ${PKG_PREFIX}/bin/perl-* ]; then
+			${PKG_PREFIX}/bin/use.perl `ls -d ${PKG_PREFIX}/bin/perl-* | sed -e "s#${PKG_PREFIX}/bin/perl-##"`
+		fi
+	fi
+	if [ ! -d ${PKG_PREFIX}/bin/perl-* ]; then
+		rm -f ${PKG_PREFIX}/bin/use.perl
+	fi
+	exit 0
+fi
+
+PERL_VER=`echo $1|sed -e 's/perl-\(.*\)_.*/\1/'`
+
+active_version=`ls -l ${PKG_PREFIX}/bin/perl 2>/dev/null|awk '{print $11}'|sed -e 's#.*perl-\(.*\)/perl#\1#'`
+if [ "x${active_version}" = "x${PERL_VER}" ]; then
+	${PKG_PREFIX}/bin/set.perl${PERL_VER} inactive
+fi
+
+exit 0
diff -ruN perl5.8.orig/pkg-install perl5.8/pkg-install
--- perl5.8.orig/pkg-install	Sat Aug 16 17:23:05 2003
+++ perl5.8/pkg-install	Tue Aug 19 22:05:20 2003
@@ -1,13 +1,29 @@
 #!/bin/sh
 
-if [ "$2" != POST-INSTALL ] ; then
-	exit 0
-fi
+PERL_VER=`echo $1|sed -e 's/perl-\(.*\)_.*/\1/'`
 
 INCLUDEDIR=/usr/include
 
-install -d ${PKG_PREFIX}/lib/perl5/site_perl/5.8.0/mach
-cd ${INCLUDEDIR} && ${PKG_PREFIX}/bin/h2ph *.h machine/*.h sys/*.h
+if [ "$2" = POST-INSTALL ] ; then
+	install -d ${PKG_PREFIX}/lib/perl5/site_perl/${PERL_VER}/mach
+	cd ${INCLUDEDIR} && ${PKG_PREFIX}/bin/perl-${PERL_VER}/h2ph *.h machine/*.h sys/*.h
 
+	cp -f ${PKG_PREFIX}/bin/perl-${PERL_VER}/use.perl ${PKG_PREFIX}/bin
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/set.perl ${PKG_PREFIX}/bin/set.perl${PERL_VER}
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/perl ${PKG_PREFIX}/bin/perl${PERL_VER}
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/perl /usr/bin/perl${PERL_VER}
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/sperl${PERL_VER} ${PKG_PREFIX}/bin/sperl${PERL_VER}
+	ln -sf ${PKG_PREFIX}/bin/perl-${PERL_VER}/sperl${PERL_VER} /usr/bin/sperl${PERL_VER}
+
+	${PKG_PREFIX}/bin/use.perl ${PERL_VER}
+	exit 0
+fi
+
+# PRE-INSTALL
+if [ -e ${PKG_PREFIX}/bin/perl -a ! -L ${PKG_PREFIX}/bin/perl ]; then
+	echo "===>  You have old-style perl port installed in ${PKG_PREFIX}/bin"
+	echo "      Deinstall it first and try again."
+	exit 1
+fi
 
 exit 0
diff -ruN perl5.8.orig/pkg-message perl5.8/pkg-message
--- perl5.8.orig/pkg-message	Sat Aug 16 17:23:05 2003
+++ perl5.8/pkg-message	Tue Aug 19 22:05:20 2003
@@ -1,10 +1,9 @@
-Installation of Perl distribution is finished.  Please note, that since
-Perl is also in the base system, this distribution will not be used by
-default.
+Installation of Perl distribution is finished.  Please note, that this 
+distribution will not be used by default.
 
 If you want this version of Perl to be used by default, please type
 
-  use.perl port
+  use.perl %%PERL_VER%%
 
 Assuming that use.perl script (which was installed with the rest of the
 Perl distribution) can be found in your PATH (you might have to type
@@ -14,9 +13,3 @@
 also put some variables into your /etc/make.conf file, so that newly
 installed ports (not packages!) will use new version of perl, and the
 system upgrades from the source will not overwrite the changes made.
-
-At any time you can also type
-
-  use.perl system
-
-if you wish to revert back to the system version of perl.
diff -ruN perl5.8.orig/pkg-plist perl5.8/pkg-plist
--- perl5.8.orig/pkg-plist	Sat Aug 16 17:23:05 2003
+++ perl5.8/pkg-plist	Tue Aug 19 22:05:20 2003
@@ -1,36 +1,44 @@
-bin/perl
- at exec ln -fs %D/%F %B/perl5
- at unexec rm %B/perl5
-bin/a2p
-bin/c2ph
-bin/dprofpp
-bin/enc2xs
-bin/find2perl
-bin/h2ph
-bin/h2xs
-bin/libnetcfg
-bin/perl%%PERL_VER%%
-bin/perlbug
-bin/perlcc
-bin/perldoc
-bin/perlivp
-bin/piconv
-bin/pl2pm
-bin/pod2html
-bin/pod2latex
-bin/pod2man
-bin/pod2text
-bin/pod2usage
-bin/podchecker
-bin/podselect
-bin/psed
-bin/pstruct
-bin/s2p
-bin/sperl%%PERL_VER%%
-bin/splain
-bin/suidperl
-bin/use.perl
-bin/xsubpp
+bin/set.perl%%PERL_VER%%
+bin/perl-%%PERL_VER%%/set.perl
+bin/perl-%%PERL_VER%%/use.perl
+bin/perl-%%PERL_VER%%/a2p
+bin/perl-%%PERL_VER%%/c2ph
+bin/perl-%%PERL_VER%%/dprofpp
+bin/perl-%%PERL_VER%%/enc2xs
+bin/perl-%%PERL_VER%%/find2perl
+bin/perl-%%PERL_VER%%/h2ph
+bin/perl-%%PERL_VER%%/h2xs
+bin/perl-%%PERL_VER%%/libnetcfg
+bin/perl-%%PERL_VER%%/perl
+bin/perl-%%PERL_VER%%/perl%%PERL_VER%%
+ at exec ln -fs %D/%F %D/bin/perl%%PERL_VER%%
+ at unexec rm %D/bin/perl%%PERL_VER%%
+ at exec ln -fs %D/%F /usr/bin/perl%%PERL_VER%%
+ at unexec rm /usr/bin/perl%%PERL_VER%%
+bin/perl-%%PERL_VER%%/perlbug
+bin/perl-%%PERL_VER%%/perlcc
+bin/perl-%%PERL_VER%%/perldoc
+bin/perl-%%PERL_VER%%/perlivp
+bin/perl-%%PERL_VER%%/piconv
+bin/perl-%%PERL_VER%%/pl2pm
+bin/perl-%%PERL_VER%%/pod2html
+bin/perl-%%PERL_VER%%/pod2latex
+bin/perl-%%PERL_VER%%/pod2man
+bin/perl-%%PERL_VER%%/pod2text
+bin/perl-%%PERL_VER%%/pod2usage
+bin/perl-%%PERL_VER%%/podchecker
+bin/perl-%%PERL_VER%%/podselect
+bin/perl-%%PERL_VER%%/psed
+bin/perl-%%PERL_VER%%/pstruct
+bin/perl-%%PERL_VER%%/s2p
+bin/perl-%%PERL_VER%%/sperl%%PERL_VER%%
+ at exec ln -fs %D/%F %D/bin/sperl%%PERL_VER%%
+ at unexec rm %D/bin/sperl%%PERL_VER%%
+ at exec ln -fs %D/%F /usr/bin/sperl%%PERL_VER%%
+ at unexec rm /usr/bin/sperl%%PERL_VER%%
+bin/perl-%%PERL_VER%%/splain
+bin/perl-%%PERL_VER%%/suidperl
+bin/perl-%%PERL_VER%%/xsubpp
 lib/perl5/%%PERL_VER%%/%%PERL_ARCH%%/Cwd.pm
 lib/perl5/%%PERL_VER%%/%%PERL_ARCH%%/Config.pm
 lib/perl5/%%PERL_VER%%/%%PERL_ARCH%%/lib.pm
@@ -1445,6 +1453,7 @@
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/Attribute 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/pod 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/man/man3 2>/dev/null || true
+ at unexec rmdir %D/lib/perl5/%%PERL_VER%%/man/man1 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%%/man 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/%%PERL_VER%% 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/site_perl/%%PERL_VER%%/%%PERL_ARCH%%/sys 2>/dev/null || true
@@ -1453,3 +1462,4 @@
 @unexec rmdir %D/lib/perl5/site_perl/%%PERL_VER%% 2>/dev/null || true
 @unexec rmdir %D/lib/perl5/site_perl 2>/dev/null || true
 @unexec rmdir %D/lib/perl5 2>/dev/null || true
+ at unexec rmdir %D/bin/perl-%%PERL_VER%% 2>/dev/null || true
--- perl5.8.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list