]> git.donarmstrong.com Git - debbugs.git/blobdiff - scripts/processall.in
fix bug in getversions
[debbugs.git] / scripts / processall.in
index 1ae25e0ffea666c90b3635d3cce34b6b66124228..2606b26e26bcf06afaefc44904157a8d7bd4550a 100755 (executable)
@@ -1,22 +1,36 @@
 #!/usr/bin/perl
+# $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
 
-require( '/etc/debbugs/config' );
-$ENV{'PATH'} = '/usr/lib/debbugs'.$ENV{'PATH'};
-chdir( "$gSpoolDir" ) || die 'chdir spool: $!\n';
-push( @INC, '/usr/lib/debbugs' );
+use warnings;
+use strict;
+
+
+use Debbugs::Config qw(:globals);
+use Debbugs::Common qw(:lock);
+
+my $lib_path = $gLibPath;
+
+use File::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') {
         print(STDERR "stop file created\n") || die $!;
@@ -24,13 +38,13 @@ for (;;) {
     }
     if (!@ids) {
         opendir(DIR,"incoming") || die $!;
-        while ($_= readdir(DIR)) { push(@ids,$_) if s/^I//; }
+        while ( defined( $_= readdir(DIR) )) { push(@ids,$_) if s/^I//; }
         last unless @ids;
         @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";
@@ -38,24 +52,37 @@ 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("/usr/lib/debbugs/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("/usr/lib/debbugs/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 $!;
     }
     print(STDOUT " done\n") || die $!;
+    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);