--- lib/ExtUtils/Install.pm
+++ lib/ExtUtils/Install.pm
@@ -680,7 +680,7 @@ sub install { #XXX OS-SPECIFIC
delete $from_to{$_};
}
my $tmpfile = install_rooted_file($pack{"read"});
- $packlist->read($tmpfile) if (-f $tmpfile);
+ $packlist->read($tmpfile) if defined $tmpfile and -f $tmpfile;
my $cwd = cwd();
my @found_files;
my %check_dirs;
@@ -784,7 +784,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;
$mode = 0444 | ( $mode & 0111 ? 0111 : 0 );
--- /dev/null
+++ t/install-dry-run.t
@@ -0,0 +1,54 @@
+#!/usr/bin/perl -w
+
+# Test that install() dry-run does not touch any installed files when the source file
+# has changed. See rt.cpan.org 41646.
+
+use strict;
+use lib 't/lib';
+
+use TieOut;
+use Test::More tests => 6;
+
+use ExtUtils::Install;
+
+use MakeMaker::Test::Setup::BFD;
+ok( setup_recurs(), 'setup' );
+END {
+ ok( chdir File::Spec->updir );
+ ok( teardown_recurs(), 'teardown' );
+}
+
+chdir 'Big-Dummy';
+my $stdout = tie *STDOUT, 'TieOut';
+
+{
+ my $source = 'lib/Big/Dummy.pm';
+ my $target = 'install-test/lib/perl/Big/Dummy.pm';
+
+ my %result;
+ install([
+ from_to => { "lib" => "install-test/lib/perl" },
+ dry_run => 0,
+ result => \%result
+ ]);
+
+ ok -f $target, "$target installed";
+
+ my $orig_mtime = (stat $target)[9];
+
+ # sleep so we can see a time difference between the source and the target
+ sleep 2;
+
+ # Change the source file so it diffs from the target
+ {
+ ok open my $fh, ">>", $source;
+ print $fh "Wibble\n";
+ }
+
+ install([
+ from_to => { 'lib' => 'install-test/lib/perl' },
+ dry_run => 1
+ ]);
+
+ is( (stat $target)[9], $orig_mtime, "install() dry-run does not touch installed files" );
+}