From: Frank Lichtenheld Date: Thu, 9 Feb 2006 17:48:17 +0000 (+0000) Subject: Begin implementing virtual package support. X-Git-Tag: switch-to-templates~148 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=dc9512b1309f4c8c6bd1171b543183e8ac8b2115;p=deb%2Fpackages.git Begin implementing virtual package support. search_package is already working, show_package needs more work --- diff --git a/bin/parse-packages b/bin/parse-packages index 817f547..7de51b6 100755 --- a/bin/parse-packages +++ b/bin/parse-packages @@ -48,6 +48,7 @@ $/ = ""; for my $archive (@ARCHIVES) { for my $suite (@SUITES) { + my %virtual_packages = (); print "Reading $archive/$suite...\n"; my %packages_all_db; tie %packages_all_db, "DB_File", "$DBDIR/packages_all_$suite.db.new", @@ -69,6 +70,11 @@ for my $archive (@ARCHIVES) { # Skip double package next if exists($packages_all_db{"$data{'package'} $data{'architecture'} $data{'version'}"}); + if ($data{'provides'}) { + foreach (split /\s*,\s*/, $data{'provides'}) { + $virtual_packages{$_}{$data{'package'}}++; + } + } $package_names{$data{'package'}} = 1; my $src = $data{'package'}; my $src_version = ''; @@ -122,6 +128,11 @@ for my $archive (@ARCHIVES) { = $data; } + foreach (keys %virtual_packages) { + my @provided_by = keys %{$virtual_packages{$_}}; + $packages_small{$_} .= "$archive $suite virtual - - - - @provided_by\000"; + } + untie %packages_all_db; } } diff --git a/cgi-bin/search_packages.pl b/cgi-bin/search_packages.pl index 516d36d..3572915 100755 --- a/cgi-bin/search_packages.pl +++ b/cgi-bin/search_packages.pl @@ -252,7 +252,7 @@ print_errors(); print_hints(); print_debug(); if (@results) { - my (%pkgs, %subsect, %sect, %desc, %binaries); + my (%pkgs, %subsect, %sect, %desc, %binaries, %provided_by); unless ($opts{searchon} eq 'sourcenames') { foreach (@results) { @@ -260,25 +260,31 @@ if (@results) { $priority, $version, $desc) = @$_; my ($pkg) = $pkg_t =~ m/^(.+)/; # untaint - $pkgs{$pkg}{$suite}{$archive}{$version}{$arch} = 1; - $subsect{$pkg}{$suite}{$archive}{$version} = $subsection; - $sect{$pkg}{$suite}{$archive}{$version} = $section - unless $section eq 'main'; - - $desc{$pkg}{$suite}{$archive}{$version} = $desc; + if ($arch ne 'virtual') { + $pkgs{$pkg}{$suite}{$archive}{$version}{$arch} = 1; + $subsect{$pkg}{$suite}{$archive}{$version} = $subsection; + $sect{$pkg}{$suite}{$archive}{$version} = $section + unless $section eq 'main'; + + $desc{$pkg}{$suite}{$archive}{$version} = $desc; + } else { + $provided_by{$pkg}{$suite}{$archive} = [ split /\s+/, $desc ]; + } } +my @pkgs = sort(keys %pkgs, keys %provided_by); if ($opts{format} eq 'html') { - my ($start, $end) = multipageheader( $input, scalar keys %pkgs, \%opts ); + my ($start, $end) = multipageheader( $input, scalar @pkgs, \%opts ); my $count = 0; - foreach my $pkg (sort keys %pkgs) { + foreach my $pkg (@pkgs) { $count++; next if $count < $start or $count > $end; printf "

Package %s

\n", $pkg; print "