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');
175 push @bcc, $_[0] unless grep { $_ eq $_[0] } @bcc;
190 for ($procline=0; $procline<=$#bodylines; $procline++) {
195 $state eq 'idle' || print "state: $state ?\n";
196 $lowstate eq 'idle' || print "lowstate: $lowstate ?\n";
197 $mergelowstate eq 'idle' || print "mergelowstate: $mergelowstate ?\n";
199 print {$transcript} "Stopping processing here.\n\n";
202 $_= $bodylines[$procline]; s/\s+$//;
203 # Remove BOM markers from UTF-8 strings
208 my $temp = decode("utf8",$_,Encode::FB_CROAK);
211 print {$transcript} "> $_\n";
214 if (m/^(?:stop|quit|--|thank(?:s|\s*you)?|kthxbye)\.*\s*$/i) {
215 print {$transcript} "Stopping processing here.\n\n";
217 } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
219 if ($dl > 0 and not grep /debug/,@common_control_options) {
220 push @common_control_options,(debug => $transcript);
222 print {$transcript} "Debug level $dl.\n\n";
223 } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
225 &sendlynxdoc("bugreport.cgi?bug=$ref","logs for $gBug#$ref");
226 } elsif (m/^send-detail\s+\#?(\d{2,})$/i) {
228 &sendlynxdoc("bugreport.cgi?bug=$ref&boring=yes",
229 "detailed logs for $gBug#$ref");
230 } elsif (m/^index(\s+full)?$/i) {
231 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
233 $ok++; # well, it's not really ok, but it fixes #81224 :)
234 } elsif (m/^index-summary\s+by-package$/i) {
235 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
237 $ok++; # well, it's not really ok, but it fixes #81224 :)
238 } elsif (m/^index-summary(\s+by-number)?$/i) {
239 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
241 $ok++; # well, it's not really ok, but it fixes #81224 :)
242 } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
243 &sendlynxdoc("pkgindex.cgi?indexon=pkg",'index of packages');
244 } elsif (m/^index(\s+|-)maints?$/i) {
245 &sendlynxdoc("pkgindex.cgi?indexon=maint",'index of maintainers');
246 } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
248 &sendlynxdoc("pkgreport.cgi?maint=" . urlsanit($maint),
249 "$gBug list for maintainer \`$maint'");
251 } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
253 &sendlynxdoc("pkgreport.cgi?pkg=" . urlsanit($package),
254 "$gBug list for package $package");
256 } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
257 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
259 $ok++; # well, it's not really ok, but it fixes #81224 :)
260 } elsif (m/^send-unmatched\s+(last|-1)$/i) {
261 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
263 $ok++; # well, it's not really ok, but it fixes #81224 :)
264 } elsif (m/^send-unmatched\s+(old|-2)$/i) {
265 print {$transcript} "This BTS function is currently disabled, sorry.\n\n";
267 $ok++; # well, it's not really ok, but it fixes #81224 :)
268 } elsif (m/^getinfo\s+([\w.-]+)$/i) {
269 # the following is basically a Debian-specific kludge, but who cares
271 if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
272 &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
273 } elsif ($req =~ /^override\.(\w+)\.([\w.-]+)$/i) {
275 &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
276 } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
277 &sendinfo("local", "$gConfigDir/$req", "$req file");
279 print {$transcript} "Info file $req does not exist.\n\n";
281 } elsif (m/^help/i) {
283 print {$transcript} "\n";
285 } elsif (m/^refcard/i) {
286 &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
287 } elsif (m/^subscribe/i) {
288 print {$transcript} <<END;
289 There is no $gProject $gBug mailing list. If you wish to review bug reports
290 please do so via http://$gWebDomain/ or ask this mail server
292 soon: MAILINGLISTS_TEXT
294 } elsif (m/^unsubscribe/i) {
295 print {$transcript} <<END;
296 soon: UNSUBSCRIBE_TEXT
297 soon: MAILINGLISTS_TEXT
299 } elsif (m/^user\s+(\S+)\s*$/i) {
301 if (Debbugs::User::is_valid_user($newuser)) {
302 my $olduser = ($user ne "" ? " (was $user)" : "");
303 print {$transcript} "Setting user to $newuser$olduser.\n";
307 print {$transcript} "Selected user id ($newuser) invalid, sorry\n";
312 } elsif (m/^usercategory\s+(\S+)(\s+\[hidden\])?\s*$/i) {
315 my $hidden = (defined $2 and $2 ne "");
322 print {$transcript} "No valid user selected\n";
326 if (not $indicated_user and defined $user) {
327 print {$transcript} "User is $user\n";
331 while (++$procline <= $#bodylines) {
332 unless ($bodylines[$procline] =~ m/^\s*([*+])\s*(\S.*)$/) {
336 print {$transcript} "> $bodylines[$procline]\n";
338 my ($o, $txt) = ($1, $2);
339 if ($#cats == -1 && $o eq "+") {
340 print {$transcript} "User defined category specification must start with a category name. Skipping.\n\n";
346 unless (ref($cats[-1]) eq "HASH") {
347 $cats[-1] = { "nam" => $cats[-1],
348 "pri" => [], "ttl" => [] };
351 my ($desc, $ord, $op);
352 if ($txt =~ m/^(.*\S)\s*\[((\d+):\s*)?\]\s*$/) {
353 $desc = $1; $ord = $3; $op = "";
354 } elsif ($txt =~ m/^(.*\S)\s*\[((\d+):\s*)?(\S+)\]\s*$/) {
355 $desc = $1; $ord = $3; $op = $4;
356 } elsif ($txt =~ m/^([^[\s]+)\s*$/) {
357 $desc = ""; $op = $1;
359 print {$transcript} "Unrecognised syntax for category section. Skipping.\n\n";
364 $ord = 999 unless defined $ord;
367 push @{$cats[-1]->{"pri"}}, $prefix . $op;
368 push @{$cats[-1]->{"ttl"}}, $desc;
369 push @ords, "$ord $catsec";
371 $cats[-1]->{"def"} = $desc;
372 push @ords, "$ord DEF";
376 my ($a1, $a2, $b1, $b2) = split / /, "$a $b";
377 ((looks_like_number($a1) and looks_like_number($a2))?$a1 <=> $b1:$a1 cmp $b1) ||
378 ((looks_like_number($a2) and looks_like_number($b2))?$a2 <=> $b2:$a2 cmp $b2);
380 $cats[-1]->{"ord"} = [map { m/^.* (\S+)/; $1 eq "DEF" ? $catsec + 1 : $1 } @ords];
381 } elsif ($o eq "*") {
384 if ($txt =~ m/^(.*\S)(\s*\[(\S+)\])\s*$/) {
385 $name = $1; $prefix = $3;
387 $name = $txt; $prefix = "";
392 # XXX: got @cats, now do something with it
393 my $u = Debbugs::User::get_user($user);
395 print {$transcript} "Added usercategory $catname.\n\n";
396 $u->{"categories"}->{$catname} = [ @cats ];
398 push @{$u->{visible_cats}},$catname;
401 print {$transcript} "Removed usercategory $catname.\n\n";
402 delete $u->{"categories"}->{$catname};
403 @{$u->{visible_cats}} = grep {$_ ne $catname} @{$u->{visible_cats}};
406 } elsif (m/^usertags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
409 my $addsubcode = $3 || "+";
411 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
412 $ref = $clonebugs{$ref};
415 print {$transcript} "No valid user selected\n";
418 } elsif (check_limit(data => read_bug(bug => $ref),
420 transcript => $transcript)) {
421 if (not $indicated_user and defined $user) {
422 print {$transcript} "User is $user\n";
426 Debbugs::User::read_usertags(\%ut, $user);
427 my @oldtags = (); my @newtags = (); my @badtags = ();
429 if (defined $tags and length $tags) {
430 for my $t (split /[,\s]+/, $tags) {
431 if ($t =~ m/^[a-zA-Z0-9.+\@-]+$/) {
439 print {$transcript} "Ignoring illegal tag/s: ".join(', ', @badtags).".\nPlease use only alphanumerics, at, dot, plus and dash.\n";
442 for my $t (keys %chtags) {
443 $ut{$t} = [] unless defined $ut{$t};
445 for my $t (keys %ut) {
446 my %res = map { ($_, 1) } @{$ut{$t}};
447 push @oldtags, $t if defined $res{$ref};
448 my $addop = ($addsubcode eq "+" or $addsubcode eq "=");
449 my $del = (defined $chtags{$t} ? $addsubcode eq "-"
450 : $addsubcode eq "=");
451 $res{$ref} = 1 if ($addop && defined $chtags{$t});
452 delete $res{$ref} if ($del);
453 push @newtags, $t if defined $res{$ref};
454 $ut{$t} = [ sort { $a <=> $b } (keys %res) ];
457 print {$transcript} "There were no usertags set.\n";
459 print {$transcript} "Usertags were: " . join(" ", @oldtags) . ".\n";
461 print {$transcript} "Usertags are now: " . join(" ", @newtags) . ".\n";
462 Debbugs::User::write_usertags(\%ut, $user);
464 } elsif (!$control) {
465 print {$transcript} <<END;
466 Unknown command or malformed arguments to command.
467 (Use control\@$gEmailDomain to manipulate reports.)
470 #### "developer only" ones start here
471 } elsif (defined valid_control($_)) {
472 my ($new_errors,$terminate_control) =
473 control_line(line => $_,
474 clonebugs => \%clonebugs,
476 common_control_options => \@common_control_options,
478 transcript => $transcript,
482 if ($terminate_control) {
487 if (++$unknowns >= 5) {
488 print {$transcript} "Too many unknown commands, stopping here.\n\n";
493 if ($procline>$#bodylines) {
494 print {$transcript} ">\nEnd of message, stopping processing here.\n\n";
496 if (!$ok && !$quickabort) {
498 print {$transcript} "No commands successfully parsed; sending the help text(s).\n";
500 print {$transcript} "\n";
503 my @maintccs = determine_recipients(recipients => \%recipients,
507 my $maintccs = 'Cc: '.join(",\n ",
508 determine_recipients(recipients => \%recipients,
514 $packagepr = "X-${gProject}-PR-Package: " . join(keys %affected_packages) . "\n" if keys %affected_packages;
516 # Add Bcc's to subscribed bugs
517 # now handled by Debbugs::Recipients
518 #push @bcc, map {"bugs=$_\@$gListDomain"} keys %bug_affected;
520 if (!defined $header{'subject'} || $header{'subject'} eq "") {
521 $header{'subject'} = "your mail";
524 # Error text here advertises how many errors there were
525 my $error_text = $errors > 0 ? " (with $errors errors)":'';
528 push @common_headers, 'X-Loop',$gMaintainerEmail;
530 my $temp_transcript = ${transcript_scalar};
532 $temp_transcript = decode("utf8",$temp_transcript,Encode::FB_CROAK);
535 create_mime_message([From => "$gMaintainerEmail ($gProject $gBug Tracking System)",
537 @maintccs ? (Cc => join(', ',@maintccs)):(),
538 Subject => "Processed${error_text}: $header{subject}",
539 'Message-ID' => "<handler.s.$nn.transcript\@$gEmailDomain>",
540 'In-Reply-To' => $header{'message-id'},
541 References => join(' ',grep {defined $_} $header{'message-id'},$data->{msgid}),
542 Precedence => 'bulk',
543 keys %affected_packages ?("X-${gProject}-PR-Package" => join(' ',keys %affected_packages)):(),
544 keys %affected_packages ?("X-${gProject}-PR-Source" =>
546 map {defined $_ ?(ref($_)?@{$_}:$_):()}
547 binary_to_source(binary => [keys %affected_packages],
548 source_only => 1))):(),
549 "X-$gProject-PR-Message" => 'transcript',
552 fill_template('mail/message_body',
553 {body => "${temp_transcript}Please contact me if you need assistance."},
556 my $repliedshow= join(', ',$replyto,
557 determine_recipients(recipients => \%recipients,
563 # -1 is the service.in log
564 &filelock("lock/-1");
565 open(AP,">>db-h/-1.log") || die "open db-h/-1.log: $!";
567 "\2\n$repliedshow\n\5\n$reply\n\3\n".
569 "<strong>Request received</strong> from <code>".
570 html_escape($header{'from'})."</code>\n".
571 "to <code>".html_escape($controlrequestaddr)."</code>\n".
573 "\7\n",escape_log(@log),"\n\3\n") || die "writing db-h/-1.log: $!";
574 close(AP) || die "open db-h/-1.log: $!";
576 utime(time,time,"db-h");
578 &sendmailmessage($reply,
579 exists $header{'x-debbugs-no-ack'}?():$replyto,
580 make_list(values %{{determine_recipients(recipients => \%recipients,
586 unlink("incoming/P$nn") || die "unlinking incoming/P$nn: $!";
588 sub sendmailmessage {
589 my ($message,@recips) = @_;
590 $message = "X-Loop: $gMaintainerEmail\n" . $message;
591 send_mail_message(message => $message,
592 recipients => \@recips,
598 my ($template,$extra_var) = @_;
600 my $variables = {config => \%config,
601 defined($ref)?(ref => $ref):(),
602 defined($data)?(data => $data):(),
603 refs => [map {exists $clonebugs{$_}?$clonebugs{$_}:$_} keys %bug_affected],
606 my $hole_var = {'&bugurl' =>
608 'http://'.$config{cgi_domain}.'/'.
609 Debbugs::CGI::bug_links(bug=>$_[0],
614 return fill_in_template(template => $template,
615 variables => $variables,
616 hole_var => $hole_var,
620 =head2 message_body_template
622 message_body_template('mail/ack',{ref=>'foo'});
624 Creates a message body using a template
628 sub message_body_template{
629 my ($template,$extra_var) = @_;
631 my $body = fill_template($template,$extra_var);
632 return fill_template('mail/message_body',
641 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
644 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
649 # print {$transcript} "Sorry, command $_[0] not yet implemented.\n\n";
651 our %checkmatch_values;
653 my ($string,$mvarname,$svarvalue,@newmergelist) = @_;
656 $mvarvalue = $checkmatch_values{$mvarname};
657 print {$transcript} "D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n"
660 "Values for \`$string' don't match:\n".
661 " #$newmergelist[0] has \`$mvarvalue';\n".
662 " #$ref has \`$svarvalue'\n"
663 if $mvarvalue ne $svarvalue;
665 print {$transcript} "D| setupmatch \`$string' /$mvarname/$svarvalue/\n"
667 $checkmatch_values{$mvarname} = $svarvalue;
672 if (keys %limit_pkgs and not defined $limit_pkgs{$data->{package}}) {
673 print {$transcript} "$gBug number $ref belongs to package $data->{package}, skipping.\n\n";
685 my %h = map { $_ => 1 } split ' ', $list;
692 return join ' ', sort keys %h;
695 # High-level bug manipulation calls
696 # Do announcements themselves
698 # Possible calling sequences:
702 # &transcript(something)
706 # $action= (something)
708 # (modify s_* variables)
709 # } while (getnextbug);
714 &dlen("nochangebug");
715 $state eq 'single' || $state eq 'multiple' || die "$state ?";
717 &endmerge if $manybugs;
719 &dlex("nochangebug");
723 our @thisbugmergelist;
726 &dlen("setbug $ref");
727 if ($ref =~ m/^-\d+/) {
728 if (!defined $clonebugs{$ref}) {
730 &dlex("setbug => noclone");
733 $ref = $clonebugs{$ref};
735 $state eq 'idle' || die "$state ?";
738 &dlex("setbug => 0s");
742 if (!&checkpkglimit) {
747 @thisbugmergelist= split(/ /,$data->{mergedwith});
748 if (!@thisbugmergelist) {
753 &dlex("setbug => 1s");
762 &dlex("setbug => 0mc");
766 $state= 'multiple'; $sref=$ref;
767 &dlex("setbug => 1m");
773 $state eq 'single' || $state eq 'multiple' || die "$state ?";
775 if (!$manybugs || !@thisbugmergelist) {
776 length($action) || die;
777 print {$transcript} "$action\n$extramessage\n";
778 &endmerge if $manybugs;
780 &dlex("getnextbug => 0");
783 $ref= shift(@thisbugmergelist);
784 &getbug || die "bug $ref disappeared";
786 &dlex("getnextbug => 1");
790 # Low-level bug-manipulation calls
791 # Do no announcements
799 # $action= (something)
804 # [getbug (returns 0)]
805 # &transcript("$action\n\n")
808 sub notfoundbug { print {$transcript} "$gBug number $ref not found. (Is it archived?)\n\n"; }
809 sub foundbug { print {$transcript} "$gBug#$ref: $data->{subject}\n"; }
813 $mergelowstate eq 'idle' || die "$mergelowstate ?";
814 &filelock('lock/merge');
815 $mergelowstate='locked';
821 $mergelowstate eq 'locked' || die "$mergelowstate ?";
823 $mergelowstate='idle';
828 &dlen("getbug $ref");
829 $lowstate eq 'idle' || die "$state ?";
830 # Only use unmerged bugs here
831 if (($data = &lockreadbug($ref,'db-h'))) {
834 &dlex("getbug => 1");
839 &dlex("getbug => 0");
845 $lowstate eq 'open' || die "$state ?";
852 &dlen("savebug $ref");
853 $lowstate eq 'open' || die "$lowstate ?";
854 length($action) || die;
855 $ref == $sref || die "read $sref but saving $ref ?";
856 append_action_to_log(bug => $ref,
858 requester => $header{from},
859 request_addr => $controlrequestaddr,
863 unlockwritebug($ref, $data);
870 print {$transcript} "C> @_ ($state $lowstate $mergelowstate)\n";
875 print {$transcript} "R> @_ ($state $lowstate $mergelowstate)\n";
882 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
883 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
889 print {$transcript} "\n";
895 print {$transcript} "\n";
902 my ($relpath,$description) = @_;
904 if (not -e "$gDocDir/$relpath") {
905 print {$transcript} "Unfortunatly, the help text doesn't exist, so it wasn't sent.\n";
906 warn "Help text $gDocDir/$relpath not found";
909 open(D,"$gDocDir/$relpath") || die "open doc file $relpath: $!";
910 while(<D>) { $doc.=$_; }
912 print {$transcript} "Sending $description in separate message.\n";
913 &sendmailmessage(<<END.$doc,$replyto);
914 From: $gMaintainerEmail ($gProject $gBug Tracking System)
916 Subject: $gProject $gBug help: $description
917 References: $header{'message-id'}
918 In-Reply-To: $header{'message-id'}
919 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
921 X-$gProject-PR-Message: doc-text $relpath
928 my ($relpath,$description) = @_;
930 open(L,"lynx -nolist -dump http://$gCGIDomain/\Q$relpath\E 2>&1 |") || die "fork for lynx: $!";
931 while(<L>) { $doc.=$_; }
933 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
934 print {$transcript} "Information ($description) is not available -\n".
935 "perhaps the $gBug does not exist or is not on the WWW yet.\n";
938 print {$transcript} "Error getting $description (code $? $!):\n$doc\n";
940 print {$transcript} "Sending $description.\n";
941 &sendmailmessage(<<END.$doc,$replyto);
942 From: $gMaintainerEmail ($gProject $gBug Tracking System)
944 Subject: $gProject $gBugs information: $description
945 References: $header{'message-id'}
946 In-Reply-To: $header{'message-id'}
947 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
949 X-$gProject-PR-Message: doc-html $relpath
958 my ($wherefrom,$path,$description) = @_;
959 if ($wherefrom eq "ftp.d.o") {
960 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or die "fork for lynx/gunzip: $!";
962 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
963 print {$transcript} "$description is not available.\n";
966 print {$transcript} "Error getting $description (code $? $!):\n$doc\n";
969 } elsif ($wherefrom eq "local") {
971 $doc = do { local $/; <P> };
974 print {$transcript} "internal errror: info files location unknown.\n";
977 print {$transcript} "Sending $description.\n";
978 &sendmailmessage(<<END.$doc,$replyto);
979 From: $gMaintainerEmail ($gProject $gBug Tracking System)
981 Subject: $gProject $gBugs information: $description
982 References: $header{'message-id'}
983 In-Reply-To: $header{'message-id'}
984 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
986 X-$gProject-PR-Message: getinfo
988 $description follows:
992 print {$transcript} "\n";