2 # $Id: service.in,v 1.35 2001/04/24 19:10:26 doogie Exp $
5 # Usage: service <code>.nn
6 # Temps: incoming/P<code>.nn
9 require('/etc/debbugs/config');
10 require('/usr/lib/debbugs/errorlib');
11 $ENV{'PATH'} = '/usr/lib/debbugs:'.$ENV{'PATH'};
12 chdir("$gSpoolDir") || die "chdir spool: $!\n";
15 open DEBUG, ">/dev/null";
19 m/^[RC]\.\d+$/ || &quit("bad argument");
22 if (!rename("incoming/G$nn","incoming/P$nn"))
23 { $_=$!.''; m/no such file or directory/i && exit 0;
24 &quit("renaming to lock: $!");
27 open(M,"incoming/P$nn");
32 grep((s/\n$//,s/\s+$//),@msg);
34 print "###\n",join("##\n",@msg),"\n###\n" if $debug;
36 chop($tdate= `date -u '+%a, %d %h %Y %T GMT'`);
38 Received: via spool for service; $tdate
41 for ($i=0; $i<=$#msg; $i++)
43 last unless length($_);
45 while ($msg[$i+1] =~ m/^\s/)
47 $fwd .= $msg[$i]."\n" if $ins; # Huh ? Where is ins set ?
50 print ">$_<\n" if $debug;
52 { $v= $1; $v =~ y/A-Z/a-z/;
53 print ">$v=$_<\n" if $debug;
55 } else { print "!>$_<\n" if $debug; }
58 if (defined $header{'resent-from'} && !defined $header{'from'}) {
59 $header{'from'} = $header{'resent-from'};
61 defined($header{'from'}) || &quit("no From header");
62 delete $header{'reply-to'} if ( defined($header{'reply-to'}) && $header{'reply-to'} =~ m/^\s*$/ );
63 if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
64 $replyto = $header{'reply-to'};
66 $replyto = $header{'from'};
69 $controlrequestaddr= $control ? "control\@$gEmailDomain" : "request\@$gEmailDomain";
71 &transcript("Processing commands for $controlrequestaddr:\n\n");
76 $mergelowstate= 'idle';
80 #strip blank line(s) after header
81 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
83 #strip, if exists, mime header
84 if ( $msg[$i] =~ /^This is a multi-part message in MIME format./ )
85 { while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i] . "\n"; $i++; }
86 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
88 if ( $msg[$i] =~ /^--/ || $msg[$i] =~ /^\s*$/ )
89 { while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i]; $i++; }
90 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
94 for ($procline=$i; $procline<=$#msg; $procline++)
95 { $state eq 'idle' || print "$state ?\n";
96 $lowstate eq 'idle' || print "$lowstate ?\n";
97 $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
98 $_= $msg[$procline]; s/\s+$//;
99 next unless m/\S/; next if m/^\s*\#/;
100 &transcript("> $_\n");
102 if (m/^stop/i || m/^quit/i || m/^--/ || m/^thank/i)
103 { &transcript("Stopping processing here.\n\n");
105 } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
107 &transcript("Debug level $dl.\n\n");
108 } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
110 &sendlynxdoc("$ref","logs for $gBug#$ref");
111 } elsif (m/^send-detail\s+\#?(\d+)$/i) {
112 &transcript("This BTS function is currently disabled, sorry.\n\n");
113 $ok++; # well, it's not really ok, but it fixes #81224 :)
114 # $ref= $1+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
115 # &sendlynxdoc("db/$reffile-b.html","additional logs for $gBug#$ref");
116 } elsif (m/^index(\s+full)?$/i) {
117 &transcript("This BTS function is currently disabled, sorry.\n\n");
118 $ok++; # well, it's not really ok, but it fixes #81224 :)
119 # &sendlynxdoc("db/ix/full.html",'full index');
120 } elsif (m/^index-summary\s+by-package$/i) {
121 &transcript("This BTS function is currently disabled, sorry.\n\n");
122 $ok++; # well, it's not really ok, but it fixes #81224 :)
123 # &sendlynxdoc("db/ix/psummary.html",'summary index sorted by package/title');
124 } elsif (m/^index-summary(\s+by-number)?$/i) {
125 &transcript("This BTS function is currently disabled, sorry.\n\n");
126 $ok++; # well, it's not really ok, but it fixes #81224 :)
127 # &sendlynxdoc("db/ix/summary.html",'summary index sorted by number/date');
128 } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
129 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=pkg",'index of packages');
130 } elsif (m/^index(\s+|-)maints?$/i) {
131 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=maint",'index of maintainers');
132 } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
134 # check for crap in $maint
135 if ($maint =~ m/^\./ || $maint !~ m/^[\d\w-+.@]+$/) {
136 &transcript("Invalid request $maint!\n");
139 &sendlynxdoc("$maint","$gBug list for maintainer \`$maint'");
141 $substrg= $2; $matches=0;
142 opendir(DBD,"$gWebDir/db/ma") || die $!;
143 while (defined($_=readdir(DBD))) {
144 next unless m/^l/ && m/\.html$/;
145 &transcript("F|$_\n") if $dl>1;
146 $filename= $_; s/^l//; s/\.html$//;
147 &transcript("P|$_\n") if $dl>2;
148 while (s/-(..)([^_])/-$1_-$2/) { }
149 &transcript("P|$_\n") if $dl>2;
150 s/^(.{0,2})_/$1-20_/g; while (s/([^-]..)_/$1-20_/) { };
151 &transcript("P|$_\n") if $dl>2;
152 s/^,(.*),(.*),([^,]+)$/$1-40_$2-20_-28_$3-29_/;
153 &transcript("P|$_\n") if $dl>2;
154 s/^([^,]+),(.*),(.*),$/$1-20_-3c_$2-40_$3-3e_/;
155 &transcript("P|$_\n") if $dl>2;
157 &transcript("P|$_\n") if $dl>2;
159 while (m/-(..)_/) { $out.= $`.sprintf("%c",hex($1)); $_=$'; }
161 &transcript("M|$out\n") if $dl>1;
162 next unless index(lc $out, lc $substrg)>=0;
163 &transcript("S|$filename\n") if $dl>0;
164 &transcript("S|$out\n") if $dl>0;
166 &sendlynxdocraw("db/ma/$filename","$gBug list for maintainer \`$out'");
169 &transcript("$gBug list(s) for $matches maintainer(s) sent.\n\n");
171 &transcript("No maintainers found containing \`$substrg'.\n".
172 "Use \`index-maint' to get list of maintainers.\n\n");
176 } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
178 # check for crap in $package
179 if ($package =~ m/^\./ || $package !~ m/^[\d\w-+.@]+$/) {
180 &transcript("Invalid request $package!\n");
183 &sendlynxdoc("$package","$gBug list for package $package sent.\n\n");
185 $substrg= $+; $matches=0;
186 opendir(DBD,"$gWebDir/db/pa") || die $!;
187 while (defined($_=readdir(DBD))) {
188 next unless m/^l/ && m/\.html$/;
189 &transcript("F|$_\n") if $dl>1;
190 $filename= $_; s/^l//; s/\.html$//;
191 next unless index(lc $_, lc $substrg)>=0;
192 &transcript("S|$filename\n") if $dl>0;
193 &transcript("S|$out\n") if $dl>0;
195 &sendlynxdocraw("db/pa/$filename","$gBug list for package \`$_'");
198 &transcript("$gBug list(s) for $matches package(s) sent.\n\n");
200 &transcript("No packages found containing \`$substrg'.\n".
201 "Use \`index-packages' to get list of packages.\n\n");
205 } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
206 &transcript("This BTS function is currently disabled, sorry.\n\n");
207 $ok++; # well, it's not really ok, but it fixes #81224 :)
208 # &sendlynxdoc("db/ju/unmatched-1.html","junk (this week)");
209 } elsif (m/^send-unmatched\s+(last|-1)$/i) {
210 &transcript("This BTS function is currently disabled, sorry.\n\n");
211 $ok++; # well, it's not really ok, but it fixes #81224 :)
212 # &sendlynxdoc("db/ju/unmatched-2.html","junk (last week)");
213 } elsif (m/^send-unmatched\s+(old|-2)$/i) {
214 &transcript("This BTS function is currently disabled, sorry.\n\n");
215 $ok++; # well, it's not really ok, but it fixes #81224 :)
216 # &sendlynxdoc("db/ju/unmatched-3.html","junk (two weeks ago)");
217 } elsif (m/^getinfo\s+([\w-.]+)$/i) {
218 # the following is basically a Debian-specific kludge, but who cares
220 if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
221 &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
222 } elsif ($req =~ /^override\.(\w+)\.([\w-.]+)$/i) {
224 &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
225 } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
226 &sendinfo("local", "$gConfigDir/$req", "$req file");
228 &transcript("Info file $req does not exist.\n\n");
230 } elsif (m/^help/i) {
234 } elsif (m/^refcard/i) {
235 &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
236 } elsif (m/^subscribe/i) {
238 There is no $gProject $gBug mailing list. If you wish to review bug reports
239 please do so via http://$gWebDomain/ or ask this mail server
241 soon: MAILINGLISTS_TEXT
243 } elsif (m/^unsubscribe/i) {
245 soon: UNSUBSCRIBE_TEXT
246 soon: MAILINGLISTS_TEXT
248 } elsif (!$control) {
250 Unknown command or malformed arguments to command.
251 (Use control\@$gEmailDomain to manipulate reports.)
254 if (++$unknowns >= 3) {
255 &transcript("Too many unknown commands, stopping here.\n\n");
258 } elsif (m/^close\s+\#?(\d+)$/i) {
262 if (length($s_done)) {
263 &transcript("$gBug is already closed, cannot re-close.\n\n");
266 $action= "$gBug closed, send any further explanations to $s_originator";
268 &addmaintainers($s_package);
269 if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
270 0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
273 From: $gMaintainerEmail ($gProject $gBug Tracking System)
275 Subject: $gBug#$ref acknowledged by developer
277 References: $header{'message-id'} $s_msgid
278 In-Reply-To: $s_msgid
279 Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
281 This is an automatic notification regarding your $gBug report
283 which was filed against the $s_package package.
285 It has been marked as closed by one of the developers, namely
288 You should be hearing from them with a substantive response shortly,
289 if you have not already done so. If not, please contact them
293 (administrator, $gProject $gBugs database)
296 &sendmailmessage($message,$s_originator);
297 } while (&getnextbug);
300 } elsif (m/^reassign\s+\#?(\d+)\s+(\S.*\S)$/i) {
302 $ref= $1; $newpackage= $2;
303 $newpackage =~ y/A-Z/a-z/;
305 if (length($s_package)) {
306 $action= "$gBug reassigned from package \`$s_package'".
307 " to \`$newpackage'.";
309 $action= "$gBug assigned to package \`$newpackage'.";
312 &addmaintainers($s_package);
313 &addmaintainers($newpackage);
314 $s_package= $newpackage;
315 } while (&getnextbug);
317 } elsif (m/^reopen\s+\#?(\d+)$/i ? ($noriginator='', 1) :
318 m/^reopen\s+\#?(\d+)\s+\=$/i ? ($noriginator='', 1) :
319 m/^reopen\s+\#?(\d+)\s+\!$/i ? ($noriginator=$replyto, 1) :
320 m/^reopen\s+\#?(\d+)\s+(\S.*\S)$/i ? ($noriginator=$2, 1) : 0) {
324 if (!length($s_done)) {
325 &transcript("$gBug is already open, cannot reopen.\n\n");
329 $noriginator eq '' ? "$gBug reopened, originator not changed." :
330 "$gBug reopened, originator set to $noriginator.";
332 &addmaintainers($s_package);
333 $s_originator= $noriginator eq '' ? $s_originator : $noriginator;
335 } while (&getnextbug);
338 } elsif (m/^forwarded\s+\#?(\d+)\s+(\S.*\S)$/i) {
340 $ref= $1; $whereto= $2;
342 if (length($s_forwarded)) {
343 $action= "Forwarded-to-address changed from $s_forwarded to $whereto.";
345 $action= "Noted your statement that $gBug has been forwarded to $whereto.";
347 if (length($s_done)) {
348 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
351 &addmaintainers($s_package);
352 if (length($gFowardList)>0 && length($gListDomain)>0 )
353 { &addccaddress("$gFowardList\@$gListDomain"); }
354 $s_forwarded= $whereto;
355 } while (&getnextbug);
357 } elsif (m/^notforwarded\s+\#?(\d+)$/i) {
361 if (!length($s_forwarded)) {
362 &transcript("$gBug is not marked as having been forwarded.\n\n");
365 $action= "Removed annotation that $gBug had been forwarded to $s_forwarded.";
367 &addmaintainers($s_package);
369 } while (&getnextbug);
372 } elsif (m/^severity\s+\#?(\d+)\s+([-0-9a-z]+)$/i ||
373 m/^priority\s+\#?(\d+)\s+([-0-9a-z]+)$/i) {
377 if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
378 &transcript("Severity level \`$newseverity' is not known.\n".
379 "Recognized are: $gShowSeverities.\n\n");
381 $printseverity= $s_severity;
382 $printseverity= "$gDefaultSeverity" if $printseverity eq '';
383 $action= "Severity set to \`$newseverity'.";
385 &addmaintainers($s_package);
386 $s_severity= $newseverity;
387 } while (&getnextbug);
389 } elsif (m/^tags?\s+\#?(\d+)\s+(([=+-])\s+)?(\S.*)?$/i) {
391 $ref = $1; $addsubcode = $3; $tags = $4;
393 if (defined $addsubcode) {
394 $addsub = "sub" if ($addsubcode eq "-");
395 $addsub = "add" if ($addsubcode eq "+");
396 $addsub = "set" if ($addsubcode eq "=");
400 foreach my $t (split /[\s,]+/, $tags) {
401 if (!grep($_ eq $t, @gTags)) {
408 &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
409 "Recognized are: ".join(' ', @gTags).".\n\n");
412 if ($addsub eq "set") {
413 $action= "Tags set to: " . join(", ", @okaytags);
414 } elsif ($addsub eq "add") {
415 $action= "Tags added: " . join(", ", @okaytags);
416 } elsif ($addsub eq "sub") {
417 $action= "Tags removed: " . join(", ", @okaytags);
420 &addmaintainers($s_package);
421 $s_keywords = '' if ($addsub eq "set");
422 if ($addsub eq "sub") {
423 foreach my $t (@badtags) {
424 $s_keywords = join ' ', grep $_ ne $t,
425 split ' ', $s_keywords;
428 foreach my $t (@okaytags) {
429 $s_keywords = join ' ', grep $_ ne $t,
430 split ' ', $s_keywords;
431 $s_keywords = "$t $s_keywords" unless($addsub eq "sub");
433 $s_keywords =~ s/\s*$//;
434 } while (&getnextbug);
436 } elsif (m/^retitle\s+\#?(\d+)\s+(\S.*\S)\s*$/i) {
438 $ref= $1; $newtitle= $2;
441 &addmaintainers($s_package);
442 $s_subject= $newtitle;
443 $action= "Changed $gBug title.";
445 &transcript("$action\n");
446 if (length($s_done)) {
447 &transcript("(By the way, that $gBug is currently marked as done.)\n");
453 } elsif (m/^unmerge\s+\#?(\d+)$/i) {
457 if (!length($s_mergedwith)) {
458 &transcript("$gBug is not marked as being merged with any others.\n\n");
461 $mergelowstate eq 'locked' || die "$mergelowstate ?";
462 $action= "Disconnected #$ref from all other report(s).";
463 @newmergelist= split(/ /,$s_mergedwith);
466 &addmaintainers($s_package);
467 $s_mergedwith= ($ref == $discref) ? ''
468 : join(' ',grep($_ ne $ref,@newmergelist));
469 } while (&getnextbug);
472 } elsif (m/^merge\s+(\d+(\s+\d+)+)\s*$/i) {
474 @tomerge= sort { $a <=> $b } split(/\s+/,$1);
478 while (defined($ref= shift(@tomerge))) {
479 &transcript("D| checking merge $ref\n") if $dl;
481 next if grep($_ eq $ref,@newmergelist);
482 if (!&getbug) { ¬foundbug; @newmergelist=(); last }
484 &transcript("D| adding $ref ($s_mergedwith)\n") if $dl;
486 &checkmatch('package','m_package',$s_package);
487 &checkmatch('forwarded addr','m_forwarded',$s_forwarded);
488 $s_severity = '$gDefaultSeverity' if $s_severity eq '';
489 &checkmatch('severity','m_severity',$s_severity);
490 &checkmatch('done mark','m_done',length($s_done) ? 'done' : 'open');
491 foreach my $t (split /\s+/, $s_keywords) { $tags{$t} = 1; }
492 if (length($mismatch)) {
493 &transcript("Mismatch - only $gBugs in same state can be merged:\n".
495 &cancelbug; @newmergelist=(); last;
497 push(@newmergelist,$ref);
498 push(@tomerge,split(/ /,$s_mergedwith));
502 @newmergelist= sort { $a <=> $b } @newmergelist;
503 $action= "Merged @newmergelist.";
504 for $ref (@newmergelist) {
505 &getbug || die "huh ? $gBug $ref disappeared during merge";
506 &addmaintainers($s_package);
507 $s_mergedwith= join(' ',grep($_ ne $ref,@newmergelist));
508 $s_keywords= join(' ', keys %tags);
511 &transcript("$action\n\n");
515 &transcript("Unknown command or malformed arguments to command.\n\n");
516 if (++$unknowns >= 5) {
517 &transcript("Too many unknown commands, stopping here.\n\n");
522 if ($procline>$#msg) {
523 &transcript(">\nEnd of message, stopping processing here.\n\n");
526 &transcript("No commands successfully parsed; sending the help text(s).\n");
531 &transcript("MC\n") if $dl>1;
533 for $maint (keys %maintccreasons) {
534 &transcript("MM|$maint|\n") if $dl>1;
535 next if $maint eq $replyto;
537 $reasonsref= $maintccreasons{$maint};
538 &transcript("MY|$maint|\n") if $dl>2;
539 for $p (sort keys %$reasonsref) {
540 &transcript("MP|$p|\n") if $dl>2;
541 $reasonstring.= ', ' if length($reasonstring);
542 $reasonstring.= $p.' ' if length($p);
543 $reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
545 if (length($reasonstring) > 40) {
546 (substr $reasonstring, 37) = "...";
548 $reasonstring = "" if (!defined($reasonstring));
549 push(@maintccs,"$maint ($reasonstring)");
550 push(@maintccaddrs,"$maint");
553 &transcript("MC|@maintccs|\n") if $dl>2;
554 $maintccs= "Cc: ".join(",\n ",@maintccs)."\n";
555 } else { $maintccs = ""; }
557 if (!defined $header{'subject'} || $header{'subject'} eq "") {
558 $header{'subject'} = "your mail";
562 From: $gMaintainerEmail ($gProject $gBug Tracking System)
564 ${maintccs}Subject: Processed: $header{'subject'}
565 In-Reply-To: $header{'message-id'}
566 References: $header{'message-id'}
567 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
569 ${transcript}Please contact me if you need assistance.
572 (administrator, $gProject $gBugs database)
576 $repliedshow= join(', ',$replyto,@maintccaddrs);
577 &filelock("lock/-1");
578 open(AP,">>db/-1.log") || &quit("open db/-1.log: $!");
580 "\2\n$repliedshow\n\5\n$reply\n\3\n".
582 "<strong>Request received</strong> from <code>".
583 &sani($header{'from'})."</code>\n".
584 "to <code>".&sani($controlrequestaddr)."</code>\n".
586 "\7\n",@log,"\n\3\n") || &quit("writing db/-1.log: $!");
587 close(AP) || &quit("open db/-1.log: $!");
589 utime(time,time,"db");
591 &sendmailmessage($reply,$replyto,@maintccaddrs);
593 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
597 map { $_->address() }
598 map { Mail::Address->parse($_) } @_;
601 sub sendmailmessage {
602 local ($message,@recips) = @_;
603 print "mailing to >@recips<\n" if $debug;
605 defined($c) || &quit("mailing forking for sendmail: $!");
606 if (!$c) { # ie, we are the child process
607 exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odi','-oem','-oi',get_addresses(@recips);
610 print(D $message) || &quit("writing to sendmail process: $!");
611 $!=0; close(D); $? && &quit("sendmail gave exit status $? ($!)");
616 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
617 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
622 # &transcript("Sorry, command $_[0] not yet implemented.\n\n");
626 local ($string,$mvarname,$svarvalue) = @_;
629 eval "\$mvarvalue= \$$mvarname";
630 &transcript("D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n")
633 "Values for \`$string' don't match:\n".
634 " #$newmergelist[0] has \`$mvarvalue';\n".
635 " #$ref has \`$svarvalue'\n"
636 if $mvarvalue ne $svarvalue;
638 &transcript("D| setupmatch \`$string' /$mvarname/$svarvalue/\n")
640 eval "\$$mvarname= \$svarvalue";
644 # High-level bug manipulation calls
645 # Do announcements themselves
647 # Possible calling sequences:
651 # &transcript(something)
655 # $action= (something)
657 # (modify s_* variables)
658 # } while (getnextbug);
661 &dlen("nochangebug");
662 $state eq 'single' || $state eq 'multiple' || die "$state ?";
664 &endmerge if $manybugs;
666 &dlex("nochangebug");
670 &dlen("setbug $ref");
671 $state eq 'idle' || die "$state ?";
674 &dlex("setbug => 0s");
677 @thisbugmergelist= split(/ /,$s_mergedwith);
678 if (!@thisbugmergelist) {
683 &dlex("setbug => 1s");
692 &dlex("setbug => 0mc");
696 $state= 'multiple'; $sref=$ref;
697 &dlex("setbug => 1m");
703 $state eq 'single' || $state eq 'multiple' || die "$state ?";
705 if (!$manybugs || !@thisbugmergelist) {
706 length($action) || die;
707 &transcript("$action\n$extramessage\n");
708 &endmerge if $manybugs;
710 &dlex("getnextbug => 0");
713 $ref= shift(@thisbugmergelist);
714 &getbug || die "bug $ref disappeared";
716 &dlex("getnextbug => 1");
720 # Low-level bug-manipulation calls
721 # Do no announcements
729 # $action= (something)
734 # [getbug (returns 0)]
735 # &transcript("$action\n\n")
738 sub notfoundbug { &transcript("$gBug number $ref not found.\n\n"); }
739 sub foundbug { &transcript("$gBug#$ref: $s_subject\n"); }
743 $mergelowstate eq 'idle' || die "$mergelowstate ?";
744 &filelock('lock/merge');
745 $mergelowstate='locked';
751 $mergelowstate eq 'locked' || die "$mergelowstate ?";
753 $mergelowstate='idle';
758 &dlen("getbug $ref");
759 $lowstate eq 'idle' || die "$state ?";
760 if (&lockreadbug($ref)) {
763 &dlex("getbug => 1");
768 &dlex("getbug => 0");
774 $lowstate eq 'open' || die "$state ?";
781 &dlen("savebug $ref");
782 $lowstate eq 'open' || die "$lowstate ?";
783 length($action) || die;
784 $ref == $sref || die "read $sref but saving $ref ?";
785 open(L,">>db/$ref.log") || &quit("opening db/$ref.log: $!");
788 "<strong>".&sani($action)."</strong>\n".
789 "Request was from <code>".&sani($header{'from'})."</code>\n".
790 "to <code>".&sani($controlrequestaddr)."</code>. \n".
792 "\7\n",@log,"\n\3\n") || &quit("writing db/$ref.log: $!");
793 close(L) || &quit("closing db/$ref.log: $!");
794 open(S,">db/$ref.status.new") || &quit("opening db/$ref.status.new: $!");
805 "$s_severity\n") || &quit("writing db/$ref.status.new: $!");
806 close(S) || &quit("closing db/$ref.status.new: $!");
807 rename("db/$ref.status.new","db/$ref.status") ||
808 &quit("installing new db/$ref.status: $!");
816 &transcript("C> @_ ($state $lowstate $mergelowstate)\n");
821 &transcript("R> @_ ($state $lowstate $mergelowstate)\n");
825 print $_[0] if $debug;
842 local ($relpath,$description) = @_;
844 open(D,"$gDocDir/$relpath") || &quit("open doc file $relpath: $!");
845 while(<D>) { $doc.=$_; }
847 &transcript("Sending $description in separate message.\n");
848 &sendmailmessage(<<END.$doc,$replyto);
849 From: $gMaintainerEmail ($gProject $gBug Tracking System)
851 Subject: $gProject $gBug help: $description
852 References: $header{'message-id'}
853 In-Reply-To: $header{'message-id'}
854 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
861 local ($relpath,$description) = @_;
863 # the below oughta use $gWebDomain but it can't
864 open(L,"lynx -nolist -dump http://bugs.debian.org/$relpath 2>&1 |") || &quit("fork for lynx: $!");
865 while(<L>) { $doc.=$_; }
867 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
868 &transcript("Information ($description) is not available -\n".
869 "perhaps the $gBug does not exist or is not on the WWW yet.\n");
872 &transcript("Error getting $description (code $? $!):\n$doc\n");
874 &transcript("Sending $description.\n");
875 &sendmailmessage(<<END.$doc,$replyto);
876 From: $gMaintainerEmail ($gProject $gBug Tracking System)
878 Subject: $gProject $gBugs information: $description
879 References: $header{'message-id'}
880 In-Reply-To: $header{'message-id'}
881 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
890 $maintccreasons{$cca}{''}{$ref}= 1;
894 { # Data structure is:
895 # maintainer email address &c -> assoc of packages -> assoc of bug#'s
896 my ($p, $addmaint, $pshow);
897 &ensuremaintainersloaded;
898 $anymaintfound=0; $anymaintnotfound=0;
899 for $p (split(m/[ \t?,()]+/,$_[0])) {
901 $pshow= ($p =~ m/[-+.a-z0-9]+/ ? $& : '');
902 if (defined($maintainerof{$p})) {
903 $addmaint= $maintainerof{$p};
904 &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
905 $maintccreasons{$addmaint}{$p}{$ref}= 1;
906 print "maintainer add >$p|$addmaint<\n" if $debug;
908 print "maintainer none >$p<\n" if $debug;
909 &transcript("MR|unknown-package|$p|$ref|\n") if $dl>2;
910 $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
915 sub ensuremaintainersloaded {
917 return if $maintainersloaded++;
918 open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
922 m/^(\S+)\s+(\S.*\S)\n$/ || &quit("maintainers bogus \`$_'");
923 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
924 $maintainerof{$1}= $2;
927 open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
931 m/^(\S+)\s+(\S.*\S)\n$/ || &quit("maintainers.override bogus \`$_'");
932 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
933 $maintainerof{$1}= $2;
938 local ($wherefrom,$path,$description) = @_;
939 if ($wherefrom eq "ftp.d.o") {
940 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or &quit("fork for lynx/gunzip: $!");
942 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
943 &transcript("$description is not available.\n");
946 &transcript("Error getting $description (code $? $!):\n$doc\n");
949 } elsif ($wherefrom eq "local") {
951 $doc = do { local $/; <P> };
954 &transcript("internal errror: info files location unknown.\n");
957 &transcript("Sending $description.\n");
958 &sendmailmessage(<<END.$doc,$replyto);
959 From: $gMaintainerEmail ($gProject $gBug Tracking System)
961 Subject: $gProject $gBugs information: $description
962 References: $header{'message-id'}
963 In-Reply-To: $header{'message-id'}
964 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
966 $description follows: