summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm
diff options
context:
space:
mode:
authorafresh1 <afresh1@openbsd.org>2019-02-13 21:15:00 +0000
committerafresh1 <afresh1@openbsd.org>2019-02-13 21:15:00 +0000
commit9f11ffb7133c203312a01e4b986886bc88c7d74b (patch)
tree6618511204c614b20256e4ef9dea39a7b311d638 /gnu/usr.bin/perl/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm
parentImport perl-5.28.1 (diff)
downloadwireguard-openbsd-9f11ffb7133c203312a01e4b986886bc88c7d74b.tar.xz
wireguard-openbsd-9f11ffb7133c203312a01e4b986886bc88c7d74b.zip
Fix merge issues, remove excess files - match perl-5.28.1 dist
looking good sthen@, Great! bluhm@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm')
-rw-r--r--gnu/usr.bin/perl/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm201
1 files changed, 110 insertions, 91 deletions
diff --git a/gnu/usr.bin/perl/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm b/gnu/usr.bin/perl/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm
index 1b98c4321e2..047c007145e 100644
--- a/gnu/usr.bin/perl/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm
+++ b/gnu/usr.bin/perl/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm
@@ -1,24 +1,18 @@
package ExtUtils::Install;
use strict;
-use vars qw(@ISA @EXPORT $VERSION $MUST_REBOOT %Config);
-
-use AutoSplit;
-use Carp ();
use Config qw(%Config);
use Cwd qw(cwd);
-use Exporter;
-use ExtUtils::Packlist;
+use Exporter ();
use File::Basename qw(dirname);
-use File::Compare qw(compare);
use File::Copy;
-use File::Find qw(find);
use File::Path;
use File::Spec;
+our @ISA = ('Exporter');
+our @EXPORT = ('install','uninstall','pm_to_blib', 'install_default');
-@ISA = ('Exporter');
-@EXPORT = ('install','uninstall','pm_to_blib', 'install_default');
+our $MUST_REBOOT;
=pod
@@ -38,11 +32,11 @@ ExtUtils::Install - install files from here to there
=head1 VERSION
-2.04
+2.14
=cut
-$VERSION = '2.04'; # <-- do not forget to update the POD section just above this line!
+our $VERSION = '2.14'; # <-- do not forget to update the POD section just above this line!
$VERSION = eval $VERSION;
=pod
@@ -95,19 +89,12 @@ Dies with a special message.
=cut
-my $Is_VMS = $^O eq 'VMS';
-my $Is_MacPerl = $^O eq 'MacOS';
-my $Is_Win32 = $^O eq 'MSWin32';
-my $Is_cygwin = $^O eq 'cygwin';
-my $CanMoveAtBoot = ($Is_Win32 || $Is_cygwin);
-my $Perm_Dir = $ENV{PERL_CORE} ? 0770 : 0755;
-
-# *note* CanMoveAtBoot is only incidentally the same condition as below
-# this needs not hold true in the future.
-my $Has_Win32API_File = ($Is_Win32 || $Is_cygwin)
- ? (eval {require Win32API::File; 1} || 0)
- : 0;
-
+BEGIN {
+ *Is_VMS = $^O eq 'VMS' ? sub(){1} : sub(){0};
+ *Is_Win32 = $^O eq 'MSWin32' ? sub(){1} : sub(){0};
+ *Is_cygwin = $^O eq 'cygwin' ? sub(){1} : sub(){0};
+ *CanMoveAtBoot = ($^O eq 'MSWin32' || $^O eq 'cygwin') ? sub(){1} : sub(){0};
+}
my $Inc_uninstall_warn_handler;
@@ -115,9 +102,12 @@ my $Inc_uninstall_warn_handler;
my $INSTALL_ROOT = $ENV{PERL_INSTALL_ROOT};
my $INSTALL_QUIET = $ENV{PERL_INSTALL_QUIET};
+$INSTALL_QUIET = 1
+ if (!exists $ENV{PERL_INSTALL_QUIET} and
+ defined $ENV{MAKEFLAGS} and
+ $ENV{MAKEFLAGS} =~ /\b(s|silent|quiet)\b/);
my $Curdir = File::Spec->curdir;
-my $Updir = File::Spec->updir;
sub _estr(@) {
return join "\n",'!' x 72,@_,'!' x 72,'';
@@ -133,9 +123,24 @@ sub _warnonce(@) {
sub _choke(@) {
my $first=shift;
my $msg=_estr "ERROR: $first",@_;
+ require Carp;
Carp::croak($msg);
}
+sub _croak {
+ require Carp;
+ Carp::croak(@_);
+}
+sub _confess {
+ require Carp;
+ Carp::confess(@_);
+}
+
+sub _compare {
+ require File::Compare;
+ File::Compare::compare(@_);
+}
+
sub _chmod($$;$) {
my ( $mode, $item, $verbose )=@_;
@@ -174,47 +179,53 @@ If $moan is true then returns 0 on error and warns instead of dies.
=cut
+{
+ my $Has_Win32API_File;
+ sub _move_file_at_boot { #XXX OS-SPECIFIC
+ my ( $file, $target, $moan )= @_;
+ _confess("Panic: Can't _move_file_at_boot on this platform!")
+ unless CanMoveAtBoot;
+
+ my $descr= ref $target
+ ? "'$file' for deletion"
+ : "'$file' for installation as '$target'";
+
+ # *note* CanMoveAtBoot is only incidentally the same condition as below
+ # this needs not hold true in the future.
+ $Has_Win32API_File = (Is_Win32 || Is_cygwin)
+ ? (eval {require Win32API::File; 1} || 0)
+ : 0 unless defined $Has_Win32API_File;
+ if ( ! $Has_Win32API_File ) {
+
+ my @msg=(
+ "Cannot schedule $descr at reboot.",
+ "Try installing Win32API::File to allow operations on locked files",
+ "to be scheduled during reboot. Or try to perform the operation by",
+ "hand yourself. (You may need to close other perl processes first)"
+ );
+ if ( $moan ) { _warnonce(@msg) } else { _choke(@msg) }
+ return 0;
+ }
+ my $opts= Win32API::File::MOVEFILE_DELAY_UNTIL_REBOOT();
+ $opts= $opts | Win32API::File::MOVEFILE_REPLACE_EXISTING()
+ unless ref $target;
+ _chmod( 0666, $file );
+ _chmod( 0666, $target ) unless ref $target;
-sub _move_file_at_boot { #XXX OS-SPECIFIC
- my ( $file, $target, $moan )= @_;
- Carp::confess("Panic: Can't _move_file_at_boot on this platform!")
- unless $CanMoveAtBoot;
-
- my $descr= ref $target
- ? "'$file' for deletion"
- : "'$file' for installation as '$target'";
-
- if ( ! $Has_Win32API_File ) {
-
- my @msg=(
- "Cannot schedule $descr at reboot.",
- "Try installing Win32API::File to allow operations on locked files",
- "to be scheduled during reboot. Or try to perform the operation by",
- "hand yourself. (You may need to close other perl processes first)"
- );
- if ( $moan ) { _warnonce(@msg) } else { _choke(@msg) }
+ if (Win32API::File::MoveFileEx( $file, $target, $opts )) {
+ $MUST_REBOOT ||= ref $target ? 0 : 1;
+ return 1;
+ } else {
+ my @msg=(
+ "MoveFileEx $descr at reboot failed: $^E",
+ "You may try to perform the operation by hand yourself. ",
+ "(You may need to close other perl processes first).",
+ );
+ if ( $moan ) { _warnonce(@msg) } else { _choke(@msg) }
+ }
return 0;
}
- my $opts= Win32API::File::MOVEFILE_DELAY_UNTIL_REBOOT();
- $opts= $opts | Win32API::File::MOVEFILE_REPLACE_EXISTING()
- unless ref $target;
-
- _chmod( 0666, $file );
- _chmod( 0666, $target ) unless ref $target;
-
- if (Win32API::File::MoveFileEx( $file, $target, $opts )) {
- $MUST_REBOOT ||= ref $target ? 0 : 1;
- return 1;
- } else {
- my @msg=(
- "MoveFileEx $descr at reboot failed: $^E",
- "You may try to perform the operation by hand yourself. ",
- "(You may need to close other perl processes first).",
- );
- if ( $moan ) { _warnonce(@msg) } else { _choke(@msg) }
- }
- return 0;
}
@@ -271,7 +282,7 @@ sub _unlink_or_rename { #XXX OS-SPECIFIC
my $error="$!";
_choke("Cannot unlink '$file': $!")
- unless $CanMoveAtBoot && $tryhard;
+ unless CanMoveAtBoot && $tryhard;
my $tmp= "AAA";
++$tmp while -e "$file.$tmp";
@@ -380,8 +391,8 @@ Abstract a -w check that tries to use POSIX::access() if possible.
sub _have_write_access {
my $dir=shift;
unless (defined $has_posix) {
- $has_posix= (!$Is_cygwin && !$Is_Win32
- && eval 'local $^W; require POSIX; 1') || 0;
+ $has_posix = (!Is_cygwin && !Is_Win32
+ && eval { local $^W; require POSIX; 1} ) || 0;
}
if ($has_posix) {
return POSIX::access($dir, POSIX::W_OK());
@@ -426,7 +437,7 @@ sub _can_write_dir {
my $path='';
my @make;
while (@dirs) {
- if ($Is_VMS) {
+ if (Is_VMS) {
$dir = File::Spec->catdir($vol,@dirs);
}
else {
@@ -520,7 +531,7 @@ sub _copy {
}
if (!$dry_run) {
File::Copy::copy($from,$to)
- or Carp::croak( _estr "ERROR: Cannot copy '$from' to '$to': $!" );
+ or _croak( _estr "ERROR: Cannot copy '$from' to '$to': $!" );
}
}
@@ -674,7 +685,7 @@ sub install { #XXX OS-SPECIFIC
if (@_==1 and eval { 1+@$from_to }) {
my %opts = @$from_to;
$from_to = $opts{from_to}
- or Carp::confess("from_to is a mandatory parameter");
+ or _confess("from_to is a mandatory parameter");
$verbose = $opts{verbose};
$dry_run = $opts{dry_run};
$uninstall_shadows = $opts{uninstall_shadows};
@@ -695,6 +706,7 @@ sub install { #XXX OS-SPECIFIC
my(%from_to) = %$from_to;
my(%pack, $dir, %warned);
+ require ExtUtils::Packlist;
my($packlist) = ExtUtils::Packlist->new();
local(*DIR);
@@ -707,6 +719,13 @@ sub install { #XXX OS-SPECIFIC
my $cwd = cwd();
my @found_files;
my %check_dirs;
+ require File::Find;
+
+ my $blib_lib = File::Spec->catdir('blib', 'lib');
+ my $blib_arch = File::Spec->catdir('blib', 'arch');
+
+ # File::Find seems to always be Unixy except on MacPerl :(
+ my $current_directory = $^O eq 'MacOS' ? $Curdir : '.';
MOD_INSTALL: foreach my $source (sort keys %from_to) {
#copy the tree to the target directory without altering
@@ -721,8 +740,6 @@ sub install { #XXX OS-SPECIFIC
my $targetroot = install_rooted_dir($from_to{$source});
- my $blib_lib = File::Spec->catdir('blib', 'lib');
- my $blib_arch = File::Spec->catdir('blib', 'arch');
if ($source eq $blib_lib and
exists $from_to{$blib_arch} and
directory_not_empty($blib_arch)
@@ -735,9 +752,7 @@ sub install { #XXX OS-SPECIFIC
_chdir($source);
# 5.5.3's File::Find missing no_chdir option
# XXX OS-SPECIFIC
- # File::Find seems to always be Unixy except on MacPerl :(
- my $current_directory= $Is_MacPerl ? $Curdir : '.';
- find(sub {
+ File::Find::find(sub {
my ($mode,$size,$atime,$mtime) = (stat)[2,7,8,9];
return if !-f _;
@@ -766,7 +781,7 @@ sub install { #XXX OS-SPECIFIC
$diff++;
} else {
# we might not need to copy this file
- $diff = compare($sourcefile, $targetfile);
+ $diff = _compare($sourcefile, $targetfile);
}
$check_dirs{$targetdir}++
unless -w $targetfile;
@@ -784,7 +799,7 @@ sub install { #XXX OS-SPECIFIC
_chdir($cwd);
}
foreach my $targetdir (sort keys %check_dirs) {
- _mkpath( $targetdir, 0, $Perm_Dir, $verbose, $dry_run );
+ _mkpath( $targetdir, 0, 0755, $verbose, $dry_run );
}
foreach my $found (@found_files) {
my ($diff, $ffd, $origfile, $mode, $size, $atime, $mtime,
@@ -798,7 +813,7 @@ sub install { #XXX OS-SPECIFIC
$targetfile= _unlink_or_rename( $targetfile, 'tryhard', 'install' )
unless $dry_run;
} elsif ( ! -d $targetdir ) {
- _mkpath( $targetdir, 0, $Perm_Dir, $verbose, $dry_run );
+ _mkpath( $targetdir, 0, 0755, $verbose, $dry_run );
}
print "Installing $targetfile\n";
@@ -807,7 +822,7 @@ sub install { #XXX OS-SPECIFIC
#XXX OS-SPECIFIC
print "utime($atime,$mtime,$targetfile)\n" if $verbose>1;
- utime($atime,$mtime + $Is_VMS,$targetfile) unless $dry_run>1;
+ utime($atime,$mtime + Is_VMS,$targetfile) unless $dry_run>1;
$mode = 0444 | ( $mode & 0111 ? 0111 : 0 );
@@ -838,7 +853,7 @@ sub install { #XXX OS-SPECIFIC
if ($pack{'write'}) {
$dir = install_rooted_dir(dirname($pack{'write'}));
- _mkpath( $dir, 0, $Perm_Dir, $verbose, $dry_run );
+ _mkpath( $dir, 0, 0755, $verbose, $dry_run );
print "Writing $pack{'write'}\n" if $verbose;
$packlist->write(install_rooted_file($pack{'write'})) unless $dry_run;
}
@@ -937,7 +952,8 @@ Returns 0 if there is not.
sub directory_not_empty ($) {
my($dir) = @_;
my $files = 0;
- find(sub {
+ require File::Find;
+ File::Find::find(sub {
return if $_ eq ".exists";
if (-f) {
$File::Find::prune++;
@@ -971,7 +987,7 @@ Consider its use discouraged.
=cut
sub install_default {
- @_ < 2 or Carp::croak("install_default should be called with 0 or 1 argument");
+ @_ < 2 or _croak("install_default should be called with 0 or 1 argument");
my $FULLEXT = @_ ? shift : $ARGV[0];
defined $FULLEXT or die "Do not know to where to write install log";
my $INST_LIB = File::Spec->catdir($Curdir,"blib","lib");
@@ -1027,6 +1043,7 @@ sub uninstall {
unless -f $fil;
# my $my_req = $self->catfile(qw(auto ExtUtils Install forceunlink.al));
# require $my_req; # Hairy, but for the first
+ require ExtUtils::Packlist;
my ($packlist) = ExtUtils::Packlist->new($fil);
foreach (sort(keys(%$packlist))) {
chomp;
@@ -1077,7 +1094,7 @@ sub inc_uninstall {
#warn join "\n","---",@dirs,"---";
my $seen_ours;
foreach $dir ( @dirs ) {
- my $canonpath = $Is_VMS ? $dir : File::Spec->canonpath($dir);
+ my $canonpath = Is_VMS ? $dir : File::Spec->canonpath($dir);
next if $canonpath eq $Curdir;
next if $seen_dir{$canonpath}++;
my $targetfile = File::Spec->catfile($canonpath,$libdir,$file);
@@ -1089,7 +1106,7 @@ sub inc_uninstall {
my $diff = 0;
if ( -f $targetfile && -s _ == -s $filepath) {
# We have a good chance, we can skip this one
- $diff = compare($filepath,$targetfile);
+ $diff = _compare($filepath,$targetfile);
} else {
$diff++;
}
@@ -1159,11 +1176,12 @@ sub run_filter {
=item B<pm_to_blib>
+ pm_to_blib(\%from_to);
pm_to_blib(\%from_to, $autosplit_dir);
pm_to_blib(\%from_to, $autosplit_dir, $filter_cmd);
Copies each key of %from_to to its corresponding value efficiently.
-Filenames with the extension .pm are autosplit into the $autosplit_dir.
+If an $autosplit_dir is provided, all .pm files will be autosplit into it.
Any destination directories are created.
$filter_cmd is an optional shell command to run each .pm file through
@@ -1181,7 +1199,7 @@ environment variable will silence this output.
sub pm_to_blib {
my($fromto,$autodir,$pm_filter) = @_;
- _mkpath($autodir,0,$Perm_Dir);
+ _mkpath($autodir,0,0755) if defined $autodir;
while(my($from, $to) = each %$fromto) {
if( -f $to && -s $from == -s $to && -M $to < -M $from ) {
print "Skip $to (unchanged)\n" unless $INSTALL_QUIET;
@@ -1196,7 +1214,7 @@ sub pm_to_blib {
my $need_filtering = defined $pm_filter && length $pm_filter &&
$from =~ /\.pm$/;
- if (!$need_filtering && 0 == compare($from,$to)) {
+ if (!$need_filtering && 0 == _compare($from,$to)) {
print "Skip $to (unchanged)\n" unless $INSTALL_QUIET;
next;
}
@@ -1204,7 +1222,7 @@ sub pm_to_blib {
# we wont try hard here. its too likely to mess things up.
forceunlink($to);
} else {
- _mkpath(dirname($to),0,$Perm_Dir);
+ _mkpath(dirname($to),0,0755);
}
if ($need_filtering) {
run_filter($pm_filter, $from, $to);
@@ -1214,10 +1232,10 @@ sub pm_to_blib {
print "cp $from $to\n" unless $INSTALL_QUIET;
}
my($mode,$atime,$mtime) = (stat $from)[2,8,9];
- utime($atime,$mtime+$Is_VMS,$to);
+ utime($atime,$mtime+Is_VMS,$to);
_chmod(0444 | ( $mode & 0111 ? 0111 : 0 ),$to);
next unless $from =~ /\.pm$/;
- _autosplit($to,$autodir);
+ _autosplit($to,$autodir) if defined $autodir;
}
}
@@ -1235,7 +1253,8 @@ locking (ie. Windows). So we wrap it and close the filehandle.
=cut
sub _autosplit { #XXX OS-SPECIFIC
- my $retval = autosplit(@_);
+ require AutoSplit;
+ my $retval = AutoSplit::autosplit(@_);
close *AutoSplit::IN if defined *AutoSplit::IN{IO};
return $retval;
@@ -1266,7 +1285,7 @@ sub DESTROY {
$plural = $i>1 ? "all those files" : "this file";
my $inst = (_invokant() eq 'ExtUtils::MakeMaker')
? ( $Config::Config{make} || 'make' ).' install'
- . ( $Is_VMS ? '/MACRO="UNINST"=1' : ' UNINST=1' )
+ . ( ExtUtils::Install::Is_VMS ? '/MACRO="UNINST"=1' : ' UNINST=1' )
: './Build install uninst=1';
print "## Running '$inst' will unlink $plural for you.\n";
}