Remove the notice about the beta; we _are_ the beta :-)
[bugscan.git] / bugdiff
1 #!/usr/bin/perl
2 # vim: ts=4 sw=4 nowrap
3
4 # Compare two buglist status-files
5
6 use Getopt::Std;
7 require scanlib;
8 require bugcfg;
9
10 $Version                = "BugDiff 1.0\nCopyright (C) Wichert Akkerman <wakkerma\@debian.org>\n";
11 $html                   = 0;
12
13
14 sub ShowVersion() {
15         print "$Version\n";
16         exit 0;
17 }
18
19 sub ShowUsage() {
20         print <<EOF;
21 Usage:
22   $0 [-V] [-h] [-H] <status1> <status2>
23 Options:
24   -V    show version
25   -h    show some (hopefully) helpfull information
26   -H    produce HTML output
27   -n    list newly opened bugs
28   -c    list closed bugs
29   -s    show statistics
30 EOF
31         exit 0;
32 }
33
34 sub closedbugs() {
35         if ($html) {
36                 if (%removed) {
37                         print "<h2>Closed/downgraded release-critical bugs</h2>\n";
38                         print "<ul>\n";
39                         for $p (sort keys %removed) {
40                                 print "  <li><em>" . &wwwname($p) . ":</em>\n";
41                                 for $b (sort split(/ /, $removed{$p})) {
42                                         print &wwwnumber($b) . " ";
43                                 }
44                                 print "\n";
45                         }
46                         print "</ul>\n";
47                 }
48         } else {
49                 print "Closed/downgraded release-critical bugs:\n" if (%removed>0);
50                 for $p (sort keys %removed) {
51                         print "   $p: ";
52                         print join(", ", sort split(/ /, $removed{$p}));
53                         print "\n";
54                 }
55         }
56 }
57
58
59 sub openedbugs() {
60         if ($html) {
61                 if (%new) {
62                         print "<h2>Opened/upgraded release-critical bugs</h2>\n";
63                         print "<ul>\n";
64                         for $p (sort keys %new) {
65                                 print "  <li><em>" . &wwwname($p) . ":</em>\n";
66                                 for $b (sort split(/ /, $new{$p})) {
67                                         print &wwwnumber($b) . " ";
68                                 }
69                                 print "\n";
70                         }
71                         print "</ul>\n";
72                 }
73         } else {
74                 print "Opened/upgraded release-critical bugs:\n" if (%new);
75                 for $p (sort keys %new) {
76                         print "   $p: ";
77                         print join(", ", sort split(/ /, $new{$p}));
78                         print "\n";
79                 }
80         }
81 }
82
83 sub statistics() {
84         if ($html) {
85                 print "<STRONG>" . ($closed ? $closed : "NO") . "</STRONG> release-critical bugs were closed and ";
86                 print "<STRONG>" . ($opened ? $opened : "NONE") . "</STRONG> were opened.<P>\n";
87         } else {
88                 print "" . ($closed ? $closed : "NO") . " release-critical bugs were closed ";
89                 print "and " . ($opened ? $opened : "NONE") . " were opened.\n\n";
90         }
91 }
92
93 getopts('VhHncs');
94 ShowUsage if ($opt_h or ($#ARGV != 1));
95 ShowVersion if ($opt_V);
96 $html=1 if ($opt_H);
97
98 &readstatus($ARGV[0]);
99 %oldbugs=%packagelist;
100 %packagelist=();
101
102 &readstatus($ARGV[1]);
103
104 $closed=0;
105 for $p (keys %oldbugs) {
106         for $b (split(/ /, $oldbugs{$p})) {
107                 if (not ($packagelist{$p} =~ m/\b$b\b/)) {
108                         $removed{$p} .= "$b ";
109                         $closed++;
110                 }
111         }
112 }
113
114 $opened=0;
115 for $p (keys %packagelist) {
116         for $b (split(/ /, $packagelist{$p})) {
117                 if (not ($oldbugs{$p} =~ m/\b$b\b/)) {
118                         $new{$p} .= "$b ";
119                         $opened++;
120                 }
121         }
122 }
123
124 statistics if ($opt_s);
125 closedbugs if ($opt_c);
126 openedbugs if ($opt_n);
127
128 exit 0;