Subject: | [patch] replace -M with Time::HiRes::stat |
Hi,
The problem I'm trying to solve is when I build any module that contains
EXE_FILES that are manified by ExtUtils::Command::MM::pod2man, which
checks for timestamps for the resulting man page (and Makefile too).
The logic it is using is correct, but modern machines are fast enough so
takes less than a second to generate a pod, and the code using -M to
check the file timestamp.
Problem appears when after "make", which is run as a unprivileged user,
I run then "sudo make install", -- but before installing, pod2man
decides (wrongly!) that it needs to regenerate manpage, and does so -
under root.
Cleaning the distro then becomes impossible under normal user.
Here I'm attaching a single patch that uses Time::HiRes::stat to fix
this problem.
Subject: | eumm.patch |
--- MM.pm.0 2011-08-10 21:33:13.107912381 +0200
+++ MM.pm 2011-08-10 22:09:38.343916883 +0200
@@ -14,6 +14,8 @@
my $Is_VMS = $^O eq 'VMS';
+use Time::HiRes qw(stat);
+sub mtime($) { (stat($_[0]))[9] }
=head1 NAME
@@ -131,8 +133,8 @@
my ($pod, $man) = splice(@ARGV, 0, 2);
next if ((-e $man) &&
- (-M $man < -M $pod) &&
- (-M $man < -M "Makefile"));
+ (mtime $man > mtime $pod) &&
+ (mtime $man > mtime "Makefile"));
print "Manifying $man\n";