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