-
Notifications
You must be signed in to change notification settings - Fork 3
/
rbplot.pl
executable file
·47 lines (43 loc) · 1.18 KB
/
rbplot.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl -w
use strict;
use JSON::XS;
use POSIX qw(strftime);
sub processfile
{
my $json = shift;
my %status;
foreach my $pkg (@$json) {
my $s = $pkg->{status};
$status{$s}++;
}
return \%status;
}
sub dumpstatus(@)
{
my @headers=(qw(datum reproducible FTBR FTBFS other));
print join(",",@headers)."\n";
@headers = map {s/datum/mtime/; s/FTBR/unreproducible/; $_} @headers;
foreach my $line (@_) {
#foreach(sort(keys(%$line))) { print "$_ $line->{$_} " } # raw stat dump
my @line;
foreach(@headers) {
my $v = $line->{$_}||0;
if($_ eq "mtime") { $v = strftime("%Y-%m-%d", gmtime($v)) }
if($_ eq "other") { $v = ($line->{nobinaries}||0) + ($line->{waitdep}||0) } # ignoring notforus (other arch)
push(@line, $v);
}
print join(",", @line),"\n"; # CSV out
}
}
my @files = @ARGV;
my @status;
foreach my $f (@files) {
open(my $fd, "<", $f) or die "error opening $f: $!";
my $json;
{ local $/ ; $json = <$fd>; }
close $fd;
my $s = processfile(decode_json($json));
$s->{mtime} = (stat($f))[9];
push(@status, $s);
}
dumpstatus(@status);