]> git.donarmstrong.com Git - bugscan.git/blob - bugcounts
A bit less repeated code, replaced by a for loop.
[bugscan.git] / bugcounts
1 #! /usr/bin/perl
2 # vim: ts=4 sw=4 nowrap
3
4 # Generate some counts for the bugreports
5
6 use Getopt::Std;
7 require scanlib;
8 require bugcfg;
9 use strict;
10 use warnings;
11
12 my $Version             = "BugCount 1.1\nCopyright (C) Wichert Akkerman <wakkerma\@debian.org>\n";
13 my $statusfile          = "status";
14 my $commentsfile        = "comments";
15
16 sub ShowVersion() {
17         print "$Version\n";
18         exit 0;
19 }
20
21 sub ShowUsage() {
22         print <<EOF;
23 Usage:
24   $0 [-V] [-h] [-S file] [-C file]
25 Options:
26   -V    show version
27   -h    show some (hopefully) helpfull information
28   -S    use different statusfile
29   -C    use different commentsfile
30 EOF
31         exit 0;
32 }
33
34 our ($opt_h,$opt_V,$opt_S,$opt_C);
35
36 getopts('VhS:C:');
37 ShowUsage if ($opt_h);
38 ShowVersion if ($opt_V);
39 $statusfile=$opt_S if ($opt_S);
40 $commentsfile=$opt_C if ($opt_C);
41
42 scanlib::readstatus($statusfile);
43 scanlib::readcomments($commentsfile);
44
45 my $total=0;            # total number of bugs
46 my $removecount=0;      # Number of bugs that will disappear if packages are removed
47 my $patchcount=0;       # Number of bugs that have a fix proposed
48 my $pendingcount=0;     # Number of bugs that will have a fix uploaded RSN
49 my $ignorecount=0;      # Number of bugs being ignored
50 my $nottestingcount=0;  # Number of bugs on packages not in testing
51 my $worrycount=0;       # Number of bugs we're actually worried about
52 my %sectcount=();       # Bugs per type
53
54 for my $p (keys %scanlib::packagelist) {
55         next if (defined $bugcfg::exclude{$p});
56         for my $nr (sort @{$scanlib::packagelist{$p}}) {
57                 next if (defined $bugcfg::exclude{$nr});
58                 $total++;
59                 $pendingcount++ if ($scanlib::bugs{$nr} =~ m/^\[[^]]*P/);
60                 $patchcount++ if ($scanlib::bugs{$nr} =~ m/^\[[^]]*\+/);
61                 $ignorecount++ if ($scanlib::bugs{$nr} =~ m/^\[[^]]*I/);
62                 $nottestingcount++ if ($scanlib::bugs{$nr} =~ m/ \[[^]]*X/);
63                 if (defined $scanlib::comments{$nr}) {
64                         my $sect = ($scanlib::comments{$nr} =~ m/\[([^]]*)\]/);
65                         $sectcount{$sect}++;
66                 }
67                 unless ($scanlib::bugs{$nr} =~ m/^\[[^]]*I/ or
68                         $scanlib::bugs{$nr} =~ m/ \[[^]]*X/ or
69                         ($scanlib::bugs{$nr} =~ m/ \[[^]]*[OSUE]/ and $scanlib::bugs{$nr} !~ m/ \[[^]]*T/)) {
70                         $worrycount++;
71                         # print STDERR "$nr $bugs{$nr}\n";
72                 }       
73         }
74
75         if (defined($scanlib::comments{$p}) && $scanlib::comments{$p} =~ m/^\[REMOVE\]/) {
76                 $removecount += scalar @{$scanlib::packagelist{$p}};
77         }
78 }
79
80 printf("%d %d %d %d %d %d %d\n", $total, $pendingcount, $patchcount, $removecount, $ignorecount, $nottestingcount, $worrycount);