| value: \0 separated tuples of "archive suite arch component section priority version shortdescription"
| (so you can split on spaces in 8 pieces, but need to not split further
| because shortdescription can have spaces)
-| arch can also be 'virtual', with c/s/p/v being undefined then, and
-| shortdescription being a space-separated list of packages providing
-| the package that is the key
Notes: - maybe add did right before shortdescription?
- - TODO: make sure for each (archive,suite), newest package is shown
- first, and all newest versions for each such section is first, so
- that one can efficiently lookup just the newest entry for a given
- (archive,suite)
+ - for each suite, newest package is shown first, and (suite,
+ architecture) is unique, the newest one is choosen. Once you find
+ the right suite, you know you've got the newest, once you found
+ your (suite,arch), you know you've found the only unique such entry
+ - The very first element is different (TODO: maybe should be
+ different DB then?), a \01 separated hash of suite -> provided-by,
+ like "suite1\01prov1 prov2\01suite2\01prov1"
| package_postfixes.db:
| key: a postfix string of a package name
use DB_File;
use Storable;
+use Deb::Versions;
use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES );
&Packages::Config::init( './' );
my %packages_small = ();
+my %virtual_packages = ();
my %package_names = ();
my %package_postfixes = ();
my %sources_packages = ();
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",
if ($data{'provides'}) {
foreach (split /\s*,\s*/, $data{'provides'}) {
- $virtual_packages{$_}{$data{'package'}}++;
+ $virtual_packages{$_}{$suite}{$data{'package'}}++;
}
}
$package_names{$data{'package'}} = 1;
$sections{$suite}{$archive}{$section}++;
$subsections{$suite}{$archive}{$subsection}++;
$priorities{$suite}{$archive}{$data{priority}}++;
- $packages_small{$data{'package'}} .= "$archive $suite $data{'architecture'} ".
- "$section $subsection $data{'priority'} $data{'version'} $sdescr\000";
+ my $pkgitem = "$archive $suite $data{'architecture'} ".
+ "$section $subsection $data{'priority'} $data{'version'} $sdescr\0";
+ my $previtem = $packages_small{$data{'package'}}{$suite}{$data{'architecture'}}
+ || $pkgitem;
+ $packages_small{$data{'package'}}{$suite}{$data{'architecture'}} = $pkgitem
+ if version_cmp($data{'version'}, (split /\s/o, $previtem)[6]) >= 0;
+ $previtem = $packages_small{$data{'package'}}{$suite}{'any'}
+ || $pkgitem;
+ $packages_small{$data{'package'}}{$suite}{'any'} = $pkgitem
+ if version_cmp($data{'version'}, (split /\s/o, $previtem)[6]) >= 0;
$sources_packages{$src} .=
"$archive $suite $data{'package'} $data{'version'} $data{'architecture'}\000";
$data{archive} = $archive;
= $data;
}
- foreach (keys %virtual_packages) {
- my @provided_by = keys %{$virtual_packages{$_}};
- $packages_small{$_} .= "$archive $suite virtual v v v v @provided_by\000";
- }
-
untie %packages_all_db;
}
}
tie %packages_small_db, "DB_File", "$DBDIR/packages_small.db.new",
O_RDWR|O_CREAT, 0666, $DB_BTREE
or die "Error creating DB: $!";
-while (my ($k, $v) = each(%packages_small)) {
- $v =~ s/.$//s;
- $packages_small_db{$k} = $v;
+while (my ($pkg, $v) = each(%packages_small)) {
+ my ($res1, $res2, $res3) = ("", "", "");
+ while (my ($suite, $v2) = each %$v) {
+ $res2 .= $v2->{'any'};
+ while (my ($arch, $v3) = each %$v2) {
+ next if $arch eq 'any' or $v3 eq $v2->{'any'};
+ $res3 .= $v3;
+ }
+ }
+
+ if (exists $virtual_packages{$pkg}) {
+ while (my ($suite, $v2) = each %{$virtual_packages{$pkg}}) {
+ $res1 .= "$suite\01".(join ' ', keys %$v2)."\01";
+ }
+ } else {
+ $res1 .= "-\01-\01";
+ }
+ $res1 =~ s/.$/\0/s;
+
+ my $res = "$res1$res2$res3";
+ $res =~ s/.$//s;
+ $packages_small_db{$pkg} = $res;
}
untie %packages_small_db;
$desc{$pkg}{$suite}{$archive}{$version} = $desc;
} else {
- $provided_by{$pkg}{$suite}{$archive} = [ split /\s+/, $desc ];
+ $provided_by{$pkg}{$suite} = [ split /\s+/, $desc ];
}
}
if @archs_to_print;
$archs_printed{$_}++ foreach @archs_to_print;
}
- if (my $p = $provided_by->{$suite}{$archive}) {
+ if (my $p = $provided_by->{$suite}) {
$str .= '<br>'._g( 'also provided by: ' ).
join( ', ', map { "<a href=\"$ROOT/$path/$_\">$_</a>" } @$p);
}
$str .= "</li>\n";
- } elsif (my $p = $provided_by->{$suite}{$archive}) {
+ } elsif (my $p = $provided_by->{$suite}) {
$str .= sprintf( "<li><a href=\"$ROOT/%s/%s\">%s</a>: Virtual package<br>",
$path, $pkg, $path );
$str .= _g( 'provided by: ' ).
my $entry = $entries{$p_name} ||
read_entry_simple( $packages, $p_name, $opts->{h_archives}, $suite);
my $short_desc = $entry->[-1];
- my $arch = $entry->[2];
- my $archive = $entry->[0];
+ my $arch = $entry->[3];
+ my $archive = $entry->[1];
if ( $short_desc ) {
my $path = $one_archive eq $archive ? "$suite/$archive" :
$suite;
if ( $is_old_pkgs ) {
push @res_pkgs, dep_item( "$ROOT/$path/$p_name",
$p_name, "$pkg_version$arch_str" );
- } elsif ($arch eq 'virtual') {
- my @provided_by = split /\s/, $short_desc;
+ } elsif (defined $entry->[0]) {
+# FIXME: can be both virtual package (defined $entry->[0]) and real one
+ my @provided_by = split /\s/, $entry->[0];
$short_desc = "virtual package provided by ";
if (@provided_by < 10) {
$short_desc .= join( ', ',map { "<a href=\"$ROOT/$path/$_\">$_</a>" } @provided_by);
$search_in_header = <<MENU;
<form method="GET" action="$SEARCH_URL">
<div id="hpacketsearch">
-<input type="hidden" name="debug" value="$values{debug}">
-<input type="hidden" name="suite" value="$values{suite}">
-<input type="hidden" name="exact" value="$values{exact}">
-<input type="hidden" name="arch" value="$values{arch}">
-<input type="hidden" name="section" value="$values{section}">
-<input type="text" size="30" name="keywords" value="$values{keywords}" id="kw">
+<input type="text" size="30" name="keywords" value="" id="kw">
<input type="submit" value="%s">
<span style="font-size: 60%%"><a href="$SEARCH_PAGE#search_packages">%s</a></span>
<br>
sub read_entry_all {
my ($hash, $key, $results, $non_results, $opts) = @_;
- my $result = $hash->{$key} || '';
+ my ($virt, $result) = split /\000/o, $hash->{$key} || "-\01-", 2;
+
+ my %virt = split /\01/o, $virt;
+ while (my ($suite, $provides) = each %virt) {
+ next if $suite eq '-';
+ if ($opts->{h_suites}{$suite}) {
+ push @$results, [ $key, "-", $suite, 'virtual', 'v', 'v', 'v', 'v',
+ (split /\s/, $provides)];
+ } else {
+ push @$non_results, [ $key, "-", $suite, 'virtual', 'v', 'v', 'v', 'v',
+ (split /\s/, $provides)];
+ }
+ }
+
foreach (split /\000/o, $result) {
my @data = split ( /\s/o, $_, 8 );
debug( "Considering entry ".join( ':', @data), 2) if DEBUG;
- if ($opts->{h_archives}{$data[0]} && $opts->{h_suites}{$data[1]}
- && ($opts->{h_archs}{$data[2]} || $data[2] eq 'all'
- || $data[2] eq 'virtual')
- && ($opts->{h_sections}{$data[3]} || $data[3] eq 'v')) {
+ if ($opts->{h_suites}{$data[1]}
+ && ($opts->{h_archs}{$data[2]} || $data[2] eq 'all')
+ && $opts->{h_sections}{$data[3]}) {
debug( "Using entry ".join( ':', @data), 2) if DEBUG;
push @$results, [ $key, @data ];
} else {
}
sub read_entry_simple {
my ($hash, $key, $archives, $suite) = @_;
- my $result = $hash->{$key} || '';
+ # FIXME: drop $archives
+
+ my ($virt, $result) = split /\000/o, $hash->{$key} || "-\01-\0", 2;
+ my %virt = split /\01/o, $virt;
debug( "read_entry_simple: key=$key, archives=".
join(" ",(keys %$archives)).", suite=$suite", 1);
- my (@data_fuzzy, @data_virtual, @data_fuzzy_virtual);
- foreach (split /\000/o, $result) {
+ # FIXME: magically encoded a max of 7 suites here by the '8'
+ foreach (split /\000/o, $result, 8) {
my @data = split ( /\s/o, $_, 8 );
- debug( "Considering entry ".join( ':', @data), 2) if DEBUG;
- if ($data[1] eq $suite) {
- if ($archives->{$data[0]}
- && ($data[2] ne 'virtual')) {
- debug( "Using entry ".join( ':', @data), 2) if DEBUG;
- return \@data;
- } elsif ($archives->{$data[0]}) {
- debug( "Virtual entry ".join( ':', @data), 2) if DEBUG;
- @data_virtual = @data;
- } elsif (($data[0] eq 'us')
- && ($data[2] ne 'virtual')) {
- debug( "Fuzzy entry ".join( ':', @data), 2) if DEBUG;
- @data_fuzzy = @data;
- } elsif ($data[0] eq 'us') {
- debug( "Virtual fuzzy entry ".join( ':', @data), 2) if DEBUG;
- @data_fuzzy_virtual = @data;
- }
- }
+ return [ $virt{$suite}, @data ] if $data[1] eq $suite;
}
- return \@data_virtual if @data_virtual;
- return \@data_fuzzy if @data_fuzzy;
- return \@data_fuzzy_virtual;
+ return [ $virt{$suite} ];
}
+
sub read_src_entry_all {
my ($hash, $key, $results, $non_results, $opts) = @_;
my $result = $hash->{$key} || '';