]> git.donarmstrong.com Git - wannabuild.git/blob - bin/wb-graph
Don't count Auto-Not-For-Us in stats for the graphs
[wannabuild.git] / bin / wb-graph
1 #!/usr/bin/perl
2 #
3
4 use strict;
5 use vars qw($dist);
6 my $previously_built;
7
8 $dist = "sid";
9
10 while( @ARGV && $ARGV[0] =~ /^-/ ) {
11         $_ = shift @ARGV;
12         if (/^-d/ || /^--dist/) {
13                 if (/^-d(.)/ || /^--dist=(.)/) {
14                         $dist = $1.$';
15                 }
16                 elsif (!@ARGV) {
17                         die "$_ option missing argument\n";
18                 }
19                 else {
20                         $dist = shift @ARGV;
21                 }
22         }
23         elsif (/^--$/) {
24                 last;
25         }
26         elsif (/^-p$/ || /^--previously-built$/) {
27                 $previously_built = 1;
28         }
29         else {
30                 die "Unknown option: $_\n";
31         }
32 }
33
34 my $date=`date -u "+%m/%d/%Y %T"`;
35 chop($date);
36 print "$date";
37
38 my @archs = qw(alpha arm hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 amd64 sparc armel kfreebsd-amd64 kfreebsd-i386);
39 my $arch;
40
41 foreach $arch (@archs) {
42
43 my($lastmsg, %n_state, $total, %n_builder, $pu_total);
44 $pu_total = 0;
45 $n_state{"Installed"} = 0; 
46 open( my $pipe, '-|', "wanna-build -A $arch --dist=$dist --list=all" )
47         or die "Cannot spawn wanna-build: $!\n";
48 while( <$pipe> ) {
49         if (/^Database for $dist doesn't exist$/) {
50                 last;
51         }
52         elsif (/^Total (\d+) package\(s\) in state (\S+)\.$/) {
53                 $n_state{$2} = $1;
54                 $pu_total += $1 if ( $2 eq "Installed" );
55         }
56         elsif (/^Total (\d+) package\(s\)$/) {
57                 $total = $1;
58         }
59         elsif (/: Installed (?:by [\w-]+ )?\[[\w-]*:/) {
60                 next;
61         }
62         elsif (/: [\w-]+ (?:by [\w-]+ )?\[\w+:(out-of-date|partial)/) {
63                 $pu_total++;
64         }
65         $lastmsg = $_;
66 }
67 close( $pipe );
68 if ($?) {
69         print ", 0, 0";
70 } else {
71 #       $total -= $n_state{"Not-For-Us"};
72         $total -= $n_state{"Auto-Not-For-Us"};
73         if ( $previously_built ) {
74                 print ", ".$n_state{"Installed"}.", ".$pu_total;
75         } else {
76                 print ", ".$n_state{"Installed"}.", ".$total;
77         }
78 }
79 }
80 print "\n";
81
82 exit 0;
83
84 sub isin {
85         my $val = shift;
86         return grep( $_ eq $val, @_ );
87 }