#!/usr/bin/perl -w # $Id: rebuild.in,v 1.3 2000/10/07 17:27:13 joy Exp $ # Load modules and set envirnment use File::Copy; require('/etc/debbugs/config'); require('/usr/lib/debbugs/errorlib'); $ENV{'PATH'} = '/usr/lib/debbugs:'.$ENV{'PATH'}; chdir("$gSpoolDir") || die "chdir spool: $!\n"; sub readreport { my $lref = shift; my $path = shift; open(S,"$path/$lref.status") || die "unable to open $path/$lref: $!\n"; chop($s_originator= ); chop($s_date= ); chop($s_subject= ); chop($s_msgid= ); chop($s_package= ); chop($s_keywords= ); chop($s_done= ); chop($s_forwarded= ); chop($s_mergedwith= ); chop($s_severity= ); close(S); 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", $s_package, $ref, $s_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", $s_package, $ref, $s_subject; } } } close IDXFILE;