6 use POSIX qw(strftime tzset);
8 #require '/usr/lib/debbugs/errorlib';
11 require '/etc/debbugs/config';
12 require '/etc/debbugs/text';
14 use vars(qw($gHTMLTail $gWebDomain));
16 my %param = readparse();
20 my %maintainer = %{getmaintainers()};
21 my %pkgsrc = %{getpkgsrc()};
23 my $ref = $param{'bug'} || quit("No bug number");
24 my $msg = $param{'msg'} || "";
25 my $boring = ($param{'boring'} || 'no') eq 'yes';
26 my $reverse = ($param{'reverse'} || 'no') eq 'yes';
28 my %status = %{getbugstatus($ref)} or &quit("Couldn't get bug status: $!");
41 my $dtime = strftime "%a, %e %b %Y %T UTC", localtime;
42 $tail_html = $debbugs::gHTMLTail;
43 $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
47 $tpack = lc $status{'package'};
48 $tpack =~ s/[^-+._a-z0-9()].*$//;
50 if ($status{severity} eq 'normal') {
52 #} elsif (grep($status{severity} eq $_, @strongseverities)) {
53 # $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
55 $showseverity = "Severity: <em>$status{severity}</em>;\n";
58 $indexentry .= $showseverity;
59 $indexentry .= "Package: <A HREF=\"" . pkgurl($status{package}) . "\">"
60 .htmlsanit($status{package})."</A>;\n";
62 $indexentry .= "Reported by: ".htmlsanit($status{originator});
63 $indexentry .= ";\nTags: <strong>"
64 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
66 if length($status{tags});
68 my @merged= split(/ /,$status{mergedwith});
70 my $mseparator= ";\nmerged with ";
72 $indexentry .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
77 my $dummy = strftime "%a, %e %b %Y %T UTC", localtime($status{date});
78 $submitted = ";\ndated ".$dummy;
80 if (length($status{done})) {
81 $indexentry .= ";\n<strong>Done:</strong> ".htmlsanit($status{done});
82 } elsif (length($status{forwarded})) {
83 $indexentry .= ";\n<strong>Forwarded</strong> to ".htmlsanit($status{forwarded});
86 my ($short, $tmaint, $tsrc);
87 $short = $ref; $short =~ s/^\d+/#$&/;
88 $tmaint = defined($maintainer{$tpack}) ? $maintainer{$tpack} : '(unknown)';
89 $tsrc = defined($pkgsrc{$tpack}) ? $pkgsrc{$tpack} : '(unknown)';
90 $descriptivehead= $indexentry.$submitted.";\nMaintainer for $status{package} is\n".
91 '<A href="http://'.$debbugs::gWebDomain.'/db/ma/l'.&maintencoded($tmaint).'.html">'.htmlsanit($tmaint).'</A>';
92 $descriptivehead.= ";\n<br>Source for $status{package} is\n".
93 '<A href="'.srcurl($tsrc)."\">$tsrc</A>";
94 $descriptivehead.= ".";
96 my $buglog = buglog($ref);
97 open L, "<$buglog" or &quit("open log for $ref: $!");
102 my $suppressnext = 0;
108 my $normstate= 'kill-init';
110 while(my $line = <L>) {
112 if ($line =~ m/^.$/ and 1 <= ord($line) && ord($line) <= 7) {
115 my $statenum = ord($line);
117 $newstate = 'autocheck' if ($statenum == 1);
118 $newstate = 'recips' if ($statenum == 2);
119 $newstate = 'kill-end' if ($statenum == 3);
120 $newstate = 'go' if ($statenum == 5);
121 $newstate = 'html' if ($statenum == 6);
122 $newstate = 'incoming-recv' if ($statenum == 7);
124 # disallowed transitions:
125 $_ = "$normstate $newstate";
126 unless (m/^(go|go-nox|html) kill-end$/
127 || m/^(kill-init|kill-end) (incoming-recv|autocheck|recips|html)$/
128 || m/^kill-body go$/)
130 &quit("$ref: Transition from $normstate to $newstate at $linenum disallowed");
133 if ($newstate eq 'go') {
137 if ($newstate eq 'html') {
141 if ($newstate eq 'kill-end') {
144 if $normstate eq 'go' || $normstate eq 'go-nox';
146 if ($normstate eq 'html') {
147 $this .= " <em><A href=\"" . bugurl($ref, "msg=$xmessage") . "\">Full text</A> available.</em>";
152 if ($suppressnext && $normstate ne 'html');
154 $show = ($xmessage == $msg) if ($msg);
158 $log = "$this\n<hr>$log";
160 $log .= "$this\n<hr>\n";
164 $xmessage++ if ($normstate ne 'html');
166 $suppressnext = $normstate eq 'html';
169 $normstate = $newstate;
174 if ($normstate eq 'incoming-recv') {
177 m/^Received: \(at (\S+)\) by (\S+)\;/
178 || &quit("bad line \`$pl' in state incoming-recv");
179 $this = "<h2>Message received at ".htmlsanit("$1\@$2")
180 . ":</h2><br>\n<pre>\n$_";
182 } elsif ($normstate eq 'html') {
184 } elsif ($normstate eq 'go') {
185 $this .= htmlsanit($_);
186 } elsif ($normstate eq 'go-nox') {
188 $this .= htmlsanit($_);
189 } elsif ($normstate eq 'recips') {
191 $this = "<h2>Message sent:</h2><br>\n";
194 $this = "<h2>Message sent to ".htmlsanit($_).":</h2><br>\n";
196 $normstate= 'kill-body';
197 } elsif ($normstate eq 'autocheck') {
198 next if !m/^X-Debian-Bugs(-\w+)?: This is an autoforward from (\S+)/;
199 $normstate= 'autowait';
200 $this = "<h2>Message received at $2:</h2><br>\n";
201 } elsif ($normstate eq 'autowait') {
203 $normstate= 'go-nox';
206 &quit("$ref state $normstate line \`$_'");
209 &quit("$ref state $normstate at end") unless $normstate eq 'kill-end';
212 print "Content-Type: text/html\n\n";
214 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
215 print "<HTML><HEAD>\n" .
216 "<TITLE>$debbugs::gProject $debbugs::gBug report logs - $short</TITLE>\n" .
218 '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
220 print "<H1>" . "$debbugs::gProject $debbugs::gBug report logs - <A HREF=\"mailto:$ref\@bugs.debian.org\">$short</A>" .
221 "<BR>" . htmlsanit($status{subject}) . "</H1>\n";
223 print "$descriptivehead\n";
228 print "</BODY></HTML>\n";