X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=bin%2Fparse-sources;h=732112658e74f236c6d8e4d9d459b5a67d277c8d;hb=552e68978a99d2d4e05d80aea0cc5308b370d10e;hp=91e8ad54d202d7d422e8dc8a10a02c451b256548;hpb=0acb0c026bd612e3f60c91748f83f454214341a9;p=deb%2Fpackages.git diff --git a/bin/parse-sources b/bin/parse-sources index 91e8ad5..7321126 100755 --- a/bin/parse-sources +++ b/bin/parse-sources @@ -20,28 +20,33 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES ); +&Packages::Config::init( './' ); my %sources_small = (); my %source_names = (); my %source_postfixes = (); -my @suites = ('oldstable', 'stable', 'testing', 'unstable', 'experimental'); - $/ = ""; -for my $suite (@suites) { +for my $archive (@ARCHIVES) { + for my $suite (@SUITES) { - print "Reading $suite...\n"; + print "Reading $archive/$suite...\n"; + my %source_names_suite = (); my %sources_all_db; - tie %sources_all_db, "DB_File", "sources_all_$suite.db.new", + tie %sources_all_db, "DB_File", "$DBDIR/sources_all_$suite.db.new", O_RDWR|O_CREAT, 0666, $DB_BTREE or die "Error creating DB: $!"; - open PKG, "zcat /org/ftp.debian.org/ftp/dists/$suite/$what/source/Sources.gz|"; + open PKG, "zcat $TOPDIR/archive/$archive/$suite/$what/source/Sources.gz|"; while () { next if /^\s*$/; my $data = ""; @@ -51,31 +56,52 @@ for my $suite (@suites) { while (/^(\S+):\s*(.*)\s*$/mg) { my ($key, $value) = ($1, $2); $value =~ s/\377/\n /g; - $data .= "$key: $value\n"; $key =~ tr [A-Z] [a-z]; $data{$key} = $value; } - $sources_all_db{"$data{'package'} $data{'version'}"} - = $data; - $source_names{$data{'package'}} = 1; + $source_names_suite{$data{'package'}} = 1; + delete $data{'binary'}; + + $data{files} =~ s/\s*\n\s*/\01/sog; + $data{files} =~ s/^\01//sg; my $section = 'main'; - my $subsection = $data{section}; + 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{'priority'} = "-" if not exists($data{'priority'}); + $data{'section'} = $section; + $data{'subsection'} = $subsection; + $data{'priority'} ||= "-"; $sources_small{$data{'package'}} .= - "$suite $section $subsection $data{'priority'} $data{'version'}\000"; + "$archive $suite $section $subsection $data{'priority'} $data{'version'}\000"; + + while (my ($key, $value) = each (%data)) { + next if $key eq 'package' or $key eq 'archive' or $key eq 'suite'; + print STDERR "WARN: $key ($suite/$archive/$data{package}/$data{architecture}\n" unless defined $value; + $data .= "$key\00$value\00"; + } + $data =~ s/.$//so; + $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; + } } print "Writing databases...\n"; my %sources_small_db; -tie %sources_small_db, "DB_File", "sources_small.db.new", +tie %sources_small_db, "DB_File", "$DBDIR/sources_small.db.new", O_RDWR|O_CREAT, 0666, $DB_BTREE or die "Error creating DB: $!"; while (my ($k, $v) = each(%sources_small)) { @@ -89,11 +115,12 @@ for my $pkg (keys %source_names) { for (my $i=0;$i