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