]> git.donarmstrong.com Git - debbugs.git/blob - scripts/rebuild.in
[project @ 2003-05-24 22:34:16 by cjwatson]
[debbugs.git] / scripts / rebuild.in
1 #!/usr/bin/perl -w
2 # $Id: rebuild.in,v 1.7 2003/05/24 22:34:16 cjwatson Exp $
3
4 # Load modules and set envirnment
5 use File::Copy;
6 $config_path = '/etc/debbugs';
7 $lib_path = '/usr/lib/debbugs';
8
9 require("$config_path/config");
10 require("$lib_path/errorlib");
11 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
12
13 chdir("$gSpoolDir") || die "chdir spool: $!\n";
14 my $data;
15
16 sub readreport {
17     my $lref = shift;
18     my $path = shift;
19         
20     $data = readbug($lref);
21     return 1;
22 }
23
24 #global variables
25 $debug = 0;
26 defined($startdate= time) || &quit("failed to get time: $!");
27
28 @ARGV==0 or &quit( "no archive given on the commandline" );
29 $archive= shift(@ARGV);
30 open IDXFILE, "> index.$archive" or &quit( "trying to reset index file: $!" );
31
32
33 if ( $archive eq 'db' )
34 {
35     opendir(DIR,'db') || next; 
36     @list= grep(m/^\d+\.status$/,readdir(DIR));
37     closedir DIR;
38     grep(s/\.status$//,@list);
39     @list= sort { $a <=> $b } @list;
40
41     #process each bug (ie, status file)
42     while ( defined( $list[0] )) 
43     {
44         my $ref = shift @list;
45         print STDERR "$ref considering\n" if $debug;
46         readreport($ref, $path);
47         printf IDXFILE "%s %d %s\n", $data->{package}, $ref, $data->{subject};
48     }
49 }
50 else
51 {
52     #get list of bugs (ie, status files)
53     for ($subdir=0; $subdir<100; $subdir++ )
54     {
55         my $path = sprintf( "$archive/%.2d", $subdir );
56         opendir(DIR,$path) || next; 
57         @list= grep(m/^\d+\.status$/,readdir(DIR));
58         closedir DIR;
59         grep(s/\.status$//,@list);
60         @list= sort { $a <=> $b } @list;
61
62         #process each bug (ie, status file)
63         while ( defined( $list[0] )) 
64         {
65             my $ref = shift @list;
66             print STDERR "$ref considering\n" if $debug;
67             readreport($ref, $path);
68             printf IDXFILE "%s %d %s\n", $data->{package}, $ref, $data->{subject};
69         }
70     }
71 }
72 close IDXFILE;