- or die "Failed to open output reverse file";
-
- open CONT, "zcat $filename|$what";
- while (<CONT>) {last if /^FILE/mo;}
- while (<CONT>) {
- my $data = "";
- my %data = ();
- chomp;
- print "Doing line ".($./1000)."k (out of approx 1.5M)\n" if $. % 250000 == 0;
- /^(.+?)\s+(\S+)$/o;
- my ($file, $value) = ($1, $2);
- $value =~ s#[^,/]+/##og;
- my @packages = split /,/, $value;
- for (@packages) {
+ or die "Failed to open output reverse file: $!";
+
+ my $changed = 0;
+ for my $archive (@archives) {
+
+ my $filename = "$TOPDIR/archive/$archive/$suite/Contents-$arch.gz";
+ next unless -f $filename;
+ # Note: ctime, because mtime is set back via rsync
+ my $ftime = (stat $filename)[10];
+ next if defined $dbtime and $dbtime > $ftime;
+ print "$archive/$suite/$arch needs update\n";
+ $changed++;
+ }
+ if ($changed) {
+ for my $archive (@archives) {
+
+ my $filename = "$TOPDIR/archive/$archive/$suite/Contents-$arch.gz";
+ next unless -f $filename;
+ print "Reading $archive/$suite/$arch...\n";
+
+ open CONT, "zcat $filename|$what"
+ or die $!;
+ my $header_found = 0;
+ while (<CONT>) { /^FILE/mo && do { $header_found = 1; last };}
+ if (eof(CONT)) { # no header found or only header found
+ close CONT; # explicit close to reset $.
+ next if $header_found;
+ open CONT, "zcat $filename|$what";
+ }
+ while (<CONT>) {
+ my $data = "";
+ my %data = ();
+ chomp;
+ print "Doing line ".($NR/1000)."k (out of approx 2.0M)\n"
+ if $NR % 250000 == 0;
+ /^(.+?)\s+(\S+)$/o;
+ my ($file, $value) = ($1, $2);
+ $value =~ s#[^,/]+/##og;
+ my @packages = split m/,/, $value;
+ for (@packages) {