X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=cgi-bin%2Fsearch_packages.pl;h=5a31a1c961e82075a9b192d158560b5871372426;hb=4049e331db0eba40193f0ec30f8e68bb020595a4;hp=48fabb4c35f3ebac80cdecff2f5e25d2ab7ed241;hpb=f7dae3f81707c8cab707df20ba2742a0087baf33;p=deb%2Fpackages.git diff --git a/cgi-bin/search_packages.pl b/cgi-bin/search_packages.pl index 48fabb4..5a31a1c 100755 --- a/cgi-bin/search_packages.pl +++ b/cgi-bin/search_packages.pl @@ -12,6 +12,7 @@ # see http://www.fsf.org/copyleft/gpl.html for a copy of the license use strict; +use lib '../lib'; use CGI qw( -oldstyle_urls ); use CGI::Carp qw( fatalsToBrowser ); use POSIX; @@ -21,6 +22,8 @@ use DB_File; use Benchmark; use Deb::Versions; +use Packages::Config qw( $DBDIR $ROOT $SEARCH_CGI $SEARCH_PAGE + @SUITES @SECTIONS @ARCHIVES @ARCHITECTURES ); use Packages::CGI; use Packages::Search qw( :all ); use Packages::HTML (); @@ -46,37 +49,9 @@ $debug = 0 if !defined($debug) || $debug !~ /^\d+$/o; $Packages::CGI::debug = $debug; # read the configuration -our $config_read_time ||= 0; our $db_read_time ||= 0; -our ( $topdir, $ROOT, @SUITES, @SECTIONS, @ARCHIVES, @ARCHITECTURES ); -# FIXME: move to own module -my $modtime = (stat( "../config.sh" ))[9]; -if ($modtime > $config_read_time) { - if (!open (C, '<', "../config.sh")) { - error( "Internal: Cannot open configuration file." ); - } - while () { - next if /^\s*\#/o; - chomp; - $topdir = $1 if /^\s*topdir="?([^\"]*)"?\s*$/o; - $ROOT = $1 if /^\s*root="?([^\"]*)"?\s*$/o; - $Packages::HTML::HOME = $1 if /^\s*home="?([^\"]*)"?\s*$/o; - $Packages::HTML::SEARCH_CGI = $1 if /^\s*searchcgi="?([^\"]*)"?\s*$/o; - $Packages::HTML::SEARCH_PAGE = $1 if /^\s*searchpage="?([^\"]*)"?\s*$/o; - $Packages::HTML::WEBMASTER_MAIL = $1 if /^\s*webmaster="?([^\"]*)"?\s*$/o; - $Packages::HTML::CONTACT_MAIL = $1 if /^\s*contact="?([^\"]*)"?\s*$/o; - @SUITES = split(/\s+/, $1) if /^\s*suites="?([^\"]*)"?\s*$/o; - @SECTIONS = split(/\s+/, $1) if /^\s*sections="?([^\"]*)"?\s*$/o; - @ARCHIVES = split(/\s+/, $1) if /^\s*archives="?([^\"]*)"?\s*$/o; - @ARCHITECTURES = split(/\s+/, $1) if /^\s*architectures="?([^\"]*)"?\s*$/o; - } - close (C); - debug( "read config ($modtime > $config_read_time)" ); - $config_read_time = $modtime; -} -my $DBDIR = $topdir . "/files/db"; -my $thisscript = $Packages::HTML::SEARCH_CGI; +&Packages::Config::init( '../' ); if (my $path = $input->param('path')) { my @components = map { lc $_ } split /\//, $path; @@ -95,6 +70,8 @@ if (my $path = $input->param('path')) { $input->param('archive', $_); } elsif ($ARCHITECTURES{$_}) { $input->param('arch', $_); + } elsif ($_ eq 'source') { + $input->param('searchon','sourcenames'); } } } @@ -102,35 +79,35 @@ if (my $path = $input->param('path')) { my ( $format, $keyword, $case, $subword, $exact, $searchon, @suites, @sections, @archives, @archs ); -# my %params_def = ( keywords => { default => undef, -# match => '^\s*([-+\@\w\/.:]+)\s*$', -# var => \$keyword }, -# suite => { default => 'stable', match => '^([\w-]+)$', -# alias => 'version', array => ',', -# var => \@suites, -# replace => { all => \@SUITES } }, -# archive => { default => 'all', match => '^([\w-]+)$', -# array => ',', var => \@archives, -# replace => { all => \@ARCHIVES } }, -# case => { default => 'insensitive', match => '^(\w+)$', -# var => \$case }, -# official => { default => 0, match => '^(\w+)$' }, -# subword => { default => 0, match => '^(\w+)$', -# var => \$subword }, -# exact => { default => undef, match => '^(\w+)$', -# var => \$exact }, -# searchon => { default => 'all', match => '^(\w+)$', -# var => \$searchon }, -# section => { default => 'all', match => '^([\w-]+)$', -# alias => 'release', array => ',', -# var => \@sections, -# replace => { all => \@SECTIONS } }, -# arch => { default => 'any', match => '^(\w+)$', -# array => ',', var => \@archs, replace => -# { any => \@ARCHITECTURES } }, -# format => { default => 'html', match => '^(\w+)$', -# var => \$format }, -# ); +my %params_def = ( keywords => { default => undef, + match => '^\s*([-+\@\w\/.:]+)\s*$', + var => \$keyword }, + suite => { default => 'stable', match => '^([\w-]+)$', + alias => 'version', array => ',', + var => \@suites, + replace => { all => \@SUITES } }, + archive => { default => 'all', match => '^([\w-]+)$', + array => ',', var => \@archives, + replace => { all => \@ARCHIVES } }, + case => { default => 'insensitive', match => '^(\w+)$', + var => \$case }, + official => { default => 0, match => '^(\w+)$' }, + subword => { default => 0, match => '^(\w+)$', + var => \$subword }, + exact => { default => undef, match => '^(\w+)$', + var => \$exact }, + searchon => { default => 'all', match => '^(\w+)$', + var => \$searchon }, + section => { default => 'all', match => '^([\w-]+)$', + alias => 'release', array => ',', + var => \@sections, + replace => { all => \@SECTIONS } }, + arch => { default => 'any', match => '^(\w+)$', + array => ',', var => \@archs, replace => + { any => \@ARCHITECTURES } }, + format => { default => 'html', match => '^(\w+)$', + var => \$format }, + ); my %opts; my %params = Packages::Search::parse_params( $input, \%params_def, \%opts ); @@ -261,7 +238,7 @@ if (!@Packages::CGI::fatal_errors && !@results) { if ($exact) { $printed++; - hint( "You have searched only for exact matches of the package name. You can try to search for package names that contain your search string." ); + hint( "You have searched only for exact matches of the package name. You can try to search for package names that contain your search string." ); } } else { if (($suites_enc eq 'all') @@ -274,10 +251,10 @@ if (!@Packages::CGI::fatal_errors && !@results) { unless ($subword) { $printed++; - hint( "You have searched only for words exactly matching your keywords. You can try to search allowing subword matching." ); + hint( "You have searched only for words exactly matching your keywords. You can try to search allowing subword matching." ); } } - hint( ( $printed ? "Or you" : "You" )." can try a different search on the Packages search page." ); + hint( ( $printed ? "Or you" : "You" )." can try a different search on the Packages search page." ); } } @@ -406,7 +383,7 @@ if (@results) { #print_results(\@results, \%opts) if @results;; my $tet1 = new Benchmark; my $tetd = timediff($tet1, $tet0); -print "Total page evaluation took ".timestr($petd)."
" +print "Total page evaluation took ".timestr($tetd)."
" if $debug_allowed; my $trailer = Packages::HTML::trailer( $ROOT );