2 # $Id: service.in,v 1.53 2002/10/06 20:05:49 cjwatson Exp $
5 # Usage: service <code>.nn
6 # Temps: incoming/P<code>.nn
11 $config_path = '/org/bugs.debian.org/etc';
12 $lib_path = '/org/bugs.debian.org/scripts';
14 require "$config_path/config";
15 require "$lib_path/errorlib";
16 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
18 chdir("$gSpoolDir") || die "chdir spool: $!\n";
21 open DEBUG, ">/dev/null";
26 m/^[RC]\.\d+$/ || &quit("bad argument");
29 if (!rename("incoming/G$nn","incoming/P$nn")) {
30 $_=$!.''; m/no such file or directory/i && exit 0;
31 &quit("renaming to lock: $!");
34 open(M,"incoming/P$nn");
39 grep((s/\n$//,s/\s+$//),@msg);
41 print "###\n",join("##\n",@msg),"\n###\n" if $debug;
43 chop($tdate= `date -u '+%a, %d %h %Y %T GMT'`);
45 Received: via spool for service; $tdate
48 for ($i=0; $i<=$#msg; $i++) {
50 last unless length($_);
52 while ($msg[$i+1] =~ m/^\s/) {
54 $fwd .= $msg[$i]."\n" if $ins; # Huh ? Where is ins set ?
57 print ">$_<\n" if $debug;
59 $v= $1; $v =~ y/A-Z/a-z/;
60 print ">$v=$_<\n" if $debug;
63 print "!>$_<\n" if $debug;
67 if (defined $header{'resent-from'} && !defined $header{'from'}) {
68 $header{'from'} = $header{'resent-from'};
71 defined($header{'from'}) || &quit("no From header");
73 delete $header{'reply-to'}
74 if ( defined($header{'reply-to'}) && $header{'reply-to'} =~ m/^\s*$/ );
76 if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
77 $replyto = $header{'reply-to'};
79 $replyto = $header{'from'};
82 $controlrequestaddr= $control ? "control\@$gEmailDomain" : "request\@$gEmailDomain";
84 &transcript("Processing commands for $controlrequestaddr:\n\n");
89 $mergelowstate= 'idle';
93 #strip blank line(s) after header
94 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
98 my $fuckheads = "(" . join("|", @gFuckheads) . ")";
99 if (@gFuckheads and $replyto =~ m/$fuckheads/) {
100 &transcript("This service is unavailable.\n\n");
104 #strip, if exists, mime header
105 if ( $msg[$i] =~ /^This is a multi-part message in MIME format./ ) {
106 while ( $i <= $#msg && length( $msg[$i] ) ) {
107 $fwd .= $msg[$i] . "\n"; $i++;
109 while ( $i <= $#msg && !length( $msg[$i] ) ) {
113 if ( $msg[$i] =~ /^--/ || $msg[$i] =~ /^\s*$/ ) {
114 while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i]; $i++; }
115 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
121 for ($procline=$i; $procline<=$#msg; $procline++) {
122 $state eq 'idle' || print "$state ?\n";
123 $lowstate eq 'idle' || print "$lowstate ?\n";
124 $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
126 &transcript("Stopping processing here.\n\n");
129 $_= $msg[$procline]; s/\s+$//;
130 next unless m/\S/; next if m/^\s*\#/;
131 &transcript("> $_\n");
133 if (m/^stop/i || m/^quit/i || m/^--/ || m/^thank/i) {
134 &transcript("Stopping processing here.\n\n");
136 } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
138 &transcript("Debug level $dl.\n\n");
139 } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
141 &sendlynxdoc("$ref","logs for $gBug#$ref");
142 } elsif (m/^send-detail\s+\#?(\d+)$/i) {
143 &transcript("This BTS function is currently disabled, sorry.\n\n");
144 $ok++; # well, it's not really ok, but it fixes #81224 :)
145 # $ref= $1+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
146 # &sendlynxdoc("db/$reffile-b.html","additional logs for $gBug#$ref");
147 } elsif (m/^index(\s+full)?$/i) {
148 &transcript("This BTS function is currently disabled, sorry.\n\n");
149 $ok++; # well, it's not really ok, but it fixes #81224 :)
150 # &sendlynxdoc("db/ix/full.html",'full index');
151 } elsif (m/^index-summary\s+by-package$/i) {
152 &transcript("This BTS function is currently disabled, sorry.\n\n");
153 $ok++; # well, it's not really ok, but it fixes #81224 :)
154 # &sendlynxdoc("db/ix/psummary.html",'summary index sorted by package/title');
155 } elsif (m/^index-summary(\s+by-number)?$/i) {
156 &transcript("This BTS function is currently disabled, sorry.\n\n");
157 $ok++; # well, it's not really ok, but it fixes #81224 :)
158 # &sendlynxdoc("db/ix/summary.html",'summary index sorted by number/date');
159 } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
160 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=pkg",'index of packages');
161 } elsif (m/^index(\s+|-)maints?$/i) {
162 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=maint",'index of maintainers');
163 } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
165 # check for crap in $maint
166 if ($maint =~ m/^\./ || $maint !~ m/^[\d\w-+.@]+$/) {
167 &transcript("Invalid request $maint!\n");
170 &sendlynxdoc("$maint","$gBug list for maintainer \`$maint'");
172 $substrg= $2; $matches=0;
173 opendir(DBD,"$gWebDir/db/ma") || die $!;
174 while (defined($_=readdir(DBD))) {
175 next unless m/^l/ && m/\.html$/;
176 &transcript("F|$_\n") if $dl>1;
177 $filename= $_; s/^l//; s/\.html$//;
178 &transcript("P|$_\n") if $dl>2;
179 while (s/-(..)([^_])/-$1_-$2/) { }
180 &transcript("P|$_\n") if $dl>2;
181 s/^(.{0,2})_/$1-20_/g; while (s/([^-]..)_/$1-20_/) { };
182 &transcript("P|$_\n") if $dl>2;
183 s/^,(.*),(.*),([^,]+)$/$1-40_$2-20_-28_$3-29_/;
184 &transcript("P|$_\n") if $dl>2;
185 s/^([^,]+),(.*),(.*),$/$1-20_-3c_$2-40_$3-3e_/;
186 &transcript("P|$_\n") if $dl>2;
188 &transcript("P|$_\n") if $dl>2;
190 while (m/-(..)_/) { $out.= $`.sprintf("%c",hex($1)); $_=$'; }
192 &transcript("M|$out\n") if $dl>1;
193 next unless index(lc $out, lc $substrg)>=0;
194 &transcript("S|$filename\n") if $dl>0;
195 &transcript("S|$out\n") if $dl>0;
197 &sendlynxdocraw("db/ma/$filename","$gBug list for maintainer \`$out'");
200 &transcript("$gBug list(s) for $matches maintainer(s) sent.\n\n");
202 &transcript("No maintainers found containing \`$substrg'.\n".
203 "Use \`index-maint' to get list of maintainers.\n\n");
207 } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
209 # check for crap in $package
210 if ($package =~ m/^\./ || $package !~ m/^[\d\w-+.@]+$/) {
211 &transcript("Invalid request $package!\n");
214 &sendlynxdoc("$package","$gBug list for package $package sent.\n\n");
216 $substrg= $+; $matches=0;
217 opendir(DBD,"$gWebDir/db/pa") || die $!;
218 while (defined($_=readdir(DBD))) {
219 next unless m/^l/ && m/\.html$/;
220 &transcript("F|$_\n") if $dl>1;
221 $filename= $_; s/^l//; s/\.html$//;
222 next unless index(lc $_, lc $substrg)>=0;
223 &transcript("S|$filename\n") if $dl>0;
224 &transcript("S|$out\n") if $dl>0;
226 &sendlynxdocraw("db/pa/$filename","$gBug list for package \`$_'");
229 &transcript("$gBug list(s) for $matches package(s) sent.\n\n");
231 &transcript("No packages found containing \`$substrg'.\n".
232 "Use \`index-packages' to get list of packages.\n\n");
236 } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
237 &transcript("This BTS function is currently disabled, sorry.\n\n");
238 $ok++; # well, it's not really ok, but it fixes #81224 :)
239 # &sendlynxdoc("db/ju/unmatched-1.html","junk (this week)");
240 } elsif (m/^send-unmatched\s+(last|-1)$/i) {
241 &transcript("This BTS function is currently disabled, sorry.\n\n");
242 $ok++; # well, it's not really ok, but it fixes #81224 :)
243 # &sendlynxdoc("db/ju/unmatched-2.html","junk (last week)");
244 } elsif (m/^send-unmatched\s+(old|-2)$/i) {
245 &transcript("This BTS function is currently disabled, sorry.\n\n");
246 $ok++; # well, it's not really ok, but it fixes #81224 :)
247 # &sendlynxdoc("db/ju/unmatched-3.html","junk (two weeks ago)");
248 } elsif (m/^getinfo\s+([\w-.]+)$/i) {
249 # the following is basically a Debian-specific kludge, but who cares
251 if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
252 &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
253 } elsif ($req =~ /^override\.(\w+)\.([\w-.]+)$/i) {
255 &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
256 } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
257 &sendinfo("local", "$gConfigDir/$req", "$req file");
259 &transcript("Info file $req does not exist.\n\n");
261 } elsif (m/^help/i) {
265 } elsif (m/^refcard/i) {
266 &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
267 } elsif (m/^subscribe/i) {
269 There is no $gProject $gBug mailing list. If you wish to review bug reports
270 please do so via http://$gWebDomain/ or ask this mail server
272 soon: MAILINGLISTS_TEXT
274 } elsif (m/^unsubscribe/i) {
276 soon: UNSUBSCRIBE_TEXT
277 soon: MAILINGLISTS_TEXT
279 } elsif (!$control) {
281 Unknown command or malformed arguments to command.
282 (Use control\@$gEmailDomain to manipulate reports.)
285 if (++$unknowns >= 3) {
286 &transcript("Too many unknown commands, stopping here.\n\n");
289 #### interesting ones start here
290 } elsif (m/^close\s+\#?(-?\d+)$/i) {
294 if (length($s_done)) {
295 &transcript("$gBug is already closed, cannot re-close.\n\n");
298 $action= "$gBug closed, send any further explanations to $s_originator";
300 &addmaintainers($s_package);
301 if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
302 0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
305 From: $gMaintainerEmail ($gProject $gBug Tracking System)
307 Subject: $gBug#$ref acknowledged by developer
309 References: $header{'message-id'} $s_msgid
310 In-Reply-To: $s_msgid
311 Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
312 Reply-To: $ref\@$gEmailDomain
314 This is an automatic notification regarding your $gBug report
316 which was filed against the $s_package package.
318 It has been marked as closed by one of the developers, namely
321 You should be hearing from them with a substantive response shortly,
322 in case you haven't already. If not, please contact them directly.
325 (administrator, $gProject $gBugs database)
328 &sendmailmessage($message,$s_originator);
329 } while (&getnextbug);
332 } elsif (m/^reassign\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
334 $ref= $1; $newpackage= $2;
335 $newpackage =~ y/A-Z/a-z/;
337 if (length($s_package)) {
338 $action= "$gBug reassigned from package \`$s_package'".
339 " to \`$newpackage'.";
341 $action= "$gBug assigned to package \`$newpackage'.";
344 &addmaintainers($s_package);
345 &addmaintainers($newpackage);
346 $s_package= $newpackage;
347 } while (&getnextbug);
349 } elsif (m/^reopen\s+\#?(-?\d+)$/i ? ($noriginator='', 1) :
350 m/^reopen\s+\#?(-?\d+)\s+\=$/i ? ($noriginator='', 1) :
351 m/^reopen\s+\#?(-?\d+)\s+\!$/i ? ($noriginator=$replyto, 1) :
352 m/^reopen\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($noriginator=$2, 1) : 0) {
356 if (!length($s_done)) {
357 &transcript("$gBug is already open, cannot reopen.\n\n");
361 $noriginator eq '' ? "$gBug reopened, originator not changed." :
362 "$gBug reopened, originator set to $noriginator.";
364 &addmaintainers($s_package);
365 $s_originator= $noriginator eq '' ? $s_originator : $noriginator;
367 } while (&getnextbug);
370 } elsif (m/^forwarded\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
372 $ref= $1; $whereto= $2;
374 if (length($s_forwarded)) {
375 $action= "Forwarded-to-address changed from $s_forwarded to $whereto.";
377 $action= "Noted your statement that $gBug has been forwarded to $whereto.";
379 if (length($s_done)) {
380 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
383 &addmaintainers($s_package);
384 if (length($gFowardList)>0 && length($gListDomain)>0 ) {
385 &addccaddress("$gFowardList\@$gListDomain");
387 $s_forwarded= $whereto;
388 } while (&getnextbug);
390 } elsif (m/^notforwarded\s+\#?(-?\d+)$/i) {
394 if (!length($s_forwarded)) {
395 &transcript("$gBug is not marked as having been forwarded.\n\n");
398 $action= "Removed annotation that $gBug had been forwarded to $s_forwarded.";
400 &addmaintainers($s_package);
402 } while (&getnextbug);
405 } elsif (m/^severity\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i ||
406 m/^priority\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i) {
410 if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
411 &transcript("Severity level \`$newseverity' is not known.\n".
412 "Recognized are: $gShowSeverities.\n\n");
414 $printseverity= $s_severity;
415 $printseverity= "$gDefaultSeverity" if $printseverity eq '';
416 $action= "Severity set to \`$newseverity'.";
418 &addmaintainers($s_package);
419 $s_severity= $newseverity;
420 } while (&getnextbug);
422 } elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s+)?(\S.*)?$/i) {
424 $ref = $1; $addsubcode = $3; $tags = $4;
426 if (defined $addsubcode) {
427 $addsub = "sub" if ($addsubcode eq "-");
428 $addsub = "add" if ($addsubcode eq "+");
429 $addsub = "set" if ($addsubcode eq "=");
433 foreach my $t (split /[\s,]+/, $tags) {
434 if (!grep($_ eq $t, @gTags)) {
441 &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
442 "Recognized are: ".join(' ', @gTags).".\n\n");
445 if ($addsub eq "set") {
446 $action= "Tags set to: " . join(", ", @okaytags);
447 } elsif ($addsub eq "add") {
448 $action= "Tags added: " . join(", ", @okaytags);
449 } elsif ($addsub eq "sub") {
450 $action= "Tags removed: " . join(", ", @okaytags);
453 &addmaintainers($s_package);
454 $s_keywords = '' if ($addsub eq "set");
455 if ($addsub eq "sub") {
456 foreach my $t (@badtags) {
457 $s_keywords = join ' ', grep $_ ne $t,
458 split ' ', $s_keywords;
461 foreach my $t (@okaytags) {
462 $s_keywords = join ' ', grep $_ ne $t,
463 split ' ', $s_keywords;
464 $s_keywords = "$t $s_keywords" unless($addsub eq "sub");
466 $s_keywords =~ s/\s*$//;
467 } while (&getnextbug);
469 } elsif (m/^retitle\s+\#?(-?\d+)\s+(\S.*\S)\s*$/i) {
471 $ref= $1; $newtitle= $2;
472 if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
473 $ref = $clonebugs{$ref};
477 &addmaintainers($s_package);
478 $s_subject= $newtitle;
479 $action= "Changed $gBug title.";
481 &transcript("$action\n");
482 if (length($s_done)) {
483 &transcript("(By the way, that $gBug is currently marked as done.)\n");
489 } elsif (m/^unmerge\s+\#?(-?\d+)$/i) {
493 if (!length($s_mergedwith)) {
494 &transcript("$gBug is not marked as being merged with any others.\n\n");
497 $mergelowstate eq 'locked' || die "$mergelowstate ?";
498 $action= "Disconnected #$ref from all other report(s).";
499 @newmergelist= split(/ /,$s_mergedwith);
502 &addmaintainers($s_package);
503 $s_mergedwith= ($ref == $discref) ? ''
504 : join(' ',grep($_ ne $ref,@newmergelist));
505 } while (&getnextbug);
508 } elsif (m/^merge\s+(\d+(\s+\d+)+)\s*$/i) {
510 @tomerge= sort { $a <=> $b } split(/\s+/,$1);
514 while (defined($ref= shift(@tomerge))) {
515 &transcript("D| checking merge $ref\n") if $dl;
517 next if grep($_ eq $ref,@newmergelist);
518 if (!&getbug) { ¬foundbug; @newmergelist=(); last }
520 &transcript("D| adding $ref ($s_mergedwith)\n") if $dl;
522 &checkmatch('package','m_package',$s_package);
523 &checkmatch('forwarded addr','m_forwarded',$s_forwarded);
524 $s_severity = '$gDefaultSeverity' if $s_severity eq '';
525 &checkmatch('severity','m_severity',$s_severity);
526 &checkmatch('done mark','m_done',length($s_done) ? 'done' : 'open');
527 foreach my $t (split /\s+/, $s_keywords) { $tags{$t} = 1; }
528 if (length($mismatch)) {
529 &transcript("Mismatch - only $gBugs in same state can be merged:\n".
531 &cancelbug; @newmergelist=(); last;
533 push(@newmergelist,$ref);
534 push(@tomerge,split(/ /,$s_mergedwith));
538 @newmergelist= sort { $a <=> $b } @newmergelist;
539 $action= "Merged @newmergelist.";
540 for $ref (@newmergelist) {
541 &getbug || die "huh ? $gBug $ref disappeared during merge";
542 &addmaintainers($s_package);
543 $s_mergedwith= join(' ',grep($_ ne $ref,@newmergelist));
544 $s_keywords= join(' ', keys %tags);
547 &transcript("$action\n\n");
550 } elsif (m/^clone\s+#?(\d+)\s+((-\d+\s+)*-\d+)\s*$/i) {
554 @newclonedids = split /\s+/, $2;
555 $newbugsneeded = scalar(@newclonedids);
559 if (length($s_mergedwith)) {
560 &transcript("$gBug is marked as being merged with others.\n\n");
563 &filelock("nextnumber.lock");
564 open(N,"nextnumber") || &quit("nextnumber: read: $!");
565 $v=<N>; $v =~ s/\n$// || &quit("nextnumber bad format");
566 $firstref= $v+0; $v += $newbugsneeded;
567 open(NN,">nextnumber"); print NN "$v\n"; close(NN);
570 $lastref = $firstref + $newbugsneeded - 1;
572 if ($newbugsneeded == 1) {
573 $action= "$gBug $origref cloned as bug $firstref.";
575 $action= "$gBug $origref cloned as bugs $firstref-$lastref.";
578 my $ohash = get_hashname($origref);
580 for $newclonedid (@newclonedids) {
581 $clonebugs{$newclonedid} = $ref;
583 my $hash = get_hashname($ref);
584 copy("db-h/$ohash/$origref.log", "db-h/$hash/$ref.log");
585 copy("db-h/$ohash/$origref.status", "db-h/$hash/$ref.status");
586 copy("db-h/$ohash/$origref.report", "db-h/$hash/$ref.report");
587 &bughook('new', $ref, "$s_originator\n$s_date\n$s_subject\n$s_msgid\n$s_package\n$s_keywords\n$s_done\n$s_forwarded\n$s_mergedwith\n$s_severity\n");
594 &transcript("Unknown command or malformed arguments to command.\n\n");
595 if (++$unknowns >= 5) {
596 &transcript("Too many unknown commands, stopping here.\n\n");
601 if ($procline>$#msg) {
602 &transcript(">\nEnd of message, stopping processing here.\n\n");
604 if (!$ok && !quickabort) {
605 &transcript("No commands successfully parsed; sending the help text(s).\n");
610 &transcript("MC\n") if $dl>1;
612 for $maint (keys %maintccreasons) {
613 &transcript("MM|$maint|\n") if $dl>1;
614 next if $maint eq $replyto;
616 $reasonsref= $maintccreasons{$maint};
617 &transcript("MY|$maint|\n") if $dl>2;
618 for $p (sort keys %$reasonsref) {
619 &transcript("MP|$p|\n") if $dl>2;
620 $reasonstring.= ', ' if length($reasonstring);
621 $reasonstring.= $p.' ' if length($p);
622 $reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
624 if (length($reasonstring) > 40) {
625 (substr $reasonstring, 37) = "...";
627 $reasonstring = "" if (!defined($reasonstring));
628 push(@maintccs,"$maint ($reasonstring)");
629 push(@maintccaddrs,"$maint");
634 &transcript("MC|@maintccs|\n") if $dl>2;
635 $maintccs .= "Cc: " . join(",\n ",@maintccs) . "\n";
638 if (!defined $header{'subject'} || $header{'subject'} eq "") {
639 $header{'subject'} = "your mail";
643 From: $gMaintainerEmail ($gProject $gBug Tracking System)
645 ${maintccs}Subject: Processed: $header{'subject'}
646 In-Reply-To: $header{'message-id'}
647 References: $header{'message-id'}
648 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
650 ${transcript}Please contact me if you need assistance.
653 (administrator, $gProject $gBugs database)
657 $repliedshow= join(', ',$replyto,@maintccaddrs);
658 &filelock("lock/-1");
659 open(AP,">>db-h/-1.log") || &quit("open db-h/-1.log: $!");
661 "\2\n$repliedshow\n\5\n$reply\n\3\n".
663 "<strong>Request received</strong> from <code>".
664 &sani($header{'from'})."</code>\n".
665 "to <code>".&sani($controlrequestaddr)."</code>\n".
667 "\7\n",@log,"\n\3\n") || &quit("writing db-h/-1.log: $!");
668 close(AP) || &quit("open db-h/-1.log: $!");
670 utime(time,time,"db-h");
672 &sendmailmessage($reply,$replyto,@maintccaddrs,@bcc);
674 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
678 map { $_->address() }
679 map { Mail::Address->parse($_) } @_;
682 sub sendmailmessage {
683 local ($message,@recips) = @_;
684 print "mailing to >@recips<\n" if $debug;
686 defined($c) || &quit("mailing forking for sendmail: $!");
687 if (!$c) { # ie, we are the child process
688 exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odb','-oem','-oi',get_addresses(@recips);
691 print(D $message) || &quit("writing to sendmail process: $!");
692 $!=0; close(D); $? && &quit("sendmail gave exit status $? ($!)");
697 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
698 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
703 # &transcript("Sorry, command $_[0] not yet implemented.\n\n");
707 local ($string,$mvarname,$svarvalue) = @_;
710 eval "\$mvarvalue= \$$mvarname";
711 &transcript("D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n")
714 "Values for \`$string' don't match:\n".
715 " #$newmergelist[0] has \`$mvarvalue';\n".
716 " #$ref has \`$svarvalue'\n"
717 if $mvarvalue ne $svarvalue;
719 &transcript("D| setupmatch \`$string' /$mvarname/$svarvalue/\n")
721 eval "\$$mvarname= \$svarvalue";
725 # High-level bug manipulation calls
726 # Do announcements themselves
728 # Possible calling sequences:
732 # &transcript(something)
736 # $action= (something)
738 # (modify s_* variables)
739 # } while (getnextbug);
742 &dlen("nochangebug");
743 $state eq 'single' || $state eq 'multiple' || die "$state ?";
745 &endmerge if $manybugs;
747 &dlex("nochangebug");
751 &dlen("setbug $ref");
752 if ($ref =~ m/^-\d+/) {
753 if (!defined $clonebugs{$ref}) {
755 &dlex("setbug => noclone");
758 $ref = $clonebugs{$ref};
760 $state eq 'idle' || die "$state ?";
763 &dlex("setbug => 0s");
766 @thisbugmergelist= split(/ /,$s_mergedwith);
767 if (!@thisbugmergelist) {
772 &dlex("setbug => 1s");
781 &dlex("setbug => 0mc");
785 $state= 'multiple'; $sref=$ref;
786 &dlex("setbug => 1m");
792 $state eq 'single' || $state eq 'multiple' || die "$state ?";
794 if (!$manybugs || !@thisbugmergelist) {
795 length($action) || die;
796 &transcript("$action\n$extramessage\n");
797 &endmerge if $manybugs;
799 &dlex("getnextbug => 0");
802 $ref= shift(@thisbugmergelist);
803 &getbug || die "bug $ref disappeared";
805 &dlex("getnextbug => 1");
809 # Low-level bug-manipulation calls
810 # Do no announcements
818 # $action= (something)
823 # [getbug (returns 0)]
824 # &transcript("$action\n\n")
827 sub notfoundbug { &transcript("$gBug number $ref not found.\n\n"); }
828 sub foundbug { &transcript("$gBug#$ref: $s_subject\n"); }
832 $mergelowstate eq 'idle' || die "$mergelowstate ?";
833 &filelock('lock/merge');
834 $mergelowstate='locked';
840 $mergelowstate eq 'locked' || die "$mergelowstate ?";
842 $mergelowstate='idle';
847 &dlen("getbug $ref");
848 $lowstate eq 'idle' || die "$state ?";
849 if (&lockreadbug($ref)) {
852 &dlex("getbug => 1");
857 &dlex("getbug => 0");
863 $lowstate eq 'open' || die "$state ?";
870 &dlen("savebug $ref");
871 $lowstate eq 'open' || die "$lowstate ?";
872 length($action) || die;
873 $ref == $sref || die "read $sref but saving $ref ?";
874 my $hash = get_hashname($ref);
875 open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!");
878 "<strong>".&sani($action)."</strong>\n".
879 "Request was from <code>".&sani($header{'from'})."</code>\n".
880 "to <code>".&sani($controlrequestaddr)."</code>. \n".
882 "\7\n",@log,"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
883 close(L) || &quit("closing db-h/$hash/$ref.log: $!");
884 open(S,">db-h/$hash/$ref.status.new") || &quit("opening db-h/$hash/$ref.status.new: $!");
895 "$s_severity\n") || &quit("writing db-h/$hash/$ref.status.new: $!");
896 close(S) || &quit("closing db-h/$hash/$ref.status.new: $!");
897 rename("db-h/$hash/$ref.status.new","db-h/$hash/$ref.status") ||
898 &quit("installing new db-h/$hash/$ref.status: $!");
899 &bughook('change',$ref,
917 &transcript("C> @_ ($state $lowstate $mergelowstate)\n");
922 &transcript("R> @_ ($state $lowstate $mergelowstate)\n");
926 print $_[0] if $debug;
943 local ($relpath,$description) = @_;
945 open(D,"$gDocDir/$relpath") || &quit("open doc file $relpath: $!");
946 while(<D>) { $doc.=$_; }
948 &transcript("Sending $description in separate message.\n");
949 &sendmailmessage(<<END.$doc,$replyto);
950 From: $gMaintainerEmail ($gProject $gBug Tracking System)
952 Subject: $gProject $gBug help: $description
953 References: $header{'message-id'}
954 In-Reply-To: $header{'message-id'}
955 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
962 local ($relpath,$description) = @_;
964 # the below oughta use $gWebDomain but it can't
965 open(L,"lynx -nolist -dump http://bugs.debian.org/$relpath 2>&1 |") || &quit("fork for lynx: $!");
966 while(<L>) { $doc.=$_; }
968 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
969 &transcript("Information ($description) is not available -\n".
970 "perhaps the $gBug does not exist or is not on the WWW yet.\n");
973 &transcript("Error getting $description (code $? $!):\n$doc\n");
975 &transcript("Sending $description.\n");
976 &sendmailmessage(<<END.$doc,$replyto);
977 From: $gMaintainerEmail ($gProject $gBug Tracking System)
979 Subject: $gProject $gBugs information: $description
980 References: $header{'message-id'}
981 In-Reply-To: $header{'message-id'}
982 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
991 $maintccreasons{$cca}{''}{$ref}= 1;
996 # maintainer email address &c -> assoc of packages -> assoc of bug#'s
997 my ($p, $addmaint, $pshow);
998 &ensuremaintainersloaded;
999 $anymaintfound=0; $anymaintnotfound=0;
1000 for $p (split(m/[ \t?,()]+/,$_[0])) {
1002 $pshow= ($p =~ m/[-+.a-z0-9]+/ ? $& : '');
1003 if (defined($pkgsrc{$p})) {
1004 push @bcc, "$pkgsrc{$p}\@packages.qa.debian.org";
1006 push @bcc, "$p\@packages.qa.debian.org";
1008 if (defined($maintainerof{$p})) {
1009 $addmaint= $maintainerof{$p};
1010 &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
1011 $maintccreasons{$addmaint}{$p}{$ref}= 1;
1012 print "maintainer add >$p|$addmaint<\n" if $debug;
1014 print "maintainer none >$p<\n" if $debug;
1015 &transcript("MR|unknown-package|$p|$ref|\n") if $dl>2;
1016 $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
1021 sub ensuremaintainersloaded {
1023 return if $maintainersloaded++;
1024 open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
1028 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
1029 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1030 $maintainerof{$1}= $2;
1033 open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
1037 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
1038 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
1039 $maintainerof{$1}= $2;
1042 open(SOURCES, "$gPackageSource") || &quit("pkgsrc open: $!");
1044 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
1045 my ($a, $b) = ($1, $2);
1046 $pkgsrc{lc($a)} = $b;
1052 local ($wherefrom,$path,$description) = @_;
1053 if ($wherefrom eq "ftp.d.o") {
1054 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or &quit("fork for lynx/gunzip: $!");
1056 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
1057 &transcript("$description is not available.\n");
1060 &transcript("Error getting $description (code $? $!):\n$doc\n");
1063 } elsif ($wherefrom eq "local") {
1065 $doc = do { local $/; <P> };
1068 &transcript("internal errror: info files location unknown.\n");
1071 &transcript("Sending $description.\n");
1072 &sendmailmessage(<<END.$doc,$replyto);
1073 From: $gMaintainerEmail ($gProject $gBug Tracking System)
1075 Subject: $gProject $gBugs information: $description
1076 References: $header{'message-id'}
1077 In-Reply-To: $header{'message-id'}
1078 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
1080 $description follows: