]> git.donarmstrong.com Git - wannabuild.git/blob - bin/wb-graph
Use -A instead of --database to selected the arch
[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 . /org/wanna-build/triggers/common
39
40 for arch in $ARCHS_unstable; do
41
42 my($lastmsg, %n_state, $total, %n_builder, $pu_total);
43 $pu_total = 0;
44 $n_state{"Installed"} = 0; 
45 open( my $pipe, '-|', "wanna-build -A $arch --dist=$dist --list=all" )
46         or die "Cannot spawn wanna-build: $!\n";
47 while( <$pipe> ) {
48         if (/^Database for $dist doesn't exist$/) {
49                 last;
50         }
51         elsif (/^Total (\d+) package\(s\) in state (\S+)\.$/) {
52                 $n_state{$2} = $1;
53                 $pu_total += $1 if ( $2 eq "Installed" );
54         }
55         elsif (/^Total (\d+) package\(s\)$/) {
56                 $total = $1;
57         }
58         elsif (/: Installed (?:by [\w-]+ )?\[[\w-]*:/) {
59                 next;
60         }
61         elsif (/: [\w-]+ (?:by [\w-]+ )?\[\w+:(out-of-date|partial)/) {
62                 $pu_total++;
63         }
64         $lastmsg = $_;
65 }
66 close( $pipe );
67 if ($?) {
68         print ", 0, 0";
69 } else {
70 #       $total -= $n_state{"Not-For-Us"};
71         if ( $previously_built ) {
72                 print ", ".$n_state{"Installed"}.", ".$pu_total;
73         } else {
74                 print ", ".$n_state{"Installed"}.", ".$total;
75         }
76 }
77 done
78 print "\n";
79
80 exit 0;
81
82 sub isin {
83         my $val = shift;
84         return grep( $_ eq $val, @_ );
85 }