#!/usr/bin/perl
#
# Create a page listing all my debian packages
#
# By Joey Hess, <joey@kitenet.net> 
# 
# Distribute and modify freely.

$package_file="/home/joey/debian/public/Packages.gz"; # Pregenerated Packages file.
$webdir="ftp://kitenet.net/pub/code/debian"; # Where are these packages, in webspace?

BEGIN { push (@INC,'../include/') }
require 'cgi-lib.pl';

print &PrintHeader;

print qq{

<html>
<head><title>Debian packages maintained by Joey Hess</title></head>
<body>
<h1 align=center>Joey's Debian packages</h1>
<P>This is a collection of all the <A HREF="http://www.debian.org/">Debian 
packages</a> I currently maintain. These same packages, as well as their 
associated source packages and other files, are also 
<A HREF="ftp://kitenet.net/pub/code/debian/">available by ftp</A>, and by
apt, if you place the following in <tt>/etc/apt/source.list</tt>:</P>
<pre>
deb http://kitenet.net/programs/code/debian /
deb-src http://kitenet.net/programs/code/debian /
</pre>
<p>You can look at my <a href="/~joey/todo-debian">Debian todo list</a> if
you like. Also, here are 
<a href="http://www.debian.org/Bugs/db/ma/lJoey_Hess,joeyh,debian.org,.html">bug
reports</a> currently filed against these packages.</p>
<p>

<ul>
};

# Read and parse packages file, convert to html, and output it.
open (P,"zcat $package_file |") || exit print "$package_file: $!\n";
while (<P>) {
	s/>/&gt;/g;
	s/</&lt;/g;
	if ($in_desc && /^\s/ eq undef) { # End of an extended description.
		$in_desc=undef;
		print "</pre>\n";
	}
	if (/^Package: (.*)/ ne undef) { # Beginning of a package.
		print "<a name=\"$1\"><li>\n";
		$total++;
	}
	if (!$in_desc) { # Normal tag of a package.
		if (/^Filename: .*\/(.*?)$/ ne undef) { # Change filename to links.
			$fn=$1;
			$_="Filename: <A HREF=\"$webdir/$fn\">$fn</a>\n";
		}
		# Remove installed-size tag: it only shows up on packages I
		# have installed, and it causes problems.
		# Remove some other fields that were just cluttering things up.
		if ((/^installed-size:/i ne undef) || 
		    (/^Maintainer:/i ne undef) || 
		    (/^Architecture:/i ne undef)) { $_='' }
		# Pretty-print value in bold.
		chomp;
		($tag,$value)=split(/: /,$_,2);
		if ($tag) {
			print "$tag: <b>$value</b><br>\n";
		}
	}
	else {
		s/\s\.//;
		print $_;
	}
	if (/^Description:/ ne undef) { 
		print "<pre>\n";
		$in_desc=1;
	}
}
close P;

print "</ul>\n<p>(That's $total packages in all.)</p>\n";
&PrintFooter;
print "</body></html>\n";
