new tickets from slaven
[andk-cpan-tools.git] / bin / filter-outdated-from-analysis-logfile.pl
blobcde4757b1b1f0cc90c5af12d7db2c574de926220
1 #!/usr/bin/perl
3 # use 5.010;
4 use strict;
5 use warnings;
7 =head1 NAME
11 =head1 SYNOPSIS
13 $0 logfile
15 =head1 OPTIONS
17 =over 8
19 =cut
21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
23 =item B<--help|h!>
25 This help
27 =back
29 =head1 DESCRIPTION
31 Reads the logfile noise written by cnntp-solver.pl. Does so backwards
32 because we are interested in the last run. Does so until it has
33 processed one complete block of anno-nnnn lines. Writes them to
34 stdout, adding and removing stuff.
36 Intended as a first step in cleaning up annotate.txt. We only extract
37 the distros that we believe should be eliminated. When we have
38 confidence that the list is OK, we pipe it in a separate step like so:
40 (on analysis):
41 2015-10-03 02:46 ~/src/installed-perls/v5.16.0/4e6d/bin/perl bin/filter-outdated-from-analysis-logfile.pl bin/cnntp-solver.sh.out | tee ~/filter-outdated-from-analysis-logfile.out
43 (on k83):
44 2015-10-03 03:51 ssh andreas@analysis cat filter-outdated-from-analysis-logfile.out | perl bin/eliminate-outdated-annotations.pl
47 =cut
50 use FindBin;
51 use lib "$FindBin::Bin/../lib";
52 BEGIN {
53 push @INC, qw( );
56 use Dumpvalue;
57 use File::Basename qw(dirname);
58 use File::Path qw(mkpath);
59 use File::Spec;
60 use File::Temp;
61 use Getopt::Long;
62 use Pod::Usage;
63 use Hash::Util qw(lock_keys);
65 our %Opt;
66 lock_keys %Opt, map { /([^=|!]+)/ } @opt;
67 GetOptions(\%Opt,
68 @opt,
69 ) or pod2usage(1);
70 if ($Opt{help}) {
71 pod2usage(0);
74 my($logfile) = @ARGV or pod2usage(1);
76 use File::ReadBackwards;
77 my $rb = File::ReadBackwards->new($logfile) or die;
78 my $annoblock;
79 # use Regexp::Debugger;
80 LINE: while (defined(my $line = $rb->readline)) {
81 $line =~ s!\e\[3[12345](?:;\d+)?m(.*?)\e\[0m!$1!sg;
82 # 1503 anno-1508 13-02-05 252: 14: 4 SHARYANTO/Org-Parser-0.30 (<0.37)
83 my($cnt,$annolabel,$date,$passes,$fails,$unknowns,$author,$distv,$state) =
84 $line =~ m/\s*(\d+)
85 \s+(anno-\d+)
86 \s+(\d{2}-\d{2}-\d{2})
87 \s+(\d+):
88 \s*(\d+):
89 \s*(\d+)
90 \s+([\w\-]+)\/
91 \s*(\S+)
92 \s+\((.+?)\)
93 /x;
94 if ($state){
95 unless (defined $annoblock) {
96 $annoblock = $annolabel;
98 last LINE unless $annolabel eq $annoblock;
99 if ($state =~ /^</) {
100 printf "%-53s %s %-12s %-12s %4d\n", $distv, $annolabel, $author, $state, $cnt;
102 } elsif (defined $annoblock) {
103 if ($line =~ /Already up-to-date/) {
104 last LINE;
109 # Local Variables:
110 # mode: cperl
111 # cperl-indent-level: 4
112 # End: