]> git.donarmstrong.com Git - wannabuild.git/blob - bin/wb-graph
initial import of /org/wanna-build
[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 = "unstable";
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                 $dist = "stable"   if $dist eq "s";
23                 $dist = "frozen"   if $dist eq "f";
24                 $dist = "unstable" if $dist eq "u";
25                 die "Bad distribution\n" if !isin($dist, qw(stable testing unstable));
26         }
27         elsif (/^--$/) {
28                 last;
29         }
30         elsif (/^-p$/ || /^--previously-built$/) {
31                 $previously_built = 1;
32         }
33         else {
34                 die "Unknown option: $_\n";
35         }
36 }
37
38 my $date=`date +%m/%d/%Y`;
39 chop($date);
40 print "$date";
41
42 my @archs = qw(alpha arm hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 amd64 sparc armel);
43 my $arch;
44
45 foreach $arch (@archs) {
46
47 my($lastmsg, %n_state, $total, %n_builder, $pu_total);
48 $pu_total = 0;
49 $n_state{"Installed"} = 0;
50 open( PIPE, "wanna-build --database=$arch/build-db --dist=$dist --list=all 2>&1 |" )
51         or die "Cannot spawn wanna-build: $!\n";
52 while( <PIPE> ) {
53         if (/^Database for $dist doesn't exist$/) {
54                 last;
55         }
56         elsif (/^Total (\d+) package\(s\) in state (\S+)\.$/) {
57                 $n_state{$2} = $1;
58                 $pu_total += $1 if ( $2 eq "Installed" );
59         }
60         elsif (/^Total (\d+) package\(s\)$/) {
61                 $total = $1;
62         }
63         elsif (/: Installed (?:by [\w-]+ )?\[[\w-]*:/) {
64                 next;
65         }
66         elsif (/: [\w-]+ (?:by [\w-]+ )?\[\w+:(out-of-date|partial)/) {
67                 $pu_total++;
68         }
69         $lastmsg = $_;
70 }
71 close( PIPE );
72 if ($?) {
73         print ", 0, 0";
74 } else {
75 #       $total -= $n_state{"Not-For-Us"};
76         if ( $previously_built ) {
77                 print ", ".$n_state{"Installed"}.", ".$pu_total;
78         } else {
79                 print ", ".$n_state{"Installed"}.", ".$total;
80         }
81 }
82 }
83 print "\n";
84
85 exit 0;
86
87 sub isin {
88         my $val = shift;
89         return grep( $_ eq $val, @_ );
90 }