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