Thanks for working on this Yves...
demerphq wrote:
------------------------------------------------------------------------ diff -wurd \.cpan\build\ExtUtils-MakeMaker-6.30/lib/ExtUtils/Install.pm ExtUtils-MakeMaker-6.30_patched/lib/ExtUtils/Install.pm --- \.cpan\build\ExtUtils-MakeMaker-6.30/lib/ExtUtils/Install.pm 2005-03-22 05:30:24.000000000 +0100 +++ ExtUtils-MakeMaker-6.30_patched/lib/ExtUtils/Install.pm 2006-01-30 23:58:27.013626600 +0100 @@ -91,6 +91,7 @@ use File::Path qw(mkpath); use File::Compare qw(compare); + my $win32=!$nonono && $^O eq 'MSWin32'; my(%from_to) = %$from_to; my(%pack, $dir, $warn_permissions); my($packlist) = ExtUtils::Packlist->new(); @@ -170,7 +171,28 @@ } if ($diff){ - if (-f $targetfile){ + if ($win32 && -f $targetfile && !unlink $targetfile) { + print "Can't remove existing '$targetfile': $!\n"; + require Win32API::File;
Note that this module is not always available 0n Win32; it's not in core. It does seem to be present ActiveState distros back to 5.005.
+ 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;