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