This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix a CPANPLUS test that fails when run on a read-only source tree
[perl5.git] / lib / CPANPLUS / Internals / Source.pm
index c58632b..f527618 100644 (file)
@@ -318,8 +318,11 @@ sub _update_source {
 
         ### `touch` the file, so windoze knows it's new -jmb
         ### works on *nix too, good fix -Kane
-        utime ( $now, $now, File::Spec->catfile($path, $file) ) or
+        ### make sure it is writable first, otherwise the `touch` will fail
+        unless (chmod ( 0644, File::Spec->catfile($path, $file) ) &&
+                utime ( $now, $now, File::Spec->catfile($path, $file) )) {
             error( loc("Couldn't touch %1", $file) );
+        }
 
     }
     return 1;