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
9 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
10 use Debbugs::Mail qw(send_mail_message);
12 use HTML::Entities qw(encode_entities);
14 use Debbugs::Config qw(:globals);
15 use Debbugs::CGI qw(html_escape);
16 $lib_path = $gLibPath;
17 require "$lib_path/errorlib";
18 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
20 chdir("$gSpoolDir") || die "chdir spool: $!\n";
23 open DEBUG, ">/dev/null";
28 m/^[RC]\.\d+$/ || &quit("bad argument");
31 if (!rename("incoming/G$nn","incoming/P$nn")) {
32 $_=$!.''; m/no such file or directory/i && exit 0;
33 &quit("renaming to lock: $!");
36 open(M,"incoming/P$nn");
43 print "###\n",join("##\n",@msg),"\n###\n" if $debug;
45 my $parser = new MIME::Parser;
46 mkdir "$gSpoolDir/mime.tmp", 0777;
47 $parser->output_under("$gSpoolDir/mime.tmp");
48 my $entity = eval { $parser->parse_data(join('',@log)) };
50 # header and decoded body respectively
51 my (@headerlines, @bodylines);
52 # Bug numbers to send e-mail to, hash so that we don't send to the
56 if ($entity and $entity->head->tags) {
57 @headerlines = @{$entity->head->header};
60 my $entity_body = getmailbody($entity);
61 @bodylines = $entity_body ? $entity_body->as_lines() : ();
64 # Legacy pre-MIME code, kept around in case MIME::Parser fails.
66 for ($i = 0; $i <= $#msg; $i++) {
68 last unless length($_);
69 while ($msg[$i+1] =~ m/^\s/) {
73 push @headerlines, $_;
76 @bodylines = @msg[$i..$#msg];
80 $_ = decode_rfc1522($_);
82 print ">$_<\n" if $debug;
85 print ">$v=$_<\n" if $debug;
88 print "!>$_<\n" if $debug;
92 # Strip off RFC2440-style PGP clearsigning.
93 if (@bodylines and $bodylines[0] =~ /^-----BEGIN PGP SIGNED/) {
94 shift @bodylines while @bodylines and length $bodylines[0];
95 shift @bodylines while @bodylines and $bodylines[0] !~ /\S/;
96 for my $findsig (0 .. $#bodylines) {
97 if ($bodylines[$findsig] =~ /^-----BEGIN PGP SIGNATURE/) {
98 $#bodylines = $findsig - 1;
102 map { s/^- // } @bodylines;
105 grep(s/\s+$//,@bodylines);
107 print "***\n",join("\n",@bodylines),"\n***\n" if $debug;
109 if (defined $header{'resent-from'} && !defined $header{'from'}) {
110 $header{'from'} = $header{'resent-from'};
113 defined($header{'from'}) || &quit("no From header");
115 delete $header{'reply-to'}
116 if ( defined($header{'reply-to'}) && $header{'reply-to'} =~ m/^\s*$/ );
118 if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
119 $replyto = $header{'reply-to'};
121 $replyto = $header{'from'};
124 # This is an error counter which should be incremented every time there is an error.
126 $controlrequestaddr= $control ? "control\@$gEmailDomain" : "request\@$gEmailDomain";
128 &transcript("Processing commands for $controlrequestaddr:\n\n");
133 $mergelowstate= 'idle';
139 $user =~ s/^.*<(.*)>.*$/$1/;
140 $user =~ s/[(].*[)]//;
141 $user =~ s/^\s*(\S+)\s+.*$/$1/;
142 $user = "" unless (Debbugs::User::is_valid_user($user));
146 my $fuckheads = "(" . join("|", @gFuckheads) . ")";
147 if (@gFuckheads and $replyto =~ m/$fuckheads/) {
148 &transcript("This service is unavailable.\n\n");
157 push @bcc, $_[0] unless grep { $_ eq $_[0] } @bcc;
160 for ($procline=0; $procline<=$#bodylines; $procline++) {
161 $state eq 'idle' || print "$state ?\n";
162 $lowstate eq 'idle' || print "$lowstate ?\n";
163 $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
165 &transcript("Stopping processing here.\n\n");
168 $_= $bodylines[$procline]; s/\s+$//;
170 &transcript("> $_\n");
173 if (m/^stop\s*$/i || m/^quit\s*$/i || m/^--\s*$/ || m/^thank(?:s|\s*you)?\s*$/i || m/^kthxbye\s*$/i) {
174 &transcript("Stopping processing here.\n\n");
176 } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
178 &transcript("Debug level $dl.\n\n");
179 } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
181 &sendlynxdoc("bugreport.cgi?bug=$ref","logs for $gBug#$ref");
182 } elsif (m/^send-detail\s+\#?(\d{2,})$/i) {
184 &sendlynxdoc("bugreport.cgi?bug=$ref&boring=yes",
185 "detailed logs for $gBug#$ref");
186 } elsif (m/^index(\s+full)?$/i) {
187 &transcript("This BTS function is currently disabled, sorry.\n\n");
189 $ok++; # well, it's not really ok, but it fixes #81224 :)
190 } elsif (m/^index-summary\s+by-package$/i) {
191 &transcript("This BTS function is currently disabled, sorry.\n\n");
193 $ok++; # well, it's not really ok, but it fixes #81224 :)
194 } elsif (m/^index-summary(\s+by-number)?$/i) {
195 &transcript("This BTS function is currently disabled, sorry.\n\n");
197 $ok++; # well, it's not really ok, but it fixes #81224 :)
198 } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
199 &sendlynxdoc("pkgindex.cgi?indexon=pkg",'index of packages');
200 } elsif (m/^index(\s+|-)maints?$/i) {
201 &sendlynxdoc("pkgindex.cgi?indexon=maint",'index of maintainers');
202 } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
204 &sendlynxdoc("pkgreport.cgi?maint=" . urlsanit($maint),
205 "$gBug list for maintainer \`$maint'");
207 } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
209 &sendlynxdoc("pkgreport.cgi?pkg=" . urlsanit($package),
210 "$gBug list for package $package");
212 } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
213 &transcript("This BTS function is currently disabled, sorry.\n\n");
215 $ok++; # well, it's not really ok, but it fixes #81224 :)
216 } elsif (m/^send-unmatched\s+(last|-1)$/i) {
217 &transcript("This BTS function is currently disabled, sorry.\n\n");
219 $ok++; # well, it's not really ok, but it fixes #81224 :)
220 } elsif (m/^send-unmatched\s+(old|-2)$/i) {
221 &transcript("This BTS function is currently disabled, sorry.\n\n");
223 $ok++; # well, it's not really ok, but it fixes #81224 :)
224 } elsif (m/^getinfo\s+([\w-.]+)$/i) {
225 # the following is basically a Debian-specific kludge, but who cares
227 if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
228 &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
229 } elsif ($req =~ /^override\.(\w+)\.([\w-.]+)$/i) {
231 &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
232 } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
233 &sendinfo("local", "$gConfigDir/$req", "$req file");
235 &transcript("Info file $req does not exist.\n\n");
237 } elsif (m/^help/i) {
241 } elsif (m/^refcard/i) {
242 &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
243 } elsif (m/^subscribe/i) {
245 There is no $gProject $gBug mailing list. If you wish to review bug reports
246 please do so via http://$gWebDomain/ or ask this mail server
248 soon: MAILINGLISTS_TEXT
250 } elsif (m/^unsubscribe/i) {
252 soon: UNSUBSCRIBE_TEXT
253 soon: MAILINGLISTS_TEXT
255 } elsif (m/^user\s+(\S+)\s*$/i) {
257 if (Debbugs::User::is_valid_user($newuser)) {
258 my $olduser = ($user ne "" ? " (was $user)" : "");
259 &transcript("Setting user to $newuser$olduser.\n");
262 &transcript("Selected user id ($newuser) invalid, sorry\n");
266 } elsif (m/^usercategory\s+(\S+)(\s+\[hidden\])?\s*$/i) {
269 my $hidden = ($2 ne "");
275 while (++$procline <= $#bodylines) {
276 unless ($bodylines[$procline] =~ m/^\s*([*+])\s*(\S.*)$/) {
280 &transcript("> $bodylines[$procline]\n");
282 my ($o, $txt) = ($1, $2);
283 if ($#cats == -1 && $o eq "+") {
284 &transcript("User defined category specification must start with a category name. Skipping.\n\n");
290 unless (ref($cats[-1]) eq "HASH") {
291 $cats[-1] = { "nam" => $cats[-1],
292 "pri" => [], "ttl" => [] };
295 my ($desc, $ord, $op);
296 if ($txt =~ m/^(.*\S)\s*\[((\d+):\s*)?\]\s*$/) {
297 $desc = $1; $ord = $3; $op = "";
298 } elsif ($txt =~ m/^(.*\S)\s*\[((\d+):\s*)?(\S+)\]\s*$/) {
299 $desc = $1; $ord = $3; $op = $4;
300 } elsif ($txt =~ m/^([^[\s]+)\s*$/) {
301 $desc = ""; $op = $1;
303 &transcript("Unrecognised syntax for category section. Skipping.\n\n");
308 $ord = 999 unless defined $ord;
311 push @{$cats[-1]->{"pri"}}, $prefix . $op;
312 push @{$cats[-1]->{"ttl"}}, $desc;
313 push @ords, "$ord $catsec";
315 @cats[-1]->{"def"} = $desc;
316 push @ords, "$ord DEF";
319 @ords = sort { my ($a1, $a2, $b1, $b2) = split / /, "$a $b";
320 $a1 <=> $b1 || $a2 <=> $b2; } @ords;
321 $cats[-1]->{"ord"} = [map { m/^.* (\S+)/; $1 eq "DEF" ? $catsec + 1 : $1 } @ords];
322 } elsif ($o eq "*") {
325 if ($txt =~ m/^(.*\S)(\s*\[(\S+)\])\s*$/) {
326 $name = $1; $prefix = $3;
328 $name = $txt; $prefix = "";
333 # XXX: got @cats, now do something with it
334 my $u = Debbugs::User::get_user($user);
336 &transcript("Added usercategory $catname.\n\n");
337 $u->{"categories"}->{$catname} = [ @cats ];
339 &transcript("Removed usercategory $catname.\n\n");
340 delete $u->{"categories"}->{$catname};
343 } elsif (m/^usertags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
345 $ref = $1; $addsubcode = $3 || "+"; $tags = $4;
347 &transcript("No valid user selected\n");
352 Debbugs::User::read_usertags(\%ut, $user);
353 my @oldtags = (); my @newtags = (); my @badtags = ();
355 for my $t (split /[,\s]+/, $tags) {
356 if ($t =~ m/^[a-zA-Z0-9.+\@-]+$/) {
363 &transcript("Ignoring illegal tag/s: ".join(', ', @badtags).".\nPlease use only alphanumerics, at, dot, plus and dash.\n");
366 for my $t (keys %chtags) {
367 $ut{$t} = [] unless defined $ut{$t};
369 for my $t (keys %ut) {
370 my %res = map { ($_, 1) } @{$ut{$t}};
371 push @oldtags, $t if defined $res{$ref};
372 my $addop = ($addsubcode eq "+" or $addsubcode eq "=");
373 my $del = (defined $chtags{$t} ? $addsubcode eq "-"
374 : $addsubcode eq "=");
375 $res{$ref} = 1 if ($addop && defined $chtags{$t});
376 delete $res{$ref} if ($del);
377 push @newtags, $t if defined $res{$ref};
378 $ut{$t} = [ sort { $a <=> $b } (keys %res) ];
381 &transcript("There were no usertags set.\n");
383 &transcript("Usertags were: " . join(" ", @oldtags) . ".\n");
385 &transcript("Usertags are now: " . join(" ", @newtags) . ".\n");
386 Debbugs::User::write_usertags(\%ut, $user);
388 } elsif (!$control) {
390 Unknown command or malformed arguments to command.
391 (Use control\@$gEmailDomain to manipulate reports.)
395 if (++$unknowns >= 3) {
396 &transcript("Too many unknown commands, stopping here.\n\n");
399 #### "developer only" ones start here
400 } elsif (m/^close\s+\#?(-?\d+)(?:\s+(\d.*))?$/i) {
403 $bug_affected{$ref}=1;
406 &transcript("'close' is deprecated; see http://$gWebDomain/Developer$gHTMLSuffix#closing.\n");
407 if (length($data->{done}) and not defined($version)) {
408 &transcript("$gBug is already closed, cannot re-close.\n\n");
413 "marked as fixed in version $version" :
415 ", send any further explanations to $data->{originator}";
417 &addmaintainers($data);
418 if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
419 0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
420 $data->{done}= $replyto;
421 my @keywords= split ' ', $data->{keywords};
422 if (grep $_ eq 'pending', @keywords) {
423 $extramessage= "Removed pending tag.\n";
424 $data->{keywords}= join ' ', grep $_ ne 'pending',
427 addfixedversions($data, $data->{package}, $version, 'binary');
430 From: $gMaintainerEmail ($gProject $gBug Tracking System)
431 To: $data->{originator}
432 Subject: $gBug#$ref acknowledged by developer
434 References: $header{'message-id'} $data->{msgid}
435 In-Reply-To: $data->{msgid}
436 Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
437 Reply-To: $ref\@$gEmailDomain
438 X-$gProject-PR-Message: they-closed-control $ref
440 This is an automatic notification regarding your $gBug report
441 #$ref: $data->{subject},
442 which was filed against the $data->{package} package.
444 It has been marked as closed by one of the developers, namely
447 You should be hearing from them with a substantive response shortly,
448 in case you haven't already. If not, please contact them directly.
451 (administrator, $gProject $gBugs database)
454 &sendmailmessage($message,$data->{originator});
455 } while (&getnextbug);
458 } elsif (m/^reassign\s+\#?(-?\d+)\s+(\S+)(?:\s+(\d.*))?$/i) {
460 $ref= $1; $newpackage= $2;
461 $bug_affected{$ref}=1;
463 $newpackage =~ y/A-Z/a-z/;
465 if (length($data->{package})) {
466 $action= "$gBug reassigned from package \`$data->{package}'".
467 " to \`$newpackage'.";
469 $action= "$gBug assigned to package \`$newpackage'.";
472 &addmaintainers($data);
473 $data->{package}= $newpackage;
474 $data->{found_versions}= [];
475 $data->{fixed_versions}= [];
476 # TODO: what if $newpackage is a source package?
477 addfoundversions($data, $data->{package}, $version, 'binary');
478 &addmaintainers($data);
479 } while (&getnextbug);
481 } elsif (m/^reopen\s+\#?(-?\d+)$/i ? ($noriginator='', 1) :
482 m/^reopen\s+\#?(-?\d+)\s+\=$/i ? ($noriginator='', 1) :
483 m/^reopen\s+\#?(-?\d+)\s+\!$/i ? ($noriginator=$replyto, 1) :
484 m/^reopen\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($noriginator=$2, 1) : 0) {
487 $bug_affected{$ref}=1;
489 if (@{$data->{fixed_versions}}) {
490 &transcript("'reopen' may be inappropriate when a bug has been closed with a version;\nyou may need to use 'found' to remove fixed versions.\n");
492 if (!length($data->{done})) {
493 &transcript("$gBug is already open, cannot reopen.\n\n");
497 $noriginator eq '' ? "$gBug reopened, originator not changed." :
498 "$gBug reopened, originator set to $noriginator.";
500 &addmaintainers($data);
501 $data->{originator}= $noriginator eq '' ? $data->{originator} : $noriginator;
502 $data->{fixed_versions}= [];
504 } while (&getnextbug);
507 } elsif (m/^found\s+\#?(-?\d+)(?:\s+(\d.*))?$/i) {
512 if (!length($data->{done}) and not defined($version)) {
513 &transcript("$gBug is already open, cannot reopen.\n\n");
519 "$gBug marked as found in version $version." :
522 &addmaintainers($data);
523 # The 'done' field gets a bit weird with version
524 # tracking, because a bug may be closed by multiple
525 # people in different branches. Until we have something
526 # more flexible, we set it every time a bug is fixed,
527 # and clear it precisely when a found command is
528 # received for the rightmost fixed-in version, which
529 # equates to the most recent fixing of the bug, or when
530 # a versionless found command is received.
531 if (defined $version) {
532 my $lastfixed = $data->{fixed_versions}[-1];
533 # TODO: what if $data->{package} is a source package?
534 addfoundversions($data, $data->{package}, $version, 'binary');
535 if (defined $lastfixed and not grep { $_ eq $lastfixed } @{$data->{fixed_versions}}) {
539 # Versionless found; assume old-style "not fixed at
541 $data->{fixed_versions} = [];
544 } while (&getnextbug);
547 } elsif (m/^notfound\s+\#?(-?\d+)\s+(\d.*)$/i) {
552 $action= "$gBug marked as not found in version $version.";
553 if (length($data->{done})) {
554 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
557 &addmaintainers($data);
558 removefoundversions($data, $data->{package}, $version, 'binary');
559 } while (&getnextbug);
561 } elsif (m/^submitter\s+\#?(-?\d+)\s+\!$/i ? ($newsubmitter=$replyto, 1) :
562 m/^submitter\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($newsubmitter=$2, 1) : 0) {
565 $bug_affected{$ref}=1;
566 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
567 $ref = $clonebugs{$ref};
570 if (&checkpkglimit) {
572 &addmaintainers($data);
573 $oldsubmitter= $data->{originator};
574 $data->{originator}= $newsubmitter;
575 $action= "Changed $gBug submitter from $oldsubmitter to $newsubmitter.";
577 &transcript("$action\n");
578 if (length($data->{done})) {
579 &transcript("(By the way, that $gBug is currently marked as done.)\n");
583 From: $gMaintainerEmail ($gProject $gBug Tracking System)
585 Subject: $gBug#$ref submitter address changed
587 References: $header{'message-id'} $data->{msgid}
588 In-Reply-To: $data->{msgid}
589 Message-ID: <handler.$ref.$nn.newsubmitter.$midix\@$gEmailDomain>
590 Reply-To: $ref\@$gEmailDomain
591 X-$gProject-PR-Message: submitter-changed $ref
593 The submitter address recorded for your $gBug report
594 #$ref: $data->{subject}
597 The old submitter address for this report was
599 The new submitter address is
602 This change was made by
604 If it was incorrect, please contact them directly.
607 (administrator, $gProject $gBugs database)
610 &sendmailmessage($message,$oldsubmitter);
617 } elsif (m/^forwarded\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
619 $ref= $1; $whereto= $2;
620 $bug_affected{$ref}=1;
622 if (length($data->{forwarded})) {
623 $action= "Forwarded-to-address changed from $data->{forwarded} to $whereto.";
625 $action= "Noted your statement that $gBug has been forwarded to $whereto.";
627 if (length($data->{done})) {
628 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
631 &addmaintainers($data);
632 if (length($gForwardList)>0 && length($gListDomain)>0 ) {
633 &addccaddress("$gForwardList\@$gListDomain");
635 $data->{forwarded}= $whereto;
636 } while (&getnextbug);
638 } elsif (m/^notforwarded\s+\#?(-?\d+)$/i) {
641 $bug_affected{$ref}=1;
643 if (!length($data->{forwarded})) {
644 &transcript("$gBug is not marked as having been forwarded.\n\n");
647 $action= "Removed annotation that $gBug had been forwarded to $data->{forwarded}.";
649 &addmaintainers($data);
650 $data->{forwarded}= '';
651 } while (&getnextbug);
654 } elsif (m/^severity\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i ||
655 m/^priority\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i) {
658 $bug_affected{$ref}=1;
660 if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
661 &transcript("Severity level \`$newseverity' is not known.\n".
662 "Recognized are: $gShowSeverities.\n\n");
664 } elsif (exists $gObsoleteSeverities{$newseverity}) {
665 &transcript("Severity level \`$newseverity' is obsolete. " .
666 "Use $gObsoleteSeverities{$newseverity} instead.\n\n");
669 $printseverity= $data->{severity};
670 $printseverity= "$gDefaultSeverity" if $printseverity eq '';
671 $action= "Severity set to \`$newseverity' from \`$printseverity'";
673 &addmaintainers($data);
674 if (defined $gStrongList and isstrongseverity($newseverity)) {
675 addbcc("$gStrongList\@$gListDomain");
677 $data->{severity}= $newseverity;
678 } while (&getnextbug);
680 } elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
682 $ref = $1; $addsubcode = $3; $tags = $4;
683 $bug_affected{$ref}=1;
685 if (defined $addsubcode) {
686 $addsub = "sub" if ($addsubcode eq "-");
687 $addsub = "add" if ($addsubcode eq "+");
688 $addsub = "set" if ($addsubcode eq "=");
692 foreach my $t (split /[\s,]+/, $tags) {
693 if (!grep($_ eq $t, @gTags)) {
700 &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
701 "Recognized are: ".join(' ', @gTags).".\n\n");
705 if ($data->{keywords} eq '') {
706 &transcript("There were no tags set.\n");
708 &transcript("Tags were: $data->{keywords}\n");
710 if ($addsub eq "set") {
711 $action= "Tags set to: " . join(", ", @okaytags);
712 } elsif ($addsub eq "add") {
713 $action= "Tags added: " . join(", ", @okaytags);
714 } elsif ($addsub eq "sub") {
715 $action= "Tags removed: " . join(", ", @okaytags);
718 &addmaintainers($data);
719 $data->{keywords} = '' if ($addsub eq "set");
720 # Allow removing obsolete tags.
721 if ($addsub eq "sub") {
722 foreach my $t (@badtags) {
723 $data->{keywords} = join ' ', grep $_ ne $t,
724 split ' ', $data->{keywords};
727 # Now process all other additions and subtractions.
728 foreach my $t (@okaytags) {
729 $data->{keywords} = join ' ', grep $_ ne $t,
730 split ' ', $data->{keywords};
731 $data->{keywords} = "$t $data->{keywords}" unless($addsub eq "sub");
733 $data->{keywords} =~ s/\s*$//;
734 } while (&getnextbug);
736 } elsif (m/^(un)?block\s+\#?(-?\d+)\s+(by|with)\s+\s*(\S.*)?$/i) {
738 my $bugnum = $2; my $blockers = $4;
740 $addsub = "sub" if ($1 eq "un");
741 if ($bugnum =~ m/^-\d+$/ && defined $clonebugs{$bugnum}) {
742 $bugnum = $clonebugs{$bugnum};
747 foreach my $b (split /[\s,]+/, $blockers) {
751 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
752 $ref = $clonebugs{$ref};
756 push @okayblockers, $ref;
758 # add to the list all bugs that are merged with $b,
759 # because all of their data must be kept in sync
760 @thisbugmergelist= split(/ /,$data->{mergedwith});
763 foreach $ref (@thisbugmergelist) {
765 push @okayblockers, $ref;
772 push @badblockers, $ref;
776 push @badblockers, $b;
780 &transcript("Unknown blocking bug/s: ".join(', ', @badblockers).".\n");
786 if ($data->{blockedby} eq '') {
787 &transcript("Was not blocked by any bugs.\n");
789 &transcript("Was blocked by: $data->{blockedby}\n");
791 if ($addsub eq "set") {
792 $action= "Blocking bugs of $bugnum set to: " . join(", ", @okayblockers);
793 } elsif ($addsub eq "add") {
794 $action= "Blocking bugs of $bugnum added: " . join(", ", @okayblockers);
795 } elsif ($addsub eq "sub") {
796 $action= "Blocking bugs of $bugnum removed: " . join(", ", @okayblockers);
801 &addmaintainers($data);
802 my @oldblockerlist = split ' ', $data->{blockedby};
803 $data->{blockedby} = '' if ($addsub eq "set");
804 foreach my $b (@okayblockers) {
805 $data->{blockedby} = manipset($data->{blockedby}, $b,
809 foreach my $b (@oldblockerlist) {
810 if (! grep { $_ eq $b } split ' ', $data->{blockedby}) {
811 push @{$removedblocks{$b}}, $ref;
814 foreach my $b (split ' ', $data->{blockedby}) {
815 if (! grep { $_ eq $b } @oldblockerlist) {
816 push @{$addedblocks{$b}}, $ref;
819 } while (&getnextbug);
821 # Now that the blockedby data is updated, change blocks data
822 # to match the changes.
823 foreach $ref (keys %addedblocks) {
825 foreach my $b (@{$addedblocks{$ref}}) {
826 $data->{blocks} = manipset($data->{blocks}, $b, 1);
831 foreach $ref (keys %removedblocks) {
833 foreach my $b (@{$removedblocks{$ref}}) {
834 $data->{blocks} = manipset($data->{blocks}, $b, 0);
840 } elsif (m/^retitle\s+\#?(-?\d+)\s+(\S.*\S)\s*$/i) {
842 $ref= $1; $newtitle= $2;
843 $bug_affected{$ref}=1;
844 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
845 $ref = $clonebugs{$ref};
848 if (&checkpkglimit) {
850 &addmaintainers($data);
851 my $oldtitle = $data->{subject};
852 $data->{subject}= $newtitle;
853 $action= "Changed $gBug title to $newtitle from $oldtitle.";
855 &transcript("$action\n");
856 if (length($data->{done})) {
857 &transcript("(By the way, that $gBug is currently marked as done.)\n");
866 } elsif (m/^unmerge\s+\#?(-?\d+)$/i) {
869 $bug_affected{$ref} = 1;
871 if (!length($data->{mergedwith})) {
872 &transcript("$gBug is not marked as being merged with any others.\n\n");
875 $mergelowstate eq 'locked' || die "$mergelowstate ?";
876 $action= "Disconnected #$ref from all other report(s).";
877 @newmergelist= split(/ /,$data->{mergedwith});
879 @bug_affected{@newmergelist} = 1 x @newmergelist;
881 &addmaintainers($data);
882 $data->{mergedwith}= ($ref == $discref) ? ''
883 : join(' ',grep($_ ne $ref,@newmergelist));
884 } while (&getnextbug);
887 } elsif (m/^merge\s+#?(-?\d+(\s+#?-?\d+)+)\s*$/i) {
889 my @tomerge= sort { $a <=> $b } split(/\s+#?/,$1);
890 my @newmergelist= ();
895 while (defined($ref= shift(@tomerge))) {
896 &transcript("D| checking merge $ref\n") if $dl;
898 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
899 $ref = $clonebugs{$ref};
901 next if grep($_ == $ref,@newmergelist);
902 if (!&getbug) { ¬foundbug; @newmergelist=(); last }
903 if (!&checkpkglimit) { &cancelbug; @newmergelist=(); last; }
905 &transcript("D| adding $ref ($data->{mergedwith})\n") if $dl;
907 &checkmatch('package','m_package',$data->{package},@newmergelist);
908 &checkmatch('forwarded addr','m_forwarded',$data->{forwarded},@newmergelist);
909 $data->{severity} = '$gDefaultSeverity' if $data->{severity} eq '';
910 &checkmatch('severity','m_severity',$data->{severity},@newmergelist);
911 &checkmatch('blocks','m_blocks',$data->{blocks},@newmergelist);
912 &checkmatch('blocked-by','m_blockedby',$data->{blockedby},@newmergelist);
913 &checkmatch('done mark','m_done',length($data->{done}) ? 'done' : 'open',@newmergelist);
914 &checkmatch('owner','m_owner',$data->{owner},@newmergelist);
915 foreach my $t (split /\s+/, $data->{keywords}) { $tags{$t} = 1; }
916 foreach my $f (@{$data->{found_versions}}) { $found{$f} = 1; }
917 foreach my $f (@{$data->{fixed_versions}}) { $fixed{$f} = 1; }
918 if (length($mismatch)) {
919 &transcript("Mismatch - only $gBugs in same state can be merged:\n".
922 &cancelbug; @newmergelist=(); last;
924 push(@newmergelist,$ref);
925 push(@tomerge,split(/ /,$data->{mergedwith}));
929 @newmergelist= sort { $a <=> $b } @newmergelist;
930 $action= "Merged @newmergelist.";
931 delete @fixed{keys %found};
932 for $ref (@newmergelist) {
933 &getbug || die "huh ? $gBug $ref disappeared during merge";
934 &addmaintainers($data);
935 @bug_affected{@newmergelist} = 1 x @newmergelist;
936 $data->{mergedwith}= join(' ',grep($_ != $ref,@newmergelist));
937 $data->{keywords}= join(' ', keys %tags);
938 $data->{found_versions}= [sort keys %found];
939 $data->{fixed_versions}= [sort keys %fixed];
942 &transcript("$action\n\n");
945 } elsif (m/^forcemerge\s+\#?(-?\d+(?:\s+\#?-?\d+)+)\s*$/i) {
947 my @temp = split /\s+\#?/,$1;
948 my $master_bug = shift @temp;
950 my @tomerge = sort { $a <=> $b } @temp;
951 unshift @tomerge,$master_bug;
952 &transcript("D| force merging ".join(',',@tomerge)."\n") if $dl;
953 my @newmergelist= ();
957 # Here we try to do the right thing.
958 # First, if the bugs are in the same package, we merge all of the found, fixed, and tags.
959 # If not, we discard the found and fixed.
960 # Everything else we set to the values of the first bug.
962 while (defined($ref= shift(@tomerge))) {
963 &transcript("D| checking merge $ref\n") if $dl;
965 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
966 $ref = $clonebugs{$ref};
968 next if grep($_ == $ref,@newmergelist);
969 if (!&getbug) { ¬foundbug; @newmergelist=(); last }
970 if (!&checkpkglimit) { &cancelbug; @newmergelist=(); last; }
972 &transcript("D| adding $ref ($data->{mergedwith})\n") if $dl;
973 $master_bug_data = $data if not defined $master_bug_data;
974 if ($data->{package} ne $master_bug_data->{package}) {
975 &transcript("Mismatch - only $gBugs in the same package can be forcibly merged:\n".
976 "$gBug $ref is not in the same package as $master_bug\n");
978 &cancelbug; @newmergelist=(); last;
980 for my $t (split /\s+/,$data->{keywords}) {
983 @found{@{$data->{found_versions}}} = (1) x @{$data->{found_versions}};
984 @fixed{@{$data->{fixed_versions}}} = (1) x @{$data->{fixed_versions}};
985 push(@newmergelist,$ref);
986 push(@tomerge,split(/ /,$data->{mergedwith}));
990 @newmergelist= sort { $a <=> $b } @newmergelist;
991 $action= "Forcibly Merged @newmergelist.";
992 delete @fixed{keys %found};
993 for $ref (@newmergelist) {
994 &getbug || die "huh ? $gBug $ref disappeared during merge";
995 &addmaintainers($data);
996 @bug_affected{@newmergelist} = 1 x @newmergelist;
997 $data->{mergedwith}= join(' ',grep($_ != $ref,@newmergelist));
998 $data->{keywords}= join(' ', keys %tags);
999 $data->{found_versions}= [sort keys %found];
1000 $data->{fixed_versions}= [sort keys %fixed];
1001 my @field_list = qw(forwarded package severity blocks blockedby owner done);
1002 @{$data}{@field_list} = @{$master_bug_data}{@field_list};
1005 &transcript("$action\n\n");
1008 } elsif (m/^clone\s+#?(\d+)\s+((-\d+\s+)*-\d+)\s*$/i) {
1012 @newclonedids = split /\s+/, $2;
1013 $newbugsneeded = scalar(@newclonedids);
1016 $bug_affected{$ref} = 1;
1018 if (length($data->{mergedwith})) {
1019 &transcript("$gBug is marked as being merged with others. Use an existing clone.\n\n");
1023 &filelock("nextnumber.lock");
1024 open(N,"nextnumber") || &quit("nextnumber: read: $!");
1025 $v=<N>; $v =~ s/\n$// || &quit("nextnumber bad format");
1026 $firstref= $v+0; $v += $newbugsneeded;
1027 open(NN,">nextnumber"); print NN "$v\n"; close(NN);
1030 $lastref = $firstref + $newbugsneeded - 1;
1032 if ($newbugsneeded == 1) {
1033 $action= "$gBug $origref cloned as bug $firstref.";
1035 $action= "$gBug $origref cloned as bugs $firstref-$lastref.";
1038 my $blocks = $data->{blocks};
1039 my $blockedby = $data->{blockedby};
1042 my $ohash = get_hashname($origref);
1043 my $clone = $firstref;
1044 @bug_affected{@newclonedids} = 1 x @newclonedids;
1045 for $newclonedid (@newclonedids) {
1046 $clonebugs{$newclonedid} = $clone;
1048 my $hash = get_hashname($clone);
1049 copy("db-h/$ohash/$origref.log", "db-h/$hash/$clone.log");
1050 copy("db-h/$ohash/$origref.status", "db-h/$hash/$clone.status");
1051 copy("db-h/$ohash/$origref.summary", "db-h/$hash/$clone.summary");
1052 copy("db-h/$ohash/$origref.report", "db-h/$hash/$clone.report");
1053 &bughook('new', $clone, $data);
1055 # Update blocking info of bugs blocked by or blocking the
1057 foreach $ref (split ' ', $blocks) {
1059 $data->{blockedby} = manipset($data->{blockedby}, $clone, 1);
1062 foreach $ref (split ' ', $blockedby) {
1064 $data->{blocks} = manipset($data->{blocks}, $clone, 1);
1072 } elsif (m/^package\s+(\S.*\S)?\s*$/i) {
1074 my @pkgs = split /\s+/, $1;
1075 if (scalar(@pkgs) > 0) {
1076 %limit_pkgs = map { ($_, 1) } @pkgs;
1077 &transcript("Ignoring bugs not assigned to: " .
1078 join(" ", keys(%limit_pkgs)) . "\n\n");
1081 &transcript("Not ignoring any bugs.\n\n");
1083 } elsif (m/^owner\s+\#?(-?\d+)\s+!$/i ? ($newowner = $replyto, 1) :
1084 m/^owner\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($newowner = $2, 1) : 0) {
1087 $bug_affected{$ref} = 1;
1089 if (length $data->{owner}) {
1090 $action = "Owner changed from $data->{owner} to $newowner.";
1092 $action = "Owner recorded as $newowner.";
1094 if (length $data->{done}) {
1095 $extramessage = "(By the way, this $gBug is currently " .
1096 "marked as done.)\n";
1099 &addmaintainers($data);
1100 $data->{owner} = $newowner;
1101 } while (&getnextbug);
1103 } elsif (m/^noowner\s+\#?(-?\d+)$/i) {
1106 $bug_affected{$ref} = 1;
1108 if (length $data->{owner}) {
1109 $action = "Removed annotation that $gBug was owned by " .
1112 &addmaintainers($data);
1113 $data->{owner} = '';
1114 } while (&getnextbug);
1116 &transcript("$gBug is not marked as having an owner.\n\n");
1121 &transcript("Unknown command or malformed arguments to command.\n\n");
1123 if (++$unknowns >= 5) {
1124 &transcript("Too many unknown commands, stopping here.\n\n");
1129 if ($procline>$#bodylines) {
1130 &transcript(">\nEnd of message, stopping processing here.\n\n");
1132 if (!$ok && !quickabort) {
1134 &transcript("No commands successfully parsed; sending the help text(s).\n");
1139 &transcript("MC\n") if $dl>1;
1141 for $maint (keys %maintccreasons) {
1142 &transcript("MM|$maint|\n") if $dl>1;
1143 next if $maint eq $replyto;
1145 $reasonsref= $maintccreasons{$maint};
1146 &transcript("MY|$maint|\n") if $dl>2;
1147 for $p (sort keys %$reasonsref) {
1148 &transcript("MP|$p|\n") if $dl>2;
1149 $reasonstring.= ', ' if length($reasonstring);
1150 $reasonstring.= $p.' ' if length($p);
1151 $reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
1153 if (length($reasonstring) > 40) {
1154 (substr $reasonstring, 37) = "...";
1156 $reasonstring = "" if (!defined($reasonstring));
1157 push(@maintccs,"$maint ($reasonstring)");
1158 push(@maintccaddrs,"$maint");
1163 &transcript("MC|@maintccs|\n") if $dl>2;
1164 $maintccs .= "Cc: " . join(",\n ",@maintccs) . "\n";
1167 # Add Bcc's to subscribed bugs
1168 push @bcc, map {"bugs=$_\@$gListDomain"} keys %bug_affected;
1170 if (!defined $header{'subject'} || $header{'subject'} eq "") {
1171 $header{'subject'} = "your mail";
1174 # Error text here advertises how many errors there were
1175 my $error_text = $errors > 0 ? " (with $errors errors)":'';
1178 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1180 ${maintccs}Subject: Processed${error_text}: $header{'subject'}
1181 In-Reply-To: $header{'message-id'}
1182 References: $header{'message-id'}
1183 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
1185 X-$gProject-PR-Message: transcript
1187 ${transcript}Please contact me if you need assistance.
1190 (administrator, $gProject $gBugs database)
1194 $repliedshow= join(', ',$replyto,@maintccaddrs);
1195 &filelock("lock/-1");
1196 open(AP,">>db-h/-1.log") || &quit("open db-h/-1.log: $!");
1198 "\2\n$repliedshow\n\5\n$reply\n\3\n".
1200 "<strong>Request received</strong> from <code>".
1201 html_escape($header{'from'})."</code>\n".
1202 "to <code>".html_escape($controlrequestaddr)."</code>\n".
1204 "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/-1.log: $!");
1205 close(AP) || &quit("open db-h/-1.log: $!");
1207 utime(time,time,"db-h");
1209 &sendmailmessage($reply,exists $header{'x-debbugs-no-ack'}?():$replyto,@maintccaddrs,@bcc);
1211 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
1213 sub sendmailmessage {
1214 local ($message,@recips) = @_;
1215 $message = "X-Loop: $gMaintainerEmail\n" . $message;
1216 send_mail_message(message => $message,
1217 recipients => \@recips,
1223 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
1224 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
1228 #sub unimplemented {
1229 # &transcript("Sorry, command $_[0] not yet implemented.\n\n");
1233 local ($string,$mvarname,$svarvalue,@newmergelist) = @_;
1235 if (@newmergelist) {
1236 eval "\$mvarvalue= \$$mvarname";
1237 &transcript("D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n")
1240 "Values for \`$string' don't match:\n".
1241 " #$newmergelist[0] has \`$mvarvalue';\n".
1242 " #$ref has \`$svarvalue'\n"
1243 if $mvarvalue ne $svarvalue;
1245 &transcript("D| setupmatch \`$string' /$mvarname/$svarvalue/\n")
1247 eval "\$$mvarname= \$svarvalue";
1252 if (keys %limit_pkgs and not defined $limit_pkgs{$data->{package}}) {
1253 &transcript("$gBug number $ref belongs to package $data->{package}, skipping.\n\n");
1265 my %h = map { $_ => 1 } split ' ', $list;
1272 return join ' ', sort keys %h;
1275 # High-level bug manipulation calls
1276 # Do announcements themselves
1278 # Possible calling sequences:
1279 # setbug (returns 0)
1281 # setbug (returns 1)
1282 # &transcript(something)
1285 # setbug (returns 1)
1286 # $action= (something)
1288 # (modify s_* variables)
1289 # } while (getnextbug);
1292 &dlen("nochangebug");
1293 $state eq 'single' || $state eq 'multiple' || die "$state ?";
1295 &endmerge if $manybugs;
1297 &dlex("nochangebug");
1301 &dlen("setbug $ref");
1302 if ($ref =~ m/^-\d+/) {
1303 if (!defined $clonebugs{$ref}) {
1305 &dlex("setbug => noclone");
1308 $ref = $clonebugs{$ref};
1310 $state eq 'idle' || die "$state ?";
1313 &dlex("setbug => 0s");
1317 if (!&checkpkglimit) {
1322 @thisbugmergelist= split(/ /,$data->{mergedwith});
1323 if (!@thisbugmergelist) {
1328 &dlex("setbug => 1s");
1337 &dlex("setbug => 0mc");
1341 $state= 'multiple'; $sref=$ref;
1342 &dlex("setbug => 1m");
1347 &dlen("getnextbug");
1348 $state eq 'single' || $state eq 'multiple' || die "$state ?";
1350 if (!$manybugs || !@thisbugmergelist) {
1351 length($action) || die;
1352 &transcript("$action\n$extramessage\n");
1353 &endmerge if $manybugs;
1355 &dlex("getnextbug => 0");
1358 $ref= shift(@thisbugmergelist);
1359 &getbug || die "bug $ref disappeared";
1361 &dlex("getnextbug => 1");
1365 # Low-level bug-manipulation calls
1366 # Do no announcements
1368 # getbug (returns 0)
1370 # getbug (returns 1)
1374 # $action= (something)
1375 # getbug (returns 1)
1377 # getbug (returns 1)
1379 # [getbug (returns 0)]
1380 # &transcript("$action\n\n")
1383 sub notfoundbug { &transcript("$gBug number $ref not found. (Is it archived?)\n\n"); }
1384 sub foundbug { &transcript("$gBug#$ref: $data->{subject}\n"); }
1388 $mergelowstate eq 'idle' || die "$mergelowstate ?";
1389 &filelock('lock/merge');
1390 $mergelowstate='locked';
1396 $mergelowstate eq 'locked' || die "$mergelowstate ?";
1398 $mergelowstate='idle';
1403 &dlen("getbug $ref");
1404 $lowstate eq 'idle' || die "$state ?";
1405 if (($data = &lockreadbug($ref))) {
1408 &dlex("getbug => 1");
1413 &dlex("getbug => 0");
1419 $lowstate eq 'open' || die "$state ?";
1426 &dlen("savebug $ref");
1427 $lowstate eq 'open' || die "$lowstate ?";
1428 length($action) || die;
1429 $ref == $sref || die "read $sref but saving $ref ?";
1430 my $hash = get_hashname($ref);
1431 open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!");
1434 "<!-- time:".time." -->\n".
1435 "<strong>".html_escape($action)."</strong>\n".
1436 "Request was from <code>".html_escape($header{'from'})."</code>\n".
1437 "to <code>".html_escape($controlrequestaddr)."</code>. \n".
1439 "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
1440 close(L) || &quit("closing db-h/$hash/$ref.log: $!");
1441 unlockwritebug($ref, $data);
1448 &transcript("C> @_ ($state $lowstate $mergelowstate)\n");
1453 &transcript("R> @_ ($state $lowstate $mergelowstate)\n");
1457 print $_[0] if $debug;
1458 $transcript.= $_[0];
1465 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
1466 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
1482 sub sendtxthelpraw {
1483 local ($relpath,$description) = @_;
1485 open(D,"$gDocDir/$relpath") || &quit("open doc file $relpath: $!");
1486 while(<D>) { $doc.=$_; }
1488 &transcript("Sending $description in separate message.\n");
1489 &sendmailmessage(<<END.$doc,$replyto);
1490 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1492 Subject: $gProject $gBug help: $description
1493 References: $header{'message-id'}
1494 In-Reply-To: $header{'message-id'}
1495 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
1497 X-$gProject-PR-Message: doc-text $relpath
1503 sub sendlynxdocraw {
1504 local ($relpath,$description) = @_;
1506 open(L,"lynx -nolist -dump http://$gCGIDomain/\Q$relpath\E 2>&1 |") || &quit("fork for lynx: $!");
1507 while(<L>) { $doc.=$_; }
1509 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
1510 &transcript("Information ($description) is not available -\n".
1511 "perhaps the $gBug does not exist or is not on the WWW yet.\n");
1514 &transcript("Error getting $description (code $? $!):\n$doc\n");
1516 &transcript("Sending $description.\n");
1517 &sendmailmessage(<<END.$doc,$replyto);
1518 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1520 Subject: $gProject $gBugs information: $description
1521 References: $header{'message-id'}
1522 In-Reply-To: $header{'message-id'}
1523 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1525 X-$gProject-PR-Message: doc-html $relpath
1534 $maintccreasons{$cca}{''}{$ref}= 1;
1537 sub addmaintainers {
1538 # Data structure is:
1539 # maintainer email address &c -> assoc of packages -> assoc of bug#'s
1542 &ensuremaintainersloaded;
1543 $anymaintfound=0; $anymaintnotfound=0;
1544 for $p (split(m/[ \t?,():]+/, $data->{package})) {
1546 $p =~ /([a-z0-9.+-]+)/;
1548 next unless defined $p;
1549 if (defined $gSubscriptionDomain) {
1550 if (defined($pkgsrc{$p})) {
1551 addbcc("$pkgsrc{$p}\@$gSubscriptionDomain");
1553 addbcc("$p\@$gSubscriptionDomain");
1556 if (defined $data->{severity} and defined $gStrongList and
1557 isstrongseverity($data->{severity})) {
1558 addbcc("$gStrongList\@$gListDomain");
1560 if (defined($maintainerof{$p})) {
1561 $addmaint= $maintainerof{$p};
1562 &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
1563 $maintccreasons{$addmaint}{$p}{$ref}= 1;
1564 print "maintainer add >$p|$addmaint<\n" if $debug;
1566 print "maintainer none >$p<\n" if $debug;
1567 &transcript("Warning: Unknown package '$p'\n");
1568 &transcript("MR|unknown-package|$p|$ref|\n") if $dl>2;
1569 $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
1573 if (length $data->{owner}) {
1574 $addmaint = $data->{owner};
1575 &transcript("MO|$addmaint|$data->{package}|$ref|\n") if $dl>2;
1576 $maintccreasons{$addmaint}{$data->{package}}{$ref} = 1;
1577 print "owner add >$data->{package}|$addmaint<\n" if $debug;
1581 sub ensuremaintainersloaded {
1583 return if $maintainersloaded++;
1584 open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
1588 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
1589 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1590 $maintainerof{$a}= $2;
1593 open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
1597 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
1598 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1599 $maintainerof{$a}= $2;
1602 open(SOURCES, "$gPackageSource") || &quit("pkgsrc open: $!");
1604 next unless m/^(\S+)\s+\S+\s+(\S.*\S)\s*$/;
1605 my ($a, $b) = ($1, $2);
1606 $pkgsrc{lc($a)} = $b;
1612 local ($wherefrom,$path,$description) = @_;
1613 if ($wherefrom eq "ftp.d.o") {
1614 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or &quit("fork for lynx/gunzip: $!");
1616 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
1617 &transcript("$description is not available.\n");
1620 &transcript("Error getting $description (code $? $!):\n$doc\n");
1623 } elsif ($wherefrom eq "local") {
1625 $doc = do { local $/; <P> };
1628 &transcript("internal errror: info files location unknown.\n");
1631 &transcript("Sending $description.\n");
1632 &sendmailmessage(<<END.$doc,$replyto);
1633 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1635 Subject: $gProject $gBugs information: $description
1636 References: $header{'message-id'}
1637 In-Reply-To: $header{'message-id'}
1638 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1640 X-$gProject-PR-Message: getinfo
1642 $description follows: