]> git.donarmstrong.com Git - bugscan.git/blob - bugreport
check oldstable bug totals
[bugscan.git] / bugreport
1 #!/usr/bin/perl
2 # vim: ts=8 sw=8 nowrap
3
4 # Generate a report of the release-critical bugs for packages
5
6 use Getopt::Std;
7 use File::Basename;
8 use lib dirname(__FILE__);
9 use bugcfg;
10 use scanlib;
11 use strict;
12 use warnings;
13
14 my $Version             = "BugReport 1.4\nCopyright (C) 1998-2002 Wichert Akkerman <wakkerma\@debian.org>\n";
15 my $html                = 0;
16 my $statusfile          = "status";
17
18 sub ShowVersion() {
19         print "$Version\n";
20         exit 0;
21 }
22
23 sub ShowUsage() {
24         print <<EOF;
25 Usage:
26   $0 [-V] [-h] [-H] [-l] [-s] [-b] [-t] [-d distrib] [-S file] [-C file]
27 Options:
28   -V    show version
29   -h    show some (hopefully) helpful information
30   -H    produce HTML output
31   -l    list all release-critical bugs
32   -s    list bug statistics
33   -b    show bugs relevant for stable only
34   -t    show bugs relevant for testing only
35   -d    only list these distributions (comma-separated)
36   -S    use different statusfile
37 EOF
38         exit 0;
39 }
40
41 sub PrintPackageHeader() {
42         my $p   = shift;        # Package to print
43         my ($name, $email);     # Name & email of maintainer
44
45         if ($html) {
46                 print "<div class=\"package\"><pre>";
47                 print "<a name=\"$p\"><strong>Package:</strong></a> " . scanlib::wwwname($p);
48                 if (defined($scanlib::section{$p})) {
49                         print " ($scanlib::section{$p}).\n";
50                 } else {
51                         print " (unknown).\n";
52                 }
53                 print "<strong>Maintainer:</strong> ";
54                 if (exists($scanlib::maintainer{$p}) && $scanlib::maintainer{$p} ne '') {
55                         if ($scanlib::maintainer{$p} =~ /(.*) <([^>]*)>/) {
56                                 ($name,$email) = ($1,$2);
57                         } elsif ($scanlib::maintainer{$p} =~ /<(.*) \((.*)\)>/) {
58                                 ($name,$email) = ($1,$2);
59                         } elsif ($scanlib::maintainer{$p} =~ /<(.*)>/) {
60                                 $name = $email = $1;
61                         }
62                         if (defined($name)) {
63                                 print "$name &lt;<a href=\"http://bugs.debian.org/$email\">$email</A>&gt;\n";
64                         } else {
65                                 print "$scanlib::maintainer{$p}\n";
66                         }
67                 } else {
68                         print "unknown\n";
69                 }
70         } else {
71                 print "\nPackage: $p ($scanlib::section{$p})\n";
72                 print "Maintainer: " . (defined($scanlib::maintainer{$p}) ? $scanlib::maintainer{$p} : "unknown") . "\n";
73         }
74 }
75
76 sub PrintPackageFooter() {
77         my $p   = shift;        # Package to print
78
79         if ($html) {
80                 print "</pre></div>\n";
81         }
82 }
83
84 sub MakeBuglist() {
85         my $p;                          # Index variable
86         my $nr;                 # Current bugnumber
87         my $sect;                       # BTS-subsection for bugnumber
88         my $header;             # Flag if packagename has already been printed
89
90         for my $p (sort {$a cmp $b} keys %scanlib::packagelist) {
91                 $header = 0;
92                 for $nr (sort @{$scanlib::packagelist{$p}}) {
93                         if (! $header) {
94                                 $header = 1;
95                                 &PrintPackageHeader($p);
96                         }
97
98                         if ($html) {
99                                 my $worry = scanlib::check_worry($scanlib::bugs{$nr});
100                         
101                                 if ($scanlib::bugs{$nr}->{'pending'}) {
102                                         print '<span style="color: #f040d0">';
103                                 } elsif ($scanlib::bugs{$nr}->{'patch'}) {
104                                         print '<span style="color: #00aa00">';
105                                 } elsif ($scanlib::bugs{$nr}->{'help'}) {
106                                         print '<span style="color: #ffaa30">';
107                                 }
108                                 print "<strike>" if ($scanlib::bugs{$nr}->{$bugcfg::debian_releases->{stable}.'-ignore'} || $scanlib::bugs{$nr}->{$bugcfg::debian_releases->{testing}.'-ignore'});
109                                 print "<em class=\"worry\">" if $worry;
110                                 ($sect=$nr) =~ s/([0-9]{2}).*/$1/;
111                                 printf "<A NAME=\"$nr\"></A>  %s [%s] [%s] %s\n", scanlib::wwwnumber($nr),
112                                         scanlib::get_taginfo($scanlib::bugs{$nr}),
113                                         scanlib::get_relinfo($scanlib::bugs{$nr}), 
114                                         scanlib::htmlsanit($scanlib::bugs{$nr}->{'subject'});
115                                 print "</em>" if $worry;
116                                 print "</strike>" if ($scanlib::bugs{$nr}->{$bugcfg::debian_releases->{stable}.'-ignore'} || $scanlib::bugs{$nr}->{$bugcfg::debian_releases->{testing}.'-ignore'});
117                         } else {
118                                 printf("  %-6d [%s] [%s] %s\n", $nr, scanlib::get_taginfo($scanlib::bugs{$nr}),
119                                         scanlib::get_relinfo($scanlib::bugs{$nr}), $scanlib::bugs{$nr}->{'subject'});
120                         }
121                         print "</span>" if ($html && ($scanlib::bugs{$nr}->{'pending'} ||
122                                                       $scanlib::bugs{$nr}->{'patch'} ||
123                                                                                   $scanlib::bugs{$nr}->{'help'}));
124                 }
125                 if ($header) {
126                         &PrintPackageFooter($p);
127                 }
128         }
129 }
130
131
132 sub MakeStatistics {
133         my $bugcount=0;         # Total number of bugs so far
134         my $patchtotal=0;       # Total number of bugs marked patch
135         my $pendingtotal=0;     # Total number of bugs marked pending
136         my $ignoretotal=0;      # Total number of bugs marked ignore
137         my $worrytotal=0;       # Total number of bugs we're actually worried about
138         my $stabletotal=0;      # Total number of bugs affecting stable
139         my %list;               # List of bugnumber associated with package
140         my %seen_bugs;          # bugs which have already been counted
141
142         for my $p (sort keys %scanlib::packagelist) {
143                 my $count = 0;          # Number of bugs for this package
144
145                 for my $nr (@{$scanlib::packagelist{$p}}) {
146                     # if we've already counted this bug, we don't want to count it again
147                     next if $seen_bugs{$nr};
148                     $seen_bugs{$nr} = 1;
149                         $pendingtotal++ if ($scanlib::bugs{$nr}->{'pending'});
150                         $patchtotal++ if ($scanlib::bugs{$nr}->{'patch'});
151                         $ignoretotal++ if ($scanlib::bugs{$nr}->{$bugcfg::debian_releases->{stable}.'-ignore'} || $scanlib::bugs{$nr}->{$bugcfg::debian_releases->{testing}.'-ignore'});
152                         $worrytotal++ if (scanlib::check_worry($scanlib::bugs{$nr}));
153                         $stabletotal++ if (scanlib::check_worry_stable($scanlib::bugs{$nr}));
154                         $oldstabletotal++ if (scanlib::check_worry_oldstable($scanlib::bugs{$nr}));
155
156                         $bugcount++;
157                         $count++;
158                 }
159         }
160
161         if ($html) {
162                 print "<strong><font color=\"red\">Total number of release-critical bugs</font>:</strong> $bugcount<BR>\n";
163                 printf("<strong>Number that have a patch:</strong> %d<BR>\n", $patchtotal);
164                 printf("<strong>Number that have a fix prepared and waiting to upload:</strong> %d<BR>\n", $pendingtotal);
165                 printf("<strong>Number that are being ignored:</strong> %d<BR>\n", $ignoretotal);
166                 printf("<strong><font color=\"blue\">Number concerning the current stable release</font>:</strong> %d<BR>\n", $stabletotal);
167                 printf("<strong><font color=\"green\">Number concerning the next release</font>:</strong> %d<P>\n", $worrytotal);
168                 printf("<strong><font color=\"green\">Number concerning the previous stable release</font>:</strong> %d<P>\n", $oldstabletotal);
169         } else {
170                 print "Total number of release-critical bugs: $bugcount\n";
171                 printf("Number that have a patch: %d\n", $patchtotal);
172                 printf("Number that have a fix prepared and waiting to upload: %d\n", $pendingtotal);
173                 printf("Number that are being ignored: %d\n", $ignoretotal);
174                 printf("Number concerning the current stable release: %d\n", $stabletotal);
175                 printf("Number concerning the next release: %d\n", $worrytotal);
176                 printf("Number concerning the previous stable release: %d\n", $oldstabletotal);
177         }
178 }
179
180
181 sub FilterPackages($) {
182         my $filter = shift;             # Distribution we want to keep
183
184         for my $p (sort keys %scanlib::packagelist) {
185                 delete $scanlib::packagelist{$p} unless (defined $scanlib::section{$p} and
186                                                          $scanlib::section{$p} =~ m/^$filter/);
187         }
188 }
189
190 sub FilterBugs() {
191         for my $p (sort keys %scanlib::packagelist) {
192                 $scanlib::packagelist{$p} = [ grep { scanlib::check_worry($scanlib::bugs{$_}) } @{$scanlib::packagelist{$p}} ];
193                 delete $scanlib::packagelist{$p} if (scalar @{$scanlib::packagelist{$p}} == 0);
194         }
195 }
196
197 sub FilterBugsStable() {
198         for my $p (sort keys %scanlib::packagelist) {
199                 $scanlib::packagelist{$p} = [ grep { scanlib::check_worry_stable($scanlib::bugs{$_}) } @{$scanlib::packagelist{$p}} ];
200                 delete $scanlib::packagelist{$p} if (scalar @{$scanlib::packagelist{$p}} == 0);
201         }
202
203 sub FilterBugsOldStable() {
204         for my $p (sort keys %scanlib::packagelist) {
205                 $scanlib::packagelist{$p} = [ grep { scanlib::check_worry_oldstable($scanlib::bugs{$_}) } @{$scanlib::packagelist{$p}} ];
206                 delete $scanlib::packagelist{$p} if (scalar @{$scanlib::packagelist{$p}} == 0);
207         }
208 }
209
210 our ($opt_h,$opt_V,$opt_S,$opt_H,$opt_d,$opt_b,$opt_t,$opt_s,$opt_l,$opt_o);
211
212 getopts('VhHlsbtod:S:');
213 ShowUsage if ($opt_h);
214 ShowVersion if ($opt_V);
215 $statusfile=$opt_S if ($opt_S);
216 $html=1 if ($opt_H);
217
218 scanlib::readstatus($statusfile);
219
220 FilterPackages($opt_d) if ($opt_d);
221 FilterBugsStable() if ($opt_b);
222 FilterBugs() if ($opt_t);
223 FilterBugsOldStable() if ($opt_o);
224
225 MakeStatistics() if ($opt_s);
226 if ($opt_l) {
227         MakeBuglist();
228 }
229
230 exit 0;
231