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