From 1c41b3bc8f5e5bb7a0e524bb9e7a9073111c6f44 Mon Sep 17 00:00:00 2001 From: ajt <> Date: Sun, 1 Oct 2000 22:38:28 -0800 Subject: [PATCH] [project @ 2000-10-01 23:38:28 by ajt] pkgreport.cgi updated to handle maintainers as well, and to merge most of the features from the various forked pkgreports common.pl updated and its api changed significantly to support new pkgreport.cgi bugreport.cgi updated to match new common.pl and merged from bugreport.cgi on master --- cgi/bugreport.cgi | 27 +++-- cgi/common.pl | 259 ++++++++++++++++++++++++++++++++-------------- cgi/pkgreport.cgi | 90 ++++++++-------- 3 files changed, 246 insertions(+), 130 deletions(-) diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi index 647011f9..2455c0a7 100755 --- a/cgi/bugreport.cgi +++ b/cgi/bugreport.cgi @@ -11,6 +11,7 @@ require '/usr/lib/debbugs/common.pl'; require '/etc/debbugs/config'; require '/etc/debbugs/text'; +use vars(qw($gHTMLTail $gWebDomain)); my $dtime; my $tail_html; @@ -18,12 +19,14 @@ my %maintainer = getmaintainers(); my $ref= param('bug') || die("No bug number"); my $archive = (param('archive') || 'no') eq 'yes'; -my %status = getbugstatus($ref, $archive); - my $msg = param('msg') || ""; my $boring = (param('boring') || 'no') eq 'yes'; my $reverse = (param('reverse') || 'no') eq 'yes'; +set_option("archive", $archive); + +my %status = getbugstatus($ref); + my $indexentry; my $descriptivehead; my $submitted; @@ -52,7 +55,10 @@ if ($status{severity} eq 'normal') { } $indexentry .= $showseverity; -$indexentry .= "Reported by: ".&sani($status{originator}); +$indexentry .= "Package: " + .htmlsanit($status{package}).";\n"; + +$indexentry .= "Reported by: ".&sani($status{originator})."; "; $indexentry .= ";\nKeywords: ".&sani($status{keywords}) if length($status{keywords}); @@ -65,9 +71,11 @@ if (@merged) { } } -$submitted = `TZ=GMT LANG=C \\ +my $dummy = `TZ=GMT LANG=C \\ date -d '1 Jan 1970 00:00:00 + $status{date} seconds' \\ - '+ %a, %d %b %Y %T %Z'`; + '+ %a, %e %b %Y %T %Z'`; +chomp($dummy); +$submitted = "dated ".$dummy; if (length($status{done})) { $indexentry .= ";\nDone: ".&sani($status{done}); @@ -132,7 +140,7 @@ while(my $line = ) { if $normstate eq 'go' || $normstate eq 'go-nox'; if ($normstate eq 'html') { - $this .= " Full text available."; + $this .= " Full text available."; } my $show = 1; @@ -198,7 +206,12 @@ while(my $line = ) { close(L); print header; -print start_html("$debbugs::gProject $debbugs::gBug report logs - $short"); +print start_html( + -TEXT => "#000000", + -BGCOLOR=>"#FFFFFF", + -LINK => "#0000FF", + -VLINK => "#800080", + -title => "$debbugs::gProject $debbugs::gBug report logs - $short"); print h1("$debbugs::gProject $debbugs::gBug report logs - $short
\n" . sani($status{subject})); diff --git a/cgi/common.pl b/cgi/common.pl index 64c48239..a5b728c9 100644 --- a/cgi/common.pl +++ b/cgi/common.pl @@ -1,28 +1,43 @@ #!/usr/bin/perl -w +my $common_archive = 0; +my $common_repeatmerged = 1; + +sub set_option { + my ($opt, $val) = @_; + if ($opt eq "archive") { $common_archive = $val; } + if ($opt eq "repeatmerged") { $common_repeatmerged = $val; } +} + sub quit { - my $msg = shift; - print header . start_html("Error"); - print "An error occurred. Dammit.\n"; - print "Error was: $msg.\n"; - print end_html; - exit 0; + my $msg = shift; + print header . start_html("Error"); + print "An error occurred. Dammit.\n"; + print "Error was: $msg.\n"; + print end_html; + exit 0; } sub abort { - my $msg = shift; - my $archive = shift; - print header . start_html("Sorry"); - print "Sorry bug #$msg doesn't seem to be in the $archive database.\n"; - print end_html; - exit 0; + my $msg = shift; + my $Archive = $common_archive ? "archive" : ""; + print header . start_html("Sorry"); + print "Sorry bug #$msg doesn't seem to be in the $Archive database.\n"; + print end_html; + exit 0; } sub htmlindexentry { my $ref = shift; - my $archive = shift; + my %status = getbugstatus($ref); + return htmlindexentrystatus(%status) if (%status); + return ""; +} + +sub htmlindexentrystatus { + my $s = shift; + my %status = %{$s}; - my %status = getbugstatus($ref, $archive ); my $result = ""; if ($status{severity} eq 'normal') { @@ -33,21 +48,19 @@ sub htmlindexentry { $showseverity = "Severity: $status{severity};\n"; } - $result .= "Package: " - . htmlsanit($status{"package"}) . ";\n" - if (length($status{"package"})); + $result .= "Package: " + . "" . htmlsanit($status{"package"}) . ";\n" + if (length($status{"package"})); $result .= $showseverity; $result .= "Reported by: " . htmlsanit($status{originator}); $result .= ";\nKeywords: " . htmlsanit($status{keywords}) if (length($status{keywords})); my @merged= split(/ /,$status{mergedwith}); - if (@merged) { - my $mseparator= ";\nmerged with "; - for my $m (@merged) { - $result .= $mseparator."#$m"; - $mseparator= ", "; - } + my $mseparator= ";\nmerged with "; + for my $m (@merged) { + $result .= $mseparator."#$m"; + $mseparator= ", "; } if (length($status{done})) { @@ -82,22 +95,28 @@ sub htmlindexentry { return $result; } +sub mainturl { + my $ref = shift; + return sprintf "http://%s/db/ma/l%s.html", + $debbugs::gWebDomain, maintencoded($ref); +} + sub pkgurl { my $ref = shift; my $params = "pkg=$ref"; - foreach my $val (@_) { 1 } + $params .= "&archive=yes" if ($common_archive); + $params .= "&repeatmerged=yes" if ($common_repeatmerged); return $debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params"; } -%saniarray= ('<','lt', '>','gt', '&','amp', '"','quot'); - sub htmlsanit { + my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot'); my $in = shift; my $out; while ($in =~ m/[<>&"]/) { - $out.= $`. '&'. $saniarray{$&}. ';'; - $in=$'; + $out .= $`. '&'. $saniarray{$&}. ';'; + $in = $'; } $out .= $in; return $out; @@ -108,9 +127,11 @@ sub bugurl { my $params = "bug=$ref"; foreach my $val (@_) { $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/); - $params .= "\&archive=yes" if ($val =~ /^archive=1/); + $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/); } - + $params .= "&archive=yes" if ($common_archive); + $params .= "&repeatmerged=yes" if ($common_repeatmerged); + return $debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params"; } @@ -123,8 +144,7 @@ sub allbugs { my @bugs = (); opendir(D, "$debbugs::gSpoolDir/db") || &quit("opendir db: $!"); - @bugs = sort { $a <=> $b } - grep s/\.status$//, + @bugs = sort {$a<=>$b} grep s/\.status$//, (grep m/^[0-9]+\.status$/, (readdir(D))); closedir(D); @@ -132,47 +152,125 @@ sub allbugs { return @bugs; } +sub htmlizebugs { + my @bugs = @_; + + my %section = (); + + my %displayshowpending = ("pending", "outstanding", + "done", "resolved", + "forwarded", "forwarded to upstream software authors"); + + if (@bugs == 0) { + return hr . h2("No reports found!"); + } + + foreach my $bug (sort {$a<=>$b} @bugs) { + my %status = getbugstatus($bug); + next unless %status; + my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith})); + if ($common_repeatmerged || $bug == $merged[0]) { + $section{$status{pending} . "_" . $status{severity}} .= + sprintf "
  • #%d: %s\n
    ", + bugurl($bug), $bug, htmlsanit($status{subject}); + $section{$status{pending} . "_" . $status{severity}} .= + htmlindexentrystatus(\%status) . "\n"; + } + } + + my $result = ""; + my $anydone = 0; + foreach my $pending (qw(pending forwarded done)) { + foreach my $severity(@debbugs::gSeverityList) { + $severity = $debbugs::gDefaultSeverity if ($severity eq ''); + next unless defined $section{${pending} . "_" . ${severity}}; + $result .= hr . h2("$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}"); + $result .= "(A list of all such bugs is available).\n"; + $result .= ul($section{$pending . "_" . $severity}); + $anydone = 1 if ($pending eq "done"); + } + } + + $result .= $debbugs::gHTMLExpireNote if ($anydone); + return $result; +} + +sub maintbugs { + my $maint = shift; + my $chk = sub { + my %d = @_; + ($maintemail = $d{"maint"}) =~ s/\s*\(.*\)\s*//; + if ($maintemail =~ m/<(.*)>/) { $maintemail = $1 } + return $maintemail eq $maint; + }; + return getbugs($chk); +} + +sub maintencbugs { + my $maint = shift; + return getbugs(sub {my %d=@_; return maintencoded($d{"maint"}) eq $maint}); +} + sub pkgbugs { - my $pkg = shift; - my $archive = shift; - if ( $archive ) { open I, "<$debbugs::gSpoolDir/index.archive" || &quit("bugindex: $!"); } - else { open I, "<$debbugs::gSpoolDir/index.db" || &quit("bugindex: $!"); } + my $inpkg = shift; + return getbugs( sub { my %d = @_; return $inpkg eq $d{"pkg"} }); +} + +sub getbugs { + my $bugfunc = shift; + + if ( $common_archive ) { + open I, "<$debbugs::gSpoolDir/index.archive" || &quit("bugindex: $!"); + } else { + open I, "<$debbugs::gSpoolDir/index.db" || &quit("bugindex: $!"); + } + my @result = (); while() - { if (m/^(\S+)\s+(\d+)\s+(.+)/ && $1 eq $pkg) - { - my $tmpstr = sprintf( "%d: %s", $2, $3 ); - $descstr{ $2 } = $tmpstr; - } + { + if (m/^(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+\[\s*([^]]*[^]\s])\s*\]\s+(\w+)\s+(.+)$/) { + if ($bugfunc->(pkg => $1, bug => $2, maint => $5, + severity => $6, title => $7)) + { + push (@result, $2); + } + } } - return %descstr; + close I; + return @result; } sub pkgbugsindex { - my $archive = shift; - my @bugs = (); - if ( $archive ) { open I, "<$debbugs::gSpoolDir/index.archive" || &quit("bugindex: $!"); } - else { open I, "<$debbugs::gSpoolDir/index.db" || &quit("bugindex: $!"); } - while() { $descstr{ $1 } = 1 if (m/^(\S+)/); } + my %descstr = (); + if ( $common_archive ) { + open I, "<$debbugs::gSpoolDir/index.archive" || &quit("bugindex: $!"); + } else { + open I, "<$debbugs::gSpoolDir/index.db" || &quit("bugindex: $!"); + } + while() { + $descstr{ $1 } = 1 if (m/^(\S+)/); + } return %descstr; } sub maintencoded { - my $input = $_; - my $encoded = ''; + my $input = shift; + my $encoded = ''; - while ($input =~ m/\W/) - { $encoded.=$`.sprintf("-%02x_",unpack("C",$&)); + while ($input =~ m/\W/) { + $encoded.=$`.sprintf("-%02x_",unpack("C",$&)); $input= $'; } + $encoded.= $input; $encoded =~ s/-2e_/\./g; $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/; $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/; $encoded =~ s/-20_/_/g; $encoded =~ s/-([^_]+)_-/-$1/g; - return $input; + return $encoded; } + sub getmaintainers { my %maintainer; @@ -189,43 +287,44 @@ sub getmaintainers { } sub getbugstatus { - my $bugnum = shift; - my $archive = shift; + my $bugnum = shift; - my %status; + my %status; - if ( $archive ) - { my $archdir = $bugnum % 100; - open(S,"$gSpoolDir/archive/$archdir/$bugnum.status" ) || &abort("$bugnum", "archive" ); - } else - { open(S,"$gSpoolDir/db/$bugnum.status") || &abort("$bugnum"); } - my @lines = qw(originator date subject msgid package keywords done + if ( $common_archive ) { + my $archdir = sprintf "%02d", $bugnum % 100; + open(S,"$gSpoolDir/archive/$archdir/$bugnum.status" ) || return undef; + } else { + open(S,"$gSpoolDir/db/$bugnum.status") || return undef; + } + my @lines = qw(originator date subject msgid package keywords done forwarded mergedwith severity); - while() { - chomp; - $status{shift @lines} = $_; - } - close(S); - $status{shift @lines} = '' while(@lines); + while() { + chomp; + $status{shift @lines} = $_; + } + close(S); + $status{shift @lines} = '' while(@lines); - $status{package} =~ s/\s*$//; - $status{package} = 'unknown' if ($status{package} eq ''); - $status{severity} = 'normal' if ($status{severity} eq ''); + $status{"package"} =~ s/\s*$//; + $status{"package"} = 'unknown' if ($status{"package"} eq ''); + $status{"severity"} = 'normal' if ($status{"severity"} eq ''); - $status{pending} = 'pending'; - $status{pending} = 'forwarded' if (length($status{forwarded})); - $status{pending} = 'done' if (length($status{done})); + $status{"pending"} = 'pending'; + $status{"pending"} = 'forwarded' if (length($status{"forwarded"})); + $status{"pending"} = 'done' if (length($status{"done"})); - return %status; + return %status; } sub buglog { - my $bugnum = shift; - my $archive = shift; - if ( $archive ) - { my $archdir = $bugnum % 100; - return "$gSpoolDir/archive/$archdir/$bugnum.log"; - } else { return "$gSpoolDir/db/$bugnum.log"; } + my $bugnum = shift; + if ( $common_archive ) { + my $archdir = sprintf "%02d", $bugnum % 100; + return "$gSpoolDir/archive/$archdir/$bugnum.log"; + } else { + return "$gSpoolDir/db/$bugnum.log"; + } } 1 diff --git a/cgi/pkgreport.cgi b/cgi/pkgreport.cgi index 60d87188..d593b77d 100755 --- a/cgi/pkgreport.cgi +++ b/cgi/pkgreport.cgi @@ -5,73 +5,77 @@ package debbugs; use strict; use CGI qw/:standard/; +require '/debian/home/ajt/newajbug/common.pl'; +#require '/usr/lib/debbugs/common.pl'; require '/usr/lib/debbugs/errorlib'; -require '/usr/lib/debbugs/common.pl'; require '/etc/debbugs/config'; require '/etc/debbugs/text'; my $pkg = param('pkg'); -my $archive = (param('archive') || 'no') eq 'yes'; -my $arc = 'yes'; +my $maint = defined $pkg ? undef : param('maint'); +my $maintenc = (defined $pkg || defined $maint) ? undef : param('maintenc'); +my $repeatmerged = (param('repeatmerged') || "yes") eq "yes"; +my $archive = (param('archive') || "no") eq "yes"; -$pkg = 'ALL' unless defined( $pkg ); -$arc = 'no' unless $archive; +$pkg = 'ALL' unless (defined($pkg) || defined($maint) || defined($maintenc)); + +my $Archived = $archive ? "Archived" : ""; -my $repeatmerged = (param('repeatmerged') || 'yes') eq 'yes'; my $this = ""; my %indexentry; -my %maintainer = (); +my %maintainer = &getmaintainers(); my %strings = (); -my %displayshowpending = ('pending','outstanding', - 'done','resolved', - 'forwarded','forwarded to upstream software authors'); - my $dtime=`date -u '+%H:%M:%S GMT %a %d %h'`; chomp($dtime); my $tail_html = $debbugs::gHTMLTail; $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/; +my $tag; +if (defined $pkg) { + $tag = "package $pkg"; +} elsif (defined $maint) { + $tag = "maintainer $maint"; +} else { + $tag = "maintainer $maintenc"; +} + +set_option("repeatmerged", $repeatmerged); +set_option("archive", $archive); + +my @bugs; +if (defined $pkg) { + @bugs = pkgbugs($pkg); +} elsif (defined $maint) { + @bugs = maintbugs($maint); +} else { + @bugs = maintencbugs($maintenc); +} + +my $result = htmlizebugs(@bugs); print header; -if( $archive ) -{ print start_html("$debbugs::gProject Archived $debbugs::gBug report logs: package $pkg"); - print h1("$debbugs::gProject Archived $debbugs::gBug report logs: package $pkg"); -} else -{ print start_html("$debbugs::gProject $debbugs::gBug report logs: package $pkg"); - print h1("$debbugs::gProject $debbugs::gBug report logs: package $pkg"); +print start_html("$debbugs::gProject $Archived $debbugs::gBug report logs: $tag"); +print h1("$debbugs::gProject $Archived $debbugs::gBug report logs: $tag"); + +if (defined $maintainer{$pkg}) { + print "

    Maintainer for $pkg is " + . htmlsanit($maintainer{$pkg}) . ".

    \n"; } -#if (defined $maintainer{$pkg}) { -# print "

    Maintainer for $pkg is " -# . htmlsanit($maintainer{$pkg}) . ".

    \n"; -#} - -print "

    Note that with multi-binary packages there may be other reports\n"; -print "filed under the different binary package names.

    \n"; - -if ( $pkg ne 'ALL' ) -{ %strings = pkgbugs($pkg, $archive); - foreach my $bug ( keys %strings ) - { $this .= "
  • ". $strings{ $bug } ."\n"; } -} else -{ %strings = pkgbugsindex( $archive ); - my @bugs = (); - foreach my $bug ( keys %strings ) { push @bugs, $bug; } - @bugs = sort { $a cmp $b } @bugs; - foreach my $bug ( @bugs ) - { $this .= "
  • ". $bug . "\n"; } +if (defined $pkg) { + print "

    Note that with multi-binary packages there may be other\n"; + print "reports filed under the different binary package names.

    \n"; +} else { + print "

    Note that maintainers may use different Maintainer fields for\n"; + print "different packages, so there may be other reports filed under\n" + print "different addresses.\n"; } -if ( length( $this ) ) -{ print "

      \n"; - print $this; - print "
    \n"; -} else -{ print "No archived reports found\n"; } +print $result; print hr; print "$tail_html"; -- 2.39.5