- lang/perl5.12 upgrade to 5.12.5

- lang/perl5.14 upgrade to 5.14.4
- lang/perl5.16 upgrade to 5.16.3
- Global modify SITE_PERL[1][2]

[1] - See more info:
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=26605+0+archive/2013/freebsd-perl/20130609.freebsd-perl
[2] - Fix for mail/cyrus-imapd* - Approved by portmrg(bapt@)

Please, see ports/UPDATING for upgrade procedure.

Reviewed by:	bapt@ (exp-run), culot@
This commit is contained in:
Andrej Zverev 2013-06-12 13:00:55 +00:00
parent f84c960066
commit 8c7d7ff2bd
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=320679
30 changed files with 151 additions and 2316 deletions

View file

@ -17,6 +17,9 @@
# installed from a port, but without the version number.
# Use this if you need to replace "#!" lines in scripts.
# PERL_VERSION - Full version of perl5 (see below for current value).
#
# PERL_VER - Short version of perl5 (major.minor without patchlevel)
#
# PERL_LEVEL - Perl version as an integer of the form MNNNPP, where
# M is major version, N is minor version, and P is
# the patch level. E.g., PERL_VERSION=5.14.2 would give
@ -31,20 +34,23 @@
# This value is added to PLIST_SUB.
# USE_PERL5 - If set, this port uses perl5 in one or more of the extract,
# patch, build, install or run phases.
# PERL_CONFIGURE
# - Configure using Perl's MakeMaker. Implies USE_PERL5.
# USE_PERL5_BUILD
# - If set, this port uses perl5 in one or more of the
#
# PERL_CONFIGURE - Configure using Perl's MakeMaker. Implies USE_PERL5.
#
# USE_PERL5_BUILD - If set, this port uses perl5 in one or more of the
# extract, patch, build or install phases.
# USE_PERL5_RUN - If set, this port uses perl5 for running.
# PERL_MODBUILD - Use Module::Build to configure, build and install port.
#
# USE_PERL5_RUN - If set, this port uses perl5 for running.
#
# PERL_MODBUILD - Use Module::Build to configure, build and install port.
.if !defined(_POSTMKINCLUDED) && !defined(Perl_Pre_Include)
Perl_Pre_Include= bsd.perl.mk
PERL_Include_MAINTAINER= perl@FreeBSD.org
PERL_VERSION?= 5.14.2
PERL_VERSION?= 5.14.4
PERL_VER?= ${PERL_VERSION:C/\.[0-9]+$//}
.if !defined(PERL_LEVEL) && defined(PERL_VERSION)
perl_major= ${PERL_VERSION:C|^([1-9]+).*|\1|}
@ -74,7 +80,7 @@ PERL_PORT?= perl5.14
PERL_PORT?= perl5.12
.endif
SITE_PERL_REL?= lib/perl5/site_perl/${PERL_VERSION}
SITE_PERL_REL?= lib/perl5/site_perl/${PERL_VER}
SITE_PERL?= ${LOCALBASE}/${SITE_PERL_REL}
PERL5= ${LOCALBASE}/bin/perl${PERL_VERSION}
@ -141,7 +147,7 @@ IGNORE= improper use of USE_PERL5
Perl_Post_Include= bsd.perl.mk
PLIST_SUB+= PERL_VERSION=${PERL_VERSION} \
PERL_VER=${PERL_VERSION} \
PERL_VER=${PERL_VER} \
PERL_ARCH=${PERL_ARCH} \
SITE_PERL=${SITE_PERL_REL}
@ -189,7 +195,7 @@ RUN_DEPENDS+= ${PERL5}:${PORTSDIR}/lang/${PERL_PORT}
CONFIGURE_ARGS+= CC="${CC}" CCFLAGS="${CFLAGS}" PREFIX="${PREFIX}" \
INSTALLPRIVLIB="${PREFIX}/lib" INSTALLARCHLIB="${PREFIX}/lib"
CONFIGURE_SCRIPT?= Makefile.PL
MAN3PREFIX?= ${PREFIX}/lib/perl5/${PERL_VERSION}
MAN3PREFIX?= ${PREFIX}/lib/perl5/${PERL_VER}
.undef HAS_CONFIGURE
.endif # defined(PERL_CONFIGURE)

View file

@ -5,6 +5,27 @@ they are unavoidable.
You should get into the habit of checking this file for changes each time
you update your ports collection, before attempting any port upgrades.
20130612:
AFFECTS: users of lang/perl* and any port that depends on it
AUTHOR: az@FreeBSD.org
lang/perl5.12 upgrade from version 5.12.4 to 5.12.5
lang/perl5.14 upgrade from version 5.14.2 to 5.14.4
lang/perl5.16 upgrade from version 5.16.2 to 5.16.3
Also was modification to directory structure where
is perl installed. Instead major.minor.patchlevel now only major.minor.
The "perl-after-upgrade" script is removed.
Please rebuild all perl ports and all ports that
depend in it:
# portmaster -r perl
or
# portupgrade -rf perl
or
# pkg install -fR perl
20130609:
AFFECTS: users of audio/flac and any port that depends on it
AUTHOR: naddy@FreeBSD.org

View file

@ -3,7 +3,7 @@
PORTNAME= perl
PORTVERSION= ${PERL_VERSION}
PORTREVISION= 5
PORTREVISION= 0
CATEGORIES= lang devel perl5
MASTER_SITES= CPAN \
${MASTER_SITE_LOCAL:S/$/:local/} \
@ -37,9 +37,10 @@ USE_PERL_DESC= Rewrite links in /usr/bin
PORTSCOUT= limitw:1,even
PERL_VERSION= 5.12.4
PERL_VERSION= 5.12.5
PERL_VER= ${PERL_VERSION:C/\.[0-9]+$//}
PERL_ARCH= mach
SITE_PERL_REL?= lib/perl5/site_perl/${PERL_VERSION}
SITE_PERL_REL?= lib/perl5/site_perl/${PERL_VER}
SITE_PERL?= ${LOCALBASE}/${SITE_PERL_REL}
USE_BZIP2= yes
@ -47,13 +48,13 @@ HAS_CONFIGURE= yes
MAKE_JOBS_UNSAFE= yes
CONFIGURE_SCRIPT=Configure
CONFIGURE_ARGS= -sde -Dprefix=${PREFIX} \
-Darchlib=${PREFIX}/lib/perl5/${PERL_VERSION}/${PERL_ARCH} \
-Dprivlib=${PREFIX}/lib/perl5/${PERL_VERSION} \
-Dman3dir=${PREFIX}/lib/perl5/${PERL_VERSION}/perl/man/man3 \
-Darchlib=${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH} \
-Dprivlib=${PREFIX}/lib/perl5/${PERL_VER} \
-Dman3dir=${PREFIX}/lib/perl5/${PERL_VER}/perl/man/man3 \
-Dman1dir=${PREFIX}/man/man1 \
-Dsitearch=${PREFIX}/${SITE_PERL_REL}/${PERL_ARCH} \
-Dsitelib=${PREFIX}/${SITE_PERL_REL} -Dscriptdir=${PREFIX}/bin \
-Dsiteman3dir=${PREFIX}/lib/perl5/${PERL_VERSION}/man/man3 \
-Dsiteman3dir=${PREFIX}/lib/perl5/${PERL_VER}/man/man3 \
-Dsiteman1dir=${PREFIX}/man/man1 \
-Ui_malloc -Ui_iconv -Uinstallusrbinperl \
-Dcc="${CC}" -Duseshrplib -Dinc_version_list=none \
@ -70,15 +71,15 @@ MAKE_ENV+= ${LOCALE_CLEANUP}
.if defined(PERL_VENDOR_PREFIX)
CONFIGURE_ARGS+= \
-Dvendorprefix=${PERL_VENDOR_PREFIX} \
-Dvendorarch=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VERSION}/${PERL_ARCH} \
-Dvendorarch=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH} \
-Dvendorbin=${PERL_VENDOR_PREFIX}/bin \
-Dvendorlib=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VERSION} \
-Dvendorman3dir=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VERSION}/man/man3 \
-Dvendorlib=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VER} \
-Dvendorman3dir=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VER}/man/man3 \
-Dvendorman1dir=${PERL_VENDOR_PREFIX}/man/man1
.endif
PLIST_SUB+= PERL_VERSION=${PERL_VERSION} \
PERL_VER=${PERL_VERSION} \
PERL_VER=${PERL_VER} \
PERL_ARCH=${PERL_ARCH} \
SITE_PERL=${SITE_PERL:S|^${LOCALBASE}/||}
@ -148,9 +149,9 @@ NO_LATEST_LINK= yes
.if ${PORT_OPTIONS:MGDBM}
MAN3+= GDBM_File.3
.endif
MAN3PREFIX= ${PREFIX}/lib/perl5/${PERL_VERSION}/perl
MAN3PREFIX= ${PREFIX}/lib/perl5/${PERL_VER}/perl
BSDPAN_DEST= ${PREFIX}/lib/perl5/${PERL_VERSION}/BSDPAN
BSDPAN_DEST= ${PREFIX}/lib/perl5/${PERL_VER}/BSDPAN
BSDPAN_FILES= BSDPAN.pm BSDPAN/Override.pm Config.pm \
ExtUtils/MM_Unix.pm \
ExtUtils/MakeMaker.pm \
@ -164,21 +165,19 @@ PKGDEINSTALL= ${WRKDIR}/pkg-deinstall
post-patch:
${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
-e 's|%%PERL_VERSION%%|${PERL_VERSION}|g;' \
-e 's|%%PERL_VER%%|${PERL_VER}|g;' \
-e 's|%%PERL_ARCH%%|${PERL_ARCH}|g;' \
-e 's|%%MAKE_CONF%%|${__MAKE_CONF}|g;' \
-e 's|%%LINK_USRBIN%%|${LINK_USRBIN}|g;' \
${FILESDIR}/use.perl \
> ${WRKDIR}/use.perl
${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
-e 's|%%PERL_VERSION%%|${PERL_VERSION}|g;' \
-e 's|%%PERL_VER%%|${PERL_VER}|g;' \
${FILESDIR}/perl-man.conf \
> ${WRKDIR}/perl-man.conf
${SED} -e 's|%%PERL%%|${PERL}|g; s|%%PERL_VERSION%%|${PERL_VERSION}|g; s|%%PKGNAME%%|${PKGNAME}|g' \
${FILESDIR}/perl-after-upgrade \
> ${WRKDIR}/perl-after-upgrade
${CP} ${WRKDIR}/use.perl ${PKGINSTALL}
${CP} ${WRKDIR}/use.perl ${PKGDEINSTALL}
${SED} -i '' -e 's|%%PERL_PKGNAME%%|${PKGNAME}|g; s|%%PERL_VER%%|5.12|g;' \
${SED} -i '' -e 's|%%PERL_PKGNAME%%|${PKGNAME}|g; s|%%PERL_VER%%|${PERL_VER}|g;' \
-e 's!%%BSDPAN_VERSION%%!${BSDPAN_VERSION}!g;' \
${BSDPAN_WRKSRC}/ExtUtils/*.pm
${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
@ -200,12 +199,9 @@ pre-su-install:
post-install:
@${STRIP_CMD} ${PREFIX}/bin/perl${PERL_VERSION}
@${STRIP_CMD} ${PREFIX}/bin/perl
@${PREFIX}/bin/pod2man ${WRKDIR}/perl-after-upgrade >${WRKDIR}/perl-after-upgrade.1
@${INSTALL_SCRIPT} ${WRKDIR}/perl-after-upgrade ${PREFIX}/bin/perl-after-upgrade
@${INSTALL_MAN} ${WRKDIR}/perl-after-upgrade.1 ${MAN1PREFIX}/man/man1/perl-after-upgrade.1
@${LN} -sf ${PREFIX}/bin/perl${PERL_VERSION} ${PREFIX}/bin/perl5
.if ${OSVERSION} >= 900022
@${INSTALL_DATA} ${WRKDIR}/perl-man.conf ${PREFIX}/etc/man.d/perl${PERL_VERSION}.conf
@${INSTALL_DATA} ${WRKDIR}/perl-man.conf ${PREFIX}/etc/man.d/perl${PERL_VER}.conf
.endif
.for files in ${BSDPAN_FILES}
${MKDIR} ${BSDPAN_DEST}/${files:H}
@ -214,14 +210,10 @@ post-install:
.endfor
PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
AZ:
test: build
@(cd ${WRKSRC}; TEST_JOBS=${MAKE_JOBS_NUMBER} make test_harness)
regression-test: test
rebuild-xs:
${LOCALBASE}/sbin/portupgrade -f `(${FIND} ${PKG_DBDIR}/p5*/+CONTENTS | \
${XARGS} ${GREP} -El 'site_perl.*\.so' | \
${SED} -e 's!/var/db/pkg/!!; s!/+CONTENTS!!;')`
.include <bsd.port.post.mk>

View file

@ -14,7 +14,6 @@ MAN1+= h2ph.1
MAN1+= h2xs.1
MAN1+= instmodsh.1
MAN1+= libnetcfg.1
MAN1+= perl-after-upgrade.1
MAN1+= perl.1
MAN1+= perl5004delta.1
MAN1+= perl5005delta.1
@ -31,6 +30,7 @@ MAN1+= perl5121delta.1
MAN1+= perl5122delta.1
MAN1+= perl5123delta.1
MAN1+= perl5124delta.1
MAN1+= perl5125delta.1
MAN1+= perl561delta.1
MAN1+= perl56delta.1
MAN1+= perl570delta.1

View file

@ -1,4 +1,4 @@
SHA256 (perl/perl-5.12.4.tar.bz2) = c920fa01a34b7752e8cbbc99c6921b908df60611d84a29c4377e4a798604767e
SIZE (perl/perl-5.12.4.tar.bz2) = 12350353
SHA256 (perl/perl-5.12.5.tar.bz2) = 10749417fd3010aae320a34181ad4cd6a4855c1fc63403b87fa4d630b18e966c
SIZE (perl/perl-5.12.5.tar.bz2) = 12252744
SHA256 (perl/BSDPAN-20111107.tar.bz2) = 2f03218a592dc65ebfdc3c6b9394d91dcf4c53aa5290a08458b837baad5a21f9
SIZE (perl/BSDPAN-20111107.tar.bz2) = 8448

View file

@ -1,603 +0,0 @@
#! %%PERL%% -w
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42)
# <tobez@FreeBSD.org> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return. Anton Berezin
# ----------------------------------------------------------------------------
#
# $FreeBSD$
# $Id: perl-after-upgrade,v 1.11 2005/06/23 19:39:00 tobez Exp $
#
=pod
=head1 NAME
perl-after-upgrade -- fixup FreeBSD packages that depend on perl
=head1 SYNOPSIS
perl-after-upgrade
perl-after-upgrade -f [-d] [-q]
perl-after-upgrade -v
=head1 DESCRIPTION
The standard procedure after a perl port (lang/perl5.X) upgrade is to
basically reinstall all other packages that depend on perl.
This is always a painful exercise. The perl-after-upgrade utility makes
this process mostly unnecessary.
The tool goes through the list of installed packages, looks for those
that depend on perl, moves files around, modifies shebang lines in those
scripts in which it is necessary to do so, tries its best to adjust
dynamically linked binaries that link with libperl.so in the old path,
and updates the package database.
After installation of the new perl is complete, either by hand from the
ports collection, or from a package, or via portupgrade, do the
following:
=over 4
=item o go root;
=item o run perl-after-upgrade utility.
Do not specify any arguments at first, so it does nothing destructive.
Pay attention to the produced output and especially to errorlist at the
end, if any;
=item o run the utility again, with B<-f> command line option.
This will actually do the work. Again, pay attention to the output
produced;
=item o fix any reported errors;
=item o reinstall required packages:
The utility will tell you what packages that depend on perl it could not
handle. It will also tell you why it happened (for example, they were
compiled against a binary incompatible perl). If you want such packages
to remain operational, you will have to reinstall then by hand or via
portupgrade.
=item o review the files left in the older perl installation.
This is typically /usr/local/lib/perl5/site_perl/5.X.Y/. There should
be very little, if any, files in that directory and its subdirectories,
excepting a number of .ph files;
=item o check that things work as they should;
=item o remove backup files from the package database.
Those will be /var/db/pkg/*/+CONTENTS.bak;
=item o that's all.
=back
=head1 COPYRIGHT AND LICENSE
Copyright 2005 by Anton Berezin
"THE BEER-WARE LICENSE" (Revision 42)
<tobez@FreeBSD.org> wrote this module. As long as you retain this
notice you can do whatever you want with this stuff. If we meet some
day, and you think this stuff is worth it, you can buy me a beer in
return.
Anton Berezin
NO WARRANTY OF ANY KIND, USE AT YOUR OWN RISK.
=head1 HISTORY
The first version of this utility was not bundled with perl package on
FreeBSD. It was dumber than the current version in several important
areas. It was faster.
=head1 CREDITS
Thanks to Mathieu Arnold for discussion.
=head1 SEE ALSO
perl(1).
=cut
use strict;
use warnings;
use 5.0100;
our $debug = 0;
# |/-\
my $pchar = "|";
my $do_progress = -t *STDOUT;
sub progress
{
if ($do_progress) {
print STDERR "$pchar";
$pchar =~ tr<|/\\-><-|/\\>;
}
}
package FreeBSD::Package;
use strict;
use warnings;
use IO::File;
use File::Copy;
sub new
{
my ($pkg, %p) = @_;
my $pkgdir = $p{pkgdir} || return undef;
my $name = $pkgdir;
$name =~ s|.*/||;
main::progress();
my $c = IO::File->new("< $pkgdir/+CONTENTS");
return undef unless $c;
my @lines;
while (<$c>) {
chomp;
push @lines, $_;
}
my $me = bless {
pkgdir => $pkgdir,
lines => \@lines,
name => $name,
}, $pkg;
return $me;
}
sub name
{
return $_[0]->{name};
}
sub lines
{
my $me = shift;
if (@_ && @_ == 1 && ref(@_) eq 'ARRAY') {
$me->{lines} = [@{$_[0]}];
$me->{changed} = 1;
} elsif (@_) {
$me->{lines} = [@_];
$me->{changed} = 1;
} else {
return @{$me->{lines}};
}
}
sub write_back
{
my ($me) = @_;
return unless $me->{changed};
main::progress();
my $file = "$me->{pkgdir}/+CONTENTS";
copy($file, "$file.bak");
my $c = IO::File->new("> $file");
return unless $c;
for (@{$me->{lines}}) {
print $c "$_\n";
}
}
package FreeBSD::Package::DB;
use strict;
use warnings;
sub new
{
my ($pkg, %p) = @_;
my $me = bless {
dbdir => $p{dbdir} || $ENV{PKG_DBDIR} || "/var/db/pkg",
}, $pkg;
$me->{packages} = [ grep { -d } glob "$me->{dbdir}/*" ];
$me->reset;
return $me;
}
sub next
{
my ($me) = @_;
while (1) {
$me->{current}++;
if ($me->{current} >= @{$me->{packages}}) {
$me->reset;
return undef;
}
my $pkg = FreeBSD::Package->new(pkgdir => $me->{packages}->[$me->{current}]);
return $pkg if $pkg;
}
}
sub reset
{
my ($me) = @_;
$me->{current} = -1;
}
package main;
use strict;
use warnings;
use File::Temp qw/tempfile/;
use File::Copy;
our $dry_run = 1;
our $quiet = 0;
my @tmpl;
our $VERSION = "1.4";
while (@ARGV) {
my $opt = shift;
if ($opt eq "-f") {
$dry_run = 0;
} elsif ($opt eq "-d") {
$debug = 1;
} elsif ($opt eq "-q") {
$quiet = 1;
} elsif ($opt eq "-v") {
$_ = $0;
s|.*/||;
print "$_ version $VERSION\n";
exit 0;
} elsif ($opt =~ /^-/) {
$_ = $0;
s|.*/||;
print "Unknown option `$opt'\n";
print "Usage:\n";
print "\t$_\n\t$_ -v\n\t$_ -f\n";
exit 1;
} else {
push @tmpl, $opt;
}
}
our $PERL_VERSION = '%%PERL_VERSION%%';
our $PERL_PKGNAME = '%%PKGNAME%%';
our $PERL_VERSION_REGEX = qr/5\.12\.\d+/;
print STDERR "- Fuzzy source re: <$PERL_VERSION_REGEX>\n" if $debug;
our @errors;
our @notes;
sub fix_script
{
my ($file) = @_;
main::progress();
return 1 if $dry_run;
my $sf = IO::File->new("< $file");
return "" unless $sf;
my $line = <$sf>;
my $md5 = "";
if ($line && $line =~ s|^(\s*#!\s*[\w/]+perl)$PERL_VERSION_REGEX\b|$1$PERL_VERSION|) {
my $dir = $file;
$dir =~ s|/[^/]+$||;
my ($fh, $fn) = tempfile(DIR=> $dir);
if ($fh) {
print $fh $line;
while (<$sf>) {
print $fh $_;
}
close $fh;
$md5 = `/sbin/md5 -q $fn`;
chomp $md5;
my $mode = (stat($file))[2] & 07777;
unlink $file or do {
push @errors, "Failed to unlink $file: $!";
unlink $fn;
return "";
};
rename $fn, $file or do {
push @errors, "Failed to rename $fn to $file: $!";
return "";
};
chmod $mode, $file;
} else {
push @errors, "Failed to modify $file: $!";
}
}
return $md5;
}
sub fix_binary
{
my ($file) = @_;
main::progress();
my $sf = IO::File->new("< $file");
return "" unless $sf;
my $was = $dry_run ? "would be" : "was";
push @notes, "The $file binary $was modified, make sure it works";
return 1 if $dry_run;
my $md5 = "";
my $dir = $file;
$dir =~ s|/[^/]+$||;
my ($fh, $fn) = tempfile(DIR=> $dir);
unless ($fn) {
push @errors, "Failed to modify $file: $!";
return "";
}
while (<$sf>) {
s|/lib/perl5/$PERL_VERSION_REGEX/mach/CORE|/lib/perl5/$PERL_VERSION/mach/CORE|g;
print $fh $_;
}
close $fh;
$md5 = `/sbin/md5 -q $fn`;
chomp $md5;
my $mode = (stat($file))[2] & 07777;
unlink $file or do {
push @errors, "Failed to unlink $file: $!";
unlink $fn;
return "";
};
rename $fn, $file or do {
push @errors, "Failed to rename $fn to $file: $!";
return "";
};
chmod $mode, $file;
return $md5;
}
sub mkdir_recur
{
my ($dir) = @_;
main::progress();
$dir =~ s|/+$||;
my $orig = $dir;
if ($dir =~ m|^$|) {
return 1;
} else {
$dir =~ s|/[^/]+$||;
my $r = mkdir_recur($dir);
return $r unless $r;
mkdir $orig, 0777;
my $e = $!;
unless (-d $orig) {
push @errors, "Could not create directory $orig: $e";
return 0;
}
return 1;
}
}
sub might_need_to_fix
{
my ($pkg) = @_;
my $pkg_name = $pkg->name;
main::progress();
if ($pkg_name =~ /^bsdpan-/) {
return 1;
}
for ($pkg->lines) {
if (/^\@pkgdep\s+perl-(threaded-)?($PERL_VERSION_REGEX)\S*\s*$/) {
return 1;
}
}
return 0;
}
sub fixable_binary
{
my ($file, $name) = @_;
main::progress();
my $fixable = 0;
for (`/usr/bin/ldd $file 2>&1`) {
if (/^\s+libperl\.so\s+=>/) {
my $found;
for (`strings $file`) {
if (m</lib/perl5/($PERL_VERSION_REGEX)/mach/CORE>) {
$found++;
if (length($1) != length($PERL_VERSION)) {
push @notes, "$name cannot be fixed up (and has to be reinstalled): cannot patch $file due to length difference";
print STDERR "- Skipping $name: cannot patch $file due to length difference\n" if $debug;
return undef;
}
print STDERR "- $name: fixable binary $file\n" if $debug && $found < 2;
$fixable = 1 if $1 ne $PERL_VERSION;
}
}
if (!$found) {
push @notes, "$name cannot be fixed up (and has to be reinstalled): $file is using unknown libperl";
print STDERR "- Skipping $name: $file is using unknown libperl\n" if $debug;
return undef;
}
}
}
return $fixable;
}
sub fixable_shared_lib
{
my ($file, $name) = @_;
main::progress();
my ($old);
for (`strings $file`) {
if (/^perl_get_sv$/) {
push @notes, "$name cannot be fixed up (and has to be reinstalled): $file uses an old perl API";
print STDERR "- Skipping $name: $file uses an old perl API\n" if $debug;
return 0;
}
}
return 1;
}
sub cannot_be_fixed
{
my ($pkg, $binaries, $scripts) = @_;
my $pkg_name = $pkg->name;
my $prefix = "";
main::progress();
for ($pkg->lines) {
if (/^\@cwd\s+(\S+)\s*$/) {
$prefix = $1;
next;
}
my $file = "$prefix/$_";
next if -l $file;
next if $file =~ /\.gz$/;
next if $file =~ /\.bz2$/;
my $sf = IO::File->new("< $file");
next unless $sf;
my $line;
sysread $sf, $line, 256;
# binary executable
if ($line && $line =~ /^\177ELF.\x01.\x09.{8}\x02\0/) {
my $fixable = fixable_binary($file, $pkg_name);
return 0 unless defined $fixable;
push @$binaries, $file if $fixable;
# shared library - can prevent us from being able to upgrade
} elsif ($line && $line =~ /^\177ELF.\x01.\x09.{8}\x03\0/) {
return 0 unless fixable_shared_lib($file, $pkg_name);
} elsif ($line && $line =~ m<^\s*#!\s*[\w/]+perl($PERL_VERSION_REGEX)\b>) {
print STDERR "- $pkg_name: fixable script $file\n" if $debug;
push @$scripts, $file if $1 ne $PERL_VERSION;
}
main::progress();
}
}
#
my $db = FreeBSD::Package::DB->new;
my ($fixed, $skipped, $tot_moved, $tot_modified) = (0,0,0,0);
while (my $pkg = $db->next) {
my @lines;
my $new_md5;
my ($adjusted, $moved, $modified) = (0,0,0);
my $pkg_name = $pkg->name;
if (@tmpl) {
my $ok;
for (@tmpl) {
if ($pkg_name =~ /^$_/) {
$ok = 1;
last;
}
}
next unless $ok;
}
unless (might_need_to_fix($pkg)) {
$skipped++;
print STDERR "- Skipping $pkg_name, it does not depend on perl\n" if $debug;
next;
}
my (@binaries_to_fix, @scripts_to_fix);
if (cannot_be_fixed($pkg, \@binaries_to_fix, \@scripts_to_fix)) {
$skipped++;
next;
}
if ($debug) {
print STDERR "- $pkg_name: ", scalar(@binaries_to_fix), " binaries to fix\n" if @binaries_to_fix;
print STDERR "- $pkg_name: ", scalar(@scripts_to_fix), " scripts to fix\n" if @scripts_to_fix;
}
my %binaries = map { $_ => 1 } @binaries_to_fix;
my %scripts = map { $_ => 1 } @scripts_to_fix;
my $prefix = "";
my $pcnt = 0;
for ($pkg->lines) {
if (/^([^@]\S+)\s*$/) {
my $from = "$prefix/$_";
local $_; # we'll need it later
$new_md5 = "";
unless (-l $from) { # skip symlinks
if ($binaries{$from}) {
$new_md5 = fix_binary($from);
} elsif ($scripts{$from}) {
$new_md5 = fix_script($from);
}
$modified++ if $new_md5;
}
my $to = $from;
if ($to =~ s|(/perl5/(?:site_perl/)?)$PERL_VERSION_REGEX|$1$PERL_VERSION|g) {
if ($to ne $from) {
my $dir = $to;
$dir =~ s|/[^/]+$||;
main::progress();
unless ($dry_run) {
if (mkdir_recur($dir)) {
move($from, $to);
} else {
push @errors, " could not move $from to $to";
}
}
$moved++;
print STDERR "- move: $from => $to\n" if $debug;
}
}
} elsif (/^\@comment\s+MD5:[\da-f]+\s*$/ && $new_md5) {
s|MD5:(\S+)|MD5:$new_md5|;
$new_md5 = "";
} else {
$new_md5 = "";
}
if (/^\@cwd\s+(\S+)\s*$/) {
$prefix = $1;
} elsif (/^\@pkgdep\s+perl-(threaded-)?($PERL_VERSION_REGEX)\S*\s*$/) {
if ($PERL_VERSION ne $2) {
my $perlver = $2;
s|perl-(threaded-)?\Q$perlver\E\S*|$PERL_PKGNAME|;
}
}
my $old = $_;
if (s|(/perl5/(?:site_perl/)?)$PERL_VERSION_REGEX|$1$PERL_VERSION|g) {
if ($old ne $_) {
$adjusted++;
print STDERR "- adjust: $_\n" if $debug;
}
}
push @lines, $_;
main::progress() if $pcnt++ % 250 == 0;
}
unless ($dry_run) {
$pkg->lines(@lines);
$pkg->write_back;
}
$fixed++ if $moved || $modified || $adjusted;
$tot_modified += $modified;
$tot_moved += $moved;
say "$pkg_name: $moved moved, $modified modified, $adjusted adjusted"
if !$quiet || ($moved || $modified || $adjusted);
}
print "\n---\n";
print "Fixed $fixed packages ($tot_moved files moved, $tot_modified files modified)\n";
print "Skipped $skipped packages\n";
if (@errors) {
print "\n**** The script has encountered following problems:\n";
for (@errors) {
print "$_\n";
}
print "\n--- Repeating summary:\n";
print "Fixed $fixed packages ($tot_moved files moved, $tot_modified files modified)\n";
print "Skipped $skipped packages\n";
}
if (@notes) {
print "\n**** In addition, please pay attention to the following:\n";
for (@notes) {
print "$_\n";
}
print "\n--- Repeating summary:\n";
print "Fixed $fixed packages ($tot_moved files moved, $tot_modified files modified)\n";
print "Skipped $skipped packages\n";
}

View file

@ -1,2 +1,2 @@
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VERSION%%/man
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VERSION%%/perl/man
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VER%%/man
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VER%%/perl/man

View file

@ -4,6 +4,7 @@
this=`echo -n $0 | /usr/bin/sed -e 's!^.*/!!'`
PERL_VERSION="%%PERL_VERSION%%"
PERL_VER="%%PERL_VER%%"
MAKE_CONF=%%MAKE_CONF%%
banner=`date +"%F %T"`
banner="# added by use.perl $banner"
@ -89,9 +90,9 @@ do_create_links()
do_post_install()
{
INCLUDEDIR=/usr/include
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VERSION%%/%%PERL_ARCH%%/auto
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VERSION%%/auto
install -d ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/man/man3
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VER%%/%%PERL_ARCH%%/auto
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VER%%/auto
install -d ${PKG_PREFIX}/lib/perl5/%%PERL_VER%%/man/man3
cd ${INCLUDEDIR} && ${PKG_PREFIX}/bin/h2ph *.h machine/*.h sys/*.h >/dev/null
}
@ -142,8 +143,8 @@ do_spam_manpath()
if [ -f /etc/manpath.config ] ; then
echo -n "Spamming /etc/manpath.config..."
echo "$banner" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/perl/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VER%%/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VER%%/perl/man" >>/etc/manpath.config
echo " Done."
fi
}

View file

@ -14,10 +14,9 @@ bin/h2xs
bin/instmodsh
bin/libnetcfg
bin/perl
bin/perl%%PERL_VER%%
bin/perl%%PERL_VERSION%%
@exec ln -fs %D/%F %B/perl5
@unexec rm -f %B/perl5 2>&1 >/dev/null || true
bin/perl-after-upgrade
bin/perlbug
bin/perldoc
bin/perlivp
@ -1043,6 +1042,7 @@ lib/perl5/%%PERL_VER%%/pod/perl5121delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5122delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5123delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5124delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5125delta.pod
lib/perl5/%%PERL_VER%%/pod/perl561delta.pod
lib/perl5/%%PERL_VER%%/pod/perl56delta.pod
lib/perl5/%%PERL_VER%%/pod/perl570delta.pod

View file

@ -3,7 +3,7 @@
PORTNAME= perl
PORTVERSION= ${PERL_VERSION}
PORTREVISION= 3
PORTREVISION= 0
CATEGORIES= lang devel perl5
MASTER_SITES= CPAN \
${MASTER_SITE_LOCAL:S/$/:local/} \
@ -37,9 +37,10 @@ USE_PERL_DESC= Rewrite links in /usr/bin
PORTSCOUT= limitw:1,even
PERL_VERSION= 5.14.2
PERL_VERSION= 5.14.4
PERL_VER= ${PERL_VERSION:C/\.[0-9]+$//}
PERL_ARCH= mach
SITE_PERL_REL?= lib/perl5/site_perl/${PERL_VERSION}
SITE_PERL_REL?= lib/perl5/site_perl/${PERL_VER}
SITE_PERL?= ${LOCALBASE}/${SITE_PERL_REL}
USE_BZIP2= yes
@ -47,13 +48,13 @@ HAS_CONFIGURE= yes
MAKE_JOBS_UNSAFE= yes
CONFIGURE_SCRIPT=Configure
CONFIGURE_ARGS= -sde -Dprefix=${PREFIX} \
-Darchlib=${PREFIX}/lib/perl5/${PERL_VERSION}/${PERL_ARCH} \
-Dprivlib=${PREFIX}/lib/perl5/${PERL_VERSION} \
-Dman3dir=${PREFIX}/lib/perl5/${PERL_VERSION}/perl/man/man3 \
-Darchlib=${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH} \
-Dprivlib=${PREFIX}/lib/perl5/${PERL_VER} \
-Dman3dir=${PREFIX}/lib/perl5/${PERL_VER}/perl/man/man3 \
-Dman1dir=${PREFIX}/man/man1 \
-Dsitearch=${PREFIX}/${SITE_PERL_REL}/${PERL_ARCH} \
-Dsitelib=${PREFIX}/${SITE_PERL_REL} -Dscriptdir=${PREFIX}/bin \
-Dsiteman3dir=${PREFIX}/lib/perl5/${PERL_VERSION}/man/man3 \
-Dsiteman3dir=${PREFIX}/lib/perl5/${PERL_VER}/man/man3 \
-Dsiteman1dir=${PREFIX}/man/man1 \
-Ui_malloc -Ui_iconv -Uinstallusrbinperl \
-Dcc="${CC}" -Duseshrplib -Dinc_version_list=none \
@ -70,15 +71,15 @@ MAKE_ENV+= ${LOCALE_CLEANUP}
.if defined(PERL_VENDOR_PREFIX)
CONFIGURE_ARGS+= \
-Dvendorprefix=${PERL_VENDOR_PREFIX} \
-Dvendorarch=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VERSION}/${PERL_ARCH} \
-Dvendorarch=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH} \
-Dvendorbin=${PERL_VENDOR_PREFIX}/bin \
-Dvendorlib=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VERSION} \
-Dvendorman3dir=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VERSION}/man/man3 \
-Dvendorlib=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VER} \
-Dvendorman3dir=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VER}/man/man3 \
-Dvendorman1dir=${PERL_VENDOR_PREFIX}/man/man1
.endif
PLIST_SUB+= PERL_VERSION=${PERL_VERSION} \
PERL_VER=${PERL_VERSION} \
PERL_VER=${PERL_VER} \
PERL_ARCH=${PERL_ARCH} \
SITE_PERL=${SITE_PERL:S|^${LOCALBASE}/||}
@ -148,9 +149,9 @@ LATEST_LINK= perl
.if ${PORT_OPTIONS:MGDBM}
MAN3+= GDBM_File.3
.endif
MAN3PREFIX= ${PREFIX}/lib/perl5/${PERL_VERSION}/perl
MAN3PREFIX= ${PREFIX}/lib/perl5/${PERL_VER}/perl
BSDPAN_DEST= ${PREFIX}/lib/perl5/${PERL_VERSION}/BSDPAN
BSDPAN_DEST= ${PREFIX}/lib/perl5/${PERL_VER}/BSDPAN
BSDPAN_FILES= BSDPAN.pm BSDPAN/Override.pm Config.pm \
ExtUtils/MM_Unix.pm \
ExtUtils/MakeMaker.pm \
@ -164,21 +165,19 @@ PKGDEINSTALL= ${WRKDIR}/pkg-deinstall
post-patch:
${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
-e 's|%%PERL_VERSION%%|${PERL_VERSION}|g;' \
-e 's|%%PERL_VER%%|${PERL_VER}|g;' \
-e 's|%%PERL_ARCH%%|${PERL_ARCH}|g;' \
-e 's|%%MAKE_CONF%%|${__MAKE_CONF}|g;' \
-e 's|%%LINK_USRBIN%%|${LINK_USRBIN}|g;' \
${FILESDIR}/use.perl \
> ${WRKDIR}/use.perl
${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
-e 's|%%PERL_VERSION%%|${PERL_VERSION}|g;' \
-e 's|%%PERL_VER%%|${PERL_VER}|g;' \
${FILESDIR}/perl-man.conf \
> ${WRKDIR}/perl-man.conf
${SED} -e 's|%%PERL%%|${PERL}|g; s|%%PERL_VERSION%%|${PERL_VERSION}|g; s|%%PKGNAME%%|${PKGNAME}|g' \
${FILESDIR}/perl-after-upgrade \
> ${WRKDIR}/perl-after-upgrade
${CP} ${WRKDIR}/use.perl ${PKGINSTALL}
${CP} ${WRKDIR}/use.perl ${PKGDEINSTALL}
${SED} -i '' -e 's|%%PERL_PKGNAME%%|${PKGNAME}|g; s|%%PERL_VER%%|5.14|g;' \
${SED} -i '' -e 's|%%PERL_PKGNAME%%|${PKGNAME}|g; s|%%PERL_VER%%|${PERL_VER}|g;' \
-e 's!%%BSDPAN_VERSION%%!${BSDPAN_VERSION}!g;' \
${BSDPAN_WRKSRC}/ExtUtils/*.pm
${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
@ -200,12 +199,9 @@ pre-su-install:
post-install:
@${STRIP_CMD} ${PREFIX}/bin/perl${PERL_VERSION}
@${STRIP_CMD} ${PREFIX}/bin/perl
@${PREFIX}/bin/pod2man ${WRKDIR}/perl-after-upgrade >${WRKDIR}/perl-after-upgrade.1
@${INSTALL_SCRIPT} ${WRKDIR}/perl-after-upgrade ${PREFIX}/bin/perl-after-upgrade
@${INSTALL_MAN} ${WRKDIR}/perl-after-upgrade.1 ${MAN1PREFIX}/man/man1/perl-after-upgrade.1
@${LN} -sf ${PREFIX}/bin/perl${PERL_VERSION} ${PREFIX}/bin/perl5
.if ${OSVERSION} >= 900022
@${INSTALL_DATA} ${WRKDIR}/perl-man.conf ${PREFIX}/etc/man.d/perl${PERL_VERSION}.conf
@${INSTALL_DATA} ${WRKDIR}/perl-man.conf ${PREFIX}/etc/man.d/perl${PERL_VER}.conf
.endif
.for files in ${BSDPAN_FILES}
${MKDIR} ${BSDPAN_DEST}/${files:H}
@ -214,14 +210,10 @@ post-install:
.endfor
PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
AZ:
test: build
@(cd ${WRKSRC}; TEST_JOBS=${MAKE_JOBS_NUMBER} make test_harness)
regression-test: test
rebuild-xs:
${LOCALBASE}/sbin/portupgrade -f `(${FIND} ${PKG_DBDIR}/p5*/+CONTENTS | \
${XARGS} ${GREP} -El 'site_perl.*\.so' | \
${SED} -e 's!/var/db/pkg/!!; s!/+CONTENTS!!;')`
.include <bsd.port.post.mk>

View file

@ -15,7 +15,6 @@ MAN1+= h2xs.1
MAN1+= instmodsh.1
MAN1+= json_pp.1
MAN1+= libnetcfg.1
MAN1+= perl-after-upgrade.1
MAN1+= perl.1
MAN1+= perl5004delta.1
MAN1+= perl5005delta.1
@ -46,6 +45,8 @@ MAN1+= perl5139delta.1
MAN1+= perl5140delta.1
MAN1+= perl5141delta.1
MAN1+= perl5142delta.1
MAN1+= perl5143delta.1
MAN1+= perl5144delta.1
MAN1+= perl561delta.1
MAN1+= perl56delta.1
MAN1+= perl570delta.1

View file

@ -1,4 +1,4 @@
SHA256 (perl/perl-5.14.2.tar.bz2) = c2a2362e8d1fdd2bfbfde801fcd78241f154c164f00fba76065ab8cc5c7b06cd
SIZE (perl/perl-5.14.2.tar.bz2) = 13226972
SHA256 (perl/perl-5.14.4.tar.bz2) = eece8c2b0d491bf6f746bd1f4f1bb7ce26f6b98e91c54690c617d7af38964745
SIZE (perl/perl-5.14.4.tar.bz2) = 13179295
SHA256 (perl/BSDPAN-20111107.tar.bz2) = 2f03218a592dc65ebfdc3c6b9394d91dcf4c53aa5290a08458b837baad5a21f9
SIZE (perl/BSDPAN-20111107.tar.bz2) = 8448

View file

@ -1,172 +0,0 @@
From 57629630785036482da04228e9bf767b3dac66b6 Mon Sep 17 00:00:00 2001
From: Yves Orton <demerphq@gmail.com>
Date: Tue, 12 Feb 2013 10:53:05 +0100
Subject: [PATCH] Prevent premature hsplit() calls, and only trigger REHASH
after hsplit()
Triggering a hsplit due to long chain length allows an attacker
to create a carefully chosen set of keys which can cause the hash
to use 2 * (2**32) * sizeof(void *) bytes ram. AKA a DOS via memory
exhaustion. Doing so also takes non trivial time.
Eliminating this check, and only inspecting chain length after a
normal hsplit() (triggered when keys>buckets) prevents the attack
entirely, and makes such attacks relatively benign.
(cherry picked from commit f1220d61455253b170e81427c9d0357831ca0fac)
---
ext/Hash-Util-FieldHash/t/10_hash.t | 18 ++++++++++++++++--
hv.c | 35 ++++++++---------------------------
t/op/hash.t | 20 +++++++++++++++++---
3 files changed, 41 insertions(+), 32 deletions(-)
diff --git a/ext/Hash-Util-FieldHash/t/10_hash.t b/ext/Hash-Util-FieldHash/t/10_hash.t
index 2cfb4e8..d58f053 100644
--- ext/Hash-Util-FieldHash/t/10_hash.t
+++ ext/Hash-Util-FieldHash/t/10_hash.t
@@ -38,15 +38,29 @@ use constant START => "a";
# some initial hash data
fieldhash my %h2;
-%h2 = map {$_ => 1} 'a'..'cc';
+my $counter= "a";
+$h2{$counter++}++ while $counter ne 'cd';
ok (!Internals::HvREHASH(%h2),
"starting with pre-populated non-pathological hash (rehash flag if off)");
my @keys = get_keys(\%h2);
+my $buckets= buckets(\%h2);
$h2{$_}++ for @keys;
+$h2{$counter++}++ while buckets(\%h2) == $buckets; # force a split
ok (Internals::HvREHASH(%h2),
- scalar(@keys) . " colliding into the same bucket keys are triggering rehash");
+ scalar(@keys) . " colliding into the same bucket keys are triggering rehash after split");
+
+# returns the number of buckets in a hash
+sub buckets {
+ my $hr = shift;
+ my $keys_buckets= scalar(%$hr);
+ if ($keys_buckets=~m!/([0-9]+)\z!) {
+ return 0+$1;
+ } else {
+ return 8;
+ }
+}
sub get_keys {
my $hr = shift;
diff --git a/hv.c b/hv.c
index 2be1feb..abb9d76 100644
--- hv.c
+++ hv.c
@@ -35,7 +35,8 @@ holds the key and hash value.
#define PERL_HASH_INTERNAL_ACCESS
#include "perl.h"
-#define HV_MAX_LENGTH_BEFORE_SPLIT 14
+#define HV_MAX_LENGTH_BEFORE_REHASH 14
+#define SHOULD_DO_HSPLIT(xhv) ((xhv)->xhv_keys > (xhv)->xhv_max) /* HvTOTALKEYS(hv) > HvMAX(hv) */
static const char S_strtab_error[]
= "Cannot modify shared string table in hv_%s";
@@ -794,29 +795,9 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
if (masked_flags & HVhek_ENABLEHVKFLAGS)
HvHASKFLAGS_on(hv);
- {
- const HE *counter = HeNEXT(entry);
-
- xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */
- if (!counter) { /* initial entry? */
- } else if (xhv->xhv_keys > xhv->xhv_max) {
- /* Use only the old HvKEYS(hv) > HvMAX(hv) condition to limit
- bucket splits on a rehashed hash, as we're not going to
- split it again, and if someone is lucky (evil) enough to
- get all the keys in one list they could exhaust our memory
- as we repeatedly double the number of buckets on every
- entry. Linear search feels a less worse thing to do. */
- hsplit(hv);
- } else if(!HvREHASH(hv)) {
- U32 n_links = 1;
-
- while ((counter = HeNEXT(counter)))
- n_links++;
-
- if (n_links > HV_MAX_LENGTH_BEFORE_SPLIT) {
- hsplit(hv);
- }
- }
+ xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */
+ if ( SHOULD_DO_HSPLIT(xhv) ) {
+ hsplit(hv);
}
if (return_svp) {
@@ -1192,7 +1173,7 @@ S_hsplit(pTHX_ HV *hv)
/* Pick your policy for "hashing isn't working" here: */
- if (longest_chain <= HV_MAX_LENGTH_BEFORE_SPLIT /* split worked? */
+ if (longest_chain <= HV_MAX_LENGTH_BEFORE_REHASH /* split worked? */
|| HvREHASH(hv)) {
return;
}
@@ -2831,8 +2812,8 @@ S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags)
xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */
if (!next) { /* initial entry? */
- } else if (xhv->xhv_keys > xhv->xhv_max /* HvKEYS(hv) > HvMAX(hv) */) {
- hsplit(PL_strtab);
+ } else if ( SHOULD_DO_HSPLIT(xhv) ) {
+ hsplit(PL_strtab);
}
}
diff --git a/t/op/hash.t b/t/op/hash.t
index 278bea7..201260a 100644
--- t/op/hash.t
+++ t/op/hash.t
@@ -39,22 +39,36 @@ use constant THRESHOLD => 14;
use constant START => "a";
# some initial hash data
-my %h2 = map {$_ => 1} 'a'..'cc';
+my %h2;
+my $counter= "a";
+$h2{$counter++}++ while $counter ne 'cd';
ok (!Internals::HvREHASH(%h2),
"starting with pre-populated non-pathological hash (rehash flag if off)");
my @keys = get_keys(\%h2);
+my $buckets= buckets(\%h2);
$h2{$_}++ for @keys;
+$h2{$counter++}++ while buckets(\%h2) == $buckets; # force a split
ok (Internals::HvREHASH(%h2),
- scalar(@keys) . " colliding into the same bucket keys are triggering rehash");
+ scalar(@keys) . " colliding into the same bucket keys are triggering rehash after split");
+
+# returns the number of buckets in a hash
+sub buckets {
+ my $hr = shift;
+ my $keys_buckets= scalar(%$hr);
+ if ($keys_buckets=~m!/([0-9]+)\z!) {
+ return 0+$1;
+ } else {
+ return 8;
+ }
+}
sub get_keys {
my $hr = shift;
# the minimum of bits required to mount the attack on a hash
my $min_bits = log(THRESHOLD)/log(2);
-
# if the hash has already been populated with a significant amount
# of entries the number of mask bits can be higher
my $keys = scalar keys %$hr;
--
1.8.1.3

View file

@ -1,30 +0,0 @@
--- hints/freebsd.sh.orig2 2011-10-09 13:30:37.000000000 +0000
+++ hints/freebsd.sh 2011-10-09 14:12:48.000000000 +0000
@@ -116,7 +116,8 @@
case "$osvers" in
0.*|1.0*) ;;
-1*|2*) cccdlflags='-DPIC -fpic'
+1.*|2.*)
+ cccdlflags='-DPIC -fpic'
lddlflags="-Bshareable $lddlflags"
;;
@@ -139,7 +140,7 @@
esac
case "$osvers" in
-0*|1*|2*|3*) ;;
+0.*|1.*|2.*|3.*) ;;
*)
ccflags="${ccflags} -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H"
@@ -196,7 +197,7 @@
$define|true|[yY]*)
lc_r=`/sbin/ldconfig -r|grep ':-lc_r'|awk '{print $NF}'|sed -n '$p'`
case "$osvers" in
- 0*|1*|2.0*|2.1*) cat <<EOM >&4
+ 0.*|1.*|2.0*|2.1*) cat <<EOM >&4
I did not know that FreeBSD $osvers supports POSIX threads.
Feel free to tell perlbug@perl.org otherwise.

View file

@ -1,603 +0,0 @@
#! %%PERL%% -w
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42)
# <tobez@FreeBSD.org> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return. Anton Berezin
# ----------------------------------------------------------------------------
#
# $FreeBSD$
# $Id: perl-after-upgrade,v 1.11 2005/06/23 19:39:00 tobez Exp $
#
=pod
=head1 NAME
perl-after-upgrade -- fixup FreeBSD packages that depend on perl
=head1 SYNOPSIS
perl-after-upgrade
perl-after-upgrade -f [-d] [-q]
perl-after-upgrade -v
=head1 DESCRIPTION
The standard procedure after a perl port (lang/perl5.X) upgrade is to
basically reinstall all other packages that depend on perl.
This is always a painful exercise. The perl-after-upgrade utility makes
this process mostly unnecessary.
The tool goes through the list of installed packages, looks for those
that depend on perl, moves files around, modifies shebang lines in those
scripts in which it is necessary to do so, tries its best to adjust
dynamically linked binaries that link with libperl.so in the old path,
and updates the package database.
After installation of the new perl is complete, either by hand from the
ports collection, or from a package, or via portupgrade, do the
following:
=over 4
=item o go root;
=item o run perl-after-upgrade utility.
Do not specify any arguments at first, so it does nothing destructive.
Pay attention to the produced output and especially to errorlist at the
end, if any;
=item o run the utility again, with B<-f> command line option.
This will actually do the work. Again, pay attention to the output
produced;
=item o fix any reported errors;
=item o reinstall required packages:
The utility will tell you what packages that depend on perl it could not
handle. It will also tell you why it happened (for example, they were
compiled against a binary incompatible perl). If you want such packages
to remain operational, you will have to reinstall then by hand or via
portupgrade.
=item o review the files left in the older perl installation.
This is typically /usr/local/lib/perl5/site_perl/5.X.Y/. There should
be very little, if any, files in that directory and its subdirectories,
excepting a number of .ph files;
=item o check that things work as they should;
=item o remove backup files from the package database.
Those will be /var/db/pkg/*/+CONTENTS.bak;
=item o that's all.
=back
=head1 COPYRIGHT AND LICENSE
Copyright 2005 by Anton Berezin
"THE BEER-WARE LICENSE" (Revision 42)
<tobez@FreeBSD.org> wrote this module. As long as you retain this
notice you can do whatever you want with this stuff. If we meet some
day, and you think this stuff is worth it, you can buy me a beer in
return.
Anton Berezin
NO WARRANTY OF ANY KIND, USE AT YOUR OWN RISK.
=head1 HISTORY
The first version of this utility was not bundled with perl package on
FreeBSD. It was dumber than the current version in several important
areas. It was faster.
=head1 CREDITS
Thanks to Mathieu Arnold for discussion.
=head1 SEE ALSO
perl(1).
=cut
use strict;
use warnings;
use 5.0100;
our $debug = 0;
# |/-\
my $pchar = "|";
my $do_progress = -t *STDOUT;
sub progress
{
if ($do_progress) {
print STDERR "$pchar";
$pchar =~ tr<|/\\-><-|/\\>;
}
}
package FreeBSD::Package;
use strict;
use warnings;
use IO::File;
use File::Copy;
sub new
{
my ($pkg, %p) = @_;
my $pkgdir = $p{pkgdir} || return undef;
my $name = $pkgdir;
$name =~ s|.*/||;
main::progress();
my $c = IO::File->new("< $pkgdir/+CONTENTS");
return undef unless $c;
my @lines;
while (<$c>) {
chomp;
push @lines, $_;
}
my $me = bless {
pkgdir => $pkgdir,
lines => \@lines,
name => $name,
}, $pkg;
return $me;
}
sub name
{
return $_[0]->{name};
}
sub lines
{
my $me = shift;
if (@_ && @_ == 1 && ref(@_) eq 'ARRAY') {
$me->{lines} = [@{$_[0]}];
$me->{changed} = 1;
} elsif (@_) {
$me->{lines} = [@_];
$me->{changed} = 1;
} else {
return @{$me->{lines}};
}
}
sub write_back
{
my ($me) = @_;
return unless $me->{changed};
main::progress();
my $file = "$me->{pkgdir}/+CONTENTS";
copy($file, "$file.bak");
my $c = IO::File->new("> $file");
return unless $c;
for (@{$me->{lines}}) {
print $c "$_\n";
}
}
package FreeBSD::Package::DB;
use strict;
use warnings;
sub new
{
my ($pkg, %p) = @_;
my $me = bless {
dbdir => $p{dbdir} || $ENV{PKG_DBDIR} || "/var/db/pkg",
}, $pkg;
$me->{packages} = [ grep { -d } glob "$me->{dbdir}/*" ];
$me->reset;
return $me;
}
sub next
{
my ($me) = @_;
while (1) {
$me->{current}++;
if ($me->{current} >= @{$me->{packages}}) {
$me->reset;
return undef;
}
my $pkg = FreeBSD::Package->new(pkgdir => $me->{packages}->[$me->{current}]);
return $pkg if $pkg;
}
}
sub reset
{
my ($me) = @_;
$me->{current} = -1;
}
package main;
use strict;
use warnings;
use File::Temp qw/tempfile/;
use File::Copy;
our $dry_run = 1;
our $quiet = 0;
my @tmpl;
our $VERSION = "1.4";
while (@ARGV) {
my $opt = shift;
if ($opt eq "-f") {
$dry_run = 0;
} elsif ($opt eq "-d") {
$debug = 1;
} elsif ($opt eq "-q") {
$quiet = 1;
} elsif ($opt eq "-v") {
$_ = $0;
s|.*/||;
print "$_ version $VERSION\n";
exit 0;
} elsif ($opt =~ /^-/) {
$_ = $0;
s|.*/||;
print "Unknown option `$opt'\n";
print "Usage:\n";
print "\t$_\n\t$_ -v\n\t$_ -f\n";
exit 1;
} else {
push @tmpl, $opt;
}
}
our $PERL_VERSION = '%%PERL_VERSION%%';
our $PERL_PKGNAME = '%%PKGNAME%%';
our $PERL_VERSION_REGEX = qr/5\.14\.\d+/;
print STDERR "- Fuzzy source re: <$PERL_VERSION_REGEX>\n" if $debug;
our @errors;
our @notes;
sub fix_script
{
my ($file) = @_;
main::progress();
return 1 if $dry_run;
my $sf = IO::File->new("< $file");
return "" unless $sf;
my $line = <$sf>;
my $md5 = "";
if ($line && $line =~ s|^(\s*#!\s*[\w/]+perl)$PERL_VERSION_REGEX\b|$1$PERL_VERSION|) {
my $dir = $file;
$dir =~ s|/[^/]+$||;
my ($fh, $fn) = tempfile(DIR=> $dir);
if ($fh) {
print $fh $line;
while (<$sf>) {
print $fh $_;
}
close $fh;
$md5 = `/sbin/md5 -q $fn`;
chomp $md5;
my $mode = (stat($file))[2] & 07777;
unlink $file or do {
push @errors, "Failed to unlink $file: $!";
unlink $fn;
return "";
};
rename $fn, $file or do {
push @errors, "Failed to rename $fn to $file: $!";
return "";
};
chmod $mode, $file;
} else {
push @errors, "Failed to modify $file: $!";
}
}
return $md5;
}
sub fix_binary
{
my ($file) = @_;
main::progress();
my $sf = IO::File->new("< $file");
return "" unless $sf;
my $was = $dry_run ? "would be" : "was";
push @notes, "The $file binary $was modified, make sure it works";
return 1 if $dry_run;
my $md5 = "";
my $dir = $file;
$dir =~ s|/[^/]+$||;
my ($fh, $fn) = tempfile(DIR=> $dir);
unless ($fn) {
push @errors, "Failed to modify $file: $!";
return "";
}
while (<$sf>) {
s|/lib/perl5/$PERL_VERSION_REGEX/mach/CORE|/lib/perl5/$PERL_VERSION/mach/CORE|g;
print $fh $_;
}
close $fh;
$md5 = `/sbin/md5 -q $fn`;
chomp $md5;
my $mode = (stat($file))[2] & 07777;
unlink $file or do {
push @errors, "Failed to unlink $file: $!";
unlink $fn;
return "";
};
rename $fn, $file or do {
push @errors, "Failed to rename $fn to $file: $!";
return "";
};
chmod $mode, $file;
return $md5;
}
sub mkdir_recur
{
my ($dir) = @_;
main::progress();
$dir =~ s|/+$||;
my $orig = $dir;
if ($dir =~ m|^$|) {
return 1;
} else {
$dir =~ s|/[^/]+$||;
my $r = mkdir_recur($dir);
return $r unless $r;
mkdir $orig, 0777;
my $e = $!;
unless (-d $orig) {
push @errors, "Could not create directory $orig: $e";
return 0;
}
return 1;
}
}
sub might_need_to_fix
{
my ($pkg) = @_;
my $pkg_name = $pkg->name;
main::progress();
if ($pkg_name =~ /^bsdpan-/) {
return 1;
}
for ($pkg->lines) {
if (/^\@pkgdep\s+perl-(threaded-)?($PERL_VERSION_REGEX)\S*\s*$/) {
return 1;
}
}
return 0;
}
sub fixable_binary
{
my ($file, $name) = @_;
main::progress();
my $fixable = 0;
for (`/usr/bin/ldd $file 2>&1`) {
if (/^\s+libperl\.so\s+=>/) {
my $found;
for (`strings $file`) {
if (m</lib/perl5/($PERL_VERSION_REGEX)/mach/CORE>) {
$found++;
if (length($1) != length($PERL_VERSION)) {
push @notes, "$name cannot be fixed up (and has to be reinstalled): cannot patch $file due to length difference";
print STDERR "- Skipping $name: cannot patch $file due to length difference\n" if $debug;
return undef;
}
print STDERR "- $name: fixable binary $file\n" if $debug && $found < 2;
$fixable = 1 if $1 ne $PERL_VERSION;
}
}
if (!$found) {
push @notes, "$name cannot be fixed up (and has to be reinstalled): $file is using unknown libperl";
print STDERR "- Skipping $name: $file is using unknown libperl\n" if $debug;
return undef;
}
}
}
return $fixable;
}
sub fixable_shared_lib
{
my ($file, $name) = @_;
main::progress();
my ($old);
for (`strings $file`) {
if (/^perl_get_sv$/) {
push @notes, "$name cannot be fixed up (and has to be reinstalled): $file uses an old perl API";
print STDERR "- Skipping $name: $file uses an old perl API\n" if $debug;
return 0;
}
}
return 1;
}
sub cannot_be_fixed
{
my ($pkg, $binaries, $scripts) = @_;
my $pkg_name = $pkg->name;
my $prefix = "";
main::progress();
for ($pkg->lines) {
if (/^\@cwd\s+(\S+)\s*$/) {
$prefix = $1;
next;
}
my $file = "$prefix/$_";
next if -l $file;
next if $file =~ /\.gz$/;
next if $file =~ /\.bz2$/;
my $sf = IO::File->new("< $file");
next unless $sf;
my $line;
sysread $sf, $line, 256;
# binary executable
if ($line && $line =~ /^\177ELF.\x01.\x09.{8}\x02\0/) {
my $fixable = fixable_binary($file, $pkg_name);
return 0 unless defined $fixable;
push @$binaries, $file if $fixable;
# shared library - can prevent us from being able to upgrade
} elsif ($line && $line =~ /^\177ELF.\x01.\x09.{8}\x03\0/) {
return 0 unless fixable_shared_lib($file, $pkg_name);
} elsif ($line && $line =~ m<^\s*#!\s*[\w/]+perl($PERL_VERSION_REGEX)\b>) {
print STDERR "- $pkg_name: fixable script $file\n" if $debug;
push @$scripts, $file if $1 ne $PERL_VERSION;
}
main::progress();
}
}
#
my $db = FreeBSD::Package::DB->new;
my ($fixed, $skipped, $tot_moved, $tot_modified) = (0,0,0,0);
while (my $pkg = $db->next) {
my @lines;
my $new_md5;
my ($adjusted, $moved, $modified) = (0,0,0);
my $pkg_name = $pkg->name;
if (@tmpl) {
my $ok;
for (@tmpl) {
if ($pkg_name =~ /^$_/) {
$ok = 1;
last;
}
}
next unless $ok;
}
unless (might_need_to_fix($pkg)) {
$skipped++;
print STDERR "- Skipping $pkg_name, it does not depend on perl\n" if $debug;
next;
}
my (@binaries_to_fix, @scripts_to_fix);
if (cannot_be_fixed($pkg, \@binaries_to_fix, \@scripts_to_fix)) {
$skipped++;
next;
}
if ($debug) {
print STDERR "- $pkg_name: ", scalar(@binaries_to_fix), " binaries to fix\n" if @binaries_to_fix;
print STDERR "- $pkg_name: ", scalar(@scripts_to_fix), " scripts to fix\n" if @scripts_to_fix;
}
my %binaries = map { $_ => 1 } @binaries_to_fix;
my %scripts = map { $_ => 1 } @scripts_to_fix;
my $prefix = "";
my $pcnt = 0;
for ($pkg->lines) {
if (/^([^@]\S+)\s*$/) {
my $from = "$prefix/$_";
local $_; # we'll need it later
$new_md5 = "";
unless (-l $from) { # skip symlinks
if ($binaries{$from}) {
$new_md5 = fix_binary($from);
} elsif ($scripts{$from}) {
$new_md5 = fix_script($from);
}
$modified++ if $new_md5;
}
my $to = $from;
if ($to =~ s|(/perl5/(?:site_perl/)?)$PERL_VERSION_REGEX|$1$PERL_VERSION|g) {
if ($to ne $from) {
my $dir = $to;
$dir =~ s|/[^/]+$||;
main::progress();
unless ($dry_run) {
if (mkdir_recur($dir)) {
move($from, $to);
} else {
push @errors, " could not move $from to $to";
}
}
$moved++;
print STDERR "- move: $from => $to\n" if $debug;
}
}
} elsif (/^\@comment\s+MD5:[\da-f]+\s*$/ && $new_md5) {
s|MD5:(\S+)|MD5:$new_md5|;
$new_md5 = "";
} else {
$new_md5 = "";
}
if (/^\@cwd\s+(\S+)\s*$/) {
$prefix = $1;
} elsif (/^\@pkgdep\s+perl-(threaded-)?($PERL_VERSION_REGEX)\S*\s*$/) {
if ($PERL_VERSION ne $2) {
my $perlver = $2;
s|perl-(threaded-)?\Q$perlver\E\S*|$PERL_PKGNAME|;
}
}
my $old = $_;
if (s|(/perl5/(?:site_perl/)?)$PERL_VERSION_REGEX|$1$PERL_VERSION|g) {
if ($old ne $_) {
$adjusted++;
print STDERR "- adjust: $_\n" if $debug;
}
}
push @lines, $_;
main::progress() if $pcnt++ % 250 == 0;
}
unless ($dry_run) {
$pkg->lines(@lines);
$pkg->write_back;
}
$fixed++ if $moved || $modified || $adjusted;
$tot_modified += $modified;
$tot_moved += $moved;
say "$pkg_name: $moved moved, $modified modified, $adjusted adjusted"
if !$quiet || ($moved || $modified || $adjusted);
}
print "\n---\n";
print "Fixed $fixed packages ($tot_moved files moved, $tot_modified files modified)\n";
print "Skipped $skipped packages\n";
if (@errors) {
print "\n**** The script has encountered following problems:\n";
for (@errors) {
print "$_\n";
}
print "\n--- Repeating summary:\n";
print "Fixed $fixed packages ($tot_moved files moved, $tot_modified files modified)\n";
print "Skipped $skipped packages\n";
}
if (@notes) {
print "\n**** In addition, please pay attention to the following:\n";
for (@notes) {
print "$_\n";
}
print "\n--- Repeating summary:\n";
print "Fixed $fixed packages ($tot_moved files moved, $tot_modified files modified)\n";
print "Skipped $skipped packages\n";
}

View file

@ -1,2 +1,2 @@
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VERSION%%/man
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VERSION%%/perl/man
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VER%%/man
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VER%%/perl/man

View file

@ -4,6 +4,7 @@
this=`echo -n $0 | /usr/bin/sed -e 's!^.*/!!'`
PERL_VERSION="%%PERL_VERSION%%"
PERL_VER="%%PERL_VER%%"
MAKE_CONF=%%MAKE_CONF%%
banner=`date +"%F %T"`
banner="# added by use.perl $banner"
@ -89,9 +90,9 @@ do_create_links()
do_post_install()
{
INCLUDEDIR=/usr/include
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VERSION%%/%%PERL_ARCH%%/auto
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VERSION%%/auto
install -d ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/man/man3
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VER%%/%%PERL_ARCH%%/auto
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VER%%/auto
install -d ${PKG_PREFIX}/lib/perl5/%%PERL_VER%%/man/man3
cd ${INCLUDEDIR} && ${PKG_PREFIX}/bin/h2ph *.h machine/*.h sys/*.h >/dev/null
}
@ -142,8 +143,8 @@ do_spam_manpath()
if [ -f /etc/manpath.config ] ; then
echo -n "Spamming /etc/manpath.config..."
echo "$banner" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/perl/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VER%%/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VER%%/perl/man" >>/etc/manpath.config
echo " Done."
fi
}

View file

@ -15,10 +15,9 @@ bin/instmodsh
bin/json_pp
bin/libnetcfg
bin/perl
bin/perl%%PERL_VER%%
bin/perl%%PERL_VERSION%%
@exec ln -fs %D/%F %B/perl5
@unexec rm -f %B/perl5 2>&1 >/dev/null || true
bin/perl-after-upgrade
bin/perlbug
bin/perldoc
bin/perlivp
@ -1121,6 +1120,8 @@ lib/perl5/%%PERL_VER%%/pod/perl5139delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5140delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5141delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5142delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5143delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5144delta.pod
lib/perl5/%%PERL_VER%%/pod/perl561delta.pod
lib/perl5/%%PERL_VER%%/pod/perl56delta.pod
lib/perl5/%%PERL_VER%%/pod/perl570delta.pod

View file

@ -3,7 +3,7 @@
PORTNAME= perl
PORTVERSION= ${PERL_VERSION}
PORTREVISION= 1
PORTREVISION= 0
CATEGORIES= lang devel perl5
MASTER_SITES= CPAN \
${MASTER_SITE_LOCAL:S/$/:local/} \
@ -37,9 +37,10 @@ USE_PERL_DESC= Rewrite links in /usr/bin
PORTSCOUT= limitw:1,even
PERL_VERSION= 5.16.2
PERL_VERSION= 5.16.3
PERL_VER= ${PERL_VERSION:C/\.[0-9]+$//}
PERL_ARCH= mach
SITE_PERL_REL?= lib/perl5/site_perl/${PERL_VERSION}
SITE_PERL_REL?= lib/perl5/site_perl/${PERL_VER}
SITE_PERL?= ${LOCALBASE}/${SITE_PERL_REL}
USE_BZIP2= yes
@ -47,13 +48,13 @@ HAS_CONFIGURE= yes
MAKE_JOBS_UNSAFE= yes
CONFIGURE_SCRIPT=Configure
CONFIGURE_ARGS= -sde -Dprefix=${PREFIX} \
-Darchlib=${PREFIX}/lib/perl5/${PERL_VERSION}/${PERL_ARCH} \
-Dprivlib=${PREFIX}/lib/perl5/${PERL_VERSION} \
-Dman3dir=${PREFIX}/lib/perl5/${PERL_VERSION}/perl/man/man3 \
-Darchlib=${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH} \
-Dprivlib=${PREFIX}/lib/perl5/${PERL_VER} \
-Dman3dir=${PREFIX}/lib/perl5/${PERL_VER}/perl/man/man3 \
-Dman1dir=${PREFIX}/man/man1 \
-Dsitearch=${PREFIX}/${SITE_PERL_REL}/${PERL_ARCH} \
-Dsitelib=${PREFIX}/${SITE_PERL_REL} -Dscriptdir=${PREFIX}/bin \
-Dsiteman3dir=${PREFIX}/lib/perl5/${PERL_VERSION}/man/man3 \
-Dsiteman3dir=${PREFIX}/lib/perl5/${PERL_VER}/man/man3 \
-Dsiteman1dir=${PREFIX}/man/man1 \
-Ui_malloc -Ui_iconv -Uinstallusrbinperl \
-Dcc="${CC}" -Duseshrplib -Dinc_version_list=none \
@ -70,15 +71,15 @@ MAKE_ENV+= ${LOCALE_CLEANUP}
.if defined(PERL_VENDOR_PREFIX)
CONFIGURE_ARGS+= \
-Dvendorprefix=${PERL_VENDOR_PREFIX} \
-Dvendorarch=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VERSION}/${PERL_ARCH} \
-Dvendorarch=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH} \
-Dvendorbin=${PERL_VENDOR_PREFIX}/bin \
-Dvendorlib=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VERSION} \
-Dvendorman3dir=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VERSION}/man/man3 \
-Dvendorlib=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VER} \
-Dvendorman3dir=${PERL_VENDOR_PREFIX}/lib/perl5/${PERL_VER}/man/man3 \
-Dvendorman1dir=${PERL_VENDOR_PREFIX}/man/man1
.endif
PLIST_SUB+= PERL_VERSION=${PERL_VERSION} \
PERL_VER=${PERL_VERSION} \
PERL_VER=${PERL_VER} \
PERL_ARCH=${PERL_ARCH} \
SITE_PERL=${SITE_PERL:S|^${LOCALBASE}/||}
@ -148,9 +149,9 @@ NO_LATEST_LINK= yes
.if ${PORT_OPTIONS:MGDBM}
MAN3+= GDBM_File.3
.endif
MAN3PREFIX= ${PREFIX}/lib/perl5/${PERL_VERSION}/perl
MAN3PREFIX= ${PREFIX}/lib/perl5/${PERL_VER}/perl
BSDPAN_DEST= ${PREFIX}/lib/perl5/${PERL_VERSION}/BSDPAN
BSDPAN_DEST= ${PREFIX}/lib/perl5/${PERL_VER}/BSDPAN
BSDPAN_FILES= BSDPAN.pm BSDPAN/Override.pm Config.pm \
ExtUtils/MM_Unix.pm \
ExtUtils/MakeMaker.pm \
@ -164,21 +165,19 @@ PKGDEINSTALL= ${WRKDIR}/pkg-deinstall
post-patch:
${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
-e 's|%%PERL_VERSION%%|${PERL_VERSION}|g;' \
-e 's|%%PERL_VER%%|${PERL_VER}|g;' \
-e 's|%%PERL_ARCH%%|${PERL_ARCH}|g;' \
-e 's|%%MAKE_CONF%%|${__MAKE_CONF}|g;' \
-e 's|%%LINK_USRBIN%%|${LINK_USRBIN}|g;' \
${FILESDIR}/use.perl \
> ${WRKDIR}/use.perl
${SED} -e 's|%%PREFIX%%|${PREFIX}|g;' \
-e 's|%%PERL_VERSION%%|${PERL_VERSION}|g;' \
-e 's|%%PERL_VER%%|${PERL_VER}|g;' \
${FILESDIR}/perl-man.conf \
> ${WRKDIR}/perl-man.conf
${SED} -e 's|%%PERL%%|${PERL}|g; s|%%PERL_VERSION%%|${PERL_VERSION}|g; s|%%PKGNAME%%|${PKGNAME}|g' \
${FILESDIR}/perl-after-upgrade \
> ${WRKDIR}/perl-after-upgrade
${CP} ${WRKDIR}/use.perl ${PKGINSTALL}
${CP} ${WRKDIR}/use.perl ${PKGDEINSTALL}
${SED} -i '' -e 's|%%PERL_PKGNAME%%|${PKGNAME}|g; s|%%PERL_VER%%|5.16|g;' \
${SED} -i '' -e 's|%%PERL_PKGNAME%%|${PKGNAME}|g; s|%%PERL_VER%%|%{PERL_VER}|g;' \
-e 's!%%BSDPAN_VERSION%%!${BSDPAN_VERSION}!g;' \
${BSDPAN_WRKSRC}/ExtUtils/*.pm
${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
@ -200,12 +199,9 @@ pre-su-install:
post-install:
@${STRIP_CMD} ${PREFIX}/bin/perl${PERL_VERSION}
@${STRIP_CMD} ${PREFIX}/bin/perl
@${PREFIX}/bin/pod2man ${WRKDIR}/perl-after-upgrade >${WRKDIR}/perl-after-upgrade.1
@${INSTALL_SCRIPT} ${WRKDIR}/perl-after-upgrade ${PREFIX}/bin/perl-after-upgrade
@${INSTALL_MAN} ${WRKDIR}/perl-after-upgrade.1 ${MAN1PREFIX}/man/man1/perl-after-upgrade.1
@${LN} -sf ${PREFIX}/bin/perl${PERL_VERSION} ${PREFIX}/bin/perl5
.if ${OSVERSION} >= 900022
@${INSTALL_DATA} ${WRKDIR}/perl-man.conf ${PREFIX}/etc/man.d/perl${PERL_VERSION}.conf
@${INSTALL_DATA} ${WRKDIR}/perl-man.conf ${PREFIX}/etc/man.d/perl${PERL_VER}.conf
.endif
.for files in ${BSDPAN_FILES}
${MKDIR} ${BSDPAN_DEST}/${files:H}
@ -214,14 +210,10 @@ post-install:
.endfor
PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
AZ:
test: build
@(cd ${WRKSRC}; TEST_JOBS=${MAKE_JOBS_NUMBER} make test_harness)
regression-test: test
rebuild-xs:
${LOCALBASE}/sbin/portupgrade -f `(${FIND} ${PKG_DBDIR}/p5*/+CONTENTS | \
${XARGS} ${GREP} -El 'site_perl.*\.so' | \
${SED} -e 's!/var/db/pkg/!!; s!/+CONTENTS!!;')`
.include <bsd.port.post.mk>

View file

@ -14,7 +14,6 @@ MAN1+= h2xs.1
MAN1+= instmodsh.1
MAN1+= json_pp.1
MAN1+= libnetcfg.1
MAN1+= perl-after-upgrade.1
MAN1+= perl.1
MAN1+= perl5004delta.1
MAN1+= perl5005delta.1
@ -32,6 +31,7 @@ MAN1+= perl5142delta.1
MAN1+= perl5160delta.1
MAN1+= perl5161delta.1
MAN1+= perl5162delta.1
MAN1+= perl5163delta.1
MAN1+= perl561delta.1
MAN1+= perl56delta.1
MAN1+= perl581delta.1

View file

@ -1,4 +1,4 @@
SHA256 (perl/perl-5.16.2.tar.bz2) = 5ba91d9aa40220c615b644bb48fa5df7fbca4afb1c9e911bdc0ce2a93f072d7d
SIZE (perl/perl-5.16.2.tar.bz2) = 13725101
SHA256 (perl/perl-5.16.3.tar.bz2) = bb7bc735e6813b177dcfccd480defcde7eddefa173b5967eac11babd1bfa98e8
SIZE (perl/perl-5.16.3.tar.bz2) = 13724906
SHA256 (perl/BSDPAN-20111107.tar.bz2) = 2f03218a592dc65ebfdc3c6b9394d91dcf4c53aa5290a08458b837baad5a21f9
SIZE (perl/BSDPAN-20111107.tar.bz2) = 8448

View file

@ -1,170 +0,0 @@
From f1220d61455253b170e81427c9d0357831ca0fac Mon Sep 17 00:00:00 2001
From: Yves Orton <demerphq@gmail.com>
Date: Tue, 12 Feb 2013 10:53:05 +0100
Subject: [PATCH] Prevent premature hsplit() calls, and only trigger REHASH
after hsplit()
Triggering a hsplit due to long chain length allows an attacker
to create a carefully chosen set of keys which can cause the hash
to use 2 * (2**32) * sizeof(void *) bytes ram. AKA a DOS via memory
exhaustion. Doing so also takes non trivial time.
Eliminating this check, and only inspecting chain length after a
normal hsplit() (triggered when keys>buckets) prevents the attack
entirely, and makes such attacks relatively benign.
---
ext/Hash-Util-FieldHash/t/10_hash.t | 18 ++++++++++++++++--
hv.c | 35 ++++++++---------------------------
t/op/hash.t | 20 +++++++++++++++++---
3 files changed, 41 insertions(+), 32 deletions(-)
diff --git a/ext/Hash-Util-FieldHash/t/10_hash.t b/ext/Hash-Util-FieldHash/t/10_hash.t
index 2cfb4e8..d58f053 100644
--- ext/Hash-Util-FieldHash/t/10_hash.t
+++ ext/Hash-Util-FieldHash/t/10_hash.t
@@ -38,15 +38,29 @@ use constant START => "a";
# some initial hash data
fieldhash my %h2;
-%h2 = map {$_ => 1} 'a'..'cc';
+my $counter= "a";
+$h2{$counter++}++ while $counter ne 'cd';
ok (!Internals::HvREHASH(%h2),
"starting with pre-populated non-pathological hash (rehash flag if off)");
my @keys = get_keys(\%h2);
+my $buckets= buckets(\%h2);
$h2{$_}++ for @keys;
+$h2{$counter++}++ while buckets(\%h2) == $buckets; # force a split
ok (Internals::HvREHASH(%h2),
- scalar(@keys) . " colliding into the same bucket keys are triggering rehash");
+ scalar(@keys) . " colliding into the same bucket keys are triggering rehash after split");
+
+# returns the number of buckets in a hash
+sub buckets {
+ my $hr = shift;
+ my $keys_buckets= scalar(%$hr);
+ if ($keys_buckets=~m!/([0-9]+)\z!) {
+ return 0+$1;
+ } else {
+ return 8;
+ }
+}
sub get_keys {
my $hr = shift;
diff --git a/hv.c b/hv.c
index 6b66251..a031703 100644
--- hv.c
+++ hv.c
@@ -35,7 +35,8 @@ holds the key and hash value.
#define PERL_HASH_INTERNAL_ACCESS
#include "perl.h"
-#define HV_MAX_LENGTH_BEFORE_SPLIT 14
+#define HV_MAX_LENGTH_BEFORE_REHASH 14
+#define SHOULD_DO_HSPLIT(xhv) ((xhv)->xhv_keys > (xhv)->xhv_max) /* HvTOTALKEYS(hv) > HvMAX(hv) */
static const char S_strtab_error[]
= "Cannot modify shared string table in hv_%s";
@@ -798,29 +799,9 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
if (masked_flags & HVhek_ENABLEHVKFLAGS)
HvHASKFLAGS_on(hv);
- {
- const HE *counter = HeNEXT(entry);
-
- xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */
- if (!counter) { /* initial entry? */
- } else if (xhv->xhv_keys > xhv->xhv_max) {
- /* Use only the old HvUSEDKEYS(hv) > HvMAX(hv) condition to limit
- bucket splits on a rehashed hash, as we're not going to
- split it again, and if someone is lucky (evil) enough to
- get all the keys in one list they could exhaust our memory
- as we repeatedly double the number of buckets on every
- entry. Linear search feels a less worse thing to do. */
- hsplit(hv);
- } else if(!HvREHASH(hv)) {
- U32 n_links = 1;
-
- while ((counter = HeNEXT(counter)))
- n_links++;
-
- if (n_links > HV_MAX_LENGTH_BEFORE_SPLIT) {
- hsplit(hv);
- }
- }
+ xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */
+ if ( SHOULD_DO_HSPLIT(xhv) ) {
+ hsplit(hv);
}
if (return_svp) {
@@ -1197,7 +1178,7 @@ S_hsplit(pTHX_ HV *hv)
/* Pick your policy for "hashing isn't working" here: */
- if (longest_chain <= HV_MAX_LENGTH_BEFORE_SPLIT /* split worked? */
+ if (longest_chain <= HV_MAX_LENGTH_BEFORE_REHASH /* split worked? */
|| HvREHASH(hv)) {
return;
}
@@ -2782,8 +2763,8 @@ S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags)
xhv->xhv_keys++; /* HvTOTALKEYS(hv)++ */
if (!next) { /* initial entry? */
- } else if (xhv->xhv_keys > xhv->xhv_max /* HvUSEDKEYS(hv) > HvMAX(hv) */) {
- hsplit(PL_strtab);
+ } else if ( SHOULD_DO_HSPLIT(xhv) ) {
+ hsplit(PL_strtab);
}
}
diff --git a/t/op/hash.t b/t/op/hash.t
index ef757a3..97eb81b 100644
--- t/op/hash.t
+++ t/op/hash.t
@@ -39,22 +39,36 @@ use constant THRESHOLD => 14;
use constant START => "a";
# some initial hash data
-my %h2 = map {$_ => 1} 'a'..'cc';
+my %h2;
+my $counter= "a";
+$h2{$counter++}++ while $counter ne 'cd';
ok (!Internals::HvREHASH(%h2),
"starting with pre-populated non-pathological hash (rehash flag if off)");
my @keys = get_keys(\%h2);
+my $buckets= buckets(\%h2);
$h2{$_}++ for @keys;
+$h2{$counter++}++ while buckets(\%h2) == $buckets; # force a split
ok (Internals::HvREHASH(%h2),
- scalar(@keys) . " colliding into the same bucket keys are triggering rehash");
+ scalar(@keys) . " colliding into the same bucket keys are triggering rehash after split");
+
+# returns the number of buckets in a hash
+sub buckets {
+ my $hr = shift;
+ my $keys_buckets= scalar(%$hr);
+ if ($keys_buckets=~m!/([0-9]+)\z!) {
+ return 0+$1;
+ } else {
+ return 8;
+ }
+}
sub get_keys {
my $hr = shift;
# the minimum of bits required to mount the attack on a hash
my $min_bits = log(THRESHOLD)/log(2);
-
# if the hash has already been populated with a significant amount
# of entries the number of mask bits can be higher
my $keys = scalar keys %$hr;
--
1.8.1.3

View file

@ -1,603 +0,0 @@
#! %%PERL%% -w
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42)
# <tobez@FreeBSD.org> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return. Anton Berezin
# ----------------------------------------------------------------------------
#
# $FreeBSD$
# $Id: perl-after-upgrade,v 1.11 2005/06/23 19:39:00 tobez Exp $
#
=pod
=head1 NAME
perl-after-upgrade -- fixup FreeBSD packages that depend on perl
=head1 SYNOPSIS
perl-after-upgrade
perl-after-upgrade -f [-d] [-q]
perl-after-upgrade -v
=head1 DESCRIPTION
The standard procedure after a perl port (lang/perl5.X) upgrade is to
basically reinstall all other packages that depend on perl.
This is always a painful exercise. The perl-after-upgrade utility makes
this process mostly unnecessary.
The tool goes through the list of installed packages, looks for those
that depend on perl, moves files around, modifies shebang lines in those
scripts in which it is necessary to do so, tries its best to adjust
dynamically linked binaries that link with libperl.so in the old path,
and updates the package database.
After installation of the new perl is complete, either by hand from the
ports collection, or from a package, or via portupgrade, do the
following:
=over 4
=item o go root;
=item o run perl-after-upgrade utility.
Do not specify any arguments at first, so it does nothing destructive.
Pay attention to the produced output and especially to errorlist at the
end, if any;
=item o run the utility again, with B<-f> command line option.
This will actually do the work. Again, pay attention to the output
produced;
=item o fix any reported errors;
=item o reinstall required packages:
The utility will tell you what packages that depend on perl it could not
handle. It will also tell you why it happened (for example, they were
compiled against a binary incompatible perl). If you want such packages
to remain operational, you will have to reinstall then by hand or via
portupgrade.
=item o review the files left in the older perl installation.
This is typically /usr/local/lib/perl5/site_perl/5.X.Y/. There should
be very little, if any, files in that directory and its subdirectories,
excepting a number of .ph files;
=item o check that things work as they should;
=item o remove backup files from the package database.
Those will be /var/db/pkg/*/+CONTENTS.bak;
=item o that's all.
=back
=head1 COPYRIGHT AND LICENSE
Copyright 2005 by Anton Berezin
"THE BEER-WARE LICENSE" (Revision 42)
<tobez@FreeBSD.org> wrote this module. As long as you retain this
notice you can do whatever you want with this stuff. If we meet some
day, and you think this stuff is worth it, you can buy me a beer in
return.
Anton Berezin
NO WARRANTY OF ANY KIND, USE AT YOUR OWN RISK.
=head1 HISTORY
The first version of this utility was not bundled with perl package on
FreeBSD. It was dumber than the current version in several important
areas. It was faster.
=head1 CREDITS
Thanks to Mathieu Arnold for discussion.
=head1 SEE ALSO
perl(1).
=cut
use strict;
use warnings;
use 5.0100;
our $debug = 0;
# |/-\
my $pchar = "|";
my $do_progress = -t *STDOUT;
sub progress
{
if ($do_progress) {
print STDERR "$pchar";
$pchar =~ tr<|/\\-><-|/\\>;
}
}
package FreeBSD::Package;
use strict;
use warnings;
use IO::File;
use File::Copy;
sub new
{
my ($pkg, %p) = @_;
my $pkgdir = $p{pkgdir} || return undef;
my $name = $pkgdir;
$name =~ s|.*/||;
main::progress();
my $c = IO::File->new("< $pkgdir/+CONTENTS");
return undef unless $c;
my @lines;
while (<$c>) {
chomp;
push @lines, $_;
}
my $me = bless {
pkgdir => $pkgdir,
lines => \@lines,
name => $name,
}, $pkg;
return $me;
}
sub name
{
return $_[0]->{name};
}
sub lines
{
my $me = shift;
if (@_ && @_ == 1 && ref(@_) eq 'ARRAY') {
$me->{lines} = [@{$_[0]}];
$me->{changed} = 1;
} elsif (@_) {
$me->{lines} = [@_];
$me->{changed} = 1;
} else {
return @{$me->{lines}};
}
}
sub write_back
{
my ($me) = @_;
return unless $me->{changed};
main::progress();
my $file = "$me->{pkgdir}/+CONTENTS";
copy($file, "$file.bak");
my $c = IO::File->new("> $file");
return unless $c;
for (@{$me->{lines}}) {
print $c "$_\n";
}
}
package FreeBSD::Package::DB;
use strict;
use warnings;
sub new
{
my ($pkg, %p) = @_;
my $me = bless {
dbdir => $p{dbdir} || $ENV{PKG_DBDIR} || "/var/db/pkg",
}, $pkg;
$me->{packages} = [ grep { -d } glob "$me->{dbdir}/*" ];
$me->reset;
return $me;
}
sub next
{
my ($me) = @_;
while (1) {
$me->{current}++;
if ($me->{current} >= @{$me->{packages}}) {
$me->reset;
return undef;
}
my $pkg = FreeBSD::Package->new(pkgdir => $me->{packages}->[$me->{current}]);
return $pkg if $pkg;
}
}
sub reset
{
my ($me) = @_;
$me->{current} = -1;
}
package main;
use strict;
use warnings;
use File::Temp qw/tempfile/;
use File::Copy;
our $dry_run = 1;
our $quiet = 0;
my @tmpl;
our $VERSION = "1.4";
while (@ARGV) {
my $opt = shift;
if ($opt eq "-f") {
$dry_run = 0;
} elsif ($opt eq "-d") {
$debug = 1;
} elsif ($opt eq "-q") {
$quiet = 1;
} elsif ($opt eq "-v") {
$_ = $0;
s|.*/||;
print "$_ version $VERSION\n";
exit 0;
} elsif ($opt =~ /^-/) {
$_ = $0;
s|.*/||;
print "Unknown option `$opt'\n";
print "Usage:\n";
print "\t$_\n\t$_ -v\n\t$_ -f\n";
exit 1;
} else {
push @tmpl, $opt;
}
}
our $PERL_VERSION = '%%PERL_VERSION%%';
our $PERL_PKGNAME = '%%PKGNAME%%';
our $PERL_VERSION_REGEX = qr/5\.16\.\d+/;
print STDERR "- Fuzzy source re: <$PERL_VERSION_REGEX>\n" if $debug;
our @errors;
our @notes;
sub fix_script
{
my ($file) = @_;
main::progress();
return 1 if $dry_run;
my $sf = IO::File->new("< $file");
return "" unless $sf;
my $line = <$sf>;
my $md5 = "";
if ($line && $line =~ s|^(\s*#!\s*[\w/]+perl)$PERL_VERSION_REGEX\b|$1$PERL_VERSION|) {
my $dir = $file;
$dir =~ s|/[^/]+$||;
my ($fh, $fn) = tempfile(DIR=> $dir);
if ($fh) {
print $fh $line;
while (<$sf>) {
print $fh $_;
}
close $fh;
$md5 = `/sbin/md5 -q $fn`;
chomp $md5;
my $mode = (stat($file))[2] & 07777;
unlink $file or do {
push @errors, "Failed to unlink $file: $!";
unlink $fn;
return "";
};
rename $fn, $file or do {
push @errors, "Failed to rename $fn to $file: $!";
return "";
};
chmod $mode, $file;
} else {
push @errors, "Failed to modify $file: $!";
}
}
return $md5;
}
sub fix_binary
{
my ($file) = @_;
main::progress();
my $sf = IO::File->new("< $file");
return "" unless $sf;
my $was = $dry_run ? "would be" : "was";
push @notes, "The $file binary $was modified, make sure it works";
return 1 if $dry_run;
my $md5 = "";
my $dir = $file;
$dir =~ s|/[^/]+$||;
my ($fh, $fn) = tempfile(DIR=> $dir);
unless ($fn) {
push @errors, "Failed to modify $file: $!";
return "";
}
while (<$sf>) {
s|/lib/perl5/$PERL_VERSION_REGEX/mach/CORE|/lib/perl5/$PERL_VERSION/mach/CORE|g;
print $fh $_;
}
close $fh;
$md5 = `/sbin/md5 -q $fn`;
chomp $md5;
my $mode = (stat($file))[2] & 07777;
unlink $file or do {
push @errors, "Failed to unlink $file: $!";
unlink $fn;
return "";
};
rename $fn, $file or do {
push @errors, "Failed to rename $fn to $file: $!";
return "";
};
chmod $mode, $file;
return $md5;
}
sub mkdir_recur
{
my ($dir) = @_;
main::progress();
$dir =~ s|/+$||;
my $orig = $dir;
if ($dir =~ m|^$|) {
return 1;
} else {
$dir =~ s|/[^/]+$||;
my $r = mkdir_recur($dir);
return $r unless $r;
mkdir $orig, 0777;
my $e = $!;
unless (-d $orig) {
push @errors, "Could not create directory $orig: $e";
return 0;
}
return 1;
}
}
sub might_need_to_fix
{
my ($pkg) = @_;
my $pkg_name = $pkg->name;
main::progress();
if ($pkg_name =~ /^bsdpan-/) {
return 1;
}
for ($pkg->lines) {
if (/^\@pkgdep\s+perl-(threaded-)?($PERL_VERSION_REGEX)\S*\s*$/) {
return 1;
}
}
return 0;
}
sub fixable_binary
{
my ($file, $name) = @_;
main::progress();
my $fixable = 0;
for (`/usr/bin/ldd $file 2>&1`) {
if (/^\s+libperl\.so\s+=>/) {
my $found;
for (`strings $file`) {
if (m</lib/perl5/($PERL_VERSION_REGEX)/mach/CORE>) {
$found++;
if (length($1) != length($PERL_VERSION)) {
push @notes, "$name cannot be fixed up (and has to be reinstalled): cannot patch $file due to length difference";
print STDERR "- Skipping $name: cannot patch $file due to length difference\n" if $debug;
return undef;
}
print STDERR "- $name: fixable binary $file\n" if $debug && $found < 2;
$fixable = 1 if $1 ne $PERL_VERSION;
}
}
if (!$found) {
push @notes, "$name cannot be fixed up (and has to be reinstalled): $file is using unknown libperl";
print STDERR "- Skipping $name: $file is using unknown libperl\n" if $debug;
return undef;
}
}
}
return $fixable;
}
sub fixable_shared_lib
{
my ($file, $name) = @_;
main::progress();
my ($old);
for (`strings $file`) {
if (/^perl_get_sv$/) {
push @notes, "$name cannot be fixed up (and has to be reinstalled): $file uses an old perl API";
print STDERR "- Skipping $name: $file uses an old perl API\n" if $debug;
return 0;
}
}
return 1;
}
sub cannot_be_fixed
{
my ($pkg, $binaries, $scripts) = @_;
my $pkg_name = $pkg->name;
my $prefix = "";
main::progress();
for ($pkg->lines) {
if (/^\@cwd\s+(\S+)\s*$/) {
$prefix = $1;
next;
}
my $file = "$prefix/$_";
next if -l $file;
next if $file =~ /\.gz$/;
next if $file =~ /\.bz2$/;
my $sf = IO::File->new("< $file");
next unless $sf;
my $line;
sysread $sf, $line, 256;
# binary executable
if ($line && $line =~ /^\177ELF.\x01.\x09.{8}\x02\0/) {
my $fixable = fixable_binary($file, $pkg_name);
return 0 unless defined $fixable;
push @$binaries, $file if $fixable;
# shared library - can prevent us from being able to upgrade
} elsif ($line && $line =~ /^\177ELF.\x01.\x09.{8}\x03\0/) {
return 0 unless fixable_shared_lib($file, $pkg_name);
} elsif ($line && $line =~ m<^\s*#!\s*[\w/]+perl($PERL_VERSION_REGEX)\b>) {
print STDERR "- $pkg_name: fixable script $file\n" if $debug;
push @$scripts, $file if $1 ne $PERL_VERSION;
}
main::progress();
}
}
#
my $db = FreeBSD::Package::DB->new;
my ($fixed, $skipped, $tot_moved, $tot_modified) = (0,0,0,0);
while (my $pkg = $db->next) {
my @lines;
my $new_md5;
my ($adjusted, $moved, $modified) = (0,0,0);
my $pkg_name = $pkg->name;
if (@tmpl) {
my $ok;
for (@tmpl) {
if ($pkg_name =~ /^$_/) {
$ok = 1;
last;
}
}
next unless $ok;
}
unless (might_need_to_fix($pkg)) {
$skipped++;
print STDERR "- Skipping $pkg_name, it does not depend on perl\n" if $debug;
next;
}
my (@binaries_to_fix, @scripts_to_fix);
if (cannot_be_fixed($pkg, \@binaries_to_fix, \@scripts_to_fix)) {
$skipped++;
next;
}
if ($debug) {
print STDERR "- $pkg_name: ", scalar(@binaries_to_fix), " binaries to fix\n" if @binaries_to_fix;
print STDERR "- $pkg_name: ", scalar(@scripts_to_fix), " scripts to fix\n" if @scripts_to_fix;
}
my %binaries = map { $_ => 1 } @binaries_to_fix;
my %scripts = map { $_ => 1 } @scripts_to_fix;
my $prefix = "";
my $pcnt = 0;
for ($pkg->lines) {
if (/^([^@]\S+)\s*$/) {
my $from = "$prefix/$_";
local $_; # we'll need it later
$new_md5 = "";
unless (-l $from) { # skip symlinks
if ($binaries{$from}) {
$new_md5 = fix_binary($from);
} elsif ($scripts{$from}) {
$new_md5 = fix_script($from);
}
$modified++ if $new_md5;
}
my $to = $from;
if ($to =~ s|(/perl5/(?:site_perl/)?)$PERL_VERSION_REGEX|$1$PERL_VERSION|g) {
if ($to ne $from) {
my $dir = $to;
$dir =~ s|/[^/]+$||;
main::progress();
unless ($dry_run) {
if (mkdir_recur($dir)) {
move($from, $to);
} else {
push @errors, " could not move $from to $to";
}
}
$moved++;
print STDERR "- move: $from => $to\n" if $debug;
}
}
} elsif (/^\@comment\s+MD5:[\da-f]+\s*$/ && $new_md5) {
s|MD5:(\S+)|MD5:$new_md5|;
$new_md5 = "";
} else {
$new_md5 = "";
}
if (/^\@cwd\s+(\S+)\s*$/) {
$prefix = $1;
} elsif (/^\@pkgdep\s+perl-(threaded-)?($PERL_VERSION_REGEX)\S*\s*$/) {
if ($PERL_VERSION ne $2) {
my $perlver = $2;
s|perl-(threaded-)?\Q$perlver\E\S*|$PERL_PKGNAME|;
}
}
my $old = $_;
if (s|(/perl5/(?:site_perl/)?)$PERL_VERSION_REGEX|$1$PERL_VERSION|g) {
if ($old ne $_) {
$adjusted++;
print STDERR "- adjust: $_\n" if $debug;
}
}
push @lines, $_;
main::progress() if $pcnt++ % 250 == 0;
}
unless ($dry_run) {
$pkg->lines(@lines);
$pkg->write_back;
}
$fixed++ if $moved || $modified || $adjusted;
$tot_modified += $modified;
$tot_moved += $moved;
say "$pkg_name: $moved moved, $modified modified, $adjusted adjusted"
if !$quiet || ($moved || $modified || $adjusted);
}
print "\n---\n";
print "Fixed $fixed packages ($tot_moved files moved, $tot_modified files modified)\n";
print "Skipped $skipped packages\n";
if (@errors) {
print "\n**** The script has encountered following problems:\n";
for (@errors) {
print "$_\n";
}
print "\n--- Repeating summary:\n";
print "Fixed $fixed packages ($tot_moved files moved, $tot_modified files modified)\n";
print "Skipped $skipped packages\n";
}
if (@notes) {
print "\n**** In addition, please pay attention to the following:\n";
for (@notes) {
print "$_\n";
}
print "\n--- Repeating summary:\n";
print "Fixed $fixed packages ($tot_moved files moved, $tot_modified files modified)\n";
print "Skipped $skipped packages\n";
}

View file

@ -1,2 +1,2 @@
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VERSION%%/man
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VERSION%%/perl/man
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VER%%/man
MANPATH %%PREFIX%%/lib/perl5/%%PERL_VER%%/perl/man

View file

@ -4,6 +4,7 @@
this=`echo -n $0 | /usr/bin/sed -e 's!^.*/!!'`
PERL_VERSION="%%PERL_VERSION%%"
PERL_VER="%%PERL_VER%%"
MAKE_CONF=%%MAKE_CONF%%
banner=`date +"%F %T"`
banner="# added by use.perl $banner"
@ -89,9 +90,9 @@ do_create_links()
do_post_install()
{
INCLUDEDIR=/usr/include
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VERSION%%/%%PERL_ARCH%%/auto
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VERSION%%/auto
install -d ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/man/man3
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VER%%/%%PERL_ARCH%%/auto
install -d ${PKG_PREFIX}/lib/perl5/site_perl/%%PERL_VER%%/auto
install -d ${PKG_PREFIX}/lib/perl5/%%PERL_VER%%/man/man3
cd ${INCLUDEDIR} && ${PKG_PREFIX}/bin/h2ph *.h machine/*.h sys/*.h >/dev/null
}
@ -142,8 +143,8 @@ do_spam_manpath()
if [ -f /etc/manpath.config ] ; then
echo -n "Spamming /etc/manpath.config..."
echo "$banner" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VERSION%%/perl/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VER%%/man" >>/etc/manpath.config
echo "OPTIONAL_MANPATH ${PKG_PREFIX}/lib/perl5/%%PERL_VER%%/perl/man" >>/etc/manpath.config
echo " Done."
fi
}

View file

@ -14,10 +14,9 @@ bin/instmodsh
bin/json_pp
bin/libnetcfg
bin/perl
bin/perl%%PERL_VER%%
bin/perl%%PERL_VERSION%%
@exec ln -fs %D/%F %B/perl5
@unexec rm -f %B/perl5 2>&1 >/dev/null || true
bin/perl-after-upgrade
bin/perlbug
bin/perldoc
bin/perlivp
@ -1042,6 +1041,7 @@ lib/perl5/%%PERL_VER%%/pod/perl5143delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5160delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5161delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5162delta.pod
lib/perl5/%%PERL_VER%%/pod/perl5163delta.pod
lib/perl5/%%PERL_VER%%/pod/perl561delta.pod
lib/perl5/%%PERL_VER%%/pod/perl56delta.pod
lib/perl5/%%PERL_VER%%/pod/perl581delta.pod

View file

@ -22,6 +22,8 @@ CONFLICTS= cyrus-1.* cyrus-imapd-2.[^1].*
LATEST_LINK= ${PORTNAME}2
PERLMAN= ${SITE_PERL_REL:S/site_perl\///}
USE_RC_SUBR= imapd
USE_OPENSSL= yes
@ -128,8 +130,8 @@ post-patch:
post-install:
.for f in ${CYRUS_MAN3}
@${GZIP_CMD} ${PREFIX}/lib/perl5/${PERL_VERSION}/man/man3/${f}
@${ECHO_CMD} lib/perl5/${PERL_VERSION}/man/man3/${f}.gz \
@${GZIP_CMD} ${PREFIX}/${PERLMAN}/man/man3/${f}
@${ECHO_CMD} ${PERLMAN}/man/man3/${f}.gz \
>>${TMPPLIST}
.endfor
.for f in ${CYRUS_MAN8}

View file

@ -17,6 +17,8 @@ CONFLICTS= cyrus-1.* cyrus-imapd-2.[^2].*
LATEST_LINK= ${PORTNAME}22
PERLMAN= ${SITE_PERL_REL:S/site_perl\///}
USE_RC_SUBR= imapd
USE_OPENSSL= yes
USE_PERL5= yes
@ -181,8 +183,8 @@ post-patch:
post-install:
.for f in ${CYRUS_MAN3}
@${GZIP_CMD} ${PREFIX}/lib/perl5/${PERL_VERSION}/man/man3/${f}
@${ECHO_CMD} lib/perl5/${PERL_VERSION}/man/man3/${f}.gz \
@${GZIP_CMD} ${PREFIX}/${PERLMAN}/man/man3/${f}
@${ECHO_CMD} ${PERLMAN}/man/man3/${f}.gz \
>>${TMPPLIST}
.endfor
.for f in ${CYRUS_MAN8}

View file

@ -20,6 +20,8 @@ CONFLICTS= cyrus-1.* cyrus-imapd-2.[^3].*
LATEST_LINK= ${PORTNAME}23
PERLMAN= ${SITE_PERL_REL:S/site_perl\///}
USE_RC_SUBR= imapd
USE_OPENSSL= yes
USE_PERL5= yes
@ -234,8 +236,8 @@ post-patch:
post-install:
.for f in ${CYRUS_MAN3}
@${GZIP_CMD} ${PREFIX}/lib/perl5/${PERL_VERSION}/man/man3/${f}
@${ECHO_CMD} lib/perl5/${PERL_VERSION}/man/man3/${f}.gz \
@${GZIP_CMD} ${PREFIX}/${PERLMAN}/man/man3/${f}
@${ECHO_CMD} ${PERLMAN}/man/man3/${f}.gz \
>>${TMPPLIST}
.endfor
.for f in ${CYRUS_MAN8}

View file

@ -20,6 +20,8 @@ CONFLICTS= cyrus-1.* cyrus-imapd-2.[^4].*
LATEST_LINK= ${PORTNAME}24
+PERLMAN= ${SITE_PERL_REL:S/site_perl\///}
USE_RC_SUBR= imapd
USE_OPENSSL= yes
USE_PERL5= yes
@ -227,8 +229,8 @@ post-patch:
post-install:
.for f in ${CYRUS_MAN3}
@${GZIP_CMD} ${PREFIX}/lib/perl5/${PERL_VERSION}/man/man3/${f}
@${ECHO_CMD} lib/perl5/${PERL_VERSION}/man/man3/${f}.gz \
@${GZIP_CMD} ${PREFIX}/${PERLMAN}/man/man3/${f}
@${ECHO_CMD} ${PERLMAN}/man/man3/${f}.gz \
>>${TMPPLIST}
.endfor
.for f in ${CYRUS_MAN8}