) {
# my ($file,$desc) = split(/:/);
# $file =~ s/^$portagedir\///;
# push(@foo,"$file") if ($desc =~ /$q/i);
# }
#close(DFILE);
# }
print header,start_html('Search Results: '.$q);
print ''."\n".
'Search Results: '.$q.'
'."\n" .
''.scalar(@foo).' Results found.';
print ' Searched '.$fcount.' ebuilds.' if $fcount > 0;
print ''."\n" .
'| Package |
'."\n";
my ($cat,$app);
foreach(@foo) {
($cat,$app) = split(/\//);
print '
| '.
''.$cat.'/'.$app.''." |
\n";
}
print '
';
footerpg();
}
# --------------------------------------- #
# List all subdirectories in category #
# --------------------------------------- #
sub gocat {
my $cat = param('cat') || 'none-entered';
my $go = 0; my @files;
foreach (@dirs) {
if ($cat eq $_) { $go++; }
}
if ($go == 1) {
@files = fetchcats($portagedir.'/'.$cat);
}
else {
error('Invalid category "'.$cat.'".');
}
print header,start_html('PortageView :: '.$cat);
print ''."\n".
''."\n" .
'| Package |
'."\n";
my $i = 1;
foreach my $file (@files) {
print '| '.$file.' | '."\n";
($i % 3) ? undef : print "
\n\n";
$i++;
}
print '
';
footerpg();
}
# --------------------------------------- #
# About #
# --------------------------------------- #
sub about {
print header,start_html('About PortageView');
print ''."\n".
'I wrote this to be a super quick version of emerge --search
combined with the'.
' Gentoo Package List on Gentoo\'s website. Since this program
runs on my rsync server, '.
'rsync19.us.gentoo.org, it is totally
up to date every 30 minutes with portage.'.
' Written in perl.'.
'
*Updates*
'."\n".
'2003-09-03: Will now show metadata.xml file if it exists.
'."\n".
'2003-09-15: Implemented a cached description system. Greatly improved description searching.
'."\n".
'Email Comments, etc. ==> raven [at] netpimpz.com
';
footerpg();
}
# --------------------------------------- #
# Fetch all main categories #
# --------------------------------------- #
sub fetchcats {
my $dir = shift;
my %invalid = ( eclass => 1, licenses => 1, metadata => 1, profiles => 1, scripts => 1, distfiles => 1, "sec-policy" => 1 );
opendir(DIR, $dir) || die "can't opendir $dir: $!";
my @dirs = grep { /[^.]/ && -d "$dir/$_" && !$invalid{$_}} readdir(DIR);
closedir DIR;
@dirs = sort { $a cmp $b }@dirs;
return(@dirs);
}
# --------------------------------------- #
# Display Page footer #
# --------------------------------------- #
sub footerpg {
print '
'.
'[ '.
'About PortageView v'.$version.' ]'."\n".
"