]> git.donarmstrong.com Git - debbugs.git/blob - scripts/rebuild.in
[project @ 2003-05-25 13:13:18 by cjwatson]
[debbugs.git] / scripts / rebuild.in
1 #!/usr/bin/perl -w
2 # $Id: rebuild.in,v 1.9 2003/05/25 13:13:18 cjwatson Exp $
3
4 # Load modules and set environment
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
15 #global variables
16 $debug = 0;
17
18 @ARGV==0 and &quit( "no archive given on the commandline" );
19 $archive= shift(@ARGV);
20 open IDXFILE, "> index.$archive" or &quit( "trying to reset index file: $!" );
21
22 #get list of bugs (ie, status files)
23 my @files;
24 for ($subdir=0; $subdir<100; $subdir++ )
25 {
26     my $path = sprintf( "$archive/%.2d", $subdir );
27     opendir(DIR,$path) || next; 
28     my @list= grep(m/^\d+\.status$/,readdir(DIR));
29     closedir DIR;
30     grep(s/\.status$//,@list);
31     push @files, @list;
32 }
33
34 @files = sort { $a <=> $b } @files;
35
36 #process each bug (ie, status file)
37 for my $ref (@files) 
38 {
39     print STDERR "$ref considering\n" if $debug;
40     my $data = readbug($ref, $archive);
41     $data->{severity} =~ y/A-Z/a-z/;
42
43     (my $pkglist = $data->{package}) =~ s/[,\s]+/,/g;
44     $pkglist =~ s/^,+//;
45     $pkglist =~ s/,+$//;
46
47     my $whendone = 'open';
48     $whendone = 'forwarded' if length $data->{forwarded};
49     $whendone = 'done' if length $data->{done};
50
51     printf IDXFILE "%s %d %d %s [%s] %s %s\n",
52         $pkglist, $ref, $data->{date}, $whendone, $data->{originator},
53         $data->{severity}, $data->{keywords};
54 }
55
56 close IDXFILE;