]> git.sven.stormbind.net Git - sven/scripts.git/blob - bposearch/search.pl
Ignore timeouts on the envertech portal
[sven/scripts.git] / bposearch / search.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use CGI;
5 use CGI::Carp qw(fatalsToBrowser);
6 my $query = new CGI;
7
8 print "Content-type: text/html\n\n";
9 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">', "\n";
10 print "<html><head><title>bpo package search</title></head><body>\n";
11
12
13 sub sendtheform {
14     print "<form action=\"search.pl\" method=\"POST\">\n";
15     print "<H1>bpo package search</H1>\n";
16     print "<input type=\"text\" name=\"query\" size=\"40\" maxlength=\"40\">\n";
17     print "<td valign=\"top\"><input type=\"submit\" name=\"send\" value=\"send\"></td>\n";
18     print "</form>\n";
19 }
20
21 sub performsearch {
22     my $query = @_[0];
23     print "<p>Server performed a query with the keyword ";
24     print $query;
25     print "</p>\n";
26
27     foreach my $value (qw/ main contrib non-free /) {
28         print "<h1>Results for packages listed in ", $value, ":</h1>\n";
29
30         open SOURCES, "$value/Sources" or die "Can't open Source file: $!";
31         my @sourceslist=<SOURCES>;
32         close SOURCES;
33         
34         for (my $i = 0; $i < @sourceslist; $i++) {
35             $_ = @sourceslist[$i];
36             if (/^Package:.*$query.*/) {
37                 my $pver=&findnextver($i, @sourceslist);
38                 my $pdir=&findnextdir($i, @sourceslist);
39                 print "<p>\n";
40                 print @sourceslist[$i],"<br>\n";
41                 print $pver, "<br>\n";
42                 print "<a href=\"http://www.backports.org/debian/", $pdir,"\">http://www.backports.org/debian/",$pdir,"</a><br>\n";
43                 print "</p>\n";
44
45             }
46         }
47
48     }
49 }
50
51
52 sub findnextver {
53     my ($startpos, @list) = @_;
54     for (my $i = $startpos; $i < @list; $i++) {
55         $_ = @list[$i];
56         if (/^Version:.*/) {
57             return $_;
58             last;
59         }
60     }
61 }
62
63 sub findnextdir {
64     my ($startpos, @list) = @_;
65     for (my $i = $startpos; $i < @list; $i++) {
66         $_ = @list[$i];
67         if (/^Directory:.*/) {
68             my @dirsplit = split / /, $_;
69             chomp(@dirsplit[1]);
70             return @dirsplit[1];
71             last;
72         }
73     }
74 }
75
76
77
78  if ($query->param('send') eq "send") {
79     &performsearch($query->param('query'));
80 } else {
81     &sendtheform();
82 }
83
84
85 print "</body></html>\n";