]> git.donarmstrong.com Git - debbugs.git/blob - scripts/rebuild.in
d422c3d38ee30d1ab3b36a9a42196379e8200045
[debbugs.git] / scripts / rebuild.in
1 #!/usr/bin/perl -w
2 # $Id: rebuild.in,v 1.6 2003/05/03 20:01:20 doogie 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         {       my $ref = shift @list;
44                 print STDERR "$ref considering\n" if $debug;
45         readreport($ref, $path);
46                 printf IDXFILE "%s %d %s\n", $data->{package}, $ref, $data->{subject};
47     }
48 }
49 else
50 {
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         {       my $ref = shift @list;
65                 print STDERR "$ref considering\n" if $debug;
66         readreport($ref, $path);
67                 printf IDXFILE "%s %d %s\n", $data->{package}, $ref, $data->{subject};
68     }
69 }
70
71 }
72 close IDXFILE;