packages2bundles.pl from LinuxCOE at Krugle
Show packages2bundles.pl syntax highlighted
#!/usr/bin/perl -w
##
# File: packages2bundles.pl
# Description: filter to generate html/bundles file from Debian Packages
# Author: Bryan Gartner < bryan.gartner@hp.com >
# inspired by Paul Telford's readdeb.pl
##
# © Copyright 2000-2007 Hewlett-Packard Development Company, L.P
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 675 Mass Ave, Cambridge, MA 02139, USA.
# This is a simple filter script:
# it reads Debian-based distribution "Packages" content as standard input
# and generates:
# - simple HTML fragments on standard output
# - a bundle list on standard error
# typical usage is to
# for pkgfile in dists/<release>/<category>/binary-<arch>/Packages.gz
# do
# zcat $pkgfile | ./packages2bundles.pl >> @prefix@/html/bundles/<distro>-<release>.html
# done
%tasks = ();
my $package;
while (<>) {
# look for Package declarations
if( /^Package: (.*)/ ) {
$package = $1;
next;
}
# look for Task declarations, push packages found into hash
if( /^Task: (.*)/ ) {
@tasks = split(",", $1);
foreach $task (@tasks) {
$task =~ s/^\s*//;
$task =~ s/\s*$//;
push( @{$tasks{$task}}, $package );
}
}
}
# generate simple HTML fragment
print "<DL>\n";
foreach $task (sort keys %tasks) {
print STDERR "$task\n";
print " <br>\n <DT><A NAME=\"$task\"><b>$task</b></A></DT>\n";
foreach $package (sort @{$tasks{$task}}) {
print " <DD>$package</DD>\n";
}
}
print "</DL>\n";
See more files for this project here