]> git.deb.at Git - deb/packages.git/blobdiff - bin/parse-sources
Update all .po and .pot files
[deb/packages.git] / bin / parse-sources
index 89f071d42d389bf77c4f05d997ddce019b0060ca..da49d6ad4ede971f0955a6d6435c202c65eddeee 100755 (executable)
@@ -2,8 +2,6 @@
 # Convert Sources.gz files into Sleepycat db files for efficient usage of
 # data
 #
-# $Id$
-#
 # Copyright (C) 2006  Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 use strict;
 use lib './lib';
 
+$| = 1;
+
 my $what = $ARGV[0] ? "non-free" : "*";
 # max. distinct results for a given package postfix
 my $MAX_SOURCE_POSTFIXES = 100;
 
 use DB_File;
+use File::Path;
 use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES );
 &Packages::Config::init( './' );
 my %sources_small = ();
@@ -35,14 +36,21 @@ my %source_postfixes = ();
 
 $/ = "";
 
+-d $DBDIR || mkpath( $DBDIR );
+
 for my $archive (@ARCHIVES) {
     for my $suite (@SUITES) {
 
        print "Reading $archive/$suite...\n";
+       my %source_names_suite = ();
        my %sources_all_db;
        tie %sources_all_db, "DB_File", "$DBDIR/sources_all_$suite.db.new",
                O_RDWR|O_CREAT, 0666, $DB_BTREE
                or die "Error creating DB: $!";
+       if (!-d "$TOPDIR/archive/$archive/$suite/") {
+               print "\tseems not to exist, skipping...\n";
+               next;
+       }
        open PKG, "zcat $TOPDIR/archive/$archive/$suite/$what/source/Sources.gz|";
        while (<PKG>) {
                next if /^\s*$/;
@@ -57,6 +65,7 @@ for my $archive (@ARCHIVES) {
                        $data{$key} = $value;
                }
                $source_names{$data{'package'}} = 1;
+               $source_names_suite{$data{'package'}} = 1;
                delete $data{'binary'};
 
                $data{files} =~ s/\s*\n\s*/\01/sog;
@@ -66,8 +75,6 @@ for my $archive (@ARCHIVES) {
                my $subsection = $data{section} || '-';
                if ($data{section} && ($data{section} =~ m=/=o)) {
                    ($section, $subsection) = split m=/=o, $data{section}, 2;
-                   ($subsection, $section) = split m=/=o, $data{section}, 2
-                       if $section eq 'non-US';
                }
                $data{'section'} = $section;
                $data{'subsection'} = $subsection;
@@ -84,6 +91,12 @@ for my $archive (@ARCHIVES) {
                $sources_all_db{"$archive $suite $data{'package'}"}
                        = $data;
        }
+       open NAMES, '>>', "$DBDIR/source_names_$suite.txt.new"
+           or die "Error creating source names list: $!";
+       foreach (sort keys %source_names_suite) {
+           print NAMES "$_\n";
+       }
+       close NAMES;
 
        untie %sources_all_db;
     }
@@ -127,6 +140,7 @@ untie %source_postfixes_db;
 
 for my $suite (@SUITES) {
        rename("$DBDIR/sources_all_$suite.db.new", "$DBDIR/sources_all_$suite.db");
+       rename("$DBDIR/source_names_$suite.txt.new", "$DBDIR/source_names_$suite.txt");
 }
 rename("$DBDIR/sources_small.db.new", "$DBDIR/sources_small.db");
 rename("$DBDIR/source_postfixes.db.new", "$DBDIR/source_postfixes.db");