2 # $Id: service.in,v 1.44 2001/09/18 20:04:41 joy 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;
60 } else { print "!>$_<\n" if $debug; }
63 if (defined $header{'resent-from'} && !defined $header{'from'}) {
64 $header{'from'} = $header{'resent-from'};
66 defined($header{'from'}) || &quit("no From header");
67 delete $header{'reply-to'} if ( defined($header{'reply-to'}) && $header{'reply-to'} =~ m/^\s*$/ );
68 if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
69 $replyto = $header{'reply-to'};
71 $replyto = $header{'from'};
74 $controlrequestaddr= $control ? "control\@$gEmailDomain" : "request\@$gEmailDomain";
76 &transcript("Processing commands for $controlrequestaddr:\n\n");
81 $mergelowstate= 'idle';
85 #strip blank line(s) after header
86 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
88 #strip, if exists, mime header
89 if ( $msg[$i] =~ /^This is a multi-part message in MIME format./ )
90 { while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i] . "\n"; $i++; }
91 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
93 if ( $msg[$i] =~ /^--/ || $msg[$i] =~ /^\s*$/ )
94 { while ( $i <= $#msg && length( $msg[$i] ) ) { $fwd .= $msg[$i]; $i++; }
95 while ( $i <= $#msg && !length( $msg[$i] ) ) { $fwd .= "\n"; $i++; }
99 for ($procline=$i; $procline<=$#msg; $procline++)
100 { $state eq 'idle' || print "$state ?\n";
101 $lowstate eq 'idle' || print "$lowstate ?\n";
102 $mergelowstate eq 'idle' || print "$mergelowstate ?\n";
103 $_= $msg[$procline]; s/\s+$//;
104 next unless m/\S/; next if m/^\s*\#/;
105 &transcript("> $_\n");
107 if (m/^stop/i || m/^quit/i || m/^--/ || m/^thank/i)
108 { &transcript("Stopping processing here.\n\n");
110 } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
112 &transcript("Debug level $dl.\n\n");
113 } elsif (m/^(send|get)\s+\#?(\d{2,})$/i) {
115 &sendlynxdoc("$ref","logs for $gBug#$ref");
116 } elsif (m/^send-detail\s+\#?(\d+)$/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 # $ref= $1+0; $reffile= $ref; $reffile =~ s,^..,$&/$&,;
120 # &sendlynxdoc("db/$reffile-b.html","additional logs for $gBug#$ref");
121 } elsif (m/^index(\s+full)?$/i) {
122 &transcript("This BTS function is currently disabled, sorry.\n\n");
123 $ok++; # well, it's not really ok, but it fixes #81224 :)
124 # &sendlynxdoc("db/ix/full.html",'full index');
125 } elsif (m/^index-summary\s+by-package$/i) {
126 &transcript("This BTS function is currently disabled, sorry.\n\n");
127 $ok++; # well, it's not really ok, but it fixes #81224 :)
128 # &sendlynxdoc("db/ix/psummary.html",'summary index sorted by package/title');
129 } elsif (m/^index-summary(\s+by-number)?$/i) {
130 &transcript("This BTS function is currently disabled, sorry.\n\n");
131 $ok++; # well, it's not really ok, but it fixes #81224 :)
132 # &sendlynxdoc("db/ix/summary.html",'summary index sorted by number/date');
133 } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
134 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=pkg",'index of packages');
135 } elsif (m/^index(\s+|-)maints?$/i) {
136 &sendlynxdoc("cgi-bin/pkgindex.cgi?indexon=maint",'index of maintainers');
137 } elsif (m/^index(\s+|-)maint\s+(\S+)$/i) {
139 # check for crap in $maint
140 if ($maint =~ m/^\./ || $maint !~ m/^[\d\w-+.@]+$/) {
141 &transcript("Invalid request $maint!\n");
144 &sendlynxdoc("$maint","$gBug list for maintainer \`$maint'");
146 $substrg= $2; $matches=0;
147 opendir(DBD,"$gWebDir/db/ma") || die $!;
148 while (defined($_=readdir(DBD))) {
149 next unless m/^l/ && m/\.html$/;
150 &transcript("F|$_\n") if $dl>1;
151 $filename= $_; s/^l//; s/\.html$//;
152 &transcript("P|$_\n") if $dl>2;
153 while (s/-(..)([^_])/-$1_-$2/) { }
154 &transcript("P|$_\n") if $dl>2;
155 s/^(.{0,2})_/$1-20_/g; while (s/([^-]..)_/$1-20_/) { };
156 &transcript("P|$_\n") if $dl>2;
157 s/^,(.*),(.*),([^,]+)$/$1-40_$2-20_-28_$3-29_/;
158 &transcript("P|$_\n") if $dl>2;
159 s/^([^,]+),(.*),(.*),$/$1-20_-3c_$2-40_$3-3e_/;
160 &transcript("P|$_\n") if $dl>2;
162 &transcript("P|$_\n") if $dl>2;
164 while (m/-(..)_/) { $out.= $`.sprintf("%c",hex($1)); $_=$'; }
166 &transcript("M|$out\n") if $dl>1;
167 next unless index(lc $out, lc $substrg)>=0;
168 &transcript("S|$filename\n") if $dl>0;
169 &transcript("S|$out\n") if $dl>0;
171 &sendlynxdocraw("db/ma/$filename","$gBug list for maintainer \`$out'");
174 &transcript("$gBug list(s) for $matches maintainer(s) sent.\n\n");
176 &transcript("No maintainers found containing \`$substrg'.\n".
177 "Use \`index-maint' to get list of maintainers.\n\n");
181 } elsif (m/^index(\s+|-)pack(age)?s?\s+(\S.*\S)$/i) {
183 # check for crap in $package
184 if ($package =~ m/^\./ || $package !~ m/^[\d\w-+.@]+$/) {
185 &transcript("Invalid request $package!\n");
188 &sendlynxdoc("$package","$gBug list for package $package sent.\n\n");
190 $substrg= $+; $matches=0;
191 opendir(DBD,"$gWebDir/db/pa") || die $!;
192 while (defined($_=readdir(DBD))) {
193 next unless m/^l/ && m/\.html$/;
194 &transcript("F|$_\n") if $dl>1;
195 $filename= $_; s/^l//; s/\.html$//;
196 next unless index(lc $_, lc $substrg)>=0;
197 &transcript("S|$filename\n") if $dl>0;
198 &transcript("S|$out\n") if $dl>0;
200 &sendlynxdocraw("db/pa/$filename","$gBug list for package \`$_'");
203 &transcript("$gBug list(s) for $matches package(s) sent.\n\n");
205 &transcript("No packages found containing \`$substrg'.\n".
206 "Use \`index-packages' to get list of packages.\n\n");
210 } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
211 &transcript("This BTS function is currently disabled, sorry.\n\n");
212 $ok++; # well, it's not really ok, but it fixes #81224 :)
213 # &sendlynxdoc("db/ju/unmatched-1.html","junk (this week)");
214 } elsif (m/^send-unmatched\s+(last|-1)$/i) {
215 &transcript("This BTS function is currently disabled, sorry.\n\n");
216 $ok++; # well, it's not really ok, but it fixes #81224 :)
217 # &sendlynxdoc("db/ju/unmatched-2.html","junk (last week)");
218 } elsif (m/^send-unmatched\s+(old|-2)$/i) {
219 &transcript("This BTS function is currently disabled, sorry.\n\n");
220 $ok++; # well, it's not really ok, but it fixes #81224 :)
221 # &sendlynxdoc("db/ju/unmatched-3.html","junk (two weeks ago)");
222 } elsif (m/^getinfo\s+([\w-.]+)$/i) {
223 # the following is basically a Debian-specific kludge, but who cares
225 if ($req =~ /^maintainers$/i && -f "$gConfigDir/Maintainers") {
226 &sendinfo("local", "$gConfigDir/Maintainers", "Maintainers file");
227 } elsif ($req =~ /^override\.(\w+)\.([\w-.]+)$/i) {
229 &sendinfo("ftp.d.o", "$req", "override file for $2 part of $1 distribution");
230 } elsif ($req =~ /^pseudo-packages\.(description|maintainers)$/i && -f "$gConfigDir/$req") {
231 &sendinfo("local", "$gConfigDir/$req", "$req file");
233 &transcript("Info file $req does not exist.\n\n");
235 } elsif (m/^help/i) {
239 } elsif (m/^refcard/i) {
240 &sendtxthelp("bug-mailserver-refcard.txt","mail servers' reference card");
241 } elsif (m/^subscribe/i) {
243 There is no $gProject $gBug mailing list. If you wish to review bug reports
244 please do so via http://$gWebDomain/ or ask this mail server
246 soon: MAILINGLISTS_TEXT
248 } elsif (m/^unsubscribe/i) {
250 soon: UNSUBSCRIBE_TEXT
251 soon: MAILINGLISTS_TEXT
253 } elsif (!$control) {
255 Unknown command or malformed arguments to command.
256 (Use control\@$gEmailDomain to manipulate reports.)
259 if (++$unknowns >= 3) {
260 &transcript("Too many unknown commands, stopping here.\n\n");
263 } elsif (m/^close\s+\#?(\d+)$/i) {
267 if (length($s_done)) {
268 &transcript("$gBug is already closed, cannot re-close.\n\n");
271 $action= "$gBug closed, send any further explanations to $s_originator";
273 &addmaintainers($s_package);
274 if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
275 0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
278 From: $gMaintainerEmail ($gProject $gBug Tracking System)
280 Subject: $gBug#$ref acknowledged by developer
282 References: $header{'message-id'} $s_msgid
283 In-Reply-To: $s_msgid
284 Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
285 Reply-To: $ref\@$gEmailDomain
287 This is an automatic notification regarding your $gBug report
289 which was filed against the $s_package package.
291 It has been marked as closed by one of the developers, namely
294 You should be hearing from them with a substantive response shortly,
295 in case you haven't already. If not, please contact them directly.
298 (administrator, $gProject $gBugs database)
301 &sendmailmessage($message,$s_originator);
302 } while (&getnextbug);
305 } elsif (m/^reassign\s+\#?(\d+)\s+(\S.*\S)$/i) {
307 $ref= $1; $newpackage= $2;
308 $newpackage =~ y/A-Z/a-z/;
310 if (length($s_package)) {
311 $action= "$gBug reassigned from package \`$s_package'".
312 " to \`$newpackage'.";
314 $action= "$gBug assigned to package \`$newpackage'.";
317 &addmaintainers($s_package);
318 &addmaintainers($newpackage);
319 $s_package= $newpackage;
320 } while (&getnextbug);
322 } elsif (m/^reopen\s+\#?(\d+)$/i ? ($noriginator='', 1) :
323 m/^reopen\s+\#?(\d+)\s+\=$/i ? ($noriginator='', 1) :
324 m/^reopen\s+\#?(\d+)\s+\!$/i ? ($noriginator=$replyto, 1) :
325 m/^reopen\s+\#?(\d+)\s+(\S.*\S)$/i ? ($noriginator=$2, 1) : 0) {
329 if (!length($s_done)) {
330 &transcript("$gBug is already open, cannot reopen.\n\n");
334 $noriginator eq '' ? "$gBug reopened, originator not changed." :
335 "$gBug reopened, originator set to $noriginator.";
337 &addmaintainers($s_package);
338 $s_originator= $noriginator eq '' ? $s_originator : $noriginator;
340 } while (&getnextbug);
343 } elsif (m/^forwarded\s+\#?(\d+)\s+(\S.*\S)$/i) {
345 $ref= $1; $whereto= $2;
347 if (length($s_forwarded)) {
348 $action= "Forwarded-to-address changed from $s_forwarded to $whereto.";
350 $action= "Noted your statement that $gBug has been forwarded to $whereto.";
352 if (length($s_done)) {
353 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
356 &addmaintainers($s_package);
357 if (length($gFowardList)>0 && length($gListDomain)>0 )
358 { &addccaddress("$gFowardList\@$gListDomain"); }
359 $s_forwarded= $whereto;
360 } while (&getnextbug);
362 } elsif (m/^notforwarded\s+\#?(\d+)$/i) {
366 if (!length($s_forwarded)) {
367 &transcript("$gBug is not marked as having been forwarded.\n\n");
370 $action= "Removed annotation that $gBug had been forwarded to $s_forwarded.";
372 &addmaintainers($s_package);
374 } while (&getnextbug);
377 } elsif (m/^severity\s+\#?(\d+)\s+([-0-9a-z]+)$/i ||
378 m/^priority\s+\#?(\d+)\s+([-0-9a-z]+)$/i) {
382 if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
383 &transcript("Severity level \`$newseverity' is not known.\n".
384 "Recognized are: $gShowSeverities.\n\n");
386 $printseverity= $s_severity;
387 $printseverity= "$gDefaultSeverity" if $printseverity eq '';
388 $action= "Severity set to \`$newseverity'.";
390 &addmaintainers($s_package);
391 $s_severity= $newseverity;
392 } while (&getnextbug);
394 } elsif (m/^tags?\s+\#?(\d+)\s+(([=+-])\s+)?(\S.*)?$/i) {
396 $ref = $1; $addsubcode = $3; $tags = $4;
398 if (defined $addsubcode) {
399 $addsub = "sub" if ($addsubcode eq "-");
400 $addsub = "add" if ($addsubcode eq "+");
401 $addsub = "set" if ($addsubcode eq "=");
405 foreach my $t (split /[\s,]+/, $tags) {
406 if (!grep($_ eq $t, @gTags)) {
413 &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
414 "Recognized are: ".join(' ', @gTags).".\n\n");
417 if ($addsub eq "set") {
418 $action= "Tags set to: " . join(", ", @okaytags);
419 } elsif ($addsub eq "add") {
420 $action= "Tags added: " . join(", ", @okaytags);
421 } elsif ($addsub eq "sub") {
422 $action= "Tags removed: " . join(", ", @okaytags);
425 &addmaintainers($s_package);
426 $s_keywords = '' if ($addsub eq "set");
427 if ($addsub eq "sub") {
428 foreach my $t (@badtags) {
429 $s_keywords = join ' ', grep $_ ne $t,
430 split ' ', $s_keywords;
433 foreach my $t (@okaytags) {
434 $s_keywords = join ' ', grep $_ ne $t,
435 split ' ', $s_keywords;
436 $s_keywords = "$t $s_keywords" unless($addsub eq "sub");
438 $s_keywords =~ s/\s*$//;
439 } while (&getnextbug);
441 } elsif (m/^retitle\s+\#?(\d+)\s+(\S.*\S)\s*$/i) {
443 $ref= $1; $newtitle= $2;
446 &addmaintainers($s_package);
447 $s_subject= $newtitle;
448 $action= "Changed $gBug title.";
450 &transcript("$action\n");
451 if (length($s_done)) {
452 &transcript("(By the way, that $gBug is currently marked as done.)\n");
458 } elsif (m/^unmerge\s+\#?(\d+)$/i) {
462 if (!length($s_mergedwith)) {
463 &transcript("$gBug is not marked as being merged with any others.\n\n");
466 $mergelowstate eq 'locked' || die "$mergelowstate ?";
467 $action= "Disconnected #$ref from all other report(s).";
468 @newmergelist= split(/ /,$s_mergedwith);
471 &addmaintainers($s_package);
472 $s_mergedwith= ($ref == $discref) ? ''
473 : join(' ',grep($_ ne $ref,@newmergelist));
474 } while (&getnextbug);
477 } elsif (m/^merge\s+(\d+(\s+\d+)+)\s*$/i) {
479 @tomerge= sort { $a <=> $b } split(/\s+/,$1);
483 while (defined($ref= shift(@tomerge))) {
484 &transcript("D| checking merge $ref\n") if $dl;
486 next if grep($_ eq $ref,@newmergelist);
487 if (!&getbug) { ¬foundbug; @newmergelist=(); last }
489 &transcript("D| adding $ref ($s_mergedwith)\n") if $dl;
491 &checkmatch('package','m_package',$s_package);
492 &checkmatch('forwarded addr','m_forwarded',$s_forwarded);
493 $s_severity = '$gDefaultSeverity' if $s_severity eq '';
494 &checkmatch('severity','m_severity',$s_severity);
495 &checkmatch('done mark','m_done',length($s_done) ? 'done' : 'open');
496 foreach my $t (split /\s+/, $s_keywords) { $tags{$t} = 1; }
497 if (length($mismatch)) {
498 &transcript("Mismatch - only $gBugs in same state can be merged:\n".
500 &cancelbug; @newmergelist=(); last;
502 push(@newmergelist,$ref);
503 push(@tomerge,split(/ /,$s_mergedwith));
507 @newmergelist= sort { $a <=> $b } @newmergelist;
508 $action= "Merged @newmergelist.";
509 for $ref (@newmergelist) {
510 &getbug || die "huh ? $gBug $ref disappeared during merge";
511 &addmaintainers($s_package);
512 $s_mergedwith= join(' ',grep($_ ne $ref,@newmergelist));
513 $s_keywords= join(' ', keys %tags);
516 &transcript("$action\n\n");
520 &transcript("Unknown command or malformed arguments to command.\n\n");
521 if (++$unknowns >= 5) {
522 &transcript("Too many unknown commands, stopping here.\n\n");
527 if ($procline>$#msg) {
528 &transcript(">\nEnd of message, stopping processing here.\n\n");
531 &transcript("No commands successfully parsed; sending the help text(s).\n");
536 &transcript("MC\n") if $dl>1;
538 for $maint (keys %maintccreasons) {
539 &transcript("MM|$maint|\n") if $dl>1;
540 next if $maint eq $replyto;
542 $reasonsref= $maintccreasons{$maint};
543 &transcript("MY|$maint|\n") if $dl>2;
544 for $p (sort keys %$reasonsref) {
545 &transcript("MP|$p|\n") if $dl>2;
546 $reasonstring.= ', ' if length($reasonstring);
547 $reasonstring.= $p.' ' if length($p);
548 $reasonstring.= join(' ',map("#$_",sort keys %{$$reasonsref{$p}}));
550 if (length($reasonstring) > 40) {
551 (substr $reasonstring, 37) = "...";
553 $reasonstring = "" if (!defined($reasonstring));
554 push(@maintccs,"$maint ($reasonstring)");
555 push(@maintccaddrs,"$maint");
558 &transcript("MC|@maintccs|\n") if $dl>2;
559 $maintccs= "Cc: ".join(",\n ",@maintccs)."\n";
560 } else { $maintccs = ""; }
562 if (!defined $header{'subject'} || $header{'subject'} eq "") {
563 $header{'subject'} = "your mail";
567 From: $gMaintainerEmail ($gProject $gBug Tracking System)
569 ${maintccs}Subject: Processed: $header{'subject'}
570 In-Reply-To: $header{'message-id'}
571 References: $header{'message-id'}
572 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
574 ${transcript}Please contact me if you need assistance.
577 (administrator, $gProject $gBugs database)
581 $repliedshow= join(', ',$replyto,@maintccaddrs);
582 &filelock("lock/-1");
583 open(AP,">>db-h/-1.log") || &quit("open db-h/-1.log: $!");
585 "\2\n$repliedshow\n\5\n$reply\n\3\n".
587 "<strong>Request received</strong> from <code>".
588 &sani($header{'from'})."</code>\n".
589 "to <code>".&sani($controlrequestaddr)."</code>\n".
591 "\7\n",@log,"\n\3\n") || &quit("writing db-h/-1.log: $!");
592 close(AP) || &quit("open db-h/-1.log: $!");
594 utime(time,time,"db-h");
596 &sendmailmessage($reply,$replyto,@maintccaddrs);
598 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
602 map { $_->address() }
603 map { Mail::Address->parse($_) } @_;
606 sub sendmailmessage {
607 local ($message,@recips) = @_;
608 print "mailing to >@recips<\n" if $debug;
610 defined($c) || &quit("mailing forking for sendmail: $!");
611 if (!$c) { # ie, we are the child process
612 exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odq','-oem','-oi',get_addresses(@recips);
615 print(D $message) || &quit("writing to sendmail process: $!");
616 $!=0; close(D); $? && &quit("sendmail gave exit status $? ($!)");
621 &sendtxthelpraw("bug-log-mailserver.txt","instructions for request\@$gEmailDomain");
622 &sendtxthelpraw("bug-maint-mailcontrol.txt","instructions for control\@$gEmailDomain")
627 # &transcript("Sorry, command $_[0] not yet implemented.\n\n");
631 local ($string,$mvarname,$svarvalue) = @_;
634 eval "\$mvarvalue= \$$mvarname";
635 &transcript("D| checkmatch \`$string' /$mvarname/$mvarvalue/$svarvalue/\n")
638 "Values for \`$string' don't match:\n".
639 " #$newmergelist[0] has \`$mvarvalue';\n".
640 " #$ref has \`$svarvalue'\n"
641 if $mvarvalue ne $svarvalue;
643 &transcript("D| setupmatch \`$string' /$mvarname/$svarvalue/\n")
645 eval "\$$mvarname= \$svarvalue";
649 # High-level bug manipulation calls
650 # Do announcements themselves
652 # Possible calling sequences:
656 # &transcript(something)
660 # $action= (something)
662 # (modify s_* variables)
663 # } while (getnextbug);
666 &dlen("nochangebug");
667 $state eq 'single' || $state eq 'multiple' || die "$state ?";
669 &endmerge if $manybugs;
671 &dlex("nochangebug");
675 &dlen("setbug $ref");
676 $state eq 'idle' || die "$state ?";
679 &dlex("setbug => 0s");
682 @thisbugmergelist= split(/ /,$s_mergedwith);
683 if (!@thisbugmergelist) {
688 &dlex("setbug => 1s");
697 &dlex("setbug => 0mc");
701 $state= 'multiple'; $sref=$ref;
702 &dlex("setbug => 1m");
708 $state eq 'single' || $state eq 'multiple' || die "$state ?";
710 if (!$manybugs || !@thisbugmergelist) {
711 length($action) || die;
712 &transcript("$action\n$extramessage\n");
713 &endmerge if $manybugs;
715 &dlex("getnextbug => 0");
718 $ref= shift(@thisbugmergelist);
719 &getbug || die "bug $ref disappeared";
721 &dlex("getnextbug => 1");
725 # Low-level bug-manipulation calls
726 # Do no announcements
734 # $action= (something)
739 # [getbug (returns 0)]
740 # &transcript("$action\n\n")
743 sub notfoundbug { &transcript("$gBug number $ref not found.\n\n"); }
744 sub foundbug { &transcript("$gBug#$ref: $s_subject\n"); }
748 $mergelowstate eq 'idle' || die "$mergelowstate ?";
749 &filelock('lock/merge');
750 $mergelowstate='locked';
756 $mergelowstate eq 'locked' || die "$mergelowstate ?";
758 $mergelowstate='idle';
763 &dlen("getbug $ref");
764 $lowstate eq 'idle' || die "$state ?";
765 if (&lockreadbug($ref)) {
768 &dlex("getbug => 1");
773 &dlex("getbug => 0");
779 $lowstate eq 'open' || die "$state ?";
786 &dlen("savebug $ref");
787 $lowstate eq 'open' || die "$lowstate ?";
788 length($action) || die;
789 $ref == $sref || die "read $sref but saving $ref ?";
790 my $hash = get_hashname($ref);
791 open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!");
794 "<strong>".&sani($action)."</strong>\n".
795 "Request was from <code>".&sani($header{'from'})."</code>\n".
796 "to <code>".&sani($controlrequestaddr)."</code>. \n".
798 "\7\n",@log,"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
799 close(L) || &quit("closing db-h/$hash/$ref.log: $!");
800 open(S,">db-h/$hash/$ref.status.new") || &quit("opening db-h/$hash/$ref.status.new: $!");
811 "$s_severity\n") || &quit("writing db-h/$hash/$ref.status.new: $!");
812 close(S) || &quit("closing db-h/$hash/$ref.status.new: $!");
813 rename("db-h/$hash/$ref.status.new","db-h/$hash/$ref.status") ||
814 &quit("installing new db-h/$hash/$ref.status: $!");
815 &bughook('change',$ref,
833 &transcript("C> @_ ($state $lowstate $mergelowstate)\n");
838 &transcript("R> @_ ($state $lowstate $mergelowstate)\n");
842 print $_[0] if $debug;
859 local ($relpath,$description) = @_;
861 open(D,"$gDocDir/$relpath") || &quit("open doc file $relpath: $!");
862 while(<D>) { $doc.=$_; }
864 &transcript("Sending $description in separate message.\n");
865 &sendmailmessage(<<END.$doc,$replyto);
866 From: $gMaintainerEmail ($gProject $gBug Tracking System)
868 Subject: $gProject $gBug help: $description
869 References: $header{'message-id'}
870 In-Reply-To: $header{'message-id'}
871 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
878 local ($relpath,$description) = @_;
880 # the below oughta use $gWebDomain but it can't
881 open(L,"lynx -nolist -dump http://bugs.debian.org/$relpath 2>&1 |") || &quit("fork for lynx: $!");
882 while(<L>) { $doc.=$_; }
884 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
885 &transcript("Information ($description) is not available -\n".
886 "perhaps the $gBug does not exist or is not on the WWW yet.\n");
889 &transcript("Error getting $description (code $? $!):\n$doc\n");
891 &transcript("Sending $description.\n");
892 &sendmailmessage(<<END.$doc,$replyto);
893 From: $gMaintainerEmail ($gProject $gBug Tracking System)
895 Subject: $gProject $gBugs information: $description
896 References: $header{'message-id'}
897 In-Reply-To: $header{'message-id'}
898 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
907 $maintccreasons{$cca}{''}{$ref}= 1;
911 { # Data structure is:
912 # maintainer email address &c -> assoc of packages -> assoc of bug#'s
913 my ($p, $addmaint, $pshow);
914 &ensuremaintainersloaded;
915 $anymaintfound=0; $anymaintnotfound=0;
916 for $p (split(m/[ \t?,()]+/,$_[0])) {
918 $pshow= ($p =~ m/[-+.a-z0-9]+/ ? $& : '');
919 if (defined($maintainerof{$p})) {
920 $addmaint= $maintainerof{$p};
921 &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
922 $maintccreasons{$addmaint}{$p}{$ref}= 1;
923 print "maintainer add >$p|$addmaint<\n" if $debug;
925 print "maintainer none >$p<\n" if $debug;
926 &transcript("MR|unknown-package|$p|$ref|\n") if $dl>2;
927 $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
932 sub ensuremaintainersloaded {
934 return if $maintainersloaded++;
935 open(MAINT,"$gMaintainerFile") || die &quit("maintainers open: $!");
939 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
940 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
941 $maintainerof{$1}= $2;
944 open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
948 m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
949 $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
950 $maintainerof{$1}= $2;
955 local ($wherefrom,$path,$description) = @_;
956 if ($wherefrom eq "ftp.d.o") {
957 $doc = `lynx -nolist -dump http://ftp.debian.org/debian/indices/$path.gz 2>&1 | gunzip -cf` or &quit("fork for lynx/gunzip: $!");
959 if ($? == 255 && $doc =~ m/^\n*lynx: Can\'t access start file/) {
960 &transcript("$description is not available.\n");
963 &transcript("Error getting $description (code $? $!):\n$doc\n");
966 } elsif ($wherefrom eq "local") {
968 $doc = do { local $/; <P> };
971 &transcript("internal errror: info files location unknown.\n");
974 &transcript("Sending $description.\n");
975 &sendmailmessage(<<END.$doc,$replyto);
976 From: $gMaintainerEmail ($gProject $gBug Tracking System)
978 Subject: $gProject $gBugs information: $description
979 References: $header{'message-id'}
980 In-Reply-To: $header{'message-id'}
981 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
983 $description follows: