2 # $Id: service.in,v 1.118 2005/10/19 01:22:14 don Exp $
4 # Usage: service <code>.nn
5 # Temps: incoming/P<code>.nn
11 use Debbugs::Config qw(:globals :config);
16 use Params::Validate qw(:types validate_with);
18 use Debbugs::Common qw(:util :quit :misc :lock);
20 use Debbugs::Status qw(:read :status :write :versions :hook);
21 use Debbugs::Packages qw(binary_to_source);
23 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522 create_mime_message);
24 use Debbugs::Mail qw(send_mail_message);
26 use Debbugs::Recipients qw(:all);
27 use HTML::Entities qw(encode_entities);
28 use Debbugs::Versions::Dpkg;
30 use Debbugs::Status qw(splitpackages);
32 use Debbugs::CGI qw(html_escape);
33 use Debbugs::Control qw(:all);
34 use Debbugs::Control::Service qw(:all);
35 use Debbugs::Log qw(:misc);
36 use Debbugs::Text qw(:templates);
38 use Scalar::Util qw(looks_like_number);
40 use List::Util qw(first);
42 use Mail::RFC822::Address;
43 use Encode qw(decode encode);
45 chdir($config{spool_dir}) or
46 die "Unable to chdir to spool_dir '$config{spool_dir}': $!";
51 my ($nn,$control) = $ARGV[0] =~ m/^(([RC])\.\d+)$/;
52 if (not defined $control or not defined $nn) {
53 die "Bad argument to service.in";
55 if (!rename("incoming/G$nn","incoming/P$nn")) {
56 defined $! and $! =~ m/no such file or directory/i and exit 0;
57 die "Failed to rename incoming/G$nn to incoming/P$nn: $!";
60 my $log_fh = IO::File->new("incoming/P$nn",'r') or
61 die "Unable to open incoming/P$nn for reading: $!";
68 print "###\n",join("##\n",@msg),"\n###\n" if $debug;
70 # Bug numbers to send e-mail to, hash so that we don't send to the
74 my (@headerlines,@bodylines);
76 my $parse_output = Debbugs::MIME::parse(join('',@log));
77 @headerlines = @{$parse_output->{header}};
78 @bodylines = @{$parse_output->{body}};
82 $_ = decode_rfc1522($_);
84 print ">$_<\n" if $debug;
87 print ">$v=$_<\n" if $debug;
90 print "!>$_<\n" if $debug;
93 $header{'message-id'} ||= '';
94 $header{subject} ||= '';
96 grep(s/\s+$//,@bodylines);
98 print "***\n",join("\n",@bodylines),"\n***\n" if $debug;
100 if (defined $header{'resent-from'} && !defined $header{'from'}) {
101 $header{'from'} = $header{'resent-from'};
104 defined($header{'from'}) || die "no From header";
106 delete $header{'reply-to'}
107 if ( defined($header{'reply-to'}) && $header{'reply-to'} =~ m/^\s*$/ );
110 if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
111 $replyto = $header{'reply-to'};
113 $replyto = $header{'from'};
116 # This is an error counter which should be incremented every time there is an error.
118 my $controlrequestaddr= ($control ? 'control' : 'request').'@'.$config{email_domain};
119 my $transcript_scalar = '';
120 open my $transcript, ">:scalar:utf8", \$transcript_scalar or
121 die "Unable to create transcript scalar: $!";
122 print {$transcript} "Processing commands for $controlrequestaddr:\n\n";
126 my %affected_packages;
128 # this is the hashref which is passed to all control calls
132 my @common_control_options =
133 (transcript => $transcript,
134 requester => $header{from},
135 request_addr => $controlrequestaddr,
136 request_msgid => $header{'message-id'},
137 request_subject => $header{subject},
139 request_replyto => $replyto,
141 affected_bugs => \%bug_affected,
142 affected_packages => \%affected_packages,
143 recipients => \%recipients,
148 my $lowstate= 'idle';
149 my $mergelowstate= 'idle';
154 $user =~ s/^.*<(.*)>.*$/$1/;
155 $user =~ s/[(].*[)]//;
156 $user =~ s/^\s*(\S+)\s+.*$/$1/;
157 $user = "" unless (Debbugs::User::is_valid_user($user));
158 my $indicated_user = 0;
163 if (@gExcludeFromControl and grep {$replyto =~ m/\Q$_\E/} @gExcludeFromControl) {
164 print {$transcript} fill_template('mail/excluded_from_control');
185 for ($procline=0; $procline<=$#bodylines; $procline++) {
190 $state eq 'idle' || print "state: $state ?\n";
191 $lowstate eq 'idle' || print "lowstate: $lowstate ?\n";
192 $mergelowstate eq 'idle' || print "mergelowstate: $mergelowstate ?\n";
194 print {$transcript} "Stopping processing here.\n\n";
197 $_= $bodylines[$procline]; s/\s+$//;
198 # Remove BOM markers from UTF-8 strings
203 my $temp = decode("utf8",$_,Encode::FB_CROAK);
206 print {$transcript} "> $_\n";
209 if (m/^(?:stop|quit|--|thank(?:s|\s*you)?|kthxbye)\.*\s*$/i) {
210 print {$transcript} "Stopping processing here.\n\n";
212 } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
214 if ($dl > 0 and not grep /debug/,@common_control_options) {
215 push @common_control_options,(debug => $transcript);
217 print {$transcript} "Debug level $dl.\n\n";
218 } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
220 &sendlynxdoc("bugreport.cgi?bug=$ref","logs for $gBug#$ref");
221 } elsif (m/^send-detail\s+\#?(\d{2,})$/i) {
223 &sendlynxdoc("bugreport.cgi?bug=$ref&boring=yes",
224 "detailed logs for $gBug#$ref");
225 } elsif (m/^index(\s+full)?$/i) {
226 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
228 $ok++; # well, it's not really ok, but it fixes #81224 :)
229 } elsif (m/^index-summary\s+by-package$/i) {
230 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
232 $ok++; # well, it's not really ok, but it fixes #81224 :)
233 } elsif (m/^index-summary(\s+by-number)?$/i) {
234 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
236 $ok++; # well, it's not really ok, but it fixes #81224 :)
237 } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
238 &sendlynxdoc("pkgindex.cgi?indexon=pkg",'index of packages');
239 } elsif (m/^index(\s+|-)maints?$/i) {
240 &sendlynxdoc("pkgindex.cgi?indexon=maint",'index of maintainers');
241 } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
243 &sendlynxdoc("pkgreport.cgi?maint=" . urlsanit($maint),
244 "$gBug list for maintainer \`$maint'");
246 } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
248 &sendlynxdoc("pkgreport.cgi?pkg=" . urlsanit($package),
249 "$gBug list for package $package");
251 } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
252 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
254 $ok++; # well, it's not really ok, but it fixes #81224 :)
255 } elsif (m/^send-unmatched\s+(last|-1)$/i) {
256 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
258 $ok++; # well, it's not really ok, but it fixes #81224 :)
259 } elsif (m/^send-unmatched\s+(old|-2)$/i) {
260 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
262 $ok++; # well, it's not really ok, but it fixes #81224 :)
263 } elsif (m/^getinfo\s+([\w.-]+)$/i) {
264 # the following is basically a Debian-specific kludge, but who cares
266 if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
267 &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
268 } elsif ($req =~ /^override\.(\w+)\.([\w.-]+)$/i) {
270 &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
271 } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
272 &sendinfo("local", "$gConfigDir/$req", "$req file");
274 print {$transcript} "Info file $req does not exist.\n\n";
276 } elsif (m/^help/i) {
278 print {$transcript} "\n";
280 } elsif (m/^refcard/i) {
281 &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
282 } elsif (m/^subscribe/i) {
283 print {$transcript} <<END;
284 There is no $gProject $gBug mailing list. If you wish to review bug reports
285 please do so via http://$gWebDomain/ or ask this mail server
287 soon: MAILINGLISTS_TEXT
289 } elsif (m/^unsubscribe/i) {
290 print {$transcript} <<END;
291 soon: UNSUBSCRIBE_TEXT
292 soon: MAILINGLISTS_TEXT
294 } elsif (m/^user\s+(\S+)\s*$/i) {
296 if (Debbugs::User::is_valid_user($newuser)) {
297 my $olduser = ($user ne "" ? " (was $user)" : "");
298 print {$transcript} "Setting user to $newuser$olduser.\n";
302 print {$transcript} "Selected user id ($newuser) invalid, sorry\n";
307 } elsif (m/^usercategory\s+(\S+)(\s+\[hidden\])?\s*$/i) {
310 my $hidden = (defined $2 and $2 ne "");
317 print {$transcript} "No valid user selected\n";
321 if (not $indicated_user and defined $user) {
322 print {$transcript} "User is $user\n";
326 while (++$procline <= $#bodylines) {
327 unless ($bodylines[$procline] =~ m/^\s*([*+])\s*(\S.*)$/) {
331 print {$transcript} "> $bodylines[$procline]\n";
333 my ($o, $txt) = ($1, $2);
334 if ($#cats == -1 && $o eq "+") {
335 print {$transcript} "User defined category specification must start with a category name. Skipping.\n\n";
341 unless (ref($cats[-1]) eq "HASH") {
342 $cats[-1] = { "nam" => $cats[-1],
343 "pri" => [], "ttl" => [] };
346 my ($desc, $ord, $op);
347 if ($txt =~ m/^(.*\S)\s*\[((\d+):\s*)?\]\s*$/) {
348 $desc = $1; $ord = $3; $op = "";
349 } elsif ($txt =~ m/^(.*\S)\s*\[((\d+):\s*)?(\S+)\]\s*$/) {
350 $desc = $1; $ord = $3; $op = $4;
351 } elsif ($txt =~ m/^([^[\s]+)\s*$/) {
352 $desc = ""; $op = $1;
354 print {$transcript} "Unrecognised syntax for category section. Skipping.\n\n";
359 $ord = 999 unless defined $ord;
362 push @{$cats[-1]->{"pri"}}, $prefix . $op;
363 push @{$cats[-1]->{"ttl"}}, $desc;
364 push @ords, "$ord $catsec";
366 $cats[-1]->{"def"} = $desc;
367 push @ords, "$ord DEF";
371 my ($a1, $a2, $b1, $b2) = split / /, "$a $b";
372 ((looks_like_number($a1) and looks_like_number($a2))?$a1 <=> $b1:$a1 cmp $b1) ||
373 ((looks_like_number($a2) and looks_like_number($b2))?$a2 <=> $b2:$a2 cmp $b2);
375 $cats[-1]->{"ord"} = [map { m/^.* (\S+)/; $1 eq "DEF" ? $catsec + 1 : $1 } @ords];
376 } elsif ($o eq "*") {
379 if ($txt =~ m/^(.*\S)(\s*\[(\S+)\])\s*$/) {
380 $name = $1; $prefix = $3;
382 $name = $txt; $prefix = "";
387 # XXX: got @cats, now do something with it
388 my $u = Debbugs::User::get_user($user);
390 print {$transcript} "Added usercategory $catname.\n\n";
391 $u->{"categories"}->{$catname} = [ @cats ];
393 push @{$u->{visible_cats}},$catname;
396 print {$transcript} "Removed usercategory $catname.\n\n";
397 delete $u->{"categories"}->{$catname};
398 @{$u->{visible_cats}} = grep {$_ ne $catname} @{$u->{visible_cats}};
401 } elsif (m/^usertags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
404 my $addsubcode = $3 || "+";
406 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
407 $ref = $clonebugs{$ref};
410 print {$transcript} "No valid user selected\n";
413 } elsif (check_limit(data => read_bug(bug => $ref),
415 transcript => $transcript)) {
416 if (not $indicated_user and defined $user) {
417 print {$transcript} "User is $user\n";
421 Debbugs::User::read_usertags(\%ut, $user);
422 my @oldtags = (); my @newtags = (); my @badtags = ();
424 if (defined $tags and length $tags) {
425 for my $t (split /[,\s]+/, $tags) {
426 if ($t =~ m/^[a-zA-Z0-9.+\@-]+$/) {
434 print {$transcript} "Ignoring illegal tag/s: ".join(', ', @badtags).".\nPlease use only alphanumerics, at, dot, plus and dash.\n";
437 for my $t (keys %chtags) {
438 $ut{$t} = [] unless defined $ut{$t};
440 for my $t (keys %ut) {
441 my %res = map { ($_, 1) } @{$ut{$t}};
442 push @oldtags, $t if defined $res{$ref};
443 my $addop = ($addsubcode eq "+" or $addsubcode eq "=");
444 my $del = (defined $chtags{$t} ? $addsubcode eq "-"
445 : $addsubcode eq "=");
446 $res{$ref} = 1 if ($addop && defined $chtags{$t});
447 delete $res{$ref} if ($del);
448 push @newtags, $t if defined $res{$ref};
449 $ut{$t} = [ sort { $a <=> $b } (keys %res) ];
452 print {$transcript} "There were no usertags set.\n";
454 print {$transcript} "Usertags were: " . join(" ", @oldtags) . ".\n";
456 print {$transcript} "Usertags are now: " . join(" ", @newtags) . ".\n";
457 Debbugs::User::write_usertags(\%ut, $user);
459 } elsif (!$control) {
460 print {$transcript} <<END;
461 Unknown command or malformed arguments to command.
462 (Use control\@$gEmailDomain to manipulate reports.)
465 #### "developer only" ones start here
466 } elsif (defined valid_control($_)) {
467 my ($new_errors,$terminate_control) =
468 control_line(line => $_,
469 clonebugs => \%clonebugs,
471 common_control_options => \@common_control_options,
473 transcript => $transcript,
477 if ($terminate_control) {
482 if (++$unknowns >= 5) {
483 print {$transcript} "Too many unknown commands, stopping here.\n\n";
488 if ($procline>$#bodylines) {
489 print {$transcript} ">\nEnd of message, stopping processing here.\n\n";
491 if (!$ok && !$quickabort) {
493 print {$transcript} "No commands successfully parsed; sending the help text(s).\n";
495 print {$transcript} "\n";
498 my @maintccs = determine_recipients(recipients => \%recipients,
502 my $maintccs = 'Cc: '.join(",\n ",
503 determine_recipients(recipients => \%recipients,
509 $packagepr = "X-${gProject}-PR-Package: " . join(keys %affected_packages) . "\n" if keys %affected_packages;
511 # Add Bcc's to subscribed bugs
512 # now handled by Debbugs::Recipients
513 #push @bcc, map {"bugs=$_\@$gListDomain"} keys %bug_affected;
515 if (!defined $header{'subject'} || $header{'subject'} eq "") {
516 $header{'subject'} = "your mail";
519 # Error text here advertises how many errors there were
520 my $error_text = $errors > 0 ? " (with $errors errors)":'';
523 push @common_headers, 'X-Loop',$gMaintainerEmail;
525 my $temp_transcript = ${transcript_scalar};
527 $temp_transcript = decode("utf8",$temp_transcript,Encode::FB_CROAK);
530 create_mime_message([From => "$gMaintainerEmail ($gProject $gBug Tracking System)",
532 @maintccs ? (Cc => join(', ',@maintccs)):(),
533 Subject => "Processed${error_text}: $header{subject}",
534 'Message-ID' => "<handler.s.$nn.transcript\@$gEmailDomain>",
535 'In-Reply-To' => $header{'message-id'},
536 References => join(' ',grep {defined $_} $header{'message-id'},$data->{msgid}),
537 Precedence => 'bulk',
538 keys %affected_packages ?("X-${gProject}-PR-Package" => join(' ',keys %affected_packages)):(),
539 keys %affected_packages ?("X-${gProject}-PR-Source" =>
541 map {defined $_ ?(ref($_)?@{$_}:$_):()}
542 binary_to_source(binary => [keys %affected_packages],
543 source_only => 1))):(),
544 "X-$gProject-PR-Message" => 'transcript',
547 fill_template('mail/message_body',
548 {body => "${temp_transcript}Please contact me if you need assistance."},
551 my $repliedshow= join(', ',$replyto,
552 determine_recipients(recipients => \%recipients,
558 # -1 is the service.in log
559 &filelock("lock/-1");
560 open(AP,">>db-h/-1.log") || die "open db-h/-1.log: $!";
562 "\2\n$repliedshow\n\5\n$reply\n\3\n".
564 "<strong>Request received</strong> from <code>".
565 html_escape($header{'from'})."</code>\n".
566 "to <code>".html_escape($controlrequestaddr)."</code>\n".
568 "\7\n",escape_log(@log),"\n\3\n") || die "writing db-h/-1.log: $!";
569 close(AP) || die "open db-h/-1.log: $!";
571 utime(time,time,"db-h");
573 &sendmailmessage($reply,
574 exists $header{'x-debbugs-no-ack'}?():$replyto,
575 make_list(values %{{determine_recipients(recipients => \%recipients,
581 unlink("incoming/P$nn") || die "unlinking incoming/P$nn: $!";
583 sub sendmailmessage {
584 my ($message,@recips) = @_;
585 $message = "X-Loop: $gMaintainerEmail\n" . $message;
586 send_mail_message(message => $message,
587 recipients => \@recips,
593 my ($template,$extra_var) = @_;
595 my $variables = {config => \%config,
596 defined($ref)?(ref => $ref):(),
597 defined($data)?(data => $data):(),
598 refs => [map {exists $clonebugs{$_}?$clonebugs{$_}:$_} keys %bug_affected],
601 my $hole_var = {'&bugurl' =>
603 'http://'.$config{cgi_domain}.'/'.
604 Debbugs::CGI::bug_links(bug=>$_[0],
609 return fill_in_template(template => $template,
610 variables => $variables,
611 hole_var => $hole_var,
615 =head2 message_body_template
617 message_body_template('mail/ack',{ref=>'foo'});
619 Creates a message body using a template
623 sub message_body_template{
624 my ($template,$extra_var) = @_;
626 my $body = fill_template($template,$extra_var);
627 return fill_template('mail/message_body',
636 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
639 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
644 # print {$transcript} "Sorry, command $_[0] not yet implemented.\n\n";
646 our %checkmatch_values;
648 my ($string,$mvarname,$svarvalue,@newmergelist) = @_;
651 $mvarvalue = $checkmatch_values{$mvarname};
652 print {$transcript} "D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n"
655 "Values for \`$string' don't match:\n".
656 " #$newmergelist[0] has \`$mvarvalue';\n".
657 " #$ref has \`$svarvalue'\n"
658 if $mvarvalue ne $svarvalue;
660 print {$transcript} "D| setupmatch \`$string' /$mvarname/$svarvalue/\n"
662 $checkmatch_values{$mvarname} = $svarvalue;
667 if (keys %limit_pkgs and not defined $limit_pkgs{$data->{package}}) {
668 print {$transcript} "$gBug number $ref belongs to package $data->{package}, skipping.\n\n";
680 my %h = map { $_ => 1 } split ' ', $list;
687 return join ' ', sort keys %h;
690 # High-level bug manipulation calls
691 # Do announcements themselves
693 # Possible calling sequences:
697 # &transcript(something)
701 # $action= (something)
703 # (modify s_* variables)
704 # } while (getnextbug);
709 &dlen("nochangebug");
710 $state eq 'single' || $state eq 'multiple' || die "$state ?";
712 &endmerge if $manybugs;
714 &dlex("nochangebug");
718 our @thisbugmergelist;
721 &dlen("setbug $ref");
722 if ($ref =~ m/^-\d+/) {
723 if (!defined $clonebugs{$ref}) {
725 &dlex("setbug => noclone");
728 $ref = $clonebugs{$ref};
730 $state eq 'idle' || die "$state ?";
733 &dlex("setbug => 0s");
737 if (!&checkpkglimit) {
742 @thisbugmergelist= split(/ /,$data->{mergedwith});
743 if (!@thisbugmergelist) {
748 &dlex("setbug => 1s");
757 &dlex("setbug => 0mc");
761 $state= 'multiple'; $sref=$ref;
762 &dlex("setbug => 1m");
768 $state eq 'single' || $state eq 'multiple' || die "$state ?";
770 if (!$manybugs || !@thisbugmergelist) {
771 length($action) || die;
772 print {$transcript} "$action\n$extramessage\n";
773 &endmerge if $manybugs;
775 &dlex("getnextbug => 0");
778 $ref= shift(@thisbugmergelist);
779 &getbug || die "bug $ref disappeared";
781 &dlex("getnextbug => 1");
785 # Low-level bug-manipulation calls
786 # Do no announcements
794 # $action= (something)
799 # [getbug (returns 0)]
800 # &transcript("$action\n\n")
803 sub notfoundbug { print {$transcript} "$gBug number $ref not found. (Is it archived?)\n\n"; }
804 sub foundbug { print {$transcript} "$gBug#$ref: $data->{subject}\n"; }
808 $mergelowstate eq 'idle' || die "$mergelowstate ?";
809 &filelock('lock/merge');
810 $mergelowstate='locked';
816 $mergelowstate eq 'locked' || die "$mergelowstate ?";
818 $mergelowstate='idle';
823 &dlen("getbug $ref");
824 $lowstate eq 'idle' || die "$state ?";
825 # Only use unmerged bugs here
826 if (($data = &lockreadbug($ref,'db-h'))) {
829 &dlex("getbug => 1");
834 &dlex("getbug => 0");
840 $lowstate eq 'open' || die "$state ?";
847 &dlen("savebug $ref");
848 $lowstate eq 'open' || die "$lowstate ?";
849 length($action) || die;
850 $ref == $sref || die "read $sref but saving $ref ?";
851 append_action_to_log(bug => $ref,
853 requester => $header{from},
854 request_addr => $controlrequestaddr,
858 unlockwritebug($ref, $data);
865 print {$transcript} "C> @_ ($state $lowstate $mergelowstate)\n";
870 print {$transcript} "R> @_ ($state $lowstate $mergelowstate)\n";
877 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
878 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
884 print {$transcript} "\n";
890 print {$transcript} "\n";
897 my ($relpath,$description) = @_;
899 if (not -e "$gDocDir/$relpath") {
900 print {$transcript} "Unfortunatly, the help text doesn't exist, so it wasn't sent.\n";
901 warn "Help text $gDocDir/$relpath not found";
904 open(D,"$gDocDir/$relpath") || die "open doc file $relpath: $!";
905 while(<D>) { $doc.=$_; }
907 print {$transcript} "Sending $description in separate message.\n";
908 &sendmailmessage(<<END.$doc,$replyto);
909 From: $gMaintainerEmail ($gProject $gBug Tracking System)
911 Subject: $gProject $gBug help: $description
912 References: $header{'message-id'}
913 In-Reply-To: $header{'message-id'}
914 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
916 X-$gProject-PR-Message: doc-text $relpath
923 my ($relpath,$description) = @_;
925 open(L,"lynx -nolist -dump http://$gCGIDomain/\Q$relpath\E 2>&1 |") || die "fork for lynx: $!";
926 while(<L>) { $doc.=$_; }
928 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
929 print {$transcript} "Information ($description) is not available -\n".
930 "perhaps the $gBug does not exist or is not on the WWW yet.\n";
933 print {$transcript} "Error getting $description (code $? $!):\n$doc\n";
935 print {$transcript} "Sending $description.\n";
936 &sendmailmessage(<<END.$doc,$replyto);
937 From: $gMaintainerEmail ($gProject $gBug Tracking System)
939 Subject: $gProject $gBugs information: $description
940 References: $header{'message-id'}
941 In-Reply-To: $header{'message-id'}
942 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
944 X-$gProject-PR-Message: doc-html $relpath
953 my ($wherefrom,$path,$description) = @_;
954 if ($wherefrom eq "ftp.d.o") {
955 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or die "fork for lynx/gunzip: $!";
957 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
958 print {$transcript} "$description is not available.\n";
961 print {$transcript} "Error getting $description (code $? $!):\n$doc\n";
964 } elsif ($wherefrom eq "local") {
966 $doc = do { local $/; <P> };
969 print {$transcript} "internal errror: info files location unknown.\n";
972 print {$transcript} "Sending $description.\n";
973 &sendmailmessage(<<END.$doc,$replyto);
974 From: $gMaintainerEmail ($gProject $gBug Tracking System)
976 Subject: $gProject $gBugs information: $description
977 References: $header{'message-id'}
978 In-Reply-To: $header{'message-id'}
979 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
981 X-$gProject-PR-Message: getinfo
983 $description follows:
987 print {$transcript} "\n";