X-Git-Url: http://git.sven.stormbind.net/?a=blobdiff_plain;f=bposearch%2Fsearch.pl;fp=bposearch%2Fsearch.pl;h=e0a272a0d61d6137d92dfea76197e3ed58d688a8;hb=8a4b76f8e7c04607b3dc3155d4b98007c946d74e;hp=0000000000000000000000000000000000000000;hpb=8e9fb924b34bb14a0ce4475b03853d4b526abc33;p=sven%2Fscripts.git diff --git a/bposearch/search.pl b/bposearch/search.pl new file mode 100644 index 0000000..e0a272a --- /dev/null +++ b/bposearch/search.pl @@ -0,0 +1,85 @@ +#!/usr/bin/perl -w + +use strict; +use CGI; +use CGI::Carp qw(fatalsToBrowser); +my $query = new CGI; + +print "Content-type: text/html\n\n"; +print '', "\n"; +print "bpo package search\n"; + + +sub sendtheform { + print "
\n"; + print "

bpo package search

\n"; + print "\n"; + print "\n"; + print "
\n"; +} + +sub performsearch { + my $query = @_[0]; + print "

Server performed a query with the keyword "; + print $query; + print "

\n"; + + foreach my $value (qw/ main contrib non-free /) { + print "

Results for packages listed in ", $value, ":

\n"; + + open SOURCES, "$value/Sources" or die "Can't open Source file: $!"; + my @sourceslist=; + close SOURCES; + + for (my $i = 0; $i < @sourceslist; $i++) { + $_ = @sourceslist[$i]; + if (/^Package:.*$query.*/) { + my $pver=&findnextver($i, @sourceslist); + my $pdir=&findnextdir($i, @sourceslist); + print "

\n"; + print @sourceslist[$i],"
\n"; + print $pver, "
\n"; + print "http://www.backports.org/debian/",$pdir,"
\n"; + print "

\n"; + + } + } + + } +} + + +sub findnextver { + my ($startpos, @list) = @_; + for (my $i = $startpos; $i < @list; $i++) { + $_ = @list[$i]; + if (/^Version:.*/) { + return $_; + last; + } + } +} + +sub findnextdir { + my ($startpos, @list) = @_; + for (my $i = $startpos; $i < @list; $i++) { + $_ = @list[$i]; + if (/^Directory:.*/) { + my @dirsplit = split / /, $_; + chomp(@dirsplit[1]); + return @dirsplit[1]; + last; + } + } +} + + + + if ($query->param('send') eq "send") { + &performsearch($query->param('query')); +} else { + &sendtheform(); +} + + +print "\n";