]> git.donarmstrong.com Git - bugscan.git/blob - bugreport
strictify bugcounts, so it works.
[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> " . &wwwname($p);
50                 print " ($scanlib::section{$p}).\n";
51                 print "<strong>Maintainer:</strong> ";
52                 if (defined($scanlib::maintainer{$p})) {
53                         $_ = $scanlib::maintainer{$p};
54                         ($name,$email) = m/(.*) <([^>]*)>/;
55                         print "$name &lt;<a href=\"http://bugs.debian.org/$email\">$email</A>&gt;\n";
56                 } else {
57                         print "unknown\n";
58                 }
59         } else {
60                 print "\nPackage: $p ($scanlib::section{$p})\n";
61                 print "Maintainer: " . (defined($scanlib::maintainer{$p}) ? $scanlib::maintainer{$p} : "unknown") . "\n";
62         }
63 }
64
65 sub PrintPackageFooter() {
66         my $p   = shift;        # Package to print
67
68         if ($html) {
69                 print "</pre></div>\n";
70         }
71 }
72
73 sub MakeBuglist() {
74         my $p;                          # Index variable
75         my $nr;                 # Current bugnumber
76         my $sect;                       # BTS-subsection for bugnumber
77         my $header;             # Flag if packagename has already been printed
78         my $fontset;            # Did we change the font?
79
80         for my $p (sort {$a cmp $b} keys %scanlib::packagelist) {
81                 next if (defined $bugcfg::exclude{$p});
82                 $header = 0;
83                 $fontset = 0;
84                 if (defined $scanlib::comments{$p}) {
85                         if ($html && defined($scanlib::comments{$p})) {
86                                 if ($scanlib::comments{$p} =~ m/^\[REMOVE\]/) {
87                                         $fontset=1;
88                                         print "<span style=\"color: red\">";
89                                 }
90                         }
91                         $header=1;
92                         &PrintPackageHeader($p);
93                         print $scanlib::comments{$p};
94                 }
95                 for $nr (sort split(/ /, $scanlib::packagelist{$p})) {
96                         next if (defined $bugcfg::exclude{$nr});
97                         if (! $header) {
98                                 $header = 1;
99                                 &PrintPackageHeader($p);
100                         }
101
102                         if ($html) {
103                                 my $worry = scanlib::check_worry($scanlib::bugs{$nr});
104                         
105                                 if ($scanlib::bugs{$nr} =~ m/ \[[^]]*X/) {
106                                         print '<span style="color: #808080">';
107                                 } elsif ($scanlib::bugs{$nr} =~ m/^\[[^]]*P/) {
108                                         print '<span style="color: #f040d0">';
109                                 } elsif ($scanlib::bugs{$nr} =~ m/^\[[^]]*\+/) {
110                                         print '<span style="color: #00aa00">';
111                                 } elsif ($scanlib::bugs{$nr} =~ m/^\[[^]]*H/) {
112                                         print '<span style="color: #ffaa30">';
113                                 }
114                                 print "<strike>" if ($scanlib::bugs{$nr} =~ m/^\[.......I\]/);
115                                 print "<em class=\"worry\">" if $worry;
116                                 ($sect=$nr) =~ s/([0-9]{2}).*/$1/;
117                                 print "<A NAME=\"$nr\"></A>  " . &wwwnumber($nr) . ' ' .
118                                           htmlsanit($scanlib::bugs{$nr}) . "\n";
119                                 print "</em>" if $worry;
120                                 print "</strike>" if ($scanlib::bugs{$nr} =~ m/^\[.......I\]/);
121                         } else {
122                                 printf("  %-6d %s\n", $nr, $scanlib::bugs{$nr});
123                         }
124                         print $scanlib::comments{$nr} if (defined($scanlib::comments{$nr}));
125                         print "[FIX] Fixed by package " . $scanlib::NMU{$nr, "source"} . ", version " . $scanlib::NMU{$nr, "version"} . " in Incoming\n" if (defined $scanlib::NMU{$nr});
126                         print "</span>" if ($html && ($scanlib::bugs{$nr} =~ m/^\[[^]]*[H+P]/ ||
127                                                       $scanlib::bugs{$nr} =~ m/ \[[^]]*X/));
128                 }
129                 print "</span>" if ($fontset);
130                 if ($header) {
131                         &PrintPackageFooter($p);
132                 }
133         }
134 }
135
136
137 sub MakeStatistics() {
138         my $bugcount;           # Total number of bugs so far
139         my $count;              # Number of bugs for this package
140         my $remtotal;           # Total number of bugs for packages marked REMOVE
141         my $patchtotal;         # Total number of bugs marked patch
142         my $pendingtotal;       # Total number of bugs marked pending
143         my $ignoretotal;        # Total number of bugs marked ignore
144         my $nottestingtotal;    # Total number of bugs on packages not in testing
145         my $worrytotal;         # Total number of bugs we're actually worried about
146         my $p;                  # Index variable
147         my %list;               # List of bugnumber associated with package
148
149         $bugcount=0;
150         for my $p (sort keys %scanlib::packagelist) {
151                 next if (defined $scanlib::exclude{$p});
152                 $count=0;
153                 for my $nr (split(/ /, $scanlib::packagelist{$p})) {
154                         $pendingtotal++ if ($scanlib::bugs{$nr} =~ m/^\[[^]]*P/);
155                         $patchtotal++ if ($scanlib::bugs{$nr} =~ m/^\[[^]]*\+/);
156                         $ignoretotal++ if ($scanlib::bugs{$nr} =~ m/^\[[^]]*I/);
157                         $nottestingtotal++ if ($scanlib::bugs{$nr} =~ m/ \[[^]]*X/);
158                         $worrytotal++ unless (
159                                 $scanlib::bugs{$nr} =~ m/^\[[^]]*I/ or
160                                 $scanlib::bugs{$nr} =~ m/ \[[^]]*X/ or
161                                 ($scanlib::bugs{$nr} =~ m/ \[[^]]*[OSUE]/ and $scanlib::bugs{$nr} !~ m/ \[[^]]*T/));
162
163                         if (not defined($scanlib::exclude{$nr})) {
164                                 $bugcount++;
165                                 $count++;
166                         } 
167                 }
168                 $remtotal+=$count if (defined($scanlib::comments{$p}) && $scanlib::comments{$p} =~ m/^\[REMOVE\]/);
169         }
170
171         if ($html) {
172                 print "<strong>Total number of release-critical bugs:</strong> $bugcount<BR>\n";
173                 printf("<strong>Number that will disappear after removing packages marked [REMOVE]:</strong> %d<BR>\n", $remtotal);
174                 printf("<strong>Number that have a patch:</strong> %d<BR>\n", $patchtotal);
175                 printf("<strong>Number that have a fix prepared and waiting to upload:</strong> %d<BR>\n", $pendingtotal);
176                 printf("<strong>Number that are being ignored:</strong> %d<BR>\n", $ignoretotal);
177                 printf("<strong>Number on packages not in testing:</strong> %d<BR>\n", $nottestingtotal);
178                 printf("<strong>Number concerning the next release (excluding ignored and not-in-testing):</strong> %d<P>\n", $worrytotal);
179         } else {
180                 print "Total number of release-critical bugs: $bugcount\n";
181                 printf("Number that will disappear after removing packages marked [REMOVE]: %d\n", $remtotal);
182                 printf("Number that have a patch: %d\n", $patchtotal);
183                 printf("Number that have a fix prepared and waiting to upload: %d\n", $pendingtotal);
184                 printf("Number that are being ignored: %d\n", $ignoretotal);
185                 printf("Number on packages not in testing: %d\n", $nottestingtotal);
186                 printf("Number concerning the next release (excluding ignored and not-in-testing): %d\n", $worrytotal);
187         }
188 }
189
190
191 sub FilterPackages() {
192         my $filter = shift;             # Distribution we want to keep
193
194         for my $p (sort keys %scanlib::packagelist) {
195                 delete $scanlib::packagelist{$p} unless ($scanlib::section{$p} =~ m/^$filter/);
196         }
197 }
198
199 sub FilterBugs() {
200         for my $p (sort keys %scanlib::packagelist) {
201                 $scanlib::packagelist{$p} = join(' ', grep { check_worry($scanlib::bugs{$_}) } split / /, $scanlib::packagelist{$p});
202                 delete $scanlib::packagelist{$p} if ($scanlib::packagelist{$p} eq '');
203         }
204 }
205
206 my ($opt_h,$opt_V,$opt_S,$opt_C,$opt_H,$opt_d,$opt_t,$opt_s,$opt_l);
207
208 getopts('VhHlstd:S:C:');
209 ShowUsage if ($opt_h);
210 ShowVersion if ($opt_V);
211 $statusfile=$opt_S if ($opt_S);
212 $commentsfile=$opt_C if ($opt_C);
213 $html=1 if ($opt_H);
214
215 scanlib::readstatus($statusfile);
216 scanlib::readcomments($commentsfile);
217 # scanlib::readNMUstatus($NMUfile);
218
219 &FilterPackages($opt_d) if ($opt_d);
220 &FilterBugs() if ($opt_t);
221
222 MakeStatistics if ($opt_s);
223 if ($opt_l) {
224         MakeBuglist 
225 }
226
227 exit 0;
228