#!/usr/bin/perl # use strict; use vars qw($dist); my $previously_built; $dist = "unstable"; while( @ARGV && $ARGV[0] =~ /^-/ ) { $_ = shift @ARGV; if (/^-d/ || /^--dist/) { if (/^-d(.)/ || /^--dist=(.)/) { $dist = $1.$'; } elsif (!@ARGV) { die "$_ option missing argument\n"; } else { $dist = shift @ARGV; } $dist = "oldstable" if $dist eq "o"; $dist = "stable" if $dist eq "s"; $dist = "tesing" if $dist eq "t"; $dist = "unstable" if $dist eq "u"; die "Bad distribution\n" if !isin($dist, qw(oldstable stable testing unstable)); } elsif (/^--$/) { last; } elsif (/^-p$/ || /^--previously-built$/) { $previously_built = 1; } else { die "Unknown option: $_\n"; } } my $date=`date +%m/%d/%Y`; chop($date); print "$date"; my @archs = qw(alpha arm hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 amd64 sparc armel); my $arch; foreach $arch (@archs) { my($lastmsg, %n_state, $total, %n_builder, $pu_total); $pu_total = 0; $n_state{"Installed"} = 0; open( PIPE, "wanna-build --database=$arch/build-db --dist=$dist --list=all 2>&1 |" ) or die "Cannot spawn wanna-build: $!\n"; while( ) { if (/^Database for $dist doesn't exist$/) { last; } elsif (/^Total (\d+) package\(s\) in state (\S+)\.$/) { $n_state{$2} = $1; $pu_total += $1 if ( $2 eq "Installed" ); } elsif (/^Total (\d+) package\(s\)$/) { $total = $1; } elsif (/: Installed (?:by [\w-]+ )?\[[\w-]*:/) { next; } elsif (/: [\w-]+ (?:by [\w-]+ )?\[\w+:(out-of-date|partial)/) { $pu_total++; } $lastmsg = $_; } close( PIPE ); if ($?) { print ", 0, 0"; } else { # $total -= $n_state{"Not-For-Us"}; if ( $previously_built ) { print ", ".$n_state{"Installed"}.", ".$pu_total; } else { print ", ".$n_state{"Installed"}.", ".$total; } } } print "\n"; exit 0; sub isin { my $val = shift; return grep( $_ eq $val, @_ ); }