| 1 |
#!/usr/bin/perl -w |
| 2 |
# $Id: rebuild.in,v 1.13 2003/08/23 15:12:57 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 |
use vars qw($gSpoolDir); |
| 12 |
|
| 13 |
$ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'}; |
| 14 |
|
| 15 |
chdir("$gSpoolDir") || die "chdir spool: $!\n"; |
| 16 |
|
| 17 |
#global variables |
| 18 |
$debug = 0; |
| 19 |
|
| 20 |
@ARGV==0 and die "no archive given on the commandline" ; |
| 21 |
my $archive = shift(@ARGV); |
| 22 |
my $index = "index.$archive"; |
| 23 |
$index = 'index.db' if $archive eq 'db-h'; |
| 24 |
open IDXFILE, "> $index" or die "trying to reset index file: $!" ; |
| 25 |
|
| 26 |
#get list of bugs (ie, status files) |
| 27 |
my @files; |
| 28 |
for ($subdir=0; $subdir<100; $subdir++ ) |
| 29 |
{ |
| 30 |
my $path = sprintf( "$archive/%.2d", $subdir ); |
| 31 |
opendir(DIR,$path) || next; |
| 32 |
my @list= grep(m/^\d+\.summary$/,readdir(DIR)); |
| 33 |
closedir DIR; |
| 34 |
grep(s/\.summary$//,@list); |
| 35 |
push @files, @list; |
| 36 |
} |
| 37 |
|
| 38 |
@files = sort { $a <=> $b } @files; |
| 39 |
|
| 40 |
#process each bug (ie, status file) |
| 41 |
for my $ref (@files) |
| 42 |
{ |
| 43 |
print STDERR "$ref considering\n" if $debug; |
| 44 |
my $data = readbug($ref, $archive); |
| 45 |
$data->{severity} =~ y/A-Z/a-z/; |
| 46 |
|
| 47 |
(my $pkglist = $data->{package}) =~ s/[,\s]+/,/g; |
| 48 |
$pkglist =~ s/^,+//; |
| 49 |
$pkglist =~ s/,+$//; |
| 50 |
|
| 51 |
my $whendone = 'open'; |
| 52 |
$whendone = 'forwarded' if length $data->{forwarded}; |
| 53 |
$whendone = 'done' if length $data->{done}; |
| 54 |
|
| 55 |
printf IDXFILE "%s %d %d %s [%s] %s %s\n", |
| 56 |
$pkglist, $ref, $data->{date}, $whendone, $data->{originator}, |
| 57 |
$data->{severity}, $data->{keywords}; |
| 58 |
} |
| 59 |
|
| 60 |
close IDXFILE; |