use 5.00503;
use vars qw(@ISA @EXPORT $VERSION);
-$VERSION = 1.32;
+$VERSION = '1.33_01';
use Exporter;
use Carp ();
$Is_VMS = $^O eq 'VMS';
$Is_MacPerl = $^O eq 'MacOS';
-my $splitchar = $^O eq 'VMS' ? '|' : ($^O eq 'os2' || $^O eq 'dos') ? ';' : ':';
-my @PERL_ENV_LIB = split $splitchar, defined $ENV{'PERL5LIB'} ? $ENV{'PERL5LIB'} : $ENV{'PERLLIB'} || '';
my $Inc_uninstall_warn_handler;
# install relative to here
=item B<install>
install(\%from_to);
- install(\%from_to, $verbose, $dont_execute);
+ install(\%from_to, $verbose, $dont_execute, $uninstall_shadows);
Copies each directory tree of %from_to to its corresponding value
preserving timestamps and permissions.
directory than the one where the files later appear.
If $verbose is true, will print out each file removed. Default is
-false.
+false. This is "make install VERBINST=1"
If $dont_execute is true it will only print what it was going to do
without actually doing it. Default is false.
+If $uninstall_shadows is true any differing versions throughout @INC
+will be uninstalled. This is "make install UNINST=1"
+
=cut
sub install {
use File::Path qw(mkpath);
use File::Compare qw(compare);
+ my $win32_special=!$nonono &&
+ $^O eq 'MSWin32' &&
+ eval { require Win32API::File; 1 };
my(%from_to) = %$from_to;
my(%pack, $dir, $warn_permissions);
my($packlist) = ExtUtils::Packlist->new();
for (readdir DIR) {
next if $_ eq $Curdir || $_ eq $Updir || $_ eq ".exists";
my $targetdir = install_rooted_dir($from_to{$source_dir_or_file});
- if (-w $targetdir ||
- mkpath($targetdir)) {
- last;
- } else {
+ mkpath($targetdir) unless $nonono;
+ if (!$nonono && !-w $targetdir) {
warn "Warning: You do not have permissions to " .
"install into $from_to{$source_dir_or_file}"
unless $warn_permissions++;
find(sub {
my ($mode,$size,$atime,$mtime) = (stat)[2,7,8,9];
return unless -f _;
- return if $_ eq ".exists";
+
+ my $origfile = $_;
+ return if $origfile eq ".exists";
my $targetdir = File::Spec->catdir($targetroot, $File::Find::dir);
- my $targetfile = File::Spec->catfile($targetdir, $_);
+ my $targetfile = File::Spec->catfile($targetdir, $origfile);
my $sourcedir = File::Spec->catdir($source, $File::Find::dir);
- my $sourcefile = File::Spec->catfile($sourcedir, $_);
+ my $sourcefile = File::Spec->catfile($sourcedir, $origfile);
my $save_cwd = cwd;
chdir $cwd; # in case the target is relative
$diff++;
}
- if ($diff){
- if (-f $targetfile){
+ if ($diff) {
+ if ($win32_special && -f $targetfile && !unlink $targetfile) {
+ print "Can't remove existing '$targetfile': $!\n";
+ my $tmp = "AAA";
+ ++$tmp while -e "$targetfile.$tmp";
+ $tmp= "$targetfile.$tmp";
+ if ( rename $targetfile, $tmp ) {
+ print "However it has been renamed as '$tmp' which ".
+ "will be removed at next reboot.\n";
+ Win32API::File::MoveFileEx( $tmp, [],
+ Win32API::File::MOVEFILE_DELAY_UNTIL_REBOOT() )
+ or die "MoveFileEx/Delete '$tmp' failed: $^E\n";
+ } else {
+ print "Installation cannot be completed until you reboot.\n",
+ "Until then using '$tmp' as the install filename.\n";
+ Win32API::File::MoveFileEx( $tmp, $targetfile,
+ Win32API::File::MOVEFILE_REPLACE_EXISTING() |
+ Win32API::File::MOVEFILE_DELAY_UNTIL_REBOOT() )
+ or die "MoveFileEx/Replace '$tmp' failed: $^E\n";
+ $targetfile = $tmp;
+ }
+ } elsif (-f $targetfile) {
forceunlink($targetfile) unless $nonono;
} else {
mkpath($targetdir,0,0755) unless $nonono;
}
if ($pack{'write'}) {
$dir = install_rooted_dir(dirname($pack{'write'}));
- mkpath($dir,0,0755);
+ mkpath($dir,0,0755) unless $nonono;
print "Writing $pack{'write'}\n";
- $packlist->write(install_rooted_file($pack{'write'}));
+ $packlist->write(install_rooted_file($pack{'write'})) unless $nonono;
}
}
@_ < 2 or die "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(File::Spec->curdir,"blib","lib");
- my $INST_ARCHLIB = File::Spec->catdir(File::Spec->curdir,"blib","arch");
- my $INST_BIN = File::Spec->catdir(File::Spec->curdir,'blib','bin');
- my $INST_SCRIPT = File::Spec->catdir(File::Spec->curdir,'blib','script');
- my $INST_MAN1DIR = File::Spec->catdir(File::Spec->curdir,'blib','man1');
- my $INST_MAN3DIR = File::Spec->catdir(File::Spec->curdir,'blib','man3');
+ my $INST_LIB = File::Spec->catdir($Curdir,"blib","lib");
+ my $INST_ARCHLIB = File::Spec->catdir($Curdir,"blib","arch");
+ my $INST_BIN = File::Spec->catdir($Curdir,'blib','bin');
+ my $INST_SCRIPT = File::Spec->catdir($Curdir,'blib','script');
+ my $INST_MAN1DIR = File::Spec->catdir($Curdir,'blib','man1');
+ my $INST_MAN3DIR = File::Spec->catdir($Curdir,'blib','man3');
install({
read => "$Config{sitearchexp}/auto/$FULLEXT/.packlist",
write => "$Config{installsitearch}/auto/$FULLEXT/.packlist",
}
sub inc_uninstall {
- my($file,$libdir,$verbose,$nonono) = @_;
+ my($filepath,$libdir,$verbose,$nonono) = @_;
my($dir);
+ my $file = (File::Spec->splitpath($filepath))[2];
my %seen_dir = ();
+
+ my @PERL_ENV_LIB = split $Config{path_sep}, defined $ENV{'PERL5LIB'}
+ ? $ENV{'PERL5LIB'} : $ENV{'PERLLIB'} || '';
+
foreach $dir (@INC, @PERL_ENV_LIB, @Config{qw(archlibexp
privlibexp
sitearchexp
# know, which is the file we just installed (AFS). So we leave
# an identical file in place
my $diff = 0;
- if ( -f $targetfile && -s _ == -s $file) {
+ if ( -f $targetfile && -s _ == -s $filepath) {
# We have a good chance, we can skip this one
- $diff = compare($file,$targetfile);
+ $diff = compare($filepath,$targetfile);
} else {
print "#$file and $targetfile differ\n" if $verbose>1;
$diff++;
sub run_filter {
my ($cmd, $src, $dest) = @_;
+ local(*CMD, *SRC);
open(CMD, "|$cmd >$dest") || die "Cannot fork: $!";
open(SRC, $src) || die "Cannot open $src: $!";
my $buf;
Copies each key of %from_to to its corresponding value efficiently.
Filenames with the extension .pm are autosplit into the $autosplit_dir.
+Any destination directories are created.
$filter_cmd is an optional shell command to run each .pm file through
prior to splitting and copying. Input is the contents of the module,
use File::Path qw(mkpath);
use File::Compare qw(compare);
use AutoSplit;
- # my $my_req = $self->catfile(qw(auto ExtUtils Install forceunlink.al));
- # require $my_req; # Hairy, but for the first
-
- if (!ref($fromto) && -r $fromto)
- {
- # Win32 has severe command line length limitations, but
- # can generate temporary files on-the-fly
- # so we pass name of file here - eval it to get hash
- open(FROMTO,"<$fromto") or die "Cannot open $fromto:$!";
- my $str = '$fromto = {qw{'.join('',<FROMTO>).'}}';
- eval $str;
- close(FROMTO);
- }
mkpath($autodir,0,0755);
while(my($from, $to) = each %$fromto) {
Original author lost in the mists of time. Probably the same as Makemaker.
-Currently maintained by Michael G Schwern <F<schwern@pobox.com>>
+Currently maintained by Michael G Schwern C<schwern@pobox.com>
-Send patches and ideas to <F<makemaker@perl.org>>.
+Send patches and ideas to C<makemaker@perl.org>.
Send bug reports via http://rt.cpan.org/. Please send your
generated Makefile along with your report.
-For more up-to-date information, see http://www.makemaker.org.
+For more up-to-date information, see L<http://www.makemaker.org>.
=head1 LICENSE
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
-See F<http://www.perl.com/perl/misc/Artistic.html>
+See L<http://www.perl.com/perl/misc/Artistic.html>
=cut