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