Perl 5.16

Bjarne D Mathiesen macintosh at mathiesen.info
Sat May 26 10:28:54 PDT 2012


Upgrading to Perl 5.16 is production ready ... at least I'm using it
actively ;-)

The two tickets necessary are :
https://trac.macports.org/ticket/34617
https://trac.macports.org/ticket/34570

If you elect to upgrade _before_ the official releases, be aware of the
caveat about reindexing your PortIndex _or_ you might be in for a world
of hurt ;-) If you upgrade before the official release, you'll have to
copy the perl5.16 port into your main repo _before_ reindexing.
Afterwards, you can keep perl5.16 in your private repo, but then new
p5-<extension> ports won't be activated for perl5.16

The attached script will upgrade from any version of Perl5 to any
version of Perl5

I've successfully used it to upgrade from
	Perl 5.12 -> Perl 5.14
	Perl 5.12 -> Perl 5.16
	Perl 5.14 -> Perl 5.16

Do make sure, that:
	CPAN is upgraded & has updated settings
	that you can see all p5.xx-<extension>s
		/port list name:^p5.xx/
_before_ you execute my script, _or_ I assure you you'll be in serious
trouble, as there're no builtin safeguards at all in my script !!!

You use my script in this way:
	/PerlSwitch 12 16/

:-) Happy Hacking :-)
-- 
Bjarne D Mathiesen
København N ; Danmark ; Europa
----------------------------------------------------------------------
denne besked er skrevet i et totalt M$-frit miljø
MacOS X 10.7.3 Lion ; 2.8GHz Intel Core i7 ; 16GB 1067MHz DDR3
-------------- next part --------------
#!/macports/bin/bash

#
# script to switch the Perl5 major version
#
# ${1}  :   the installed version
# ${2}  :   the new version
#

#
# set prefix to where you've installed MacPorts
#
declare prefix='/macports'

#
# take a snapshot of the CPAN modules installed
# http://mailman.theapt.org/pipermail/openbsd-newbies/2003-October/002021.html
#
declare snapshot=$(perl -MCPAN -e autobundle | grep 'cpan/Bundle/Snapshot')

#
# install the new version of Perl5
#
port -s install perl5.${2} +shared +threads

#
# replace all installed old p5-<name>
# with new ones dependent on the new version of perl5
#
port -q installed name:^p5.${1} \
| while read portname version active
do
    port -f deactivate ${portname}
    port -f -s install ${portname/${1}/${2}}
done

#
# make the new version of perl5 the default and major version
#
port -n -f upgrade --force --enforce-variants perl5 -perl5_${1} +perl5_${2}

#
# check if cpan has been initialised for the new version
#
cpan

#
# force uninstall of the old version of perl5
#
port -f uninstall perl5.${1}
port clean --all perl5.${1}


#
# find and re-install all ports dependent upon old perl5 extensions
#
( ( port installed name:^p5.${1} \
| while read portname version active
do 
    port -q dependents ${portname}
done ) \
| sort -u \
| grep -v p5.${1} ) \
| xargs -n1 port -s -n upgrade --force 

#
# update all cpan modules to the new version of perl5
#
#perl -MCPAN -e "install ${snapshot}"
cpan -u

#
# remove stray files
#
find ${prefix} -iname '*.mpsaved' -delete
find ${prefix} -iname '*.mp_*' -delete

#
# remove old perl5 extensions
#
port -q installed \
| grep -v 'active' \
| while read portname version
do
    port -f uninstall ${portname} ${version}
    port clean --all ${portname} ${version}
done


More information about the macports-dev mailing list