+ }
+}
+
+
+sub MakeStatistics {
+ my $bugcount=0; # Total number of bugs so far
+ my $patchtotal=0; # Total number of bugs marked patch
+ my $pendingtotal=0; # Total number of bugs marked pending
+ my $ignoretotal=0; # Total number of bugs marked ignore
+ my $worrytotal=0; # Total number of bugs we're actually worried about
+ my $stabletotal=0; # Total number of bugs affecting stable
+ my $oldstabletotal=0; # Total number of bugs affecting oldstable
+ my %list; # List of bugnumber associated with package
+ my %seen_bugs; # bugs which have already been counted
+
+ for my $p (sort keys %scanlib::packagelist) {
+ my $count = 0; # Number of bugs for this package
+
+ for my $nr (@{$scanlib::packagelist{$p}}) {
+ # if we've already counted this bug, we don't want to count it again
+ next if $seen_bugs{$nr};
+ $seen_bugs{$nr} = 1;
+ $pendingtotal++ if ($scanlib::bugs{$nr}->{'pending'});
+ $patchtotal++ if ($scanlib::bugs{$nr}->{'patch'});
+ $ignoretotal++ if ($scanlib::bugs{$nr}->{$bugcfg::debian_releases->{stable}.'-ignore'} || $scanlib::bugs{$nr}->{$bugcfg::debian_releases->{testing}.'-ignore'});
+ $worrytotal++ if (scanlib::check_worry($scanlib::bugs{$nr}));
+ $stabletotal++ if (scanlib::check_worry_stable($scanlib::bugs{$nr}));
+ $oldstabletotal++ if (scanlib::check_worry_oldstable($scanlib::bugs{$nr}));
+
+ $bugcount++;
+ $count++;
+ }
+ }
+
+ if ($html) {
+ print "<strong><font color=\"#9400D3\">Total number of release-critical bugs</font>:</strong> $bugcount<BR>\n";
+ printf("<strong>Number that have a patch:</strong> %d<BR>\n", $patchtotal);
+ printf("<strong>Number that have a fix prepared and waiting to upload:</strong> %d<BR>\n", $pendingtotal);
+ printf("<strong>Number that are being ignored:</strong> %d<BR>\n", $ignoretotal);
+ printf("<strong><font color=\"#56b4e9\">Number concerning the current stable release</font>:</strong> %d<BR>\n", $stabletotal);
+ printf("<strong><font color=\"#009e73\">Number concerning the next release</font>:</strong> %d<P>\n", $worrytotal);
+ printf("<strong><font color=\"#e69f00\">Number concerning the previous stable release</font>:</strong> %d<P>\n", $oldstabletotal);
+ } else {
+ print "Total number of release-critical bugs: $bugcount\n";
+ printf("Number that have a patch: %d\n", $patchtotal);
+ printf("Number that have a fix prepared and waiting to upload: %d\n", $pendingtotal);
+ printf("Number that are being ignored: %d\n", $ignoretotal);
+ printf("Number concerning the current stable release: %d\n", $stabletotal);
+ printf("Number concerning the next release: %d\n", $worrytotal);
+ printf("Number concerning the previous stable release: %d\n", $oldstabletotal);
+ }
+}
+
+
+sub FilterPackages($) {
+ my $filter = shift; # Distribution we want to keep
+
+ for my $p (sort keys %scanlib::packagelist) {
+ delete $scanlib::packagelist{$p} unless (defined $scanlib::section{$p} and
+ $scanlib::section{$p} =~ m/^$filter/);
+ }
+}
+
+sub FilterBugs() {
+ for my $p (sort keys %scanlib::packagelist) {
+ $scanlib::packagelist{$p} = [ grep { scanlib::check_worry($scanlib::bugs{$_}) } @{$scanlib::packagelist{$p}} ];
+ delete $scanlib::packagelist{$p} if (scalar @{$scanlib::packagelist{$p}} == 0);
+ }
+}
+
+sub FilterBugsStable() {
+ for my $p (sort keys %scanlib::packagelist) {
+ $scanlib::packagelist{$p} = [ grep { scanlib::check_worry_stable($scanlib::bugs{$_}) } @{$scanlib::packagelist{$p}} ];
+ delete $scanlib::packagelist{$p} if (scalar @{$scanlib::packagelist{$p}} == 0);
+ }
+}
+sub FilterBugsOldStable() {
+ for my $p (sort keys %scanlib::packagelist) {
+ $scanlib::packagelist{$p} = [ grep { scanlib::check_worry_oldstable($scanlib::bugs{$_}) } @{$scanlib::packagelist{$p}} ];
+ delete $scanlib::packagelist{$p} if (scalar @{$scanlib::packagelist{$p}} == 0);
+ }
+}
+
+our ($opt_h,$opt_V,$opt_S,$opt_H,$opt_d,$opt_b,$opt_t,$opt_s,$opt_l,$opt_o);
+
+getopts('VhHlsbtod:S:');
+ShowUsage if ($opt_h);
+ShowVersion if ($opt_V);
+$statusfile=$opt_S if ($opt_S);
+$html=1 if ($opt_H);
+
+scanlib::readstatus($statusfile);
+
+FilterPackages($opt_d) if ($opt_d);
+FilterBugsStable() if ($opt_b);
+FilterBugs() if ($opt_t);
+FilterBugsOldStable() if ($opt_o);
+
+MakeStatistics() if ($opt_s);
+if ($opt_l) {
+ MakeBuglist();
+}
+
+exit 0;
+