malc0 / BoC

An online share-based accounting system
Other
0 stars 0 forks source link

commit to use utime errors on stretch #1

Open wookey opened 5 years ago

wookey commented 5 years ago

https://github.com/malc0/BoC/commit/79ec5e4045e296765a0fb422aab012466d4cca0b causes this error if you run boc on Debian stretch:

"utime" is not exported by the Time::HiRes module Can't continue after import errors at /usr/lib/x86_64-linux-gnu/perl/5.24/Time/HiRes.pm line 68. BEGIN failed--compilation aborted at /home/expo/boe/boc/boc.pl line 12.

Reverting that change lets BoC run. It sounds like the change is useful to avoid sync problems. Can we make it work in stretch?

malc0 commented 5 years ago

The error is due to an incorrect version check on Time::HiRes, which is now fixed in 6b0916f7. This isn't going to help you with stretch however, as the shipped Time::HiRes is too old. The below patch (atop 6b0916f7) should solve the 79ec5e4 problem in a slightly uglier way:

diff --git a/boc.pl b/boc.pl
index 4ebe13b..9134900 100755
--- a/boc.pl
+++ b/boc.pl
@@ -9,7 +9,7 @@ use CGI::Carp qw(fatalsToBrowser);
 use Digest::SHA qw(sha1_hex);
 use List::Util qw(first max min sum);
 use Text::Wrap;
-use Time::HiRes 1.9737 qw(stat usleep utime);
+use Time::HiRes 1.9725 qw(stat usleep);

 # non core
 use CGI::Session '-ip-match';
@@ -4118,6 +4118,7 @@ sub fix_newest
        my $ref = fmtime('newest');
        my $max = untaint (max map (((stat)[9] // 0), grep (-f, glob ("$config{Root}/* $config{Root}/*/*"))));
        if ($max > $ref) {
+               $max += 1;      # compensate for standard utime() truncating fractional seconds
                flock_wc("$config{Root}/newest", {});
                utime ($max, $max, "$config{Root}/newest");
        }