Check that a package is really present in a distribution before putting
[bugscan.git] / bugreport
index 83c8736..1686ae8 100755 (executable)
--- a/bugreport
+++ b/bugreport
@@ -6,14 +6,12 @@
 use Getopt::Std;
 require scanlib;
 require bugcfg;
 use Getopt::Std;
 require scanlib;
 require bugcfg;
+use strict;
+use warnings;
 
 
-$Version               = "BugReport 1.4\nCopyright (C) 1998-2002 Wichert Akkerman <wakkerma\@debian.org>\n";
-$html                  = 0;
-$statusfile            = "status";
-$commentsfile  = "comments";
-$NMUfile               = "/debian/home/doogie/public_html/incoming/bugs_closed";
-$NMUfile               = "/debian/home/doogie/chgscan/db/bugs_closed"; # Changed as of request by dark  -Joey, 99/11/22
-$NMUfile               = "http://auric.debian.org/~doogie/incoming/bugs_closed"; # Changed as of request by dark  -Joey, 99/11/22
+my $Version            = "BugReport 1.4\nCopyright (C) 1998-2002 Wichert Akkerman <wakkerma\@debian.org>\n";
+my $html               = 0;
+my $statusfile         = "status";
 
 sub ShowVersion() {
        print "$Version\n";
 
 sub ShowVersion() {
        print "$Version\n";
@@ -23,44 +21,49 @@ sub ShowVersion() {
 sub ShowUsage() {
        print <<EOF;
 Usage:
 sub ShowUsage() {
        print <<EOF;
 Usage:
-  $0 [-V] [-h] [-H] [-l] -[s] [-d distrib] [-S file] [-C file]
+  $0 [-V] [-h] [-H] [-l] [-s] [-d distrib] [-S file] [-C file]
 Options:
   -V    show version
   -h    show some (hopefully) helpful information
   -H    produce HTML output
   -l    list all release-critical bugs
   -s    list bug statistics
 Options:
   -V    show version
   -h    show some (hopefully) helpful information
   -H    produce HTML output
   -l    list all release-critical bugs
   -s    list bug statistics
+  -t    show bugs relevant for testing only
   -d    only list these distributions (comma-separated)
   -S    use different statusfile
   -d    only list these distributions (comma-separated)
   -S    use different statusfile
-  -C    use different commentsfile
 EOF
        exit 0;
 }
 
 sub PrintPackageHeader() {
 EOF
        exit 0;
 }
 
 sub PrintPackageHeader() {
-       local($p)       = shift;        # Package to print
-       local ($name, $email);  # Name & email of maintainer
+       my $p   = shift;        # Package to print
+       my ($name, $email);     # Name & email of maintainer
 
        if ($html) {
 
        if ($html) {
-           print "<div class=\"package\"><pre>";
-               print "<a name=\"$p\"><strong>Package:</strong></a> " . &wwwname($p);
-               print " ($section{$p}).\n";
+               print "<div class=\"package\"><pre>";
+               print "<a name=\"$p\"><strong>Package:</strong></a> " . scanlib::wwwname($p);
+               print " ($scanlib::section{$p}).\n";
                print "<strong>Maintainer:</strong> ";
                print "<strong>Maintainer:</strong> ";
-               if (defined($maintainer{$p})) {
-                       $_ = $maintainer{$p};
-                       ($name,$email) = m/(.*) <([^>]*)>/;
+               if (defined($scanlib::maintainer{$p})) {
+                       if ($scanlib::maintainer{$p} =~ /(.*) <([^>]*)>/) {
+                               ($name,$email) = ($1,$2);
+                       } elsif ($scanlib::maintainer{$p} =~ /<(.*) \((.*)\)>/) {
+                               ($name,$email) = ($1,$2);
+                       } elsif ($scanlib::maintainer{$p} =~ /<(.*)>/) {
+                               $name = $email = $1;
+                       }
                        print "$name &lt;<a href=\"http://bugs.debian.org/$email\">$email</A>&gt;\n";
                } else {
                        print "unknown\n";
                }
        } else {
                        print "$name &lt;<a href=\"http://bugs.debian.org/$email\">$email</A>&gt;\n";
                } else {
                        print "unknown\n";
                }
        } else {
-               print "\nPackage: $p ($section{$p})\n";
-               print "Maintainer: " . (defined($maintainer{$p}) ? $maintainer{$p} : "unknown") . "\n";
+               print "\nPackage: $p ($scanlib::section{$p})\n";
+               print "Maintainer: " . (defined($scanlib::maintainer{$p}) ? $scanlib::maintainer{$p} : "unknown") . "\n";
        }
 }
 
 sub PrintPackageFooter() {
        }
 }
 
 sub PrintPackageFooter() {
-       local($p)       = shift;        # Package to print
+       my $p   = shift;        # Package to print
 
        if ($html) {
                print "</pre></div>\n";
 
        if ($html) {
                print "</pre></div>\n";
@@ -68,67 +71,46 @@ sub PrintPackageFooter() {
 }
 
 sub MakeBuglist() {
 }
 
 sub MakeBuglist() {
-       local ($p);                             # Index variable
-       local ($nr);                    # Current bugnumber
-       local ($sect);                  # BTS-subsection for bugnumber
-       local ($header);                # Flag if packagename has already been printed
-       local ($fontset);               # Did we change the font?
-
-       for $p (sort {$a cmp $b} keys %packagelist) {
-               next if (defined $exclude{$p});
+       my $p;                          # Index variable
+       my $nr;                 # Current bugnumber
+       my $sect;                       # BTS-subsection for bugnumber
+       my $header;             # Flag if packagename has already been printed
+
+       for my $p (sort {$a cmp $b} keys %scanlib::packagelist) {
+               next if (defined $bugcfg::exclude{$p});
                $header = 0;
                $header = 0;
-               $fontset = 0;
-               if (defined $comments{$p}) {
-                       if ($html && defined($comments{$p})) {
-                               if ($comments{$p} =~ m/^\[REMOVE\]/) {
-                                       $fontset=1;
-                                       print "<span style=\"color: red\">";
-                               }
-                       }
-                       $header=1;
-                       &PrintPackageHeader($p);
-                       print $comments{$p};
-               }
-               for $nr (sort split(/ /, $packagelist{$p})) {
-                       next if (defined $exclude{$nr});
+               for $nr (sort @{$scanlib::packagelist{$p}}) {
+                       next if (defined $bugcfg::exclude{$nr});
                        if (! $header) {
                                $header = 1;
                                &PrintPackageHeader($p);
                        }
 
                        if ($html) {
                        if (! $header) {
                                $header = 1;
                                &PrintPackageHeader($p);
                        }
 
                        if ($html) {
-                           $worry = 1;
-                               if ($bugs{$nr} =~ m/^\[[^]]*I/ or
-                                       $bugs{$nr} =~ m/ \[[^]]*X/ or
-                                       ($bugs{$nr} =~ m/ \[[^]]*[OSUE]/ and $bugs{$nr} !~ m/ \[[^]]*T/)) {
-                                       $worry = 0;
-                               }
+                               my $worry = scanlib::check_worry($scanlib::bugs{$nr});
                        
                        
-                               if ($bugs{$nr} =~ m/ \[[^]]*X/) {
+                               if ($scanlib::bugs{$nr} =~ m/ \[[^]]*X/) {
                                        print '<span style="color: #808080">';
                                        print '<span style="color: #808080">';
-                               } elsif ($bugs{$nr} =~ m/^\[[^]]*P/) {
+                               } elsif ($scanlib::bugs{$nr} =~ m/^\[[^]]*P/) {
                                        print '<span style="color: #f040d0">';
                                        print '<span style="color: #f040d0">';
-                               } elsif ($bugs{$nr} =~ m/^\[[^]]*\+/) {
+                               } elsif ($scanlib::bugs{$nr} =~ m/^\[[^]]*\+/) {
                                        print '<span style="color: #00aa00">';
                                        print '<span style="color: #00aa00">';
-                               } elsif ($bugs{$nr} =~ m/^\[[^]]*H/) {
+                               } elsif ($scanlib::bugs{$nr} =~ m/^\[[^]]*H/) {
                                        print '<span style="color: #ffaa30">';
                                }
                                        print '<span style="color: #ffaa30">';
                                }
-                               print "<strike>" if ($bugs{$nr} =~ m/^\[.......I\]/);
+                               print "<strike>" if ($scanlib::bugs{$nr} =~ m/^\[.......I\]/);
                                print "<em class=\"worry\">" if $worry;
                                ($sect=$nr) =~ s/([0-9]{2}).*/$1/;
                                print "<em class=\"worry\">" if $worry;
                                ($sect=$nr) =~ s/([0-9]{2}).*/$1/;
-                               print "<A NAME=\"$nr\"></A>  " . &wwwnumber($nr) . ' ' .
-                                         htmlsanit($bugs{$nr}) . "\n";
+                               print "<A NAME=\"$nr\"></A>  " . scanlib::wwwnumber($nr) . ' ' .
+                                         scanlib::htmlsanit($scanlib::bugs{$nr}) . "\n";
                                print "</em>" if $worry;
                                print "</em>" if $worry;
-                               print "</strike>" if ($bugs{$nr} =~ m/^\[.......I\]/);
+                               print "</strike>" if ($scanlib::bugs{$nr} =~ m/^\[.......I\]/);
                        } else {
                        } else {
-                               printf("  %-6d %s\n", $nr, $bugs{$nr});
+                               printf("  %-6d %s\n", $nr, $scanlib::bugs{$nr});
                        }
                        }
-                       print $comments{$nr} if (defined($comments{$nr}));
-                       print "[FIX] Fixed by package " . $NMU{$nr, "source"} . ", version " . $NMU{$nr, "version"} . " in Incoming\n" if (defined $NMU{$nr});
-                       print "</span>" if ($html && ($bugs{$nr} =~ m/^\[[^]]*[H+P]/ ||
-                                                     $bugs{$nr} =~ m/ \[[^]]*X/));
+                       print "</span>" if ($html && ($scanlib::bugs{$nr} =~ m/^\[[^]]*[H+P]/ ||
+                                                     $scanlib::bugs{$nr} =~ m/ \[[^]]*X/));
                }
                }
-               print "</span>" if ($fontset);
                if ($header) {
                        &PrintPackageFooter($p);
                }
                if ($header) {
                        &PrintPackageFooter($p);
                }
@@ -137,42 +119,34 @@ sub MakeBuglist() {
 
 
 sub MakeStatistics() {
 
 
 sub MakeStatistics() {
-       local($bugcount);               # Total number of bugs so far
-       local($count);                  # Number of bugs for this package
-       local($remtotal);               # Total number of bugs for packages marked REMOVE
-       local($patchtotal);             # Total number of bugs marked patch
-       local($pendingtotal);           # Total number of bugs marked pending
-       local($ignoretotal);            # Total number of bugs marked ignore
-       local($nottestingtotal);        # Total number of bugs on packages not in testing
-       local($worrytotal);             # Total number of bugs we're actually worried about
-       local($p);                              # Index variable
-       local(%list);                   # List of bugnumber associated with package
-
-       $bugcount=0;
-       for $p (sort keys %packagelist) {
-               next if (defined $exclude{$p});
-               $count=0;
-               for $nr (split(/ /, $packagelist{$p})) {
-                       $pendingtotal++ if ($bugs{$nr} =~ m/^\[[^]]*P/);
-                       $patchtotal++ if ($bugs{$nr} =~ m/^\[[^]]*\+/);
-                       $ignoretotal++ if ($bugs{$nr} =~ m/^\[[^]]*I/);
-                       $nottestingtotal++ if ($bugs{$nr} =~ m/ \[[^]]*X/);
-                       $worrytotal++ unless (
-                               $bugs{$nr} =~ m/^\[[^]]*I/ or
-                               $bugs{$nr} =~ m/ \[[^]]*X/ or
-                               ($bugs{$nr} =~ m/ \[[^]]*[OSUE]/ and $bugs{$nr} !~ m/ \[[^]]*T/));
-
-                       if (not defined($exclude{$nr})) {
+       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 $nottestingtotal=0;  # Total number of bugs on packages not in testing
+       my $worrytotal=0;       # Total number of bugs we're actually worried about
+       my %list;               # List of bugnumber associated with package
+
+       for my $p (sort keys %scanlib::packagelist) {
+               my $count = 0;          # Number of bugs for this package
+
+               next if (defined $scanlib::exclude{$p});
+               for my $nr (@{$scanlib::packagelist{$p}}) {
+                       $pendingtotal++ if ($scanlib::bugs{$nr} =~ m/^\[[^]]*P/);
+                       $patchtotal++ if ($scanlib::bugs{$nr} =~ m/^\[[^]]*\+/);
+                       $ignoretotal++ if ($scanlib::bugs{$nr} =~ m/^\[[^]]*I/);
+                       $nottestingtotal++ if ($scanlib::bugs{$nr} =~ m/ \[[^]]*X/);
+                       $worrytotal++ if (scanlib::check_worry($scanlib::bugs{$nr}));
+
+                       if (not defined($scanlib::exclude{$nr})) {
                                $bugcount++;
                                $count++;
                        } 
                }
                                $bugcount++;
                                $count++;
                        } 
                }
-               $remtotal+=$count if (defined($comments{$p}) && $comments{$p} =~ m/^\[REMOVE\]/);
        }
 
        if ($html) {
                print "<strong>Total number of release-critical bugs:</strong> $bugcount<BR>\n";
        }
 
        if ($html) {
                print "<strong>Total number of release-critical bugs:</strong> $bugcount<BR>\n";
-               printf("<strong>Number that will disappear after removing packages marked [REMOVE]:</strong> %d<BR>\n", $remtotal);
                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>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);
@@ -180,7 +154,6 @@ sub MakeStatistics() {
                printf("<strong>Number concerning the next release (excluding ignored and not-in-testing):</strong> %d<P>\n", $worrytotal);
        } else {
                print "Total number of release-critical bugs: $bugcount\n";
                printf("<strong>Number concerning the next release (excluding ignored and not-in-testing):</strong> %d<P>\n", $worrytotal);
        } else {
                print "Total number of release-critical bugs: $bugcount\n";
-               printf("Number that will disappear after removing packages marked [REMOVE]: %d\n", $remtotal);
                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 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);
@@ -190,30 +163,37 @@ sub MakeStatistics() {
 }
 
 
 }
 
 
-sub FilterPackages() {
-       local($filter) = shift;         # Distribution we want to keep
+sub FilterPackages($) {
+       my $filter = shift;             # Distribution we want to keep
 
 
-       for $p (sort keys %packagelist) {
-               delete $packagelist{$p} unless ($section{$p} =~ m/^$filter/);
+       for my $p (sort keys %scanlib::packagelist) {
+               delete $scanlib::packagelist{$p} unless ($scanlib::section{$p} =~ m/^$filter/);
        }
 }
 
        }
 }
 
-getopts('VhHlsd:S:C:');
+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);
+       }
+}
+
+our ($opt_h,$opt_V,$opt_S,$opt_H,$opt_d,$opt_t,$opt_s,$opt_l);
+
+getopts('VhHlstd:S:');
 ShowUsage if ($opt_h);
 ShowVersion if ($opt_V);
 $statusfile=$opt_S if ($opt_S);
 ShowUsage if ($opt_h);
 ShowVersion if ($opt_V);
 $statusfile=$opt_S if ($opt_S);
-$commentsfile=$opt_C if ($opt_C);
 $html=1 if ($opt_H);
 
 $html=1 if ($opt_H);
 
-&readstatus($statusfile);
-&readcomments($commentsfile);
-&readNMUstatus($NMUfile);
+scanlib::readstatus($statusfile);
 
 
-&FilterPackages($opt_d) if ($opt_d);
+FilterPackages($opt_d) if ($opt_d);
+FilterBugs() if ($opt_t);
 
 MakeStatistics if ($opt_s);
 if ($opt_l) {
 
 MakeStatistics if ($opt_s);
 if ($opt_l) {
-       MakeBuglist 
+       MakeBuglist();
 }
 
 exit 0;
 }
 
 exit 0;