#!/usr/bin/perl -w # $Id: rebuild.in,v 1.6 2003/05/03 20:01:20 doogie Exp $ # Load modules and set envirnment use File::Copy; $config_path = '/etc/debbugs'; $lib_path = '/usr/lib/debbugs'; require("$config_path/config"); require("$lib_path/errorlib"); $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'}; chdir("$gSpoolDir") || die "chdir spool: $!\n"; my $data; sub readreport { my $lref = shift; my $path = shift; $data = readbug($lref); return 1; } #global variables $debug = 0; defined($startdate= time) || &quit("failed to get time: $!"); @ARGV==0 or &quit( "no archive given on the commandline" ); $archive= shift(@ARGV); open IDXFILE, "> index.$archive" or &quit( "trying to reset index file: $!" ); if ( $archive eq 'db' ) { opendir(DIR,'db') || next; @list= grep(m/^\d+\.status$/,readdir(DIR)); closedir DIR; grep(s/\.status$//,@list); @list= sort { $a <=> $b } @list; #process each bug (ie, status file) while ( defined( $list[0] )) { my $ref = shift @list; print STDERR "$ref considering\n" if $debug; readreport($ref, $path); printf IDXFILE "%s %d %s\n", $data->{package}, $ref, $data->{subject}; } } else { #get list of bugs (ie, status files) for ($subdir=0; $subdir<100; $subdir++ ) { my $path = sprintf( "$archive/%.2d", $subdir ); opendir(DIR,$path) || next; @list= grep(m/^\d+\.status$/,readdir(DIR)); closedir DIR; grep(s/\.status$//,@list); @list= sort { $a <=> $b } @list; #process each bug (ie, status file) while ( defined( $list[0] )) { my $ref = shift @list; print STDERR "$ref considering\n" if $debug; readreport($ref, $path); printf IDXFILE "%s %d %s\n", $data->{package}, $ref, $data->{subject}; } } } close IDXFILE;