]> git.donarmstrong.com Git - debbugs.git/blob - scripts/processall
serve_cache is not exported by Debbugs::Libravatar
[debbugs.git] / scripts / processall
1 #!/usr/bin/perl
2 # $Id: processall.in,v 1.13 2005/10/06 03:46:13 ajt Exp $
3 #
4 # Usage: processall
5 #
6 # Uses up: incoming/I<code><bugnum>.nn
7 # Temps:   incoming/[GP].nn
8 # Creates: incoming/E.nn
9 # Stop:    stop
10
11 use warnings;
12 use strict;
13
14
15 use Debbugs::Config qw(:globals);
16 use Debbugs::Common qw(:lock);
17
18 my $lib_path = $gLibPath;
19
20 use File::Path;
21
22 chdir( $gSpoolDir ) || die "chdir spool: $!\n";
23
24 #open(DEBUG,">&4");
25
26 umask(002);
27
28 $|=1;
29 my %fudged;
30 my @ids;
31
32 my $ndone = 0;
33 &filelock('incoming-cleaner');
34 for (;;) {
35     if (-f 'stop') {
36         print(STDERR "stop file created\n") || die $!;
37         last;
38     }
39     if (!@ids) {
40         opendir(DIR,"incoming") || die $!;
41         while ( defined( $_= readdir(DIR) )) { push(@ids,$_) if s/^I//; }
42         last unless @ids;
43         @ids= sort(@ids);
44     }
45     stat("$gMaintainerFile") || die "stat $gMaintainerFile: $!\n";
46     my $nf= @ids;
47     my $id= shift(@ids);
48     unless (rename("incoming/I$id","incoming/G$id")) {
49         if ($fudged{$id}) {
50             die "$id already fudged once! $!\n";
51         }
52         $fudged{$id}= 1;
53         next;
54     }
55     my $c;
56     if ($id =~ m/^[RC]/) {
57          print(STDOUT "[$nf] $id service ...") || die $!;
58         defined($c=fork) || die $!;
59         if (!$c) { exec("$lib_path/service",$id); die "unable to execute $lib_path/service: $!"; }
60     } elsif ($id =~ m/^[BMQFDUL]/) {
61         print(STDOUT "[$nf] $id process ...") || die $!;
62         defined($c=fork) || die $!;
63         if (!$c) { exec("$lib_path/process",$id); die "unable to execute $lib_path/process: $!"; }
64     } else {
65         die "bad name $id";
66     }
67     my $cc=waitpid($c,0); $cc == $c || die "$cc $c $!";
68     my $status=$?;
69     if ($status) {
70         print(STDERR "$id: process failed ($status $!) - now in [PG]$id\n") || die $!;
71     }
72     print(STDOUT " done\n") || die $!;
73     rmtree("$gSpoolDir/mime.tmp",0,1);
74     $ndone++;
75 }
76
77
78 system("$lib_path/gen-indices",'--quick') == 0 or print STDERR "gen-indices failed\n";
79
80 if (@gPostProcessall) {
81     system @gPostProcessall == 0 or print STDERR "\@gPostProcessall failed: ".join(' ',@gPostProcessall)."\n";
82 }
83
84
85
86 &unfilelock;
87
88 exit(0);