From ed5e21f46b69d8ad26136eebe086afbb76ebc28b Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Wed, 24 Sep 2008 19:51:50 -0700 Subject: [PATCH] * Stop hard coding the path to spool in age-1 * Fix affects usage * Support bugs= in pkgreport.cgi * Comment out CGI::Alert usage for the time being; eventually we'll probably replace it with an optional home-grown replacement that is less sucky. * Handle maint='' in get_bugs instead of out in pkgreport (this enables this search to work from soap) --- Debbugs/Bugs.pm | 60 +++++++++++++++++++++++++++++++++----------- Debbugs/CGI.pm | 2 ++ cgi/bugreport.cgi | 5 ++++ cgi/pkgreport.cgi | 63 +++++++++++++++++++++++++---------------------- cgi/search.cgi | 2 +- debian/changelog | 2 ++ scripts/age-1 | 2 +- 7 files changed, 90 insertions(+), 46 deletions(-) diff --git a/Debbugs/Bugs.pm b/Debbugs/Bugs.pm index 36bcc7b..dfcb0c5 100644 --- a/Debbugs/Bugs.pm +++ b/Debbugs/Bugs.pm @@ -430,6 +430,14 @@ sub get_bugs_by_idx{ ); my %bugs = (); + # If we're given an empty maint (unmaintained packages), we can't + # handle it, so bail out here + for my $maint (make_list(exists $param{maint}?$param{maint}:[])) { + if (defined $maint and $maint eq '') { + die "Can't handle empty maint (unmaintained packages) in get_bugs_by_idx"; + } + } + # We handle src packages, maint and maintenc by mapping to the # appropriate binary packages, then removing all packages which # don't match all queries @@ -532,6 +540,9 @@ sub get_bugs_flatfile{ # dist => {type => SCALAR|ARRAYREF, # optional => 1, # }, + bugs => {type => SCALAR|ARRAYREF, + optional => 1, + }, archive => {type => BOOLEAN, default => 1, }, @@ -559,6 +570,23 @@ sub get_bugs_flatfile{ @usertag_bugs{make_list(@{$param{usertags}}{make_list($param{tag})}) } = (1) x make_list(@{$param{usertags}}{make_list($param{tag})}); } + my $unmaintained_packages = 0; + # unmaintained packages is a special case + for my $maint (make_list(exists $param{maint}?$param{maint}:[])) { + if (defined $maint and $maint eq '' and not $unmaintained_packages) { + $unmaintained_packages = 1; + our %maintainers = %{getmaintainers()}; + $param{function} = [exists $param{function}? + (ref $param{function}?@{$param{function}}:$param{function}):(), + sub {my %d=@_; + foreach my $try (splitpackages($d{"pkg"})) { + return 1 if not exists $maintainers{$try}; + } + return 0; + } + ]; + } + } # We handle src packages, maint and maintenc by mapping to the # appropriate binary packages, then removing all packages which # don't match all queries @@ -569,7 +597,7 @@ sub get_bugs_flatfile{ exists $param{src} or exists $param{maint}) { delete @param{qw(maint src)}; - $param{package} = [@packages]; + $param{package} = [@packages] if @packages; } my $grep_bugs = 0; my %bugs; @@ -577,15 +605,17 @@ sub get_bugs_flatfile{ $bugs{$_} = 1 for make_list($param{bugs}); $grep_bugs = 1; } - if (exists $param{owner} or exists $param{correspondent} or exists $param{affects}) { - $bugs{$_} = 1 for get_bugs_by_idx(exists $param{correspondent}?(correspondent => $param{correspondent}):(), - exists $param{owner}?(owner => $param{owner}):(), - exists $param{affects}?(affects => $param{affects}):(), + # These queries have to be handled by get_bugs_by_idx + if (exists $param{owner} + or exists $param{correspondent} + or exists $param{affects}) { + $bugs{$_} = 1 for get_bugs_by_idx(map {exists $param{$_}?($_,$param{$_}):()} + qw(owner correspondent affects), ); $grep_bugs = 1; } my @bugs; - while (<$flatfile>) { + BUG: while (<$flatfile>) { next unless m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/; my ($pkg,$bug,$time,$status,$submitter,$severity,$tags) = ($1,$2,$3,$4,$5,$6,$7); next if $grep_bugs and not exists $bugs{$bug}; @@ -629,14 +659,16 @@ sub get_bugs_flatfile{ my @bug_tags = split ' ', $tags; my @packages = splitpackages($pkg); my $package = (@packages > 1)?\@packages:$packages[0]; - next unless - $param{function}->(pkg => $package, - bug => $bug, - status => $status, - submitter => $submitter, - severity => $severity, - tags => \@bug_tags, - ); + for my $function (make_list($param{function})) { + next BUG unless + $function->(pkg => $package, + bug => $bug, + status => $status, + submitter => $submitter, + severity => $severity, + tags => \@bug_tags, + ); + } } push @bugs, $bug; } diff --git a/Debbugs/CGI.pm b/Debbugs/CGI.pm index 1ba4799..cceeb36 100644 --- a/Debbugs/CGI.pm +++ b/Debbugs/CGI.pm @@ -350,8 +350,10 @@ our @package_search_key_order = (package => 'in package', submitter => 'submitted by', owner => 'owned by', status => 'with status', + affects => 'which affect package', correspondent => 'with mail from', newest => 'newest bugs', + bugs => 'in bug', ); our %package_search_keys = @package_search_key_order; diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi index d01a286..f3c7ff6 100755 --- a/cgi/bugreport.cgi +++ b/cgi/bugreport.cgi @@ -76,6 +76,11 @@ if (not defined $buglog) { -type => "text/html", -charset => 'utf-8', ); + print fill_in_template(template=>'cgi/no_such_bug', + variables => {modify_time => strftime('%a, %e %b %Y %T UTC', gmtime), + bug_num => $ref, + }, + ); exit 0; } diff --git a/cgi/pkgreport.cgi b/cgi/pkgreport.cgi index 2a69dfd..3ddad9b 100755 --- a/cgi/pkgreport.cgi +++ b/cgi/pkgreport.cgi @@ -24,6 +24,8 @@ use Debbugs::Common qw(getparsedaddrs make_list getmaintainers getpseudodesc); use Debbugs::Bugs qw(get_bugs bug_filter newest_bug); use Debbugs::Packages qw(getsrcpkgs getpkgsrc get_versions); +use Debbugs::Status qw(splitpackages); + use Debbugs::CGI qw(:all); use Debbugs::CGI::Pkgreport qw(:all); @@ -77,10 +79,15 @@ if (exists $param{form_options} and defined $param{form_options}) { next unless exists $param{$incexc}; $param{$incexc} = [grep /\S\:\S/, make_list($param{$incexc})]; } + for my $key (keys %package_search_keys) { + next unless exists $param{key}; + $param{$key} = [map {split /\s*,\s*/} make_list($param{$key})]; + } # kill off keys for which empty values are meaningless - for my $key (qw(package src submitter severity status dist)) { + for my $key (qw(package src submitter affects severity status dist)) { next unless exists $param{$key}; - $param{$key} = [grep {length $_} make_list($param{$key})]; + $param{$key} = [grep {defined $_ and length $_} + make_list($param{$key})]; } print $q->redirect(munge_url('pkgreport.cgi?',%param)); exit 0; @@ -332,8 +339,9 @@ my @temp = @package_search_key_order; while (my ($key,$value) = splice @temp, 0, 2) { next unless exists $param{$key}; my @entries = (); - $param{$key} = [map {split /\s*,\s*/} make_list($param{$key})]; - for my $entry (grep {defined $_ and length $_ } make_list($param{$key})) { + for my $entry (make_list($param{$key})) { + # we'll handle newest below + next if $key eq 'newest'; my $extra = ''; if (exists $param{dist} and ($key eq 'package' or $key eq 'src')) { my %versions = get_versions(package => $entry, @@ -358,39 +366,34 @@ while (my ($key,$value) = splice @temp, 0, 2) { } $extra= " ($verdesc)" if keys %versions; } - push @entries, $entry.$extra; + if ($key eq 'maint' and $entry eq '') { + push @entries, "no one (packages without maintainers)" + } + else { + push @entries, $entry.$extra; + } } push @title,$value.' '.join(' or ', @entries) if @entries; } -my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title); -@title = (); - -# we have to special case the maint="" search, unfortunatly. -if (defined $param{maint} and $param{maint} eq "" or ref($param{maint}) and not @{$param{maint}}) { - my %maintainers = %{getmaintainers()}; - @bugs = get_bugs(function => - sub {my %d=@_; - foreach my $try (splitpackages($d{"pkg"})) { - return 1 if not exists $maintainers{$try}; - } - return 0; - } - ); - $title = $gBugs.' in packages with no maintainer'; -} -elsif (defined $param{newest}) { +if (defined $param{newest}) { my $newest_bug = newest_bug(); @bugs = ($newest_bug - $param{newest} + 1) .. $newest_bug; - $title = @bugs.' newest '.$gBugs; -} -else { - #yeah for magick! - @bugs = get_bugs((map {exists $param{$_}?($_,$param{$_}):()} - keys %package_search_keys, 'archive'), - usertags => \%ut, - ); + push @title, 'in '.@bugs.' newest reports'; + $param{bugs} = [exists $param{bugs}?make_list($param{bugs}):(), + @bugs, + ]; } +my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title); +@title = (); + +#yeah for magick! +@bugs = get_bugs((map {exists $param{$_}?($_,$param{$_}):()} + grep {$_ ne 'newest'} + keys %package_search_keys, 'archive'), + usertags => \%ut, + ); + if (defined $param{version}) { $title .= " at version $param{version}"; } diff --git a/cgi/search.cgi b/cgi/search.cgi index 03d2cc5..b1f5e09 100755 --- a/cgi/search.cgi +++ b/cgi/search.cgi @@ -14,7 +14,7 @@ BEGIN{ use CGI::Simple; -use CGI::Alert 'don@donarmstrong.com'; +# use CGI::Alert 'nobody@example.com'; use Search::Estraier; use Debbugs::Config qw(:config); diff --git a/debian/changelog b/debian/changelog index 949ef46..7e3d768 100644 --- a/debian/changelog +++ b/debian/changelog @@ -224,6 +224,8 @@ debbugs (2.4.2) UNRELEASED; urgency=low extra status box (closes: #499990) Thanks to James Vega for the patch. * Return 404 when a bug number that does not exist is used (closes: #499997) + * Comment out CGI::Alert use for the time being (closes: #499681) + * No longer hard-code paths in age-1 (closes: #499682) -- Colin Watson Fri, 20 Jun 2003 18:57:25 +0100 diff --git a/scripts/age-1 b/scripts/age-1 index cc2e72d..65c39d7 100755 --- a/scripts/age-1 +++ b/scripts/age-1 @@ -1,7 +1,7 @@ #!/bin/sh # $Id: age-1.in,v 1.3 2002/01/06 10:46:24 ajt Exp $ set -e -cd /var/lib/debbugs/spool/db-h +cd "$(perl -MDebbugs::Config=:config -e 'print $config{spool_dir}')" test -f ./-3.log && rm ./-3.log test -f ./-2.log && mv ./-2.log ./-3.log test -f ./-1.log && mv ./-1.log ./-2.log -- 2.39.2