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