2 # This script is part of debbugs, and is released
3 # under the terms of the GPL version 2, or any later
4 # version at your option.
5 # See the file README and COPYING for more information.
7 # [Other people have contributed to this file; their copyrights should
9 # Copyright 2004-2006 by Anthony Towns <ajt@debian.org>
10 # Copyright 2007 by Don Armstrong <don@donarmstrong.com>.
16 use POSIX qw(strftime nice);
18 use Debbugs::Config qw(:globals :text :config);
22 use Debbugs::Common qw(getparsedaddrs make_list getmaintainers getpseudodesc);
24 use Debbugs::Bugs qw(get_bugs bug_filter newest_bug);
25 use Debbugs::Packages qw(getsrcpkgs getpkgsrc get_versions);
27 use Debbugs::Status qw(splitpackages);
29 use Debbugs::CGI qw(:all);
31 use Debbugs::CGI::Pkgreport qw(:all);
33 use Debbugs::Text qw(:templates);
36 my $q = new CGI::Simple;
38 if ($q->request_method() eq 'HEAD') {
39 print $q->header(-type => "text/html",
45 my $default_params = {ordering => 'normal',
52 our %param = cgi_parameters(query => $q,
53 single => [qw(ordering archive repeatmerged),
54 qw(bug-rev pend-rev sev-rev),
55 qw(maxdays mindays version),
56 qw(data which dist newest),
58 default => $default_params,
61 my ($form_options,$param) = ({},undef);
62 ($form_options,$param)= form_options_and_normal_param(\%param)
63 if $param{form_options};
65 %param = %{$param} if defined $param;
67 if (exists $param{form_options} and defined $param{form_options}) {
68 delete $param{form_options};
69 delete $param{submit} if exists $param{submit};
70 for my $default (keys %{$default_params}) {
71 if (exists $param{$default} and
72 not ref($default_params->{$default}) and
73 $default_params->{$default} eq $param{$default}
75 delete $param{$default};
78 for my $incexc (qw(include exclude)) {
79 next unless exists $param{$incexc};
80 $param{$incexc} = [grep /\S\:\S/, make_list($param{$incexc})];
82 for my $key (keys %package_search_keys) {
83 next unless exists $param{key};
84 $param{$key} = [map {split /\s*,\s*/} make_list($param{$key})];
86 # kill off keys for which empty values are meaningless
87 for my $key (qw(package src submitter affects severity status dist)) {
88 next unless exists $param{$key};
89 $param{$key} = [grep {defined $_ and length $_}
90 make_list($param{$key})];
92 print $q->redirect(munge_url('pkgreport.cgi?',%param));
96 # map from yes|no to 1|0
97 for my $key (qw(repeatmerged bug-rev pend-rev sev-rev)) {
98 if (exists $param{$key}){
99 if ($param{$key} =~ /^no$/i) {
102 elsif ($param{$key}) {
108 if (lc($param{archive}) eq 'no') {
111 elsif (lc($param{archive}) eq 'yes') {
116 if (exists $param{dist} and $param{dist} eq '') {
120 my $include = $param{'&include'} || $param{'include'} || "";
121 my $exclude = $param{'&exclude'} || $param{'exclude'} || "";
123 my $users = $param{'users'} || "";
125 my $ordering = $param{'ordering'};
126 my $raw_sort = ($param{'raw'} || "no") eq "yes";
127 my $old_view = ($param{'oldview'} || "no") eq "yes";
128 my $age_sort = ($param{'age'} || "no") eq "yes";
129 unless (defined $ordering) {
130 $ordering = "normal";
131 $ordering = "oldview" if $old_view;
132 $ordering = "raw" if $raw_sort;
133 $ordering = 'age' if $age_sort;
135 $param{ordering} = $ordering;
137 our ($bug_order) = $ordering =~ /(age(?:rev)?)/;
138 $bug_order = '' if not defined $bug_order;
140 my $bug_rev = ($param{'bug-rev'} || "no") eq "yes";
141 my $pend_rev = ($param{'pend-rev'} || "no") eq "yes";
142 my $sev_rev = ($param{'sev-rev'} || "no") eq "yes";
144 my @inc_exc_mapping = ({name => 'pending',
162 key => 'includesubj',
166 key => 'excludesubj',
169 for my $incexcmap (@inc_exc_mapping) {
170 push @{$param{$incexcmap->{incexc}}}, map {"$incexcmap->{name}:$_"}
171 map{split /\s*,\s*/} make_list($param{$incexcmap->{key}})
172 if exists $param{$incexcmap->{key}};
173 delete $param{$incexcmap->{key}};
177 my $maxdays = ($param{'maxdays'} || -1);
178 my $mindays = ($param{'mindays'} || 0);
179 my $version = $param{'version'} || undef;
182 our %hidden = map { $_, 1 } qw(status severity classification);
186 "pri" => [map { "pending=$_" }
187 qw(pending forwarded pending-fixed fixed done absent)],
188 "ttl" => ["Outstanding","Forwarded","Pending Upload",
189 "Fixed in NMU","Resolved","From other Branch"],
190 "def" => "Unknown Pending Status",
191 "ord" => [0,1,2,3,4,5,6],
195 "pri" => [map { "severity=$_" } @gSeverityList],
196 "ttl" => [map { $gSeverityDisplay{$_} } @gSeverityList],
197 "def" => "Unknown Severity",
198 "ord" => [0..@gSeverityList],
200 "classification" => [ {
201 "nam" => "Classification",
202 "pri" => [qw(pending=pending+tag=wontfix
203 pending=pending+tag=moreinfo
204 pending=pending+tag=patch
205 pending=pending+tag=confirmed
207 "ttl" => ["Will Not Fix","More information needed",
208 "Patch Available","Confirmed"],
209 "def" => "Unclassified",
210 "ord" => [2,3,4,1,0,5],
212 "oldview" => [ qw(status severity) ],
213 "normal" => [ qw(status severity classification) ],
216 if (exists $param{which} and exists $param{data}) {
217 $param{$param{which}} = [exists $param{$param{which}}?(make_list($param{$param{which}})):(),
218 make_list($param{data}),
220 delete $param{which};
224 if (defined $param{maintenc}) {
225 $param{maint} = maint_decode($param{maintenc});
226 delete $param{maintenc}
230 if (not grep {exists $param{$_}} keys %package_search_keys and exists $param{users}) {
231 $param{usertag} = [make_list($param{users})];
234 if (exists $param{pkg}) {
235 $param{package} = $param{pkg};
243 for my $user (map {split /[\s*,\s*]+/} make_list($param{users}||[])) {
244 next unless length($user);
245 add_user($user,\%ut,\%bugusertags,\%seen_users,\%cats,\%hidden);
248 if (defined $param{usertag}) {
249 for my $usertag (make_list($param{usertag})) {
251 my ($u, $t) = split /:/, $usertag, 2;
252 Debbugs::User::read_usertags(\%select_ut, $u);
253 unless (defined $t && $t ne "") {
254 $t = join(",", keys(%select_ut));
256 add_user($u,\%ut,\%bugusertags,\%seen_users,\%cats,\%hidden);
257 push @{$param{tag}}, split /,/, $t;
261 quitcgi("You have to choose something to select by") unless grep {exists $param{$_}} keys %package_search_keys;
264 my $Archived = $param{archive} ? " Archived" : "";
266 my $this = munge_url('pkgreport.cgi?',
273 my $dtime = strftime "%a, %e %b %Y %T UTC", gmtime;
274 my $tail_html = $gHTMLTail;
275 $tail_html = $gHTMLTail;
276 $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
281 # addusers for source and binary packages being searched for
282 my $pkgsrc = getpkgsrc();
283 my $srcpkg = getsrcpkgs();
284 for my $package (# For binary packages, add the binary package
285 # and corresponding source package
286 make_list($param{package}||[]),
287 (map {defined $pkgsrc->{$_}?($pkgsrc->{$_}):()}
288 make_list($param{package}||[]),
290 # For source packages, add the source package
291 # and corresponding binary packages
292 make_list($param{src}||[]),
293 (map {defined $srcpkg->{$_}?($srcpkg->{$_}):()}
294 make_list($param{src}||[]),
297 next unless defined $package;
298 add_user($package.'@'.$config{usertag_package_domain},
299 \%ut,\%bugusertags,\%seen_users,\%cats,\%hidden)
300 if defined $config{usertag_package_domain};
304 # walk through the keys and make the right get_bugs query.
306 my $form_option_variables = {};
307 $form_option_variables->{search_key_order} = [@package_search_key_order];
309 # Set the title sanely and clean up parameters
311 my @temp = @package_search_key_order;
312 while (my ($key,$value) = splice @temp, 0, 2) {
313 next unless exists $param{$key};
315 for my $entry (make_list($param{$key})) {
316 # we'll handle newest below
317 next if $key eq 'newest';
319 if (exists $param{dist} and ($key eq 'package' or $key eq 'src')) {
320 my %versions = get_versions(package => $entry,
321 (exists $param{dist}?(dist => $param{dist}):()),
322 (exists $param{arch}?(arch => $param{arch}):(arch => $config{default_architectures})),
323 ($key eq 'src'?(arch => q(source)):()),
328 if (keys %versions > 1) {
329 $verdesc = 'versions '. join(', ',
330 map { $_ .' ['.join(', ',
331 sort @{$versions{$_}}
336 $verdesc = 'version '.join(', ',
340 $extra= " ($verdesc)" if keys %versions;
342 if ($key eq 'maint' and $entry eq '') {
343 push @entries, "no one (packages without maintainers)"
346 push @entries, $entry.$extra;
349 push @title,$value.' '.join(' or ', @entries) if @entries;
351 if (defined $param{newest}) {
352 my $newest_bug = newest_bug();
353 @bugs = ($newest_bug - $param{newest} + 1) .. $newest_bug;
354 push @title, 'in '.@bugs.' newest reports';
355 $param{bugs} = [exists $param{bugs}?make_list($param{bugs}):(),
360 my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title);
364 @bugs = get_bugs((map {exists $param{$_}?($_,$param{$_}):()}
365 grep {$_ ne 'newest'}
366 keys %package_search_keys, 'archive'),
370 if (defined $param{version}) {
371 $title .= " at version $param{version}";
373 elsif (defined $param{dist}) {
374 $title .= " in $param{dist}";
377 $title = html_escape($title);
379 my @names; my @prior; my @order;
380 determine_ordering(cats => \%cats,
382 ordering => \$ordering,
389 # strip out duplicate bugs
391 @bugs{@bugs} = @bugs;
394 my $result = pkg_htmlizebugs(bugs => \@bugs,
399 ordering => $ordering,
400 bugusertags => \%bugusertags,
402 bug_order => $bug_order,
403 repeatmerged => $param{repeatmerged},
408 (exists $param{dist})?(dist => $param{dist}):(),
411 print "Content-Type: text/html; charset=utf-8\n\n";
413 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
414 print "<HTML><HEAD>\n" .
415 "<TITLE>$title -- $gProject$Archived $gBug report logs</TITLE>\n" .
416 qq(<link rel="stylesheet" href="$gWebHostBugDir/css/bugs.css" type="text/css">) .
418 '<BODY onload="pagemain();">' .
420 print qq(<DIV id="status_mask"></DIV>\n);
421 print "<H1>" . "$gProject$Archived $gBug report logs: $title" .
426 my $pkg = $param{package} if defined $param{package};
427 my $src = $param{src} if defined $param{src};
429 my $pseudodesc = getpseudodesc();
430 if (defined $pseudodesc and defined $pkg and exists $pseudodesc->{$pkg}) {
434 # output infomration about the packages
436 for my $package (make_list($param{package}||[])) {
437 print generate_package_info(binary => 1,
443 for my $package (make_list($param{src}||[])) {
444 print generate_package_info(binary => 0,
451 if (exists $param{maint} or exists $param{maintenc}) {
452 print "<p>Note that maintainers may use different Maintainer fields for\n";
453 print "different packages, so there may be other reports filed under\n";
454 print "different addresses.\n";
456 if (exists $param{submitter}) {
457 print "<p>Note that people may use different email accounts for\n";
458 print "different bugs, so there may be other reports filed under\n";
459 print "different addresses.\n";
464 # my %archive_values = (both => 'archived and unarchived',
465 # 0 => 'not archived',
468 # while (my ($key,$value) = each %archive_values) {
469 # next if $key eq lc($param{archive});
470 # push @archive_links, qq(<a href=").
471 # html_escape(pkg_url((
473 # $_ eq 'archive'?():($_,$param{$_})
476 # )).qq(">$value reports </a>);
478 # print '<p>See the '.join (' or ',@archive_links)."</p>\n";
482 print pkg_javascript() . "\n";
484 print qq(<h2 class="outstanding"><!--<a class="options" href="javascript:toggle(1)">-->Options<!--</a>--></h2>\n);
486 print option_form(template => 'cgi/pkgreport_options',
488 form_options => $form_options,
489 variables => $form_option_variables,
492 # print "<h2 class=\"outstanding\"><a class=\"options\" href=\"javascript:toggle(1)\">Options</a></h2>\n";
493 # print "<div id=\"a_1\">\n";
494 # printf "<form action=\"%s\" method=POST>\n", myurl();
496 # print "<table class=\"forms\">\n";
498 # my ($checked_any, $checked_sui, $checked_ver) = ("", "", "");
499 # if (defined $dist) {
500 # $checked_sui = "CHECKED";
501 # } elsif (defined $version) {
502 # $checked_ver = "CHECKED";
504 # $checked_any = "CHECKED";
507 # print "<tr><td>Show bugs applicable to</td>\n";
508 # print " <td><input id=\"b_1_1\" name=vt value=none type=radio onchange=\"enable(1);\" $checked_any>anything</td></tr>\n";
509 # print "<tr><td></td>";
510 # print " <td><input id=\"b_1_2\" name=vt value=bysuite type=radio onchange=\"enable(1);\" $checked_sui>" . pkg_htmlselectsuite(1,2,1) . " for " . pkg_htmlselectarch(1,2,2) . "</td></tr>\n";
512 # if (defined $pkg) {
513 # my $v = html_escape($version) || "";
514 # my $pkgsane = html_escape($pkg->[0]);
515 # print "<tr><td></td>";
516 # print " <td><input id=\"b_1_3\" name=vt value=bypkg type=radio onchange=\"enable(1);\" $checked_ver>$pkgsane version <input id=\"b_1_3_1\" name=version value=\"$v\"></td></tr>\n";
517 # } elsif (defined $src) {
518 # my $v = html_escape($version) || "";
519 # my $srcsane = html_escape($src->[0]);
520 # print "<tr><td></td>";
521 # print " <td><input name=vt value=bysrc type=radio onchange=\"enable(1);\" $checked_ver>$srcsane version <input id=\"b_1_3_1\" name=version value=\"$v\"></td></tr>\n";
523 # print "<tr><td> </td></tr>\n";
525 # my $includetags = html_escape(join(" ", grep { !m/^subj:/i } map {split /[\s,]+/} ref($include)?@{$include}:$include));
526 # my $excludetags = html_escape(join(" ", grep { !m/^subj:/i } map {split /[\s,]+/} ref($exclude)?@{$exclude}:$exclude));
527 # my $includesubj = html_escape(join(" ", map { s/^subj://i; $_ } grep { m/^subj:/i } map {split /[\s,]+/} ref($include)?@{$include}:$include));
528 # my $excludesubj = html_escape(join(" ", map { s/^subj://i; $_ } grep { m/^subj:/i } map {split /[\s,]+/} ref($exclude)?@{$exclude}:$exclude));
529 # my $vismindays = ($mindays == 0 ? "" : $mindays);
530 # my $vismaxdays = ($maxdays == -1 ? "" : $maxdays);
532 # my $sel_rmy = ($param{repeatmerged} ? " selected" : "");
533 # my $sel_rmn = ($param{repeatmerged} ? "" : " selected");
534 # my $sel_ordraw = ($ordering eq "raw" ? " selected" : "");
535 # my $sel_ordold = ($ordering eq "oldview" ? " selected" : "");
536 # my $sel_ordnor = ($ordering eq "normal" ? " selected" : "");
537 # my $sel_ordage = ($ordering eq "age" ? " selected" : "");
539 # my $chk_bugrev = ($bug_rev ? " checked" : "");
540 # my $chk_pendrev = ($pend_rev ? " checked" : "");
541 # my $chk_sevrev = ($sev_rev ? " checked" : "");
544 # <tr><td>Only include bugs tagged with </td><td><input name=include value="$includetags"> or that have <input name=includesubj value="$includesubj"> in their subject</td></tr>
545 # <tr><td>Exclude bugs tagged with </td><td><input name=exclude value="$excludetags"> or that have <input name=excludesubj value="$excludesubj"> in their subject</td></tr>
546 # <tr><td>Only show bugs older than</td><td><input name=mindays value="$vismindays" size=5> days, and younger than <input name=maxdays value="$vismaxdays" size=5> days</td></tr>
548 # <tr><td> </td></tr>
550 # <tr><td>Merged bugs should be</td><td>
551 # <select name=repeatmerged>
552 # <option value=yes$sel_rmy>displayed separately</option>
553 # <option value=no$sel_rmn>combined</option>
555 # <tr><td>Categorise bugs by</td><td>
556 # <select name=ordering>
557 # <option value=raw$sel_ordraw>bug number only</option>
558 # <option value=old$sel_ordold>status and severity</option>
559 # <option value=normal$sel_ordnor>status, severity and classification</option>
560 # <option value=age$sel_ordage>status, severity, classification, and age</option>
565 # my $o = $param{"ordering"} || "";
566 # for my $n (keys %cats) {
567 # next if ($n eq "normal" || $n eq "oldview");
568 # next if defined $hidden{$n};
571 # print "<option disabled>------</option>\n";
573 # my @names = map { ref($_) eq "HASH" ? $_->{"nam"} : $_ } @{$cats{$n}};
575 # if (@names == 1) { $name = $names[0]; }
576 # else { $name = " and " . pop(@names); $name = join(", ", @names) . $name; }
578 # printf "<option value=\"%s\"%s>%s</option>\n",
579 # $n, ($o eq $n ? " selected" : ""), $name;
583 # print "</select></td></tr>\n";
585 # printf "<tr><td>Order bugs by</td><td>%s</td></tr>\n",
586 # pkg_htmlselectyesno("pend-rev", "outstanding bugs first", "done bugs first", $pend_rev);
587 # printf "<tr><td></td><td>%s</td></tr>\n",
588 # pkg_htmlselectyesno("sev-rev", "highest severity first", "lowest severity first", $sev_rev);
589 # printf "<tr><td></td><td>%s</td></tr>\n",
590 # pkg_htmlselectyesno("bug-rev", "oldest bugs first", "newest bugs first", $bug_rev);
593 # <tr><td> </td></tr>
594 # <tr><td colspan=2><input value="Reload page" type="submit"> with new settings</td></tr>
597 # print "</table></form></div>\n";
600 print "<p>$tail_html";
602 print "</body></html>\n";