]> git.donarmstrong.com Git - dak.git/blob - scripts/debian/update-ftpstats
ba3c25be2d884d39c841ac7fc64d52c205fef563
[dak.git] / scripts / debian / update-ftpstats
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use IO::Uncompress::AnyUncompress ":all";
7
8 my %data;
9 my %data2;
10 my @archs = ("source", "all", "amd64", "arm64", "i386", "alpha", "arm", "armel", "armhf", "hppa",
11              "hurd-i386", "ia64", "kfreebsd-amd64", "kfreebsd-i386", "mips", "mipsel", "powerpc", "s390",
12              "s390x", "sparc");
13
14 for my $file (@ARGV) {
15   my $FH = new IO::Uncompress::AnyUncompress $file, Transparent => 1
16     or warn "Cannot open $file: $AnyUncompressError\n";
17   while (<$FH>) {
18     if (/^(\d{8})\d{6}\|(?:k(?:atie|elly)|process-(?:accepted|upload))(?:\|dak)?\|installed\|[^|]+\|[^|]+\|(\d+)\|([-\w]+)$/) {
19       if (not defined $data{$1}) {
20         foreach $a (@archs) {
21           $data{$1}{$a} = 0;
22         }
23       }
24       $data{$1}{$3} += $2;
25       $data2{$1}{$3}++;
26     }
27   }
28 }
29
30 foreach my $p (sort keys %data) {
31   print "$p";
32   foreach $a (@archs) {
33     print ", $data{$p}{$a}";
34   }
35   print "\n";
36 }