summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2001-04-03 18:38:53 +0000
committerjoe <joe@FreeBSD.org>2001-04-03 18:38:53 +0000
commit5ba9bf6f375d8762100b11e981e9c1a19c9b92d6 (patch)
treeda5c13597d941a4bc48f997c1fb4f2a868b52c92 /gnu/usr.bin
parentc6f99edeba3d4cc95dbbdf695db587222aa7c0a2 (diff)
downloadFreeBSD-src-5ba9bf6f375d8762100b11e981e9c1a19c9b92d6.zip
FreeBSD-src-5ba9bf6f375d8762100b11e981e9c1a19c9b92d6.tar.gz
Commit the first version of BSDPAN.
BSDPAN is the collection of modules that provides tighter than ever integration of Perl into BSD Unix. Currently, BSDPAN does the following: o makes p5- FreeBSD ports PREFIX-clean; o registers Perl modules in the FreeBSD package database with a package name derived from the module name. The name is of the form: bsdpan-ModuleName-V.VV. Anyone interested in where BSDPAN is developing should read Anton's message to the ports mailling list: Message-ID: <20010105040828.A26011@heechee.tobez.org> Submitted by: Anton Berezin <tobez@tobez.org>
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/perl/BSDPAN/BSDPAN.pm119
-rw-r--r--gnu/usr.bin/perl/BSDPAN/BSDPAN/Override.pm150
-rw-r--r--gnu/usr.bin/perl/BSDPAN/ExtUtils/MM_Unix.pm94
-rw-r--r--gnu/usr.bin/perl/BSDPAN/ExtUtils/Packlist.pm337
-rw-r--r--gnu/usr.bin/perl/BSDPAN/Makefile18
-rw-r--r--gnu/usr.bin/perl/BSDPAN/README20
-rw-r--r--gnu/usr.bin/perl/Makefile2
-rw-r--r--gnu/usr.bin/perl/Makefile.inc2
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-elf.alpha4
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-elf.arm324
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-elf.i3864
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-elf.ia644
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-elf.ppc4
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-elf.sparc4
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-elf.sparc644
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-threads-elf.alpha4
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-threads-elf.arm324
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-threads-elf.i3864
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-threads-elf.ia644
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-threads-elf.ppc4
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc4
-rw-r--r--gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc644
22 files changed, 769 insertions, 29 deletions
diff --git a/gnu/usr.bin/perl/BSDPAN/BSDPAN.pm b/gnu/usr.bin/perl/BSDPAN/BSDPAN.pm
new file mode 100644
index 0000000..0ce6bbc
--- /dev/null
+++ b/gnu/usr.bin/perl/BSDPAN/BSDPAN.pm
@@ -0,0 +1,119 @@
+# ----------------------------------------------------------------------------
+# "THE BEER-WARE LICENSE"
+# <tobez@tobez.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$
+#
+package BSDPAN;
+#
+# The pod documentation for this module is at the end of this file.
+#
+use Config;
+
+my $bsdpan_path; # Directory pathname of BSDPAN itself
+
+BEGIN {
+ # Find this module's own path. Do this before anything else
+ # happens, even before the rest of the module compiles. Do this
+ # by looking into undocumented entries in the main (::) symbol
+ # table.
+ for (keys %::) {
+ $bsdpan_path = $1 if /^_<(.*\/|)BSDPAN.pm$/;
+ }
+ # deduce the BSDPAN's directory pathname
+ $bsdpan_path = '.' if $bsdpan_path eq '';
+ $bsdpan_path =~ tr|/|/|s;
+ $bsdpan_path =~ s|/$||;
+}
+
+sub path {
+ return $bsdpan_path;
+}
+
+sub perl_version {
+ return $Config{version};
+}
+
+sub perl_ver {
+ # pre-5.6.0 perls
+ return $Config{apiversion} if exists $Config{apiversion};
+ # post-5.6.0 perls
+ return $Config{version};
+}
+
+sub perl_arch {
+ # pre-5.6.0 perls
+ return $Config{archname} if exists $Config{apiversion};
+ # post-5.6.0 perls
+ return 'mach';
+}
+
+sub builds_port {
+ # Are we building a p5 port at the moment?
+ # XXX There must be a more reliable way to check this.
+ if (defined $ENV{ARCH} ||
+ defined $ENV{OPSYS} ||
+ defined $ENV{OSREL} ||
+ defined $ENV{OSVERSION} ||
+ defined $ENV{PORTOBJFORMAT} ||
+ defined $ENV{SYSTEMVERSION}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub builds_standalone {
+ return !BSDPAN->builds_port;
+}
+
+1;
+__END__
+=head1 NAME
+
+BSDPAN - Symbiogenetic tool for Perl & BSD
+
+=head1 SYNOPSIS
+
+ use BSDPAN;
+ $path = BSDPAN->path;
+ $ver = BSDPAN->perl_version;
+ $ver = BSDPAN->perl_ver;
+ $arch = BSDPAN->perl_arch;
+ $port = BSDPAN->builds_port;
+ $noport = BSDPAN->builds_standalone;
+
+=head1 DESCRIPTION
+
+BSDPAN is the collection of modules that provides tighter than ever
+integration of Perl into BSD Unix.
+
+Currently, BSDPAN does the following:
+
+=over 4
+
+=item o makes p5- FreeBSD ports PREFIX-clean;
+
+=item o registers Perl modules with FreeBSD package database.
+
+=back
+
+BSDPAN achieves this by overriding certain functionality of the core
+Perl modules, ExtUtils::MM_Unix, and ExtUtils::Packlist.
+
+BSDPAN B<module> itself just provides useful helper functions for the
+rest of the modules in BSDPAN collection.
+
+=head1 AUTHOR
+
+Anton Berezin, tobez@tobez.org
+
+=head1 SEE ALSO
+
+perl(1), ExtUtils::MakeMaker(1), L<BSDPAN::Override(1)>,
+L<BSDPAN::ExtUtils::MM_Unix(1)>, L<BSDPAN::ExtUtils::Packlist(1)>.
+
+=cut
diff --git a/gnu/usr.bin/perl/BSDPAN/BSDPAN/Override.pm b/gnu/usr.bin/perl/BSDPAN/BSDPAN/Override.pm
new file mode 100644
index 0000000..f7e8030
--- /dev/null
+++ b/gnu/usr.bin/perl/BSDPAN/BSDPAN/Override.pm
@@ -0,0 +1,150 @@
+# ----------------------------------------------------------------------------
+# "THE BEER-WARE LICENSE"
+# <tobez@tobez.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$
+#
+package BSDPAN::Override;
+#
+# The pod documentation for this module is at the end of this file.
+#
+use strict;
+use Carp;
+require Exporter;
+require SelfLoader; # XXX 2nd-order magic over SelfLoader's magic :-)
+# require AutoLoader; # XXX do we need to do similar hoop-la with it?
+
+use vars qw(@ISA @EXPORT);
+@ISA = qw(Exporter);
+@EXPORT = qw(override);
+
+my %overridden; # a cache to detect multiple overrides
+
+sub import {
+ my $pkg = caller;
+ croak("BSDPAN::Override can only operate for other BSDPAN modules")
+ unless $pkg =~ s/^BSDPAN:://;
+
+ # make sure the BSDPAN module will not stay on the way
+ my @oinc = @INC;
+ my $bsdpan_path = BSDPAN->path;
+ my @ninc;
+ for my $inc_component (@INC) {
+ push @ninc, $inc_component unless $inc_component eq $bsdpan_path;
+ }
+ @INC = @ninc;
+ my $pm = $pkg;
+ $pm =~ s|::|/|g;
+ delete $INC{"$pm.pm"};
+
+ # try to load the original module
+ # XXX be careful with nested `use' and `require'
+ eval "require $pkg;" or die("Cannot load $pkg: $@");
+
+ # restore the original @INC
+ @INC = @oinc;
+
+ # do the traditional `sub import' job
+ BSDPAN::Override->export_to_level(1, @_);
+
+ # and prepare `sub import' functionality for the original module
+ my $pkg_isa = eval "*$pkg\::ISA\{ARRAY}";
+ if ($pkg_isa && grep { /Exporter/ } @$pkg_isa) {
+ eval "package $pkg; sub import { $pkg->export_to_level(2,\@_); }";
+ die $@ if $@;
+ }
+}
+
+sub override ($$) {
+ my ($name, $replacement_sub) = @_;
+
+ # if name is unqualified, try to guess the right namespace
+ unless ($name =~ /::/) {
+ my $pkg = caller;
+ croak("BSDPAN::Override can only operate for other BSDPAN modules")
+ unless $pkg =~ s/^BSDPAN:://;
+ $name = "$pkg\::$name";
+ }
+
+ # do nothing if $name is already overridden
+ return if $overridden{$name};
+
+ # get the package $name belongs to
+ my $pkg = $name; $pkg =~ s/::[^:]*$//;
+
+ # do we need to protect against SelfLoader?
+ my $sl_autoload = eval "*$pkg\::AUTOLOAD{CODE}";
+ $sl_autoload = 0
+ if $sl_autoload && $sl_autoload != \&SelfLoader::AUTOLOAD;
+
+ # get the reference to the original sub
+ my $name_addr = eval "*$name\{CODE}";
+
+ #
+ # Substitute the symbol table entry with the replacement sub.
+ #
+ if ($name_addr) {
+ # temporarily disable warnings
+ local $SIG{__WARN__} = sub {};
+ if ($sl_autoload) {
+ # Ouch! Don't ask. :-)
+ eval <<EOF;
+*$name = sub {
+ \$replacement_sub->( sub {
+ \$SelfLoader::AUTOLOAD = "$name";
+ local \$SIG{__WARN__} = sub {};
+ my \@r = \$sl_autoload->(\@_);
+ my \$real_addr = "*$name\{CODE}";
+ *$name = sub { \$replacement_sub->(
+ \$real_addr, \@_) };
+ }, \@_)
+};
+EOF
+ } else {
+ eval "*$name = sub {
+ \$replacement_sub->(\$name_addr, \@_) };";
+ }
+ die "$@\n" if $@;
+ $overridden{$name} = 1;
+ } else {
+ croak("Cannot override `$name': there is no such thing");
+ }
+}
+
+1;
+__END__
+=head1 NAME
+
+BSDPAN::Override - Perl module for overriding subs in other modules
+
+=head1 SYNOPSIS
+
+ package BSDPAN::Some::Perl::Module;
+ use BSDPAN::Override;
+ ...
+ sub my_sub {
+ my $orig = shift;
+ ...
+ &$orig;
+ ...
+ }
+ ...
+ BEGIN { override 'some_sub', \&my_sub; }
+
+=head1 DESCRIPTION
+
+BSDPAN::Override provides a way for other BSDPAN modules to override the
+functionality of arbitrary Perl modules.
+
+=head1 AUTHOR
+
+Anton Berezin, tobez@tobez.org
+
+=head1 SEE ALSO
+
+perl(1), L<BSDPAN(1)>.
+
+=cut
diff --git a/gnu/usr.bin/perl/BSDPAN/ExtUtils/MM_Unix.pm b/gnu/usr.bin/perl/BSDPAN/ExtUtils/MM_Unix.pm
new file mode 100644
index 0000000..43acdae
--- /dev/null
+++ b/gnu/usr.bin/perl/BSDPAN/ExtUtils/MM_Unix.pm
@@ -0,0 +1,94 @@
+# ----------------------------------------------------------------------------
+# "THE BEER-WARE LICENSE"
+# <tobez@tobez.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$
+#
+package BSDPAN::ExtUtils::MM_Unix;
+#
+# The pod documentation for this module is at the end of this file.
+#
+use strict;
+use Carp;
+use BSDPAN;
+use BSDPAN::Override;
+
+sub init_main {
+ my $orig = shift;
+ my $him = $_[0];
+
+ my @r = &$orig;
+
+ # MakeMaker insist to use perl system path first;
+ # free it of this misconception, since we know better.
+ $him->{PERL_LIB} = BSDPAN->path;
+
+ # MakeMaker is pretty lame when the user specifies PREFIX.
+ # It has too fine granularity regarding the various places
+ # it installs things in. So in order to make a port PREFIX-
+ # clean we modify some parameters it does not usually touch.
+ #
+ # XXX MakeMaker does some `clever' tricks depending whether
+ # PREFIX contains the `perl' substring or not. This severely
+ # confuses port's PLIST, so we avoid such things here.
+ #
+ # This code should arguably do what it does even in the
+ # case we are not installing a port, but let's be conservative
+ # here and not violate Perl's own POLA.
+ if ($him->{PREFIX} ne '/usr/local' && BSDPAN->builds_port) {
+ my $site_perl = "lib/perl5/site_perl";
+ my $perl_ver = BSDPAN->perl_ver;
+ my $perl_version = BSDPAN->perl_version;
+ my $perl_arch = BSDPAN->perl_arch;
+ my $perl_man = "lib/perl5/$perl_version/man";
+ $him->{INSTALLSITELIB} = "\$(PREFIX)/$site_perl/$perl_ver";
+ $him->{INSTALLSITEARCH} =
+ "\$(PREFIX)/$site_perl/$perl_ver/$perl_arch";
+ $him->{INSTALLBIN} = "\$(PREFIX)/bin";
+ $him->{INSTALLSCRIPT} = "\$(PREFIX)/bin";
+ # these strange values seem to be default
+ $him->{INSTALLMAN1DIR} = "\$(PREFIX)/man/man1";
+ $him->{INSTALLMAN3DIR} = "\$(PREFIX)/$perl_man/man3";
+ }
+
+ return @r;
+}
+
+BEGIN {
+ override 'init_main', \&init_main;
+}
+
+1;
+=head1 NAME
+
+BSDPAN::ExtUtils::MM_Unix - Override ExtUtils::MM_Unix functionality
+
+=head1 SYNOPSIS
+
+ None
+
+=head1 DESCRIPTION
+
+BSDPAN::ExtUtils::MM_Unix overrides init_main() sub of the standard perl
+module ExtUtils::MM_Unix.
+
+The overridden init_main() first calls the original init_main(). Then,
+if the Perl port build is detected, and the PREFIX stored in the
+ExtUtils::MM_Unix object is not F</usr/local/>, it proceeds to change
+various installation paths ExtUtils::MM_Unix maintains, to match PREFIX.
+
+Thus, BSDPAN::ExtUtils::MM_Unix is responsible for making p5- ports
+PREFIX-clean.
+
+=head1 AUTHOR
+
+Anton Berezin, tobez@tobez.org
+
+=head1 SEE ALSO
+
+perl(1), L<BSDPAN(1)>, L<BSDPAN::Override(1)>, ports(7).
+
+=cut
diff --git a/gnu/usr.bin/perl/BSDPAN/ExtUtils/Packlist.pm b/gnu/usr.bin/perl/BSDPAN/ExtUtils/Packlist.pm
new file mode 100644
index 0000000..24a39a9
--- /dev/null
+++ b/gnu/usr.bin/perl/BSDPAN/ExtUtils/Packlist.pm
@@ -0,0 +1,337 @@
+# ----------------------------------------------------------------------------
+# "THE BEER-WARE LICENSE"
+# <tobez@tobez.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$
+#
+package BSDPAN::ExtUtils::Packlist;
+#
+# The pod documentation for this module is at the end of this file.
+#
+use strict;
+use Carp;
+use Fcntl;
+use BSDPAN;
+use BSDPAN::Override;
+
+sub write {
+ my $orig = shift; # original ExtUtils::Packlist::write
+ my $him = $_[0]; # ExtUtils::Packlist object
+
+ # If it is a reference to a tied hash, obtain the underlying
+ # ExtUtils::Packlist object
+ $him = tied(%$him) || $him;
+
+ # call the original write() with all parameters intact
+ &$orig;
+
+ # do nothing if p5- port is being built
+ return if BSDPAN->builds_port;
+
+ print "FreeBSD: Registering installation in the package database\n";
+
+ my ($pkg_name,$pkg_comment,$pkg_descr) = gather_pkg_info($him);
+
+ my ($ok, $comment_file, $descr_file, $packinglist_file);
+ TRY: {
+ last TRY unless $pkg_name;
+
+ $comment_file = write_tmp_file($him, $pkg_comment);
+ last TRY unless $comment_file;
+
+ my $descr_file = write_tmp_file($him, $pkg_descr);
+ last TRY unless $descr_file;
+
+ my @files = sort { $a cmp $b } get_file_list($him);
+ my @dirs = sort { length($b) <=> length ($a) }
+ get_dir_list($him, @files);
+
+ my @packinglist;
+ push @packinglist, "\@name $pkg_name\n", "\@cwd /\n";
+ push @packinglist,
+ "\@comment This package was generated by BSDPAN\n";
+ push @packinglist, "$_\n"
+ for @files;
+ push @packinglist, "\@unexec rmdir $_ 2>/dev/null || true\n"
+ for @dirs;
+
+ my $packinglist_file = write_tmp_file($him, join '', @packinglist);
+ last TRY unless $packinglist_file;
+
+ my $contents = `/usr/sbin/pkg_create -O -f $packinglist_file -c $comment_file -d $descr_file $pkg_name`;
+ unless (($? >> 8) == 0) {
+ warn("pkg_create exited with code " .
+ int($? >> 8) . "\n");
+ last TRY;
+ }
+
+ my $pkg_db_dir = $ENV{PKG_DBDIR} || "/var/db/pkg";
+ my $pkg_dir = "$pkg_db_dir/$pkg_name";
+ unless (mkdir($pkg_dir, 0777)) {
+ warn("Cannot create directory $pkg_dir: $!\n");
+ last TRY;
+ }
+
+ write_file($him, "$pkg_dir/+CONTENTS", $contents) or last TRY;
+ write_file($him, "$pkg_dir/+COMMENT", $pkg_comment) or last TRY;
+ write_file($him, "$pkg_dir/+DESC", $pkg_descr) or last TRY;
+ $ok = 1;
+ }
+ unlink $descr_file if $descr_file;
+ unlink $comment_file if $comment_file;
+ unlink $packinglist_file if $packinglist_file;
+}
+
+sub write_file {
+ my ($him, $pathname, $contents) = @_;
+
+ my $fh = ExtUtils::Packlist::mkfh();
+
+ unless (open($fh, "> $pathname")) {
+ carp("Cannot create file $pathname: $!");
+ return;
+ }
+ print $fh $contents;
+ close($fh);
+ return 1;
+}
+
+sub write_tmp_file {
+ my ($him, $contents) = @_;
+
+ my $fh = ExtUtils::Packlist::mkfh();
+ my $cnt = 0;
+ my $pathname;
+
+ until (defined(fileno($fh)) || $cnt > 20) {
+ my $rnd = int(1000000 * rand);
+ my $file = sprintf("packlist.%06d", $rnd);
+
+ if (exists($ENV{PKG_TMPDIR}) &&
+ $ENV{PKG_TMPDIR} =~ "^/" &&
+ -d $ENV{PKG_TMPDIR}) {
+ $pathname = "$ENV{PKG_TMPDIR}/$file";
+ sysopen($fh, $pathname, O_WRONLY|O_EXCL|O_CREAT);
+ }
+
+ if (!defined(fileno($fh)) &&
+ exists($ENV{TMPDIR}) &&
+ $ENV{TMPDIR} =~ "^/" &&
+ -d $ENV{TMPDIR}) {
+ $pathname = "$ENV{TMPDIR}/$file";
+ sysopen($fh, $pathname, O_WRONLY|O_EXCL|O_CREAT);
+ }
+
+ if (!defined(fileno($fh)) &&
+ -d "/var/tmp") {
+ $pathname = "/var/tmp/$file";
+ sysopen($fh, $pathname, O_WRONLY|O_EXCL|O_CREAT);
+ }
+
+ if (!defined(fileno($fh)) &&
+ -d "/tmp") {
+ $pathname = "/tmp/$file";
+ sysopen($fh, $pathname, O_WRONLY|O_EXCL|O_CREAT);
+ }
+
+ if (!defined(fileno($fh)) &&
+ -d "/usr/tmp") {
+ $pathname = "/usr/tmp/$file";
+ sysopen($fh, $pathname, O_WRONLY|O_EXCL|O_CREAT);
+ }
+ $cnt++;
+ }
+
+ unless (defined fileno $fh) {
+ carp("Can't create temporary file\n");
+ return;
+ }
+
+ print $fh $contents;
+ close($fh);
+ return $pathname;
+}
+
+sub get_file_list {
+ my ($him) = @_;
+
+ my @files = ($him->{packfile});
+
+ foreach my $key (keys(%{$him->{data}})) {
+ push @files, $key if -f $key;
+ }
+
+ return @files;
+}
+
+sub get_dir_list {
+ my ($him,@files) = @_;
+
+ my %alldirs;
+
+ for my $file (@files) {
+ $file =~ s|/[^/]+$||;
+ $alldirs{$file}++ if -d $file;
+ }
+
+ delete $alldirs{'/'};
+ return keys %alldirs;
+}
+
+sub gather_pkg_info {
+ my ($him) = @_;
+
+ my ($distname, $version, $main_module) = get_makefile_pieces($him);
+ return unless $distname;
+
+ my $pkg_name = "bsdpan-$distname-$version";
+ my ($comment, $descr) = get_description($him,$main_module);
+ return ($pkg_name,$comment,$descr);
+}
+
+sub get_makefile_pieces {
+ my ($him) = @_;
+
+ my $fh = ExtUtils::Packlist::mkfh();
+ unless (open($fh, "< Makefile")) {
+ carp("Can't open file Makefile: $!");
+ return;
+ }
+
+ my ($distname,$version,$main_module);
+ while (<$fh>) {
+ /^DISTNAME\s*=\s*(\S+)\s*$/ and $distname = $1;
+ /^VERSION\s*=\s*(\S+)\s*$/ and $version = $1;
+ /^VERSION_FROM\s*=\s*(\S+)\s*$/ and $main_module = $1;
+ }
+
+ close($fh);
+
+ $main_module = guess_main_module($him) unless defined $main_module;
+
+ if (defined $distname &&
+ defined $version &&
+ defined $main_module) {
+ return ($distname,$version,$main_module);
+ }
+}
+
+sub guess_main_module {
+ my ($him) = @_;
+
+ my @pm;
+
+ for my $key (keys(%{$him->{data}})) {
+ push @pm, $key if $key =~ /\.pm$/;
+ }
+
+ if (@pm == 0) {
+ return undef;
+ } elsif (@pm == 1) {
+ return $pm[0];
+ } else {
+ return (sort { length($a) <=> length($b) } @pm)[0];
+ }
+}
+
+sub get_description {
+ my ($him,$file) = @_;
+
+ my $fh = ExtUtils::Packlist::mkfh();
+ unless (open($fh, "< $file")) {
+ carp("Can't open file $file: $!");
+ return;
+ }
+
+ my ($comment, $descr);
+ $descr = '';
+ my $state = 'seek-head';
+
+ while (<$fh>) {
+ if (/^=head1\s+(.*)$/) {
+ if ($1 eq 'NAME') {
+ $state = 'get-comment';
+ } elsif ($1 eq 'DESCRIPTION') {
+ $state = 'get-description';
+ } else {
+ $state = 'seek-head';
+ }
+ } elsif ($state eq 'get-comment') {
+ next if /^$/;
+ next if /^=/;
+ $comment = $_;
+ $state = 'seek-head';
+ } elsif ($state eq 'get-description') {
+ next if /^=/;
+ next if /^$/ && $descr eq '';
+ if (/^$/) {
+ $state = 'seek-head';
+ } else {
+ $descr .= $_;
+ }
+ }
+ }
+
+ close($fh);
+
+ unless ($comment) {
+ print "FreeBSD: Cannot determine short module description\n";
+ $comment = 'Unknown perl module';
+ }
+
+ unless ($descr) {
+ print "FreeBSD: Cannot determine module description\n";
+ $descr = 'There is no description for the perl module';
+ }
+
+ return ($comment,$descr);
+}
+
+BEGIN {
+ override 'write', \&write;
+}
+
+1;
+=head1 NAME
+
+BSDPAN::ExtUtils::Packlist - Override ExtUtils::Packlist functionality
+
+=head1 SYNOPSIS
+
+ None
+
+=head1 DESCRIPTION
+
+BSDPAN::ExtUtils::Packlist overrides write() sub of the standard perl
+module ExtUtils::Packlist.
+
+The overridden write() first calls the original write(). Then,
+if the Perl port build is detected, it returns quietly.
+
+If, however, the Perl module being built is not a port, write()
+obtains the list of installed files that ExtUtils::Packlist internally
+maintains. Then it tries to deduce the distname, the version, and the
+name of the main F<.pm> file. Then it scans the F<*.pm> files that
+constite the module, trying to find what to use as the module comment
+(short description) and the description.
+
+After gathering all this information, the overridden write() invokes
+pkg_create(1), hereby registering the module with FreeBSD package
+database.
+
+If any of the above steps is unsuccessful, BSDPAN::ExtUtils::Packlist
+quietly returns, with the result which is equivalent to pre-BSDPAN
+functionality.
+
+=head1 AUTHOR
+
+Anton Berezin, tobez@tobez.org
+
+=head1 SEE ALSO
+
+perl(1), L<BSDPAN(1)>, L<BSDPAN::Override(1)>, pkg_create(1).
+
+=cut
diff --git a/gnu/usr.bin/perl/BSDPAN/Makefile b/gnu/usr.bin/perl/BSDPAN/Makefile
new file mode 100644
index 0000000..b0b5e55
--- /dev/null
+++ b/gnu/usr.bin/perl/BSDPAN/Makefile
@@ -0,0 +1,18 @@
+# $FreeBSD$
+#
+# Doing a make install builds /usr/libdata/perl/BSDPAN
+
+DDIR= ${DESTDIR}/usr/libdata/perl/BSDPAN
+
+NOOBJ= noobj
+
+all clean cleandir depend lint tags:
+
+FILES= BSDPAN.pm BSDPAN/Override.pm ExtUtils/MM_Unix.pm ExtUtils/Packlist.pm
+
+.for file in ${FILES}
+beforeinstall::
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 ${file} ${DDIR}/${file}
+.endfor
+
+.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/perl/BSDPAN/README b/gnu/usr.bin/perl/BSDPAN/README
new file mode 100644
index 0000000..6ffab35
--- /dev/null
+++ b/gnu/usr.bin/perl/BSDPAN/README
@@ -0,0 +1,20 @@
+$FreeBSD$
+
+For importers of the future Perl versions. BSDPAN operation depends on
+the fact it is loaded before system Perl modules. To achieve this, the
+semi-documented (it is described as undocumented in Perl documentation)
+define APPLLIB_EXP is used. Run Perl configure as follows (with other
+relevant arguments of course):
+
+ sh Configure -Dccflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
+
+Since FreeBSD uses its own Makefile to build Perl, it is necessary to
+duplicate this as an extra CFLAG. This resides currently in
+gnu/usr.bin/perl/Makefile.inc:
+
+ CFLAGS+= '-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
+
+If APPLLIB_EXP ever gets removed from Perl, some other way of putting
+/usr/libdata/perl/BSDPAN in the start of @INC must be devised.
+
+-Anton <tobez@tobez.org>
diff --git a/gnu/usr.bin/perl/Makefile b/gnu/usr.bin/perl/Makefile
index 6770bae..fd0fa55 100644
--- a/gnu/usr.bin/perl/Makefile
+++ b/gnu/usr.bin/perl/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-SUBDIR= libperl perl suidperl library pod utils x2p
+SUBDIR= libperl perl suidperl library pod utils x2p BSDPAN
MAINTAINER=markm@freebsd.org
diff --git a/gnu/usr.bin/perl/Makefile.inc b/gnu/usr.bin/perl/Makefile.inc
index 88620ea..0b55620 100644
--- a/gnu/usr.bin/perl/Makefile.inc
+++ b/gnu/usr.bin/perl/Makefile.inc
@@ -87,6 +87,8 @@ MAKEMAKER_ARGS= INSTALLDIRS=perl PERL_SRC=${.OBJDIR} \
PERL=${MINIPERL} FULLPERL=perl DEFINE=-I${DESTDIR}/usr/include \
DEFINE=-DPERL_CORE
+CFLAGS+= '-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
+
.if defined(PERL_THREADED) && ${PERL_THREADED} == "true"
CFLAGS+= -pthread
THREAD= threads-
diff --git a/gnu/usr.bin/perl/libperl/config.SH-elf.alpha b/gnu/usr.bin/perl/libperl/config.SH-elf.alpha
index 8e09cda..729bf67 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-elf.alpha
+++ b/gnu/usr.bin/perl/libperl/config.SH-elf.alpha
@@ -52,7 +52,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags='-fno-strict-aliasing'
+ccflags='-fno-strict-aliasing -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__FreeBSD__=5 __FreeBSD_cc_version=500001 __GNUC_MINOR__=95 __alpha_ev4__=1 __unix=1 __unix__=1 cpu=alpha cpu=ev4 machine=alpha system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -70,7 +70,7 @@ cpio=''
cpp='cpp'
cpp_stuff='42'
cppccsymbols='__ELF__=1 __GNUC__=2 __alpha=1 __alpha__=1 unix=1'
-cppflags='-fno-strict-aliasing'
+cppflags='-fno-strict-aliasing -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-elf.arm32 b/gnu/usr.bin/perl/libperl/config.SH-elf.arm32
index 8c1def8..0f9560f 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-elf.arm32
+++ b/gnu/usr.bin/perl/libperl/config.SH-elf.arm32
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags=''
+ccflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=arm32 machine=arm32 system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -62,7 +62,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-elf.i386 b/gnu/usr.bin/perl/libperl/config.SH-elf.i386
index 157125a..b892221 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-elf.i386
+++ b/gnu/usr.bin/perl/libperl/config.SH-elf.i386
@@ -52,7 +52,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags='-fno-strict-aliasing'
+ccflags='-fno-strict-aliasing -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__FreeBSD__=5 __FreeBSD_cc_version=500001 __GNUC_MINOR__=95 __i386=1 __i386__=1 __unix=1 __unix__=1 cpu=i386 machine=i386 system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -70,7 +70,7 @@ cpio=''
cpp='cpp'
cpp_stuff='42'
cppccsymbols='__ELF__=1 __GNUC__=2 i386=1 unix=1'
-cppflags='-fno-strict-aliasing'
+cppflags='-fno-strict-aliasing -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-elf.ia64 b/gnu/usr.bin/perl/libperl/config.SH-elf.ia64
index 5e27521..f56fa9f 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-elf.ia64
+++ b/gnu/usr.bin/perl/libperl/config.SH-elf.ia64
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags=''
+ccflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=ia64 machine=ia64 system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -62,7 +62,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-elf.ppc b/gnu/usr.bin/perl/libperl/config.SH-elf.ppc
index e94d7b8..d947bdd 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-elf.ppc
+++ b/gnu/usr.bin/perl/libperl/config.SH-elf.ppc
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags=''
+ccflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=ppc machine=ppc system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -62,7 +62,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-elf.sparc b/gnu/usr.bin/perl/libperl/config.SH-elf.sparc
index 271d23a..f48e2a1 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-elf.sparc
+++ b/gnu/usr.bin/perl/libperl/config.SH-elf.sparc
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags=''
+ccflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=sparc machine=sparc system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -62,7 +62,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-elf.sparc64 b/gnu/usr.bin/perl/libperl/config.SH-elf.sparc64
index 618b792..3643b1f 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-elf.sparc64
+++ b/gnu/usr.bin/perl/libperl/config.SH-elf.sparc64
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags=''
+ccflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=sparc64 machine=sparc64 system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -62,7 +62,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.alpha b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.alpha
index 1084220..5b71a98 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.alpha
+++ b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.alpha
@@ -52,7 +52,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags='-fno-strict-aliasing -pthread'
+ccflags='-fno-strict-aliasing -pthread -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__FreeBSD__=5 __FreeBSD_cc_version=500001 __GNUC_MINOR__=95 __alpha=1 __alpha__=1 __unix=1 __unix__=1 cpu=alpha machine=alpha system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -70,7 +70,7 @@ cpio=''
cpp='cpp'
cpp_stuff='42'
cppccsymbols='__ELF__=1 __GNUC__=2 __alpha=1 __alpha__=1 unix=1'
-cppflags='-fno-strict-aliasing'
+cppflags='-fno-strict-aliasing -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.arm32 b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.arm32
index 7f92309..2f456a2 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.arm32
+++ b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.arm32
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags='-pthread'
+ccflags='-pthread -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=arm32 machine=arm32 system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -64,7 +64,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.i386 b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.i386
index 8859476..57da64e 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.i386
+++ b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.i386
@@ -52,7 +52,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags='-fno-strict-aliasing -pthread'
+ccflags='-fno-strict-aliasing -pthread -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__FreeBSD__=5 __FreeBSD_cc_version=500001 __GNUC_MINOR__=95 __i386=1 __i386__=1 __unix=1 __unix__=1 cpu=i386 machine=i386 system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -70,7 +70,7 @@ cpio=''
cpp='cpp'
cpp_stuff='42'
cppccsymbols='__ELF__=1 __GNUC__=2 i386=1 unix=1'
-cppflags='-fno-strict-aliasing'
+cppflags='-fno-strict-aliasing -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.ia64 b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.ia64
index 72af605..f20552c 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.ia64
+++ b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.ia64
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags=' -pthread'
+ccflags='-pthread -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=ia64 machine=ia64 system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -62,7 +62,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.ppc b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.ppc
index ff7f944..04f888c 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.ppc
+++ b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.ppc
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags=' -pthread'
+ccflags='-pthread -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=ppc machine=ppc system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -62,7 +62,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc
index 60dbff5..e0575a2 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc
+++ b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags=' -pthread'
+ccflags='-pthread -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=sparc machine=sparc system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -62,7 +62,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
diff --git a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc64 b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc64
index 0a719b0..e2a39d6 100644
--- a/gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc64
+++ b/gnu/usr.bin/perl/libperl/config.SH-threads-elf.sparc64
@@ -46,7 +46,7 @@ cat='cat'
cc='cc'
cccdlflags='-DPIC -fpic'
ccdlflags=' -Wl,-R/usr/lib'
-ccflags=' -pthread'
+ccflags='-pthread -DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
ccsymbols='__ELF__=1 __FreeBSD__=4 __FreeBSD_cc_version=400004 __GNUC_MINOR__=95 __GNUC__=2 cpu=sparc64 machine=sparc64 system=FreeBSD system=unix'
cf_by='markm'
cf_email='markm@FreeBSD.org'
@@ -62,7 +62,7 @@ cp='cp'
cpio=''
cpp='cpp'
cpp_stuff='42'
-cppflags=''
+cppflags='-DAPPLLIB_EXP="/usr/libdata/perl/BSDPAN"'
cpplast='-'
cppminus='-'
cpprun='cc -E'
OpenPOWER on IntegriCloud