]> git.donarmstrong.com Git - debbugs.git/blob - scripts/processall.in
[project @ 2001-07-15 10:05:23 by doogie]
[debbugs.git] / scripts / processall.in
1 #!/usr/bin/perl
2 # $Id: processall.in,v 1.5 2001/07/15 10:05:23 doogie 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;    process/stop
10
11 require( '/etc/debbugs/config' );
12 require( '/usr/lib/debbugs/errorlib' );
13 $ENV{'PATH'} = '/usr/lib/debbugs:'.$ENV{'PATH'};
14 chdir( "$gSpoolDir" ) || die 'chdir spool: $!\n';
15 push( @INC, '/usr/lib/debbugs' );
16
17 #open(DEBUG,">&4");
18
19 $|=1;
20 undef %fudged;
21
22 &filelock('incoming-cleaner');
23 for (;;) {
24     if (-f 'stop') {
25         print(STDERR "stop file created\n") || die $!;
26         last;
27     }
28     if (!@ids) {
29         opendir(DIR,"incoming") || die $!;
30         while ( defined( $_= readdir(DIR) )) { push(@ids,$_) if s/^I//; }
31         last unless @ids;
32         @ids= sort(@ids);
33     }
34     stat("$gMaintainerFile") || die "stat $gMaintainerFile: $!\n";
35     $nf= @ids;
36     $id= shift(@ids);
37     unless (rename("incoming/I$id","incoming/G$id")) {
38         if ($fudged{$id}) {
39             die "$id already fudged once! $!\n";
40         }
41         $fudged{$id}= 1;
42         next;
43     }
44     if ($id =~ m/^[RC]/) {
45         print(STDOUT "[$nf] $id service ...") || die $!;
46         defined($c=fork) || die $!;
47         if (!$c) { exec("/usr/lib/debbugs/service",$id); die $!; }
48     } elsif ($id =~ m/^[BMQFDU]/) {
49         print(STDOUT "[$nf] $id process ...") || die $!;
50         defined($c=fork) || die $!;
51         if (!$c) { exec("/usr/lib/debbugs/process",$id); die $!; }
52     } else {
53         die "bad name $id";
54     }
55     $cc=waitpid($c,0); $cc == $c || die "$cc $c $!";
56     $status=$?;
57     if ($status) {
58         print(STDERR "$id: process failed ($status $!) - now in [PG]$id\n") || die $!;
59     }
60     print(STDOUT " done\n") || die $!;
61     $ndone++;
62 }
63 &unfilelock;
64
65 exit(0);