]> git.donarmstrong.com Git - debbugs.git/blobdiff - scripts/processall.in
* import lockreadbug
[debbugs.git] / scripts / processall.in
index 745ad50232edc3532ef9db4771ac9616cb4cdfbb..2606b26e26bcf06afaefc44904157a8d7bd4550a 100755 (executable)
@@ -1,32 +1,35 @@
 #!/usr/bin/perl
-# $Id: processall.in,v 1.8 2002/10/06 22:54:48 cjwatson Exp $
+# $Id: processall.in,v 1.13 2005/10/06 03:46:13 ajt Exp $
 #
 # Usage: processall
 #
 # Uses up: incoming/I<code><bugnum>.nn
 # Temps:   incoming/[GP].nn
 # Creates: incoming/E.nn
-# Stop;    process/stop
+# Stop:    stop
 
-$config_path = '/org/bugs.debian.org/etc';
-$lib_path = '/org/bugs.debian.org/scripts';
+use warnings;
+use strict;
 
-require "$config_path/config";
-require "$lib_path/errorlib";
-$ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
+
+use Debbugs::Config qw(:globals);
+use Debbugs::Common qw(:lock);
+
+my $lib_path = $gLibPath;
 
 use File::Path;
 
-chdir( "$gSpoolDir" ) || die 'chdir spool: $!\n';
-push( @INC, "$lib_path" );
+chdir( $gSpoolDir ) || die "chdir spool: $!\n";
 
 #open(DEBUG,">&4");
 
 umask(002);
 
 $|=1;
-undef %fudged;
+my %fudged;
+my @ids;
 
+my $ndone = 0;
 &filelock('incoming-cleaner');
 for (;;) {
     if (-f 'stop') {
@@ -40,8 +43,8 @@ for (;;) {
         @ids= sort(@ids);
     }
     stat("$gMaintainerFile") || die "stat $gMaintainerFile: $!\n";
-    $nf= @ids;
-    $id= shift(@ids);
+    my $nf= @ids;
+    my $id= shift(@ids);
     unless (rename("incoming/I$id","incoming/G$id")) {
         if ($fudged{$id}) {
             die "$id already fudged once! $!\n";
@@ -49,19 +52,20 @@ for (;;) {
         $fudged{$id}= 1;
         next;
     }
+    my $c;
     if ($id =~ m/^[RC]/) {
-        print(STDOUT "[$nf] $id service ...") || die $!;
+        print(STDOUT "[$nf] $id service ...") || die $!;
         defined($c=fork) || die $!;
-        if (!$c) { exec("$lib_path/service",$id); die $!; }
-    } elsif ($id =~ m/^[BMQFDU]/) {
+        if (!$c) { exec("$lib_path/service",$id); die "unable to execute $lib_path/service: $!"; }
+    } elsif ($id =~ m/^[BMQFDUL]/) {
         print(STDOUT "[$nf] $id process ...") || die $!;
         defined($c=fork) || die $!;
-        if (!$c) { exec("$lib_path/process",$id); die $!; }
+        if (!$c) { exec("$lib_path/process",$id); die "unable to execute $lib_path/process: $!"; }
     } else {
         die "bad name $id";
     }
-    $cc=waitpid($c,0); $cc == $c || die "$cc $c $!";
-    $status=$?;
+    my $cc=waitpid($c,0); $cc == $c || die "$cc $c $!";
+    my $status=$?;
     if ($status) {
         print(STDERR "$id: process failed ($status $!) - now in [PG]$id\n") || die $!;
     }
@@ -69,6 +73,16 @@ for (;;) {
     rmtree("$gSpoolDir/mime.tmp",0,1);
     $ndone++;
 }
+
+
+system("$lib_path/gen-indices",'--quick') == 0 or print STDERR "gen-indices failed\n";
+
+if (@gPostProcessall) {
+    system @gPostProcessall == 0 or print STDERR "\@gPostProcessall failed: ".join(' ',@gPostProcessall)."\n";
+}
+
+
+
 &unfilelock;
 
 exit(0);