diff options
author | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2017-06-05 14:13:36 +0100 |
---|---|---|
committer | Chris 'BinGOs' Williams <chris@bingosnet.co.uk> | 2017-06-05 15:57:12 +0100 |
commit | 9de35bb263b4599827a76615d5e6ef08fb7e32c6 (patch) | |
tree | 3b398d0de0aa0216f4e682e393d65f3bbcae5f1c | |
parent | 8514fcfe19dd1f0b8c39f9607592a853ac68913f (diff) | |
download | perl-9de35bb263b4599827a76615d5e6ef08fb7e32c6.tar.gz |
Update ExtUtils-Install to CPAN version 2.14
[DELTA]
2.14
- Fix tests for when perl path contains a space
2.12
- Fix win32 check
2.10
- 'make -s' support: set $INSTALL_QUIET automatically
2.08
- Optimisations:
* use our instead of vars
* lazy load modules
* make OS variables into constants
* move some calculations out of a loop
2.06
- Removed instructions using Build.PL from README
- Load Win32API::File for _move_file_at_boot only when needed
- Allow disabling autosplit by omitting autosplit dir
-rwxr-xr-x | Porting/Maintainers.pl | 2 | ||||
-rwxr-xr-x | Porting/cmpVERSION.pl | 1 | ||||
-rw-r--r-- | cpan/ExtUtils-Install/lib/ExtUtils/Install.pm | 192 | ||||
-rw-r--r-- | cpan/ExtUtils-Install/lib/ExtUtils/Installed.pm | 2 | ||||
-rw-r--r-- | cpan/ExtUtils-Install/lib/ExtUtils/Packlist.pm | 2 | ||||
-rw-r--r-- | cpan/ExtUtils-Install/t/Install.t | 14 | ||||
-rw-r--r-- | cpan/ExtUtils-Install/t/InstallWithMM.t | 2 | ||||
-rw-r--r-- | cpan/ExtUtils-Install/t/Installed.t | 3 | ||||
-rw-r--r-- | cpan/ExtUtils-Install/t/lib/MakeMaker/Test/Setup/BFD.pm | 12 |
9 files changed, 139 insertions, 91 deletions
diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index 26ada3539f..b7d4b3b8fe 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -446,7 +446,7 @@ use File::Glob qw(:case); }, 'ExtUtils::Install' => { - 'DISTRIBUTION' => 'BINGOS/ExtUtils-Install-2.04.tar.gz', + 'DISTRIBUTION' => 'BINGOS/ExtUtils-Install-2.14.tar.gz', 'FILES' => q[cpan/ExtUtils-Install], 'EXCLUDED' => [ qw( t/lib/Test/Builder.pm diff --git a/Porting/cmpVERSION.pl b/Porting/cmpVERSION.pl index 67e9b395ca..dd21b655fe 100755 --- a/Porting/cmpVERSION.pl +++ b/Porting/cmpVERSION.pl @@ -81,6 +81,7 @@ if ($exclude_upstream) { # usually because they pull in their version from some other file. my %skip; @skip{ + 'cpan/ExtUtils-Install/t/lib/MakeMaker/Test/Setup/BFD.pm', # just a test module 'cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/BFD.pm', # just a test module 'cpan/ExtUtils-MakeMaker/t/lib/MakeMaker/Test/Setup/XS.pm', # just a test module 'cpan/IO-Compress/lib/File/GlobMapper.pm', # upstream needs to supply $VERSION diff --git a/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm b/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm index 1e8ac4cd12..047c007145 100644 --- a/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm +++ b/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,18 +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); - -# *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; @@ -114,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,''; @@ -132,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 )=@_; @@ -173,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; } @@ -270,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"; @@ -379,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()); @@ -425,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 { @@ -519,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': $!" ); } } @@ -673,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}; @@ -694,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); @@ -706,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 @@ -720,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) @@ -734,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 _; @@ -765,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; @@ -806,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 ); @@ -936,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++; @@ -970,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"); @@ -1026,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; @@ -1076,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); @@ -1088,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++; } @@ -1158,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 @@ -1180,7 +1199,7 @@ environment variable will silence this output. sub pm_to_blib { my($fromto,$autodir,$pm_filter) = @_; - _mkpath($autodir,0,0755); + _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; @@ -1195,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; } @@ -1213,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; } } @@ -1234,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; @@ -1265,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"; } diff --git a/cpan/ExtUtils-Install/lib/ExtUtils/Installed.pm b/cpan/ExtUtils-Install/lib/ExtUtils/Installed.pm index 061c32916f..8327a95a3d 100644 --- a/cpan/ExtUtils-Install/lib/ExtUtils/Installed.pm +++ b/cpan/ExtUtils-Install/lib/ExtUtils/Installed.pm @@ -17,7 +17,7 @@ my $DOSISH = ($^O =~ /^(MSWin\d\d|os2|dos|mint)$/); require VMS::Filespec if $Is_VMS; use vars qw($VERSION); -$VERSION = '2.04'; +$VERSION = '2.14'; $VERSION = eval $VERSION; sub _is_prefix { diff --git a/cpan/ExtUtils-Install/lib/ExtUtils/Packlist.pm b/cpan/ExtUtils-Install/lib/ExtUtils/Packlist.pm index c1ab00216b..f94e3d05cc 100644 --- a/cpan/ExtUtils-Install/lib/ExtUtils/Packlist.pm +++ b/cpan/ExtUtils-Install/lib/ExtUtils/Packlist.pm @@ -5,7 +5,7 @@ use strict; use Carp qw(); use Config; use vars qw($VERSION $Relocations); -$VERSION = '2.04'; +$VERSION = '2.14'; $VERSION = eval $VERSION; # Used for generating filehandle globs. IO::File might not be available! diff --git a/cpan/ExtUtils-Install/t/Install.t b/cpan/ExtUtils-Install/t/Install.t index 440d23082d..0900b58cb8 100644 --- a/cpan/ExtUtils-Install/t/Install.t +++ b/cpan/ExtUtils-Install/t/Install.t @@ -12,7 +12,7 @@ use File::Path; use File::Spec; use File::Temp qw[tempdir]; -use Test::More tests => 60; +use Test::More tests => 62; use MakeMaker::Test::Setup::BFD; @@ -269,3 +269,15 @@ SKIP: { ok(compare("$bigdir/Dummy.pm", "$bigdir/DummyOrig.pm"), "orig file should be different"); } + +pm_to_blib( { 'lib/Dummy/Split.pm' => 'blib/lib/Dummy/Split.pm' }, + 'blib/lib/auto' + ); + +ok( -r 'blib/lib/auto/Dummy/Split/split.al', + 'pm_to_blib does autosplit on appropriate files', +); +eval { + pm_to_blib( { 'lib/Dummy/Split.pm' => 'blib/lib/Dummy/Split.pm' } ); +}; +is $@, '', 'pm_to_blib with no autodir works'; diff --git a/cpan/ExtUtils-Install/t/InstallWithMM.t b/cpan/ExtUtils-Install/t/InstallWithMM.t index 58ffd3eceb..d656d43833 100644 --- a/cpan/ExtUtils-Install/t/InstallWithMM.t +++ b/cpan/ExtUtils-Install/t/InstallWithMM.t @@ -56,7 +56,7 @@ delete @ENV{qw(PREFIX LIB MAKEFLAGS)}; ok( chdir('Big-Dummy'), "chdir'd to Big-Dummy" ) || diag("chdir failed: $!"); - my @mpl_out = run(qq{$perl Makefile.PL "PREFIX=../dummy-install"}); + my @mpl_out = run(qq{"$perl" Makefile.PL "PREFIX=../dummy-install"}); END { rmtree '../dummy-install'; } cmp_ok( $?, '==', 0, 'Makefile.PL exited with zero' ) || diff --git a/cpan/ExtUtils-Install/t/Installed.t b/cpan/ExtUtils-Install/t/Installed.t index 5c5c4d3d09..d6a099e9c7 100644 --- a/cpan/ExtUtils-Install/t/Installed.t +++ b/cpan/ExtUtils-Install/t/Installed.t @@ -109,6 +109,9 @@ my $fake_mod_dir = File::Spec->catdir(cwd(), 'auto', 'FakeMod'); # should find $fake_mod_dir via '.' in @INC + local @INC = @INC; + push @INC, '.' if not $INC[-1] eq '.'; + my $realei = ExtUtils::Installed->new(); isa_ok( $realei, 'ExtUtils::Installed' ); isa_ok( $realei->{Perl}{packlist}, 'ExtUtils::Packlist' ); diff --git a/cpan/ExtUtils-Install/t/lib/MakeMaker/Test/Setup/BFD.pm b/cpan/ExtUtils-Install/t/lib/MakeMaker/Test/Setup/BFD.pm index 868d0b9019..37ca9a3c01 100644 --- a/cpan/ExtUtils-Install/t/lib/MakeMaker/Test/Setup/BFD.pm +++ b/cpan/ExtUtils-Install/t/lib/MakeMaker/Test/Setup/BFD.pm @@ -90,6 +90,18 @@ foreach my $key (qw(INST_LIB INST_ARCHLIB)) { } END + 'Big-Dummy/lib/Dummy/Split.pm' => <<'END', +package Dummy::Split; +$VERSION = 0.02; +use AutoLoader 'AUTOLOAD'; + +__END__ + +sub split { print "split\n"; } + +1; +END + ); |