compsxml2bundles.pl from LinuxCOE at Krugle
Show compsxml2bundles.pl syntax highlighted
#!/usr/bin/perl -w
##
# File: compxml2bundles.pl
# Description: filter to generate html/bundles file from RedHat comps.xml
# Author: Bryan Gartner < bryan.gartner@hp.com >
# inspired by Paul Telford's readxml.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 RedHat-based distribution comps (xml) content as standard input
# and generates:
# - simple HTML fragments on standard output
# - a bundle list on standard error
# typical usage is to
# ./compsxml2bundles.pl < RedHat/base/comp.xml > @prefix@/html/bundles/<distro>-<version>.html
print "<DL>\n";
while (<>) {
chomp;
# find bundle name
if ( /<name>(.*?)<\/name>/ ) {
print STDERR "$1\n";
print " <br>\n <DT><A NAME=\"$1\"><b>$1</b></A></DT>\n";
}
# parse bundle packages
if ( /<packagereq/ ) {
if ( /type=.*optional/ ) {
$suffix = "[ <font size=\"-1\"><i>optional</i></font> ]</DD>";
} else { $suffix = "</DD>"; }
$_ =~ s/<[^>]*>//gs;
s/^\s+//;
s/\s+$//;
print " <DD>$_ $suffix\n";
}
if ( /<subcategory>(.*?)<\/subcategory>/ ) {
print " <DD>$1 [ <font size=\"-1\"><i>subcategory</i></font> ]</DD>\n";
}
if ( /<groupid>(.*?)<\/groupid>/ ) {
print " <DD>$1 </DD>\n";
}
}
print "</DL>\n";
See more files for this project here