1997-11-23 23:23:08 +01:00
|
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
|
|
# convert a ports INDEX file to HTML
|
|
|
|
|
#
|
|
|
|
|
# by John Fieber <jfieber@freebsd.org>
|
|
|
|
|
# Mon May 13 10:31:58 EST 1996
|
2008-08-25 14:39:17 +02:00
|
|
|
|
# $FreeBSD: www/ja/ports/portindex,v 1.32 2006/08/19 21:24:43 hrs Exp $
|
1997-11-23 23:23:08 +01:00
|
|
|
|
# The FreeBSD Japanese Documentation Project
|
2004-01-10 19:38:00 +01:00
|
|
|
|
# Original revision: 1.49
|
1997-11-23 23:23:08 +01:00
|
|
|
|
|
|
|
|
|
############################################################
|
|
|
|
|
|
1998-08-26 17:01:06 +02:00
|
|
|
|
# Load local config file. You can override in portindex.conf
|
|
|
|
|
# the variables for the default web and the ftp server. This
|
|
|
|
|
# make it easy to maintain a local web mirror and let the
|
|
|
|
|
# URL point to yourself and not to the standard FreeBSD FTP server.
|
|
|
|
|
$config = $0 . '.' . 'conf';
|
|
|
|
|
do $config if -f $config;
|
|
|
|
|
|
1997-11-23 23:23:08 +01:00
|
|
|
|
# This is the base of where we ftp stuff from
|
1998-08-26 17:01:06 +02:00
|
|
|
|
if ($ENV{'MASTER_FTP_SERVER'}) {
|
|
|
|
|
$ftpserver = $ENV{'MASTER_FTP_SERVER'};
|
|
|
|
|
} else {
|
2001-11-19 16:35:49 +01:00
|
|
|
|
$ftpserver = 'ftp://ftp.FreeBSD.org' if !$ftpserver;
|
1998-08-26 17:01:06 +02:00
|
|
|
|
}
|
2001-05-21 16:47:09 +02:00
|
|
|
|
$base = "" if !$base;
|
1998-08-26 17:01:06 +02:00
|
|
|
|
$baseHTTP = $base if !$baseHTTP;
|
2003-09-25 19:10:22 +02:00
|
|
|
|
$baseFTP = "$ftpserver/pub/FreeBSD/ports/ports";
|
2008-08-25 14:39:17 +02:00
|
|
|
|
my $baseCVSWEB = 'http://www.FreeBSD.org/cgi/cvsweb.cgi/';
|
2001-11-19 16:35:49 +01:00
|
|
|
|
$urlcgi = 'http://www.FreeBSD.org/cgi/url.cgi' if !$urlcgi;
|
1999-03-09 16:13:47 +01:00
|
|
|
|
$packagesURL = "$ftpserver/pub/FreeBSD/ports/i386/packages-stable/All/"
|
1998-08-26 17:01:06 +02:00
|
|
|
|
if !$packagesURL;
|
|
|
|
|
# support tar on the fly or gzip'ed tar on the fly
|
2001-05-21 16:47:09 +02:00
|
|
|
|
$ftparchive = '';
|
2001-07-14 18:41:46 +02:00
|
|
|
|
$ftparchive = '.tar' if !defined $ftparchive;
|
1997-11-23 23:23:08 +01:00
|
|
|
|
|
1999-03-09 16:13:47 +01:00
|
|
|
|
# ports download sources script
|
2001-11-19 16:35:49 +01:00
|
|
|
|
$pds = 'http://www.FreeBSD.org/cgi/pds.cgi';
|
1999-03-09 16:13:47 +01:00
|
|
|
|
|
1998-04-25 18:41:06 +02:00
|
|
|
|
# better layout and link to the sources
|
|
|
|
|
if ($urlcgi) {
|
|
|
|
|
$baseHTTP = $urlcgi . '?' . $baseHTTP;
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-23 23:23:08 +01:00
|
|
|
|
$today = &getdate;
|
|
|
|
|
|
1998-08-12 15:06:48 +02:00
|
|
|
|
&packages_exist('packages.exists', *packages);
|
2001-05-21 16:47:09 +02:00
|
|
|
|
&category_description(($ARGV[1] || '.') . '/categories', *category_description);
|
1997-11-23 23:23:08 +01:00
|
|
|
|
&main;
|
|
|
|
|
|
|
|
|
|
sub getdate {
|
|
|
|
|
# @months = ("January", "February", "March", "April", "May","June",
|
|
|
|
|
# "July", "August", "September", "October", "November", "December");
|
|
|
|
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
|
|
|
|
$year += 1900;
|
2000-01-10 12:08:53 +01:00
|
|
|
|
# return "Last modified: $mday-$months[$mon]-$year";
|
1997-11-23 23:23:08 +01:00
|
|
|
|
$mon++;
|
2000-01-10 12:08:53 +01:00
|
|
|
|
return "<22>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: $year ǯ $mon <20><> $mday <20><>";
|
1997-11-23 23:23:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub header {
|
|
|
|
|
local ($fh, $htext) = @_;
|
2006-08-19 23:26:51 +02:00
|
|
|
|
print $fh "<!DOCTYPE html PUBLIC \"-//FreeBSD//DTD HTML 4.01 Transitional-Based Extension//EN\" [\n";
|
2001-11-19 16:35:49 +01:00
|
|
|
|
print $fh "<!ENTITY base CDATA '..'>\n";
|
1997-11-23 23:23:08 +01:00
|
|
|
|
print $fh "<!ENTITY date \"<em>$today</em>\">\n";
|
2001-11-19 16:35:49 +01:00
|
|
|
|
print $fh "<!ENTITY title '$htext'>\n";
|
1997-11-23 23:23:08 +01:00
|
|
|
|
print $fh "<!ENTITY blurb SYSTEM \"ports.inc\">\n";
|
2006-08-19 23:26:51 +02:00
|
|
|
|
print $fh "<!ENTITY % navinclude.ports \"INCLUDE\">\n";
|
2001-11-19 16:35:49 +01:00
|
|
|
|
print $fh "<!ENTITY email 'ports'>\n";
|
1997-11-23 23:23:08 +01:00
|
|
|
|
print $fh "]>\n";
|
|
|
|
|
print $fh "<html>&header;\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub footer {
|
|
|
|
|
local ($fh, $ftext) = @_;
|
|
|
|
|
print $fh "\n$ftext\n";
|
|
|
|
|
print $fh "&footer;\n";
|
|
|
|
|
print $fh "</BODY>\n</HTML>\n";
|
|
|
|
|
}
|
|
|
|
|
|
1998-08-12 15:06:48 +02:00
|
|
|
|
sub packages_exist {
|
|
|
|
|
local($file, *p) = @_;
|
|
|
|
|
|
|
|
|
|
open(P, $file) || do {
|
|
|
|
|
warn "open $file: $!\n";
|
|
|
|
|
warn "Cannot create packages links\n";
|
|
|
|
|
return 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
while(<P>) {
|
|
|
|
|
chop;
|
|
|
|
|
$p{$_} = 1;
|
|
|
|
|
}
|
|
|
|
|
close P;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 16:13:47 +01:00
|
|
|
|
sub category_description {
|
|
|
|
|
local($file, *p) = @_;
|
|
|
|
|
|
|
|
|
|
open(P, $file) || do {
|
|
|
|
|
warn "open $file: $!\n";
|
|
|
|
|
warn "Cannot find category description\n";
|
|
|
|
|
return 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
local($category, $description);
|
|
|
|
|
while(<P>) {
|
|
|
|
|
# ignore comments
|
|
|
|
|
next if /^\s*#/;
|
|
|
|
|
|
|
|
|
|
($category, $description) = /^\s*"([^"]+)",\s*"([^"]+)/;
|
|
|
|
|
$p{$category} = $description;
|
|
|
|
|
}
|
|
|
|
|
close P;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-23 23:23:08 +01:00
|
|
|
|
sub main {
|
|
|
|
|
|
|
|
|
|
$sep = "<B>:</B>";
|
|
|
|
|
|
1998-02-12 03:32:52 +01:00
|
|
|
|
# 'COMMENT' translation database
|
|
|
|
|
if (open(COMF, "comments.ja")) {
|
|
|
|
|
while (<COMF>) {
|
|
|
|
|
($a, $b) = split('\|');
|
|
|
|
|
next if !defined($b);
|
|
|
|
|
chop($b);
|
|
|
|
|
$b =~ s/&/&/g;
|
|
|
|
|
$b =~ s/</</g;
|
|
|
|
|
$b =~ s/>/>/g;
|
|
|
|
|
$descLANG{$a} = $b;
|
|
|
|
|
}
|
|
|
|
|
}
|
1997-12-07 16:44:08 +01:00
|
|
|
|
|
1999-05-06 17:15:22 +02:00
|
|
|
|
open(INDEX, $ARGV[0]);
|
|
|
|
|
while (<INDEX>) {
|
1997-11-23 23:23:08 +01:00
|
|
|
|
chop;
|
|
|
|
|
s/&/&/g;
|
|
|
|
|
s/</</g;
|
|
|
|
|
s/>/>/g;
|
|
|
|
|
|
|
|
|
|
# Read a record
|
|
|
|
|
($name, $loc, $prefix, $desc, $ldesc, $owner, $cats,
|
1999-05-06 17:15:22 +02:00
|
|
|
|
$bdep, $rdep, $www) = split('\|');
|
1997-11-23 23:23:08 +01:00
|
|
|
|
|
|
|
|
|
# Check for double hyphens in the name (--).
|
|
|
|
|
$name =~ s/--/-/g;
|
|
|
|
|
|
|
|
|
|
# Split the categories into an array
|
|
|
|
|
@cat = split("[ \t]+", $cats);
|
|
|
|
|
|
|
|
|
|
$catkey{$name} = $cat[0];
|
|
|
|
|
|
1999-03-09 16:13:47 +01:00
|
|
|
|
local($sourcepath) = $loc;
|
|
|
|
|
$sourcepath =~ s%/usr/%%;
|
|
|
|
|
|
1998-02-12 03:32:52 +01:00
|
|
|
|
# desc translation
|
|
|
|
|
($lloc = $loc) =~ s@^/usr/ports/@@;
|
|
|
|
|
$desc = $descLANG{$lloc}
|
|
|
|
|
if ($descLANG{$lloc} ne '');
|
|
|
|
|
|
1997-11-23 23:23:08 +01:00
|
|
|
|
foreach $i (@cat) {
|
|
|
|
|
|
|
|
|
|
$stats{$i}++;
|
|
|
|
|
|
|
|
|
|
# figure out the FTP url
|
2003-09-25 19:10:22 +02:00
|
|
|
|
$loc =~ s/\/usr\//$baseCVSWEB/;
|
2001-05-21 16:47:09 +02:00
|
|
|
|
$ldesc =~ s/\/usr\//$baseHTTP/;
|
1997-11-23 23:23:08 +01:00
|
|
|
|
|
|
|
|
|
# The name description and maintainer
|
2001-07-14 18:41:46 +02:00
|
|
|
|
$data{$i} .= "<DT><B><A NAME=\"$name\"></A><A HREF=\"${loc}${ftparchive}\">$name</A></B> ";
|
1998-08-12 15:06:48 +02:00
|
|
|
|
|
|
|
|
|
$data{$i} .= "<DD>$desc<BR><A HREF=\"$ldesc\"><3E>ܤ<EFBFBD><DCA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></A>";
|
2003-09-25 19:10:22 +02:00
|
|
|
|
if ($packages{"$name.tbz"}) {
|
|
|
|
|
$data{$i} .= qq{ | <a href="$packagesURL$name.tbz"><3E>ѥå<D1A5><C3A5><EFBFBD><EFBFBD><EFBFBD></a>};
|
|
|
|
|
} elsif ($packages{"$name.tgz"}) {
|
1998-08-12 15:06:48 +02:00
|
|
|
|
$data{$i} .= qq{ | <a href="$packagesURL$name.tgz"><3E>ѥå<D1A5><C3A5><EFBFBD><EFBFBD><EFBFBD></a>};
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-09 16:13:47 +01:00
|
|
|
|
$data{$i} .= qq{ | <A HREF="$pds?$sourcepath"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></A>};
|
|
|
|
|
|
1999-05-06 17:15:22 +02:00
|
|
|
|
if ($www ne "") {
|
|
|
|
|
$data{$i} .= qq{ | <a href="$www">Main Web Site</a>};
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-23 23:23:08 +01:00
|
|
|
|
$ownerurl = $owner;
|
|
|
|
|
$ownerurl =~ s/</</g;
|
|
|
|
|
$owenrurl =~ s/>/>/g;
|
|
|
|
|
$data{$i} .=
|
|
|
|
|
"<BR><I><3E>ݼ<EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>:</I> <A HREF=\"mailto:$ownerurl\">$owner</A>";
|
|
|
|
|
|
|
|
|
|
# If there are any dependencies, list them
|
|
|
|
|
if ($bdep ne "" || $rdep ne "") {
|
|
|
|
|
$data{$i} .= "<BR><I>ɬ<>פʤ<D7A4><CAA4><EFBFBD>:</I> ";
|
|
|
|
|
@dep = split(/ /, "$bdep $rdep");
|
1999-03-09 16:13:47 +01:00
|
|
|
|
local($last) = '';
|
|
|
|
|
foreach $j (sort @dep) {
|
|
|
|
|
next if $j eq $last;
|
|
|
|
|
$last = $j;
|
|
|
|
|
$data{$i} .= " <A HREF=\"##$j##.html#$j\">$j</A>,";
|
1997-11-23 23:23:08 +01:00
|
|
|
|
}
|
|
|
|
|
# remove the trailing comma
|
|
|
|
|
chop $data{$i};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If the port is listed in more than one category, throw
|
|
|
|
|
# in some cross references
|
|
|
|
|
if ($#cat > 0) {
|
|
|
|
|
$data{$i} .= "<BR><EM><3E><><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD><CBA4>ޤޤ<DEA4><DEA4>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD>:</EM> ";
|
|
|
|
|
foreach $j (@cat) {
|
|
|
|
|
if ($j ne $i) {
|
|
|
|
|
if ($j eq $cat[0]) {
|
|
|
|
|
$data{$i} .= " <STRONG><A HREF=\"$j.html#$name\">\u$j</A></STRONG>,";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$data{$i} .= " <A HREF=\"$j.html#$name\">\u$j</A>,";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# remove the trailing comma
|
|
|
|
|
chop($data{$i});
|
|
|
|
|
}
|
|
|
|
|
$data{$i} .= "<P></P></DD>\n"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Add an entry to the master index
|
1998-09-30 18:35:17 +02:00
|
|
|
|
|
|
|
|
|
# workaround for SGML bug, `--' is not allowed in comments
|
|
|
|
|
local($sname) = $name;
|
|
|
|
|
$sname =~ s/--/-=/g;
|
1997-11-23 23:23:08 +01:00
|
|
|
|
$master[$portnumber] =
|
1998-09-30 18:35:17 +02:00
|
|
|
|
"<!-- $sname --><STRONG><A HREF=\"$cat[0].html#$name\">$name</A></STRONG> " .
|
1997-11-23 23:23:08 +01:00
|
|
|
|
" -- <EM>$desc</EM><BR>\n";
|
|
|
|
|
$portnumber++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
open(MOUTF, ">index.sgml");
|
|
|
|
|
|
|
|
|
|
&header(MOUTF, "FreeBSD Ports");
|
|
|
|
|
# print MOUTF "<!--#include virtual=\"./ports.inc\" -->\n";
|
|
|
|
|
print MOUTF "&blurb;";
|
2004-01-10 19:38:00 +01:00
|
|
|
|
print MOUTF "<hr><P>FreeBSD Ports Collection <20>ˤϡ<CBA4><CFA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> $portnumber <20>Ĥ<EFBFBD> ports <20><><EFBFBD><EFBFBD><F3B6A1A4><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><br> <A HREF=\"$baseFTP/ports.tar.gz\">$portnumber <20>Ĥ<EFBFBD><C4A4>٤Ƥ<D9A4> ports <20><> tar <20>ǤޤȤ<DEA4><C8A4><EFBFBD> gzip <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></A> (<28><><EFBFBD>褽 21 <20>ᥬ<EFBFBD>Х<EFBFBD><D0A5><EFBFBD>) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɤ<EFBFBD><C9A4>뤫<EFBFBD><EBA4AB><EFBFBD>ʲ<EFBFBD><CAB2><EFBFBD>ʬ<EFBFBD>फ<EFBFBD>餿<EFBFBD>ɤäƤ<C3A4><C6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n";
|
1997-11-23 23:23:08 +01:00
|
|
|
|
|
|
|
|
|
print MOUTF "<UL>\n";
|
|
|
|
|
|
|
|
|
|
@foos = sort(keys %stats);
|
|
|
|
|
foreach $key (@foos) {
|
|
|
|
|
# For the master file...
|
|
|
|
|
print MOUTF
|
1999-03-09 16:13:47 +01:00
|
|
|
|
"<LI><A HREF=\"$key.html\">\u$key</A> <em>($stats{$key})</em>";
|
|
|
|
|
if ($category_description{$key}) {
|
|
|
|
|
print MOUTF " -- " . $category_description{$key};
|
|
|
|
|
}
|
2000-01-10 12:08:53 +01:00
|
|
|
|
|
|
|
|
|
# Someone forgot to add a category to the description file
|
|
|
|
|
# or there is a typo in the category field.
|
|
|
|
|
# else {
|
|
|
|
|
# warn "No description found for category: ``$key''!\n";
|
|
|
|
|
# warn "Please fix me or send an E-Mail to doc\@FreeBSD.org\a\n";
|
|
|
|
|
# sleep(3);
|
|
|
|
|
# }
|
1999-03-09 16:13:47 +01:00
|
|
|
|
print MOUTF "</LI>\n";
|
1997-11-23 23:23:08 +01:00
|
|
|
|
|
|
|
|
|
# Create the category file
|
|
|
|
|
open(OUTF, ">$key.sgml");
|
1999-03-09 16:13:47 +01:00
|
|
|
|
&header(OUTF, "FreeBSD Ports: \u$key");
|
|
|
|
|
if ($category_description{$key}) {
|
|
|
|
|
print OUTF "<h3>", $category_description{$key}, "</h3>\n";
|
|
|
|
|
}
|
1997-11-23 23:23:08 +01:00
|
|
|
|
print OUTF "<DL>\n";
|
|
|
|
|
$d = join("\n", sort(split(/\n/, $data{$key})));
|
|
|
|
|
$d =~ s/##([^#]*)##/$catkey{$1}/g;
|
|
|
|
|
print OUTF $d;
|
|
|
|
|
print OUTF "</DL>\n";
|
2000-01-10 12:08:53 +01:00
|
|
|
|
&footer(OUTF, "<p></p><A HREF=\"index.html\">Port <20><>ʬ<EFBFBD><CAAC></A>" .
|
|
|
|
|
" -- <A HREF=\"master-index.html\"><3E><><EFBFBD><EFBFBD></A>");
|
1997-11-23 23:23:08 +01:00
|
|
|
|
close(OUTF);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
print MOUTF "</UL>\n";
|
|
|
|
|
print MOUTF
|
|
|
|
|
"<UL><LI><A HREF=\"master-index.html\">$portnumber <20>Ĥ<EFBFBD> ports <20><><EFBFBD>Ƥ<C6A4><F2A5A2A5>ե<EFBFBD><D5A5>٥åȽ<C3A5><C8BD><EFBFBD><EFBFBD>¤٤<C2A4><D9A4><EFBFBD><EFBFBD><EFBFBD></A></LI></UL>\n";
|
|
|
|
|
&footer(MOUTF, "");
|
|
|
|
|
close(MOUTF);
|
|
|
|
|
|
|
|
|
|
# Create the master index file
|
|
|
|
|
open(MINDEX, ">master-index.sgml");
|
2000-12-31 12:08:43 +01:00
|
|
|
|
&header(MINDEX, "FreeBSD Ports Collection <20><><EFBFBD><EFBFBD>");
|
1997-11-23 23:23:08 +01:00
|
|
|
|
print MINDEX "<P>\n";
|
|
|
|
|
print MINDEX sort @master;
|
|
|
|
|
print MINDEX "</P>";
|
2000-01-10 12:08:53 +01:00
|
|
|
|
&footer(MINDEX, "<A HREF=\"index.html\">Port <20><>ʬ<EFBFBD><CAAC></A>");
|
1997-11-23 23:23:08 +01:00
|
|
|
|
close(MINDEX);
|
|
|
|
|
|
1999-05-06 17:15:22 +02:00
|
|
|
|
close(INDEX);
|
1997-11-23 23:23:08 +01:00
|
|
|
|
}
|