diff --git a/en/cgi/ports.cgi b/en/cgi/ports.cgi index 7f175c9b69..0afb3e5dba 100755 --- a/en/cgi/ports.cgi +++ b/en/cgi/ports.cgi @@ -1,745 +1,754 @@ #!/usr/bin/perl -T # -# Copyright (c) 1996-2002 Wolfram Schneider , Berlin. +# Copyright (c) 1996-2003 Wolfram Schneider # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD$ +# $FreeBSD: www/en/cgi/ports.cgi,v 1.64 2003/03/04 11:56:15 roam Exp $ # # ports.cgi - search engine for FreeBSD ports # o search for a port by name or description # o search for new or updated ports # # # If you want use this script on your own host this line must # work for you: $ cvs rdiff -D'last week' ports/INDEX sub init_variables { $cvsroot = '/usr/local/www/cvsroot/FreeBSD'; # $CVSROOT $localPrefix = '/usr/ports'; # ports prefix $ports_database = 'ports/INDEX'; # unset $ENV{'CVSROOT'}; @cvscmd = ('cvs', '-Q', '-R', '-d', $cvsroot); # URL of ports tree for browsing $remotePrefixFtp = 'ports'; # 'ftp://ftp.FreeBSD.org/pub/FreeBSD/branches/-current/ports'; # URL of ports tree for download $remotePrefixFtpDownload = - 'ftp://ftp.FreeBSD.org/pub/FreeBSD/branches/-current/ports'; + 'http://cvsweb.FreeBSD.org/ports'; + $remoteSuffixFtpDownload = '%s.tar.gz?tarball=1'; # where to get -current packages local($p) = 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386'; local($palpha) = 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/alpha'; local($pia64) = 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/ia64'; local($psparc64) = 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/sparc64'; $remotePrefixFtpPackagesDefault = '4.7-STABLE/i386'; %remotePrefixFtpPackages = ( '5.0-CURRENT/i386', "$p/packages-current/All", '4.7-STABLE/i386', " $p/packages-4-stable/All", '5.0-RELEASE/i386', "$p/packages-5.0-release/All", '4.7-RELEASE/i386', "$p/packages-4.7-release/All", '4.6-RELEASE/i386', "$p/packages-4.6-release/All", '5.0-CURRENT/alpha', "$palpha/packages-current/All", '4.7-STABLE/alpha', "$palpha/packages-4-stable/All", '5.0-RELEASE/alpha', "$palpha/packages-5.0-release/All", '4.7-RELEASE/alpha', "$palpha/packages-4.7-release/All", '4.6-RELEASE/alpha', "$palpha/packages-4.6-release/All", '5.0-CURRENT/ia64', "$pia64/packages-current/All", '5.0-RELEASE/ia64', "$pia64/packages-5.0-release/All", '5.0-CURRENT/sparc64', "$psparc64/packages-current/All", '5.0-RELEASE/sparc64', "$psparc64/packages-5.0-release/All", ); %relDate = ( '5.0-CURRENT/i386', 'today', '4.7-STABLE/i386', 'today', '5.0-RELEASE/i386', '2003-01-19 17:34:28 UTC', '4.7-RELEASE/i386', '2002-10-10 14:47:54 UTC', '4.6-RELEASE/i386', '2002-06-15 23:01:20 UTC', '5.0-CURRENT/alpha', 'today', '4.7-STABLE/alpha', 'today', '5.0-RELEASE/alpha', '2003-01-19 17:34:28 UTC', '4.7-RELEASE/alpha', '2002-10-10 14:47:54 UTC', '4.6-RELEASE/alpha', '2002-06-15 23:01:20 UTC', '5.0-CURRENT/ia64', 'today', '5.0-RELEASE/ia64', '2003-01-19 17:34:28 UTC', '5.0-CURRENT/sparc64', 'today', '5.0-RELEASE/sparc64', '2003-01-19 17:34:28 UTC', ); $remotePrefixHtml = '../ports'; # CVS Web interface $remotePrefixCvs = 'http://cvsweb.FreeBSD.org/ports'; # Ports documentation $portsDesc = '../ports/'; # location of the tiny BSD daemon $daemonGif = ''; # visible E-Mail address, plain text $mailto = 'www@FreeBSD.org'; # Mailinglist for FreeBSD Ports $mailtoList = 'ports@FreeBSD.org'; # use mailto:email?subject $mailtoAdvanced = 'yes'; # the URL if you click at the E-Mail address (see below) $mailtoURL = 'http://www.FreeBSD.org/ports/'; $mailtoURL = "mailto:$mailto" if !$mailtoURL; # security $ENV{'PATH'} = '/bin:/usr/bin'; # ports download sources script $pds = 'pds.cgi'; # make plain text URLs clickable cgi script $url = 'url.cgi'; local($packageDB) = '../ports/packages.exists'; &packages_exist($packageDB, *packages) if -f $packageDB; } sub packages_exist { local($file, *p) = @_; open(P, $file) || do { warn "open $file: $!\n"; warn "Cannot create packages links\n"; return 1; }; while(

) { chop; $p{$_} = 1; } close P; return 0; } # return the date of the last ports database update sub last_update { local($file) = "$cvsroot/$ports_database,v"; local($date) = 'unknown'; open(DB, $file) || do { &warn("$file: $!\n"); &exit; }; local($head); while() { $head = $1 if (/^head\s+([0-9.]+);?\s*$/); if (/^date/ && /^date\s+([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+);\s+/) { $date = ($1 < 100 ? $1 + 1900 : $1) . qq{-$2-$3 $4:$5:$6 UTC}; last; } } close DB; return $date . "; based on revision " . $head; } sub last_update_message { return "

Last database update: " . &last_update . "
\n"; } sub dec { local($_) = @_; s/\+/ /g; # '+' -> space s/%(..)/pack("c",hex($1))/ge; # '%ab' -> char ab return($_); } sub header { print "Content-type: text/html\n"; print "\n"; } # $indent is a bit of optional data processing I put in for # formatting the data nicely when you are emailing it. # This is derived from code by Denis Howe # and Thomas A Fine sub decode_form { local($form, *data, $indent, $key, $_) = @_; foreach $_ (split(/&/, $form)) { ($key, $_) = split(/=/, $_, 2); $_ =~ s/\+/ /g; # + -> space $key =~ s/\+/ /g; # + -> space $_ =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # undo % escapes $key =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # undo % escapes $_ =~ s/[\r\n]+/\n\t/g if defined($indent); # indent data after \n $data{$key} = $_; } } # encode unknown data for use in a URL sub encode_url { local($_) = @_; s/([\000-\032\;\/\?\:\@\&\=\%\'\"\`\<\>\177-\377 ])/sprintf('%%%02x',ord($1))/eg; # s/%20/+/g; $_; } sub warn { print "$_[0]" } sub env { defined($ENV{$_[0]}) ? $ENV{$_[0]} : undef; } sub exit { exit 0 }; sub readindex { local($date, *var, *msec) = @_; local(@co) = ('co', '-p'); if ($date =~ /^rev([1-9]+\.[0-9]+)$/) { # diff by revision push(@co, ('-r', $1)); } else { # diff by date push(@co, ('-D', $date)); } push(@co, $ports_database); local(@tmp, @s); open(C, "-|") || exec (@cvscmd, @co); while() { chop; @tmp = split(/\|/); $var{"$tmp[4]"} = $_; @s = split(/\s+/, $tmp[6]); foreach (@s) { $msec{"$tmp[4],$_"} = 1; } } close C; } # extract sub collections sub readcoll { local(@co) = ('co', '-p', 'ports/INDEX'); local(@a, @b, %key); local($file) = '../ports/categories'; if (-r $file && open(C, $file)) { while() { chop; if (/^\s*\"([^\"]+)\"\s*,/) { #" @b = split(/\s+/, $1); foreach (@b) { if (!defined($key{$_})) { $key{$_} = 1; } } } } } else { open(C, "-|") || exec (@cvscmd, @co); while() { chop; @a = split('\|'); @b = split(/\s+/, $a[6]); foreach (@b) { if (!defined($key{$_})) { $key{$_} = 1; } } } } close C; @a = (); foreach (sort keys %key) { push(@a, $_); } return @a; } # basic function for HTML output sub out { local($line, $old) = @_; local($version, $path, $local, $comment, $descfile, $email, $sections, $bdepends, $rdepends, @rest) = split(/\|/, $line); if ($path =~ m%^$localPrefix/([^/]+)%o) { if (!$out_sec || $1 ne $out_sec) { print "\n" if $counter > 0; print qq{\n

} . qq{Category $1} . "

\n
\n"; $out_sec = $1; } } $counter++; $pathDownload = $path; $pathB= $path; $pathB =~ s/^$localPrefix/ports/o; $path =~ s/^$localPrefix/$remotePrefixFtp/o; $pathDownload =~ s/^$localPrefix/$remotePrefixFtpDownload/o; + if ($remoteSuffixFtpDownload) { + if (substr($remoteSuffixFtpDownload, 0, 2) eq '%s') { + $pathDownload =~ m,([^/]+)+$,; + $pathDownload .= "/$1" . substr($remoteSuffixFtpDownload, 2); + } else { + $pathDownload .= $remoteSuffixFtpDownload; + } + } $descfile =~ s/^$localPrefix/$remotePrefixFtp/o; print qq{
$version\n}; print qq{
$comment
\n}; if ($old) { local($l) = $descfile; $l =~ s%^$remotePrefixFtp%$remotePrefixCvs%o; $l =~ s%/([^/]+)$%/Attic/$1%; print qq{Was Maintained by: $email
} . qq{Removed why
}; } else { local($l) = $path; $l =~ s%^$remotePrefixFtp%$remotePrefixCvs%o; #$l .= '/Makefile'; print qq{Maintained by: $email
}; local(@s) = split(/\s+/, $sections); if ($#s > 0) { print qq{Also listed in: }; foreach (@s) { print qq{$_ } if $_ ne $out_sec; } print "
\n"; } if ($bdepends || $rdepends) { local($flag) = 0; local($last) = ''; print qq{Requires: }; foreach (sort split(/\s+/, "$bdepends $rdepends")) { # delete double entries next if $_ eq $last; $last = $_; print ", " if $flag; $flag++; print qq{$_}; } print "
\n"; } print qq[Description : Sources :\n]; if (($release eq $remotePrefixFtpPackagesDefault && $packages{"$version.tgz"}) || $release ne $remotePrefixFtpPackagesDefault ) { print qq[Package :\n]; } print qq[Changes : Download

]; }; }; # new/updated/removed ports output sub out_ports { if ($type eq "new") { foreach $key (sort keys %today) { if (!$past{$key}) { if ($section eq "all" || $msec{"$key,$section"}) { &out($today{$key}, 0); } } } } elsif ($type eq "removed") { foreach $key (sort keys %past) { if (!$today{$key}) { if ($section eq "all" || $msec{"$key,$section"}) { &out($past{$key}, 1); } } } } else { # changed foreach $key (sort keys %today) { if ($past{$key} && $past{$key} ne $today{$key}) { @a = split(/\|/, $today{$key}); @b = split(/\|/, $past{$key}); next if $a[0] eq $b[0]; if ($section eq "all" || $msec{"$key,$section"}) { &out($today{$key}, 0); } } } } } # search and output sub search_ports { local(@a) = (); local($key, $name, $text); foreach $key (sort keys %today) { next if $today{$key} !~ /$query/oi; @a = split(/\|/, $today{$key}); $name = $a[0]; #$name =~ s/(\W)/\\$1/g; $text = $a[3]; #$text =~ s/(\W)/\\$1/g; #warn "$stype:$query: $name $text\n"; if ($stype eq "name" && $name =~ /$query/o) { &out($today{$key}, 0); } elsif ($stype eq "text" && $text =~ /$query/oi) { &out($today{$key}, 0); } elsif ($stype eq "all" && ($text =~ /$query/oi || $name =~ /$query/io)) { &out($today{$key}, 0); } elsif ($stype eq 'maintainer' && $a[5] =~ /$query/io) { &out($today{$key}, 0); } elsif ($stype eq 'requires' && ($a[7] =~ /$query/io || $a[8] =~ /$query/io)) { &out($today{$key}, 0); } } } sub forms { print qq{ FreeBSD Ports Changes

FreeBSD Ports Changes $daemonGif

FreeBSD Ports [short description followed ...] FAQ

}; print qq{ "Package Name" search for the name of port or distribution. "Description" search case-insensitive in a short comment about the port. "All" search case-insensitive for the package name and in the description about the port.

Search for:
}; print qq{

"New" print ports which are new in the ports collection or moved from an other ports section. "Changed" print updated ports. "Removed" print ports which are deleted from ports collections or moved to an other ports section.

\n\n

}; } sub footer { print qq{ © 1996-2002 by Wolfram Schneider. All rights reserved.
}; - #print q{$FreeBSD$} . "
\n"; + #print q{$FreeBSD: www/en/cgi/ports.cgi,v 1.64 2003/03/04 11:56:15 roam Exp $} . "
\n"; print qq{Please direct questions about this service to $mailto
\n}; print qq{General questions about FreeBSD ports should be sent to } . qq{} . qq{$mailtoList
\n}; print &last_update_message; print "
\n

\n"; } sub footer2 { print "\n\n\n"; } sub check_input { if ($query) { $stype = "all" if !$stype; if (!($stype eq "name" || $stype eq "text" || $stype eq "maintainer" || $stype eq "requires" || $stype eq "all")) { &warn("unknown search type ``$type'', use `all', `text', `name', 'requires', or `maintainer'\n"); &exit(0); } else { return; } } if (!($type eq "new" || $type eq "changed" || $type eq "removed")) { &warn("unknown type `$type', use `new', `changed', or `removed'\n"); &exit(0); } if ($time !~ /^[1-9][0-9]*\s+(month|week)\s+ago$/ && # support diff by revision too $time !~ /^rev[1-9]+\.[0-9]+$/ ) { &warn("unkwnon date: `$time'\n"); &exit(0); } } sub faq { print qq{\nFAQ\n

FreeBSD Ports Changed FAQ

Keywords

Description
A more detailed description.
Download
Download the ports directory.
Package
Download the pre-compiled software package.
Changes
Read the latest changes.
Sources
Links to all source files.

Misc

All links point to the FreeBSD-stable version and not to the latest releases.

The script ports.cgi use the file FreeBSD-CVS/ports/INDEX,v as database for all operation. INDEX,v will be updated by hand by the portsmeister.

You may also search the ports manual pages.

Get the Source of this script.

Back to the search engine


}; } # # Main # &init_variables; $query_string = &env('QUERY_STRING'); $path_info = &env('PATH_INFO'); &decode_form($query_string, *form); $type = $form{'type'}; $time = $form{'time'}; $section = $form{'sektion'}; $query = $form{'query'}; $stype = $form{'stype'}; $release = $form{'release'}; $release = $remotePrefixFtpPackagesDefault if !$release || !defined($remotePrefixFtpPackages{$release}); $script_name = &env('SCRIPT_NAME'); if ($path_info eq "/source") { print "Content-type: text/plain\n\n"; open(R, $0) || do { print "ick!\n"; &exit; }; while() { print } close R; &exit; } # Full text search in ports//port>/pkg-descr if ($stype eq 'pkgdescr') { local($url) = 'http://www.FreeBSD.org/cgi/search.cgi?source=pkgdescr&max=25'; $query =~ s/\s+/+/g; print "Location: $url&words=$query\n"; print "Content-type: text/plain\n\n"; &exit; } &header; if ($path_info eq "/faq.html") { &faq; &footer; &footer2; &exit(0); } # allow `/ports.cgi?netscape' where 'netscape' is the query port to search # this make links to this script shorter if (!$query && !$type && $query_string =~ /^([^=&]+)$/) { $query = $1; } # automatically read collections, need only 0.2 sec on a pentium @sec = &readcoll; &forms; $query =~ s/^\s+//; $query =~ s/\s+$//; if ($query_string eq "" || (!$query && !$type)) { &footer; &footer2; &exit(0); } #warn "type: $type time: $time section: $section stype: $stype query: $query"; &check_input; $counter = 0; # search if ($query) { &readindex($relDate{$release}, *today, *msec); $query =~ s/([^\w\^])/\\$1/g; &search_ports; } # ports changes else { &readindex('today', *today, *msec); &readindex($time, *past, *msec); &out_ports; } if (!$counter) { print "Sorry, nothing found.\n"; print qq{You may look for other } . qq{FreeBSD Search Services.\n}; } else { print "
\n"; } print "
\n"; &footer; &footer2;