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