-# FIXME
-# check if the Packages files are there
-#my @files = glob ("$fdir/$file");
-#if ($#files == -1) {
-# XXX has to be updated for new architectures
-# if ($format eq 'html') {
-# if (($version eq "stable" and $arch =~ /^(hurd|sh)$/)
-# || ($version eq "oldstable" and $arch =~ /^amd64$/)) {
-# print "Error: the $arch architecture didn't exist in $version.<br>\n"
-# ."Please go back and choose a different distribution.\n";
-# } else {
-# print "Error: Packages/Sources file not found.<br>\n"
-# ."If the problem persists, please inform $ENV{SERVER_ADMIN}.\n";
-# printf "<p>$file</p>";
-# }
-# &printfooter;
-# }
-# exit;
-#}
-
- my @files;
- foreach my $s (@suites) {
- foreach my $sec (@sections) {
- foreach my $a (@archs) {
- foreach my $archive (@ARCHIVES) {
- if (($searchon eq 'names' or $searchon eq 'sourcenames')
- and $exact) {
- my ( %packages, $file );
- if ($search_on_sources) {
- $file = "$FLATDIR/$s/$sec/Sources.$archive.db";
- } else {
- $file = "$FLATDIR/$s/$sec/Packages-$a.$archive.db";
- }
- if (-f $file) {
- print "DEBUG: Use file $file<br>"
- if $debug > 1;
-
- tie %packages, 'DB_File', $file, O_RDONLY
- or die "Couldn't open packages file $file: $!";
-
- if (my $data = $packages{$searchkeyword}) {
- print "DEBUG: Found result $data<br>"
- if $debug > 1;
- push @results, "$file:$data";
- }
- }
- } else {
- my $file;
- if ($search_on_sources) {
- $file = "$FLATDIR/$s/$sec/Sources.$archive";
- } else {
- $file = "$FLATDIR/$s/$sec/Packages-$a.$archive";
- }
- if (-f $file) {
- print "DEBUG: Use file $file<br>"
- if $debug > 1;
-
- # use_grep is currently way faster, though
- # I can't pinpoint exactly why, yet
- # most probably the perl regexes are
- # slow compared to the simpler grep
- # regexes
- unless ($use_grep) {
- open my $pkg_fh, '<', $file
- or die "Couldn't open packages file $file: $!";
-
- foreach (<$pkg_fh>) {
- if (/$searchkeyword/o) {
- print "DEBUG: Found result $_<br>"
- if $debug > 1;
-
- push @results, "$file:$_";
- }
- }
- } else {
- push @files, $file;
- }
- }
- }
- }
- }
+ my %packages;
+ tie %packages, 'DB_File', "$DBDIR/packages_small.db", O_RDONLY, 0666, $DB_BTREE
+ or die "couldn't tie DB $DBDIR/packages_small.db: $!";
+
+ my $result = $packages{$keyword};
+ foreach (split /\000/, $result) {
+ my @data = split ( /\s/, $_, 6 );
+ #FIXME, should be done on db generation
+ if ($data[2] =~ m,/,) {
+ $data[2] =~ s,/.*$,,;
+ } else {
+ $data[2] = 'main';