]> git.deb.at Git - deb/packages.git/blobdiff - bin/parse-contents
Add basic l10n support.
[deb/packages.git] / bin / parse-contents
index 341ecd5783394cfcef859fae632d5896432cdc6a..12b7ed824a40dbb933d0bc7b7a10e675153b9081 100755 (executable)
@@ -22,6 +22,8 @@
 use strict;
 use lib './lib';
 
+$| = 1;
+
 # Important, we want sorting and such to happen like in the C locale: binary,
 # without any fancy collation. FIXME: is this actually adequate?
 $ENV{"LC_ALL"} = 'C';
@@ -35,6 +37,7 @@ my $SORT_REVERSE_CONCURRENTLY = 1;
 
 use DB_File;
 use Storable;
+use File::Path;
 use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @ARCHITECTURES );
 &Packages::Config::init( './' );
 
@@ -43,6 +46,7 @@ my @suites = @SUITES;
 my @archs = @ARCHITECTURES;
 
 $DBDIR .= "/contents";
+-d $DBDIR || mkpath( $DBDIR );
 
 for my $archive (@archives) { for my $suite (@suites) {
 
@@ -64,9 +68,10 @@ for my $archive (@archives) { for my $suite (@suites) {
        $extra = "|sort" if $SORT_REVERSE_CONCURRENTLY;
 
        open REVERSED, "$extra>$DBDIR/reverse.tmp"
-               or die "Failed to open output reverse file";
+               or die "Failed to open output reverse file: $!";
 
-       open CONT, "zcat $filename|$what";
+       open CONT, "zcat $filename|$what"
+               or die $!;
        while (<CONT>) {last if /^FILE/mo;}
        while (<CONT>) {
                my $data = "";
@@ -117,6 +122,15 @@ for my $archive (@archives) { for my $suite (@suites) {
                or die "Oops";
   }
 
+
+  my $go = 0;
+  my $suite_mtime = (stat "$DBDIR/reverse_$suite.db")[9];
+  for my $file (glob "$DBDIR/reverse_${suite}_*.txt") {
+         $go = 1 if not defined $suite_mtime
+                 or $suite_mtime < (stat $file)[9];
+  }
+  next unless $go;
+
   print "Merging reverse path lists for ${suite}...\n";
 
   open MERGED, "sort -m $DBDIR/reverse_${suite}_*.txt |"
@@ -162,16 +176,4 @@ for my $archive (@archives) { for my $suite (@suites) {
   rename "$DBDIR/reverse_$suite.db.new", "$DBDIR/reverse_$suite.db";
 }}
 
-#print "Writing databases...\n";
-
-# FIXME: missing filenames due to optimising above. Need to store filenames
-# per-suite/arch, but merge them in the end for better cached searching
-#open FILENAMES, "> $DBDIR/filenames.txt.new";
-#for (keys %filenames) {
-#      print FILENAMES "$_\n";
-#}
-#close FILENAMES;
-
-#rename("$DBDIR/filenames.txt.new", "$DBDIR/filenames.txt");
-
 # vim: set ts=4