2 # $Id: service.in,v 1.46 2002/01/19 05:39:28 ajt Exp $
5 # Usage: service <code>.nn
6 # Temps: incoming/P<code>.nn
9 $config_path = '/org/bugs.debian.org/etc';
10 $lib_path = '/org/bugs.debian.org/scripts';
12 require "$config_path/config";
13 require "$lib_path/errorlib";
14 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
16 chdir("$gSpoolDir") || die "chdir spool: $!\n";
19 open DEBUG, ">/dev/null";
24 m/^[RC]\.\d+$/ || &quit("bad argument");
27 if (!rename("incoming/G$nn","incoming/P$nn")) {
28 $_=$!.''; m/no such file or directory/i && exit 0;
29 &quit("renaming to lock: $!");
32 open(M,"incoming/P$nn");
37 grep((s/\n$//,s/\s+$//),@msg);
39 print "###\n",join("##\n",@msg),"\n###\n" if $debug;
41 chop($tdate= `date -u '+%a, %d %h %Y %T GMT'`);
43 Received: via spool for service; $tdate
46 for ($i=0; $i<=$#msg; $i++) {
48 last unless length($_);
50 while ($msg[$i+1] =~ m/^\s/) {
52 $fwd .= $msg[$i]."\n" if $ins; # Huh ? Where is ins set ?
55 print ">$_<\n" if $debug;
57 $v= $1; $v =~ y/A-Z/a-z/;
58 print ">$v=$_<\n" if $debug;
61 print "!>$_<\n" if $debug;
65 if (defined $header{'resent-from'} && !defined $header{'from'}) {
66 $header{'from'} = $header{'resent-from'};
69 defined($header{'from'}) || &quit("no From header");
71 delete $header{'reply-to'}
72 if ( defined($header{'reply-to'}) && $header{'reply-to'} =~ m/^\s*$/ );
74 if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
75 $replyto = $header{'reply-to'};
77 $replyto = $header{'from'};
80 $controlrequestaddr= $control ? "control\@$gEmailDomain" : "request\@$gEmailDomain";
82 &transcript("Processing commands for $controlrequestaddr:\n\n");
87 $mergelowstate= 'idle';
91 #strip blank line(s) after header
92 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
96 my $fuckheads = "(" . join("|", @gFuckheads) . ")";
97 if ($replyto =~ m/$fuckheads/) {
98 &transcript("This service is unavailable.\n\n");
102 #strip, if exists, mime header
103 if ( $msg[$i] =~ /^This is a multi-part message in MIME format./ ) {
104 while ( $i <= $#msg && length( $msg[$i] ) ) {
105 $fwd .= $msg[$i] . "\n"; $i++;
107 while ( $i <= $#msg && !length( $msg[$i] ) ) {
111 if ( $msg[$i] =~ /^--/ || $msg[$i] =~ /^\s*$/ ) {
112 while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i]; $i++; }
113 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
118 for ($procline=$i; $procline<=$#msg; $procline++) {
119 $state eq 'idle' || print "$state ?\n";
120 $lowstate eq 'idle' || print "$lowstate ?\n";
121 $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
123 &transcript("Stopping processing here.\n\n");
126 $_= $msg[$procline]; s/\s+$//;
127 next unless m/\S/; next if m/^\s*\#/;
128 &transcript("> $_\n");
130 if (m/^stop/i || m/^quit/i || m/^--/ || m/^thank/i) {
131 &transcript("Stopping processing here.\n\n");
133 } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
135 &transcript("Debug level $dl.\n\n");
136 } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
138 &sendlynxdoc("$ref","logs for $gBug#$ref");
139 } elsif (m/^send-detail\s+\#?(\d+)$/i) {
140 &transcript("This BTS function is currently disabled, sorry.\n\n");
141 $ok++; # well, it's not really ok, but it fixes #81224 :)
142 # $ref= $1+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
143 # &sendlynxdoc("db/$reffile-b.html","additional logs for $gBug#$ref");
144 } elsif (m/^index(\s+full)?$/i) {
145 &transcript("This BTS function is currently disabled, sorry.\n\n");
146 $ok++; # well, it's not really ok, but it fixes #81224 :)
147 # &sendlynxdoc("db/ix/full.html",'full index');
148 } elsif (m/^index-summary\s+by-package$/i) {
149 &transcript("This BTS function is currently disabled, sorry.\n\n");
150 $ok++; # well, it's not really ok, but it fixes #81224 :)
151 # &sendlynxdoc("db/ix/psummary.html",'summary index sorted by package/title');
152 } elsif (m/^index-summary(\s+by-number)?$/i) {
153 &transcript("This BTS function is currently disabled, sorry.\n\n");
154 $ok++; # well, it's not really ok, but it fixes #81224 :)
155 # &sendlynxdoc("db/ix/summary.html",'summary index sorted by number/date');
156 } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
157 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=pkg",'index of packages');
158 } elsif (m/^index(\s+|-)maints?$/i) {
159 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=maint",'index of maintainers');
160 } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
162 # check for crap in $maint
163 if ($maint =~ m/^\./ || $maint !~ m/^[\d\w-+.@]+$/) {
164 &transcript("Invalid request $maint!\n");
167 &sendlynxdoc("$maint","$gBug list for maintainer \`$maint'");
169 $substrg= $2; $matches=0;
170 opendir(DBD,"$gWebDir/db/ma") || die $!;
171 while (defined($_=readdir(DBD))) {
172 next unless m/^l/ && m/\.html$/;
173 &transcript("F|$_\n") if $dl>1;
174 $filename= $_; s/^l//; s/\.html$//;
175 &transcript("P|$_\n") if $dl>2;
176 while (s/-(..)([^_])/-$1_-$2/) { }
177 &transcript("P|$_\n") if $dl>2;
178 s/^(.{0,2})_/$1-20_/g; while (s/([^-]..)_/$1-20_/) { };
179 &transcript("P|$_\n") if $dl>2;
180 s/^,(.*),(.*),([^,]+)$/$1-40_$2-20_-28_$3-29_/;
181 &transcript("P|$_\n") if $dl>2;
182 s/^([^,]+),(.*),(.*),$/$1-20_-3c_$2-40_$3-3e_/;
183 &transcript("P|$_\n") if $dl>2;
185 &transcript("P|$_\n") if $dl>2;
187 while (m/-(..)_/) { $out.= $`.sprintf("%c",hex($1)); $_=$'; }
189 &transcript("M|$out\n") if $dl>1;
190 next unless index(lc $out, lc $substrg)>=0;
191 &transcript("S|$filename\n") if $dl>0;
192 &transcript("S|$out\n") if $dl>0;
194 &sendlynxdocraw("db/ma/$filename","$gBug list for maintainer \`$out'");
197 &transcript("$gBug list(s) for $matches maintainer(s) sent.\n\n");
199 &transcript("No maintainers found containing \`$substrg'.\n".
200 "Use \`index-maint' to get list of maintainers.\n\n");
204 } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
206 # check for crap in $package
207 if ($package =~ m/^\./ || $package !~ m/^[\d\w-+.@]+$/) {
208 &transcript("Invalid request $package!\n");
211 &sendlynxdoc("$package","$gBug list for package $package sent.\n\n");
213 $substrg= $+; $matches=0;
214 opendir(DBD,"$gWebDir/db/pa") || die $!;
215 while (defined($_=readdir(DBD))) {
216 next unless m/^l/ && m/\.html$/;
217 &transcript("F|$_\n") if $dl>1;
218 $filename= $_; s/^l//; s/\.html$//;
219 next unless index(lc $_, lc $substrg)>=0;
220 &transcript("S|$filename\n") if $dl>0;
221 &transcript("S|$out\n") if $dl>0;
223 &sendlynxdocraw("db/pa/$filename","$gBug list for package \`$_'");
226 &transcript("$gBug list(s) for $matches package(s) sent.\n\n");
228 &transcript("No packages found containing \`$substrg'.\n".
229 "Use \`index-packages' to get list of packages.\n\n");
233 } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
234 &transcript("This BTS function is currently disabled, sorry.\n\n");
235 $ok++; # well, it's not really ok, but it fixes #81224 :)
236 # &sendlynxdoc("db/ju/unmatched-1.html","junk (this week)");
237 } elsif (m/^send-unmatched\s+(last|-1)$/i) {
238 &transcript("This BTS function is currently disabled, sorry.\n\n");
239 $ok++; # well, it's not really ok, but it fixes #81224 :)
240 # &sendlynxdoc("db/ju/unmatched-2.html","junk (last week)");
241 } elsif (m/^send-unmatched\s+(old|-2)$/i) {
242 &transcript("This BTS function is currently disabled, sorry.\n\n");
243 $ok++; # well, it's not really ok, but it fixes #81224 :)
244 # &sendlynxdoc("db/ju/unmatched-3.html","junk (two weeks ago)");
245 } elsif (m/^getinfo\s+([\w-.]+)$/i) {
246 # the following is basically a Debian-specific kludge, but who cares
248 if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
249 &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
250 } elsif ($req =~ /^override\.(\w+)\.([\w-.]+)$/i) {
252 &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
253 } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
254 &sendinfo("local", "$gConfigDir/$req", "$req file");
256 &transcript("Info file $req does not exist.\n\n");
258 } elsif (m/^help/i) {
262 } elsif (m/^refcard/i) {
263 &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
264 } elsif (m/^subscribe/i) {
266 There is no $gProject $gBug mailing list. If you wish to review bug reports
267 please do so via http://$gWebDomain/ or ask this mail server
269 soon: MAILINGLISTS_TEXT
271 } elsif (m/^unsubscribe/i) {
273 soon: UNSUBSCRIBE_TEXT
274 soon: MAILINGLISTS_TEXT
276 } elsif (!$control) {
278 Unknown command or malformed arguments to command.
279 (Use control\@$gEmailDomain to manipulate reports.)
282 if (++$unknowns >= 3) {
283 &transcript("Too many unknown commands, stopping here.\n\n");
286 #### interesting ones start here
287 } elsif (m/^close\s+\#?(-?\d+)$/i) {
291 if (length($s_done)) {
292 &transcript("$gBug is already closed, cannot re-close.\n\n");
295 $action= "$gBug closed, send any further explanations to $s_originator";
297 &addmaintainers($s_package);
298 if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
299 0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
302 From: $gMaintainerEmail ($gProject $gBug Tracking System)
304 Subject: $gBug#$ref acknowledged by developer
306 References: $header{'message-id'} $s_msgid
307 In-Reply-To: $s_msgid
308 Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
309 Reply-To: $ref\@$gEmailDomain
311 This is an automatic notification regarding your $gBug report
313 which was filed against the $s_package package.
315 It has been marked as closed by one of the developers, namely
318 You should be hearing from them with a substantive response shortly,
319 in case you haven't already. If not, please contact them directly.
322 (administrator, $gProject $gBugs database)
325 &sendmailmessage($message,$s_originator);
326 } while (&getnextbug);
329 } elsif (m/^reassign\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
331 $ref= $1; $newpackage= $2;
332 $newpackage =~ y/A-Z/a-z/;
334 if (length($s_package)) {
335 $action= "$gBug reassigned from package \`$s_package'".
336 " to \`$newpackage'.";
338 $action= "$gBug assigned to package \`$newpackage'.";
341 &addmaintainers($s_package);
342 &addmaintainers($newpackage);
343 $s_package= $newpackage;
344 } while (&getnextbug);
346 } elsif (m/^reopen\s+\#?(-?\d+)$/i ? ($noriginator='', 1) :
347 m/^reopen\s+\#?(-?\d+)\s+\=$/i ? ($noriginator='', 1) :
348 m/^reopen\s+\#?(-?\d+)\s+\!$/i ? ($noriginator=$replyto, 1) :
349 m/^reopen\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($noriginator=$2, 1) : 0) {
353 if (!length($s_done)) {
354 &transcript("$gBug is already open, cannot reopen.\n\n");
358 $noriginator eq '' ? "$gBug reopened, originator not changed." :
359 "$gBug reopened, originator set to $noriginator.";
361 &addmaintainers($s_package);
362 $s_originator= $noriginator eq '' ? $s_originator : $noriginator;
364 } while (&getnextbug);
367 } elsif (m/^forwarded\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
369 $ref= $1; $whereto= $2;
371 if (length($s_forwarded)) {
372 $action= "Forwarded-to-address changed from $s_forwarded to $whereto.";
374 $action= "Noted your statement that $gBug has been forwarded to $whereto.";
376 if (length($s_done)) {
377 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
380 &addmaintainers($s_package);
381 if (length($gFowardList)>0 && length($gListDomain)>0 )
382 { &addccaddress("$gFowardList\@$gListDomain"); }
383 $s_forwarded= $whereto;
384 } while (&getnextbug);
386 } elsif (m/^notforwarded\s+\#?(-?\d+)$/i) {
390 if (!length($s_forwarded)) {
391 &transcript("$gBug is not marked as having been forwarded.\n\n");
394 $action= "Removed annotation that $gBug had been forwarded to $s_forwarded.";
396 &addmaintainers($s_package);
398 } while (&getnextbug);
401 } elsif (m/^severity\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i ||
402 m/^priority\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i) {
406 if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
407 &transcript("Severity level \`$newseverity' is not known.\n".
408 "Recognized are: $gShowSeverities.\n\n");
410 $printseverity= $s_severity;
411 $printseverity= "$gDefaultSeverity" if $printseverity eq '';
412 $action= "Severity set to \`$newseverity'.";
414 &addmaintainers($s_package);
415 $s_severity= $newseverity;
416 } while (&getnextbug);
418 } elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s+)?(\S.*)?$/i) {
420 $ref = $1; $addsubcode = $3; $tags = $4;
422 if (defined $addsubcode) {
423 $addsub = "sub" if ($addsubcode eq "-");
424 $addsub = "add" if ($addsubcode eq "+");
425 $addsub = "set" if ($addsubcode eq "=");
429 foreach my $t (split /[\s,]+/, $tags) {
430 if (!grep($_ eq $t, @gTags)) {
437 &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
438 "Recognized are: ".join(' ', @gTags).".\n\n");
441 if ($addsub eq "set") {
442 $action= "Tags set to: " . join(", ", @okaytags);
443 } elsif ($addsub eq "add") {
444 $action= "Tags added: " . join(", ", @okaytags);
445 } elsif ($addsub eq "sub") {
446 $action= "Tags removed: " . join(", ", @okaytags);
449 &addmaintainers($s_package);
450 $s_keywords = '' if ($addsub eq "set");
451 if ($addsub eq "sub") {
452 foreach my $t (@badtags) {
453 $s_keywords = join ' ', grep $_ ne $t,
454 split ' ', $s_keywords;
457 foreach my $t (@okaytags) {
458 $s_keywords = join ' ', grep $_ ne $t,
459 split ' ', $s_keywords;
460 $s_keywords = "$t $s_keywords" unless($addsub eq "sub");
462 $s_keywords =~ s/\s*$//;
463 } while (&getnextbug);
465 } elsif (m/^retitle\s+\#?(-?\d+)\s+(\S.*\S)\s*$/i) {
467 $ref= $1; $newtitle= $2;
470 &addmaintainers($s_package);
471 $s_subject= $newtitle;
472 $action= "Changed $gBug title.";
474 &transcript("$action\n");
475 if (length($s_done)) {
476 &transcript("(By the way, that $gBug is currently marked as done.)\n");
482 } elsif (m/^unmerge\s+\#?(-?\d+)$/i) {
486 if (!length($s_mergedwith)) {
487 &transcript("$gBug is not marked as being merged with any others.\n\n");
490 $mergelowstate eq 'locked' || die "$mergelowstate ?";
491 $action= "Disconnected #$ref from all other report(s).";
492 @newmergelist= split(/ /,$s_mergedwith);
495 &addmaintainers($s_package);
496 $s_mergedwith= ($ref == $discref) ? ''
497 : join(' ',grep($_ ne $ref,@newmergelist));
498 } while (&getnextbug);
501 } elsif (m/^merge\s+(-?\d+(\s+-?\d+)+)\s*$/i) {
503 @tomerge= sort { $a <=> $b } split(/\s+/,$1);
507 while (defined($ref= shift(@tomerge))) {
508 &transcript("D| checking merge $ref\n") if $dl;
510 next if grep($_ eq $ref,@newmergelist);
511 if (!&getbug) { ¬foundbug; @newmergelist=(); last }
513 &transcript("D| adding $ref ($s_mergedwith)\n") if $dl;
515 &checkmatch('package','m_package',$s_package);
516 &checkmatch('forwarded addr','m_forwarded',$s_forwarded);
517 $s_severity = '$gDefaultSeverity' if $s_severity eq '';
518 &checkmatch('severity','m_severity',$s_severity);
519 &checkmatch('done mark','m_done',length($s_done) ? 'done' : 'open');
520 foreach my $t (split /\s+/, $s_keywords) { $tags{$t} = 1; }
521 if (length($mismatch)) {
522 &transcript("Mismatch - only $gBugs in same state can be merged:\n".
524 &cancelbug; @newmergelist=(); last;
526 push(@newmergelist,$ref);
527 push(@tomerge,split(/ /,$s_mergedwith));
531 @newmergelist= sort { $a <=> $b } @newmergelist;
532 $action= "Merged @newmergelist.";
533 for $ref (@newmergelist) {
534 &getbug || die "huh ? $gBug $ref disappeared during merge";
535 &addmaintainers($s_package);
536 $s_mergedwith= join(' ',grep($_ ne $ref,@newmergelist));
537 $s_keywords= join(' ', keys %tags);
540 &transcript("$action\n\n");
544 &transcript("Unknown command or malformed arguments to command.\n\n");
545 if (++$unknowns >= 5) {
546 &transcript("Too many unknown commands, stopping here.\n\n");
551 if ($procline>$#msg) {
552 &transcript(">\nEnd of message, stopping processing here.\n\n");
554 if (!$ok && !quickabort) {
555 &transcript("No commands successfully parsed; sending the help text(s).\n");
560 &transcript("MC\n") if $dl>1;
562 for $maint (keys %maintccreasons) {
563 &transcript("MM|$maint|\n") if $dl>1;
564 next if $maint eq $replyto;
566 $reasonsref= $maintccreasons{$maint};
567 &transcript("MY|$maint|\n") if $dl>2;
568 for $p (sort keys %$reasonsref) {
569 &transcript("MP|$p|\n") if $dl>2;
570 $reasonstring.= ', ' if length($reasonstring);
571 $reasonstring.= $p.' ' if length($p);
572 $reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
574 if (length($reasonstring) > 40) {
575 (substr $reasonstring, 37) = "...";
577 $reasonstring = "" if (!defined($reasonstring));
578 push(@maintccs,"$maint ($reasonstring)");
579 push(@maintccaddrs,"$maint");
582 &transcript("MC|@maintccs|\n") if $dl>2;
583 $maintccs= "Cc: ".join(",\n ",@maintccs)."\n";
584 } else { $maintccs = ""; }
586 if (!defined $header{'subject'} || $header{'subject'} eq "") {
587 $header{'subject'} = "your mail";
591 From: $gMaintainerEmail ($gProject $gBug Tracking System)
593 ${maintccs}Subject: Processed: $header{'subject'}
594 In-Reply-To: $header{'message-id'}
595 References: $header{'message-id'}
596 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
598 ${transcript}Please contact me if you need assistance.
601 (administrator, $gProject $gBugs database)
605 $repliedshow= join(', ',$replyto,@maintccaddrs);
606 &filelock("lock/-1");
607 open(AP,">>db-h/-1.log") || &quit("open db-h/-1.log: $!");
609 "\2\n$repliedshow\n\5\n$reply\n\3\n".
611 "<strong>Request received</strong> from <code>".
612 &sani($header{'from'})."</code>\n".
613 "to <code>".&sani($controlrequestaddr)."</code>\n".
615 "\7\n",@log,"\n\3\n") || &quit("writing db-h/-1.log: $!");
616 close(AP) || &quit("open db-h/-1.log: $!");
618 utime(time,time,"db-h");
620 &sendmailmessage($reply,$replyto,@maintccaddrs);
622 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
626 map { $_->address() }
627 map { Mail::Address->parse($_) } @_;
630 sub sendmailmessage {
631 local ($message,@recips) = @_;
632 print "mailing to >@recips<\n" if $debug;
634 defined($c) || &quit("mailing forking for sendmail: $!");
635 if (!$c) { # ie, we are the child process
636 exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odq','-oem','-oi',get_addresses(@recips);
639 print(D $message) || &quit("writing to sendmail process: $!");
640 $!=0; close(D); $? && &quit("sendmail gave exit status $? ($!)");
645 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
646 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
651 # &transcript("Sorry, command $_[0] not yet implemented.\n\n");
655 local ($string,$mvarname,$svarvalue) = @_;
658 eval "\$mvarvalue= \$$mvarname";
659 &transcript("D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n")
662 "Values for \`$string' don't match:\n".
663 " #$newmergelist[0] has \`$mvarvalue';\n".
664 " #$ref has \`$svarvalue'\n"
665 if $mvarvalue ne $svarvalue;
667 &transcript("D| setupmatch \`$string' /$mvarname/$svarvalue/\n")
669 eval "\$$mvarname= \$svarvalue";
673 # High-level bug manipulation calls
674 # Do announcements themselves
676 # Possible calling sequences:
680 # &transcript(something)
684 # $action= (something)
686 # (modify s_* variables)
687 # } while (getnextbug);
690 &dlen("nochangebug");
691 $state eq 'single' || $state eq 'multiple' || die "$state ?";
693 &endmerge if $manybugs;
695 &dlex("nochangebug");
699 &dlen("setbug $ref");
700 if ($ref =~ m/^-\d+/) {
701 if (!defined $clonebugs{$ref}) {
703 &dlex("setbug => noclone");
706 $ref = $clonebugs{$ref};
708 $state eq 'idle' || die "$state ?";
711 &dlex("setbug => 0s");
714 @thisbugmergelist= split(/ /,$s_mergedwith);
715 if (!@thisbugmergelist) {
720 &dlex("setbug => 1s");
729 &dlex("setbug => 0mc");
733 $state= 'multiple'; $sref=$ref;
734 &dlex("setbug => 1m");
740 $state eq 'single' || $state eq 'multiple' || die "$state ?";
742 if (!$manybugs || !@thisbugmergelist) {
743 length($action) || die;
744 &transcript("$action\n$extramessage\n");
745 &endmerge if $manybugs;
747 &dlex("getnextbug => 0");
750 $ref= shift(@thisbugmergelist);
751 &getbug || die "bug $ref disappeared";
753 &dlex("getnextbug => 1");
757 # Low-level bug-manipulation calls
758 # Do no announcements
766 # $action= (something)
771 # [getbug (returns 0)]
772 # &transcript("$action\n\n")
775 sub notfoundbug { &transcript("$gBug number $ref not found.\n\n"); }
776 sub foundbug { &transcript("$gBug#$ref: $s_subject\n"); }
780 $mergelowstate eq 'idle' || die "$mergelowstate ?";
781 &filelock('lock/merge');
782 $mergelowstate='locked';
788 $mergelowstate eq 'locked' || die "$mergelowstate ?";
790 $mergelowstate='idle';
795 &dlen("getbug $ref");
796 $lowstate eq 'idle' || die "$state ?";
797 if (&lockreadbug($ref)) {
800 &dlex("getbug => 1");
805 &dlex("getbug => 0");
811 $lowstate eq 'open' || die "$state ?";
818 &dlen("savebug $ref");
819 $lowstate eq 'open' || die "$lowstate ?";
820 length($action) || die;
821 $ref == $sref || die "read $sref but saving $ref ?";
822 my $hash = get_hashname($ref);
823 open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!");
826 "<strong>".&sani($action)."</strong>\n".
827 "Request was from <code>".&sani($header{'from'})."</code>\n".
828 "to <code>".&sani($controlrequestaddr)."</code>. \n".
830 "\7\n",@log,"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
831 close(L) || &quit("closing db-h/$hash/$ref.log: $!");
832 open(S,">db-h/$hash/$ref.status.new") || &quit("opening db-h/$hash/$ref.status.new: $!");
843 "$s_severity\n") || &quit("writing db-h/$hash/$ref.status.new: $!");
844 close(S) || &quit("closing db-h/$hash/$ref.status.new: $!");
845 rename("db-h/$hash/$ref.status.new","db-h/$hash/$ref.status") ||
846 &quit("installing new db-h/$hash/$ref.status: $!");
847 &bughook('change',$ref,
865 &transcript("C> @_ ($state $lowstate $mergelowstate)\n");
870 &transcript("R> @_ ($state $lowstate $mergelowstate)\n");
874 print $_[0] if $debug;
891 local ($relpath,$description) = @_;
893 open(D,"$gDocDir/$relpath") || &quit("open doc file $relpath: $!");
894 while(<D>) { $doc.=$_; }
896 &transcript("Sending $description in separate message.\n");
897 &sendmailmessage(<<END.$doc,$replyto);
898 From: $gMaintainerEmail ($gProject $gBug Tracking System)
900 Subject: $gProject $gBug help: $description
901 References: $header{'message-id'}
902 In-Reply-To: $header{'message-id'}
903 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
910 local ($relpath,$description) = @_;
912 # the below oughta use $gWebDomain but it can't
913 open(L,"lynx -nolist -dump http://bugs.debian.org/$relpath 2>&1 |") || &quit("fork for lynx: $!");
914 while(<L>) { $doc.=$_; }
916 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
917 &transcript("Information ($description) is not available -\n".
918 "perhaps the $gBug does not exist or is not on the WWW yet.\n");
921 &transcript("Error getting $description (code $? $!):\n$doc\n");
923 &transcript("Sending $description.\n");
924 &sendmailmessage(<<END.$doc,$replyto);
925 From: $gMaintainerEmail ($gProject $gBug Tracking System)
927 Subject: $gProject $gBugs information: $description
928 References: $header{'message-id'}
929 In-Reply-To: $header{'message-id'}
930 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
939 $maintccreasons{$cca}{''}{$ref}= 1;
944 # maintainer email address &c -> assoc of packages -> assoc of bug#'s
945 my ($p, $addmaint, $pshow);
946 &ensuremaintainersloaded;
947 $anymaintfound=0; $anymaintnotfound=0;
948 for $p (split(m/[ \t?,()]+/,$_[0])) {
950 $pshow= ($p =~ m/[-+.a-z0-9]+/ ? $& : '');
951 if (defined($maintainerof{$p})) {
952 $addmaint= $maintainerof{$p};
953 &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
954 $maintccreasons{$addmaint}{$p}{$ref}= 1;
955 print "maintainer add >$p|$addmaint<\n" if $debug;
957 print "maintainer none >$p<\n" if $debug;
958 &transcript("MR|unknown-package|$p|$ref|\n") if $dl>2;
959 $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
964 sub ensuremaintainersloaded {
966 return if $maintainersloaded++;
967 open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
971 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
972 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
973 $maintainerof{$1}= $2;
976 open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
980 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
981 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
982 $maintainerof{$1}= $2;
987 local ($wherefrom,$path,$description) = @_;
988 if ($wherefrom eq "ftp.d.o") {
989 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or &quit("fork for lynx/gunzip: $!");
991 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
992 &transcript("$description is not available.\n");
995 &transcript("Error getting $description (code $? $!):\n$doc\n");
998 } elsif ($wherefrom eq "local") {
1000 $doc = do { local $/; <P> };
1003 &transcript("internal errror: info files location unknown.\n");
1006 &transcript("Sending $description.\n");
1007 &sendmailmessage(<<END.$doc,$replyto);
1008 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1010 Subject: $gProject $gBugs information: $description
1011 References: $header{'message-id'}
1012 In-Reply-To: $header{'message-id'}
1013 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1015 $description follows: