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