From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Tue Jul 28 1998 - 15:55:25 EDT
[ I'm Cc'ing the list since they didn't get the original mail with the
file, Daniel ]
Hi Rick,
> I start using your rpmfind and rpm2html tools more and more often.
> I think they are both useful for RPM users and to demonstrate the power of
> RDF (which I think is another reason why you created the tools).
Yep,
> I have a remark/contribution about findrpm, namely that it can only find those
> RPMs whose name are already known. I think, to utilise RDF at its maximum, it
> would be better to allow a sort of query language, a bit like SQL (I know this
> is a topic of debate in the W3C).
Try out rpmfind version 0.97 and use the --apropos option :-)
Querying using RDF in not yet in the charter of any W3C group, it may well
be addressed in the future. There is also some similar work in the DASL group
at IETF.
> To satisfy my own curiosity, I constructed a little cgi-bin script which I named
> rpm2html.sh (sorry for the confusing name -> but I think it could be integrated
> into your rpm2html tool). I added it to this file for your convenience.
> Please note how it can generate the file format of the RDFs you used on the fly,
> as only one of its possibilities.
Ok, It's probably time I add a contrib section to the rpmfind/rpm2html
pages, note however that I won't put it in rufus.w3.org cgi-bin directory
for obvious security reasons. But with restricted access it can be a good
base for a networked management tool !
Note also that rpm2html can guery the installed database to produce the
full set of HTML/RDF files for the packages installed on the machine. Use
the predefined [localbase] directory name in your config file to dump them.
> I hope this work can inspire you to future directions.
> Meanwhile, keep up the interesting work you're doing!
Note that the RDF files will have to be updated to follow the current
XML/namespace/RDF specifications or coming out soon ...
I changed the content-type sent to text/xml since it has been registred.
Daniel
rpm2html.sh, to be installed in your cgi-bin, follows:
------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------
#!/bin/sh
#
# This utility transfers requested information on RPMs installed on a system
# to a querying host.
#
# Rick van Rein, July 28, 1998.
echo Content-Type: text/xml
echo
if [ $# -eq 0 ]; then
cat <<EOF
<HTML>
<HEAD><TITLE>rpm2html.sh help file</TITLE></HEAD>
<BODY>
<H2>rpm2html.sh</H2>
This package queries an RPM database and returns the requested information in
RDF format. This format is defined by the WWW conosrtium and used by tools like
rpmfind.<P>
This version of the rpm2html.sh package is a premature demo with problems with
escaping spaces. Use at your own risk and amusement.
<H3>Examples of use</H3>
First, let us look at some example uses of <CODE>rpm2html.sh</CODE>.
<H4>Extensive example</H4>
Place the shell script for rpm2html.sh in your <CODE>/cgi-bin</CODE> and request
the following URL from your web server:
<PRE>
<A HREF="http://localhost/cgi-bin/rpm2html.sh?NAME+VERSION+GROUP:Networking+BUILDARCHS">http://localhost/cgi-bin/rpm2html.sh?NAME+VERSION+GROUP:Networking+BUILDARCHS>
</PRE>
This returns a <EM>source</EM> file with a result like this:
<PRE>
<?XML version="1.0"?>
<?namespace href="http://www.rpm.org/" AS="RPM"?>
<?namespace href="http://www.w3.org/TR/WD-rdf-syntax#" AS="RDF"?>
<RDF:RDF>
<RDF:Description>
<RPM:NAME>smb2</RPM:NAME>
<RPM:VERSION>0.0</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>telnet</RPM:NAME>
<RPM:VERSION>0.10</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>pidentd</RPM:NAME>
<RPM:VERSION>2.8.2</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>netkit-base</RPM:NAME>
<RPM:VERSION>0.10</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>samba</RPM:NAME>
<RPM:VERSION>1.9.18p2</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>rsh</RPM:NAME>
<RPM:VERSION>0.10</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>finger</RPM:NAME>
<RPM:VERSION>0.10</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>rstatd</RPM:NAME>
<RPM:VERSION>3.03</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>rusers</RPM:NAME>
<RPM:VERSION>0.10</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>rwho</RPM:NAME>
<RPM:VERSION>0.10</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>tftp</RPM:NAME>
<RPM:VERSION>0.10</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>timed</RPM:NAME>
<RPM:VERSION>0.10</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>ypbind</RPM:NAME>
<RPM:VERSION>3.3</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
<RDF:Description>
<RPM:NAME>snag-o-rama</RPM:NAME>
<RPM:VERSION>1.4</RPM:VERSION>
<RPM:BUILDARCHS>(none)</RPM:BUILDARCHS>
</RDF:Description>
</RDF:RDF>
</PRE>
This is a general version of the format used by <CODE>rpmfind</CODE>, but the
querying facilities allow more flexible searches than just by package name.
<H4>Online help</H4>
Obtain online help with URL:
<PRE>
<A HREF="http://localhost/cgi-bin/rpm2html.sh">http://localhost/cgi-bin/rpm2html.sh>
</PRE>
<H4>Online generation of rpmfind information</H4>
The <CODE>rpmfind</CODE> utility seeks out information based on a package name.
This is just one of the applications of <CODE>rpm2html.sh</CODE>, and it is generated as follows (say, the package sought is <CODE>xbill</CODE>):
<PRE>
<A HREF="http://localhost/cgi-bin/rpm2html.sh?NAME:xbill+Name+Version+Release+Arch+Os+Distribution+Vendor+Size">http://localhost/cgi-bin/rpm2html.sh?NAME:xbill+Name+Version+Release+Arch+Os+Distribution+Vendor+Size>
</PRE>
Well... except that I left out the tags <CODE>DATE</CODE> and <CODE>SUBDIR</CODE> because my RPM (version 2.4.12) didn't accept them.
And another difference is the absense of the <CODE>RDF:HREF</CODE> fields in the <CODE><RDF:Description ... ></CODE> sections... I do not have a solid place to point at for them, like on <A HREF="http://www.rpm.org">http://www.rpm.org>!
<H3>General use</H3>
To use <CODE>rpm2html.sh</CODE>, give it arguments of the form <CODE>TAG=VALUE</CODE>, where <CODE>TAG</CODE> is a tag recognised by <CODE>rpm</CODE> and <CODE>VALUE</CODE> is a value that you want it to have.<P>
Furthermore, give arguments <CODE>TAG</CODE> for all the tags that you want listed in the RDF description.
<H3>Supported tags</H3>
This daemon supports the following tags:
<PRE>
EOF
for i in `rpm --querytags`; do echo " $i"; done
cat <<EOF
</PRE>
</BODY>
</HTML>
EOF
exit 0
fi
# Given a list of identifiers, build a queryformat for RPM:
firstlist2queryformat () {
for i in $*
do echo -n " $i:%{$i}"
done
echo
}
secondlist2queryformat () {
for i in $*
do echo -n " $i=%{$i}"
done
echo
}
# The following variables contain the SELECT and WHERE clauses, like in SQL:
SELECT=$(echo -n $(for i in $*
do echo $i
done | grep -v :))
WHERE=$(echo -n $(for i in $*
do echo $i
done | grep :))
# WHSEL is what to select to determine WHERE-conformance:
WHSEL=$(echo -n $(for i in $WHERE
do echo $i
done | sed s/:.*//))
# Q1FMT is the query format for the first (WHSEL) query
Q1FMT=`firstlist2queryformat $WHSEL`
# Q1OUT is the output from the first (WHSEL) query: a list of package matching
# the query's WHERE clause
Q1OUT=$(echo $(rpm -qa --qf "%{NAME}$Q1FMT\n" | grep "^[^\ ]* $WHERE\$" | sed s/\ .*$//))
# Q2FMT is the query format for the second (SELECT) query
Q2FMT=`secondlist2queryformat $SELECT`
Q2OUT=$(for i in $Q1OUT
do rpm -q $i --qf "$Q2FMT\n"
done)
#
# Now format Q2OUT as RDF information by mapping directly:
#
# RDF.1: Generate RDF header
cat <<EOF
<?XML version="1.0"?>
<?namespace href="http://www.rpm.org/" AS="RPM"?>
<?namespace href="http://www.w3.org/TR/WD-rdf-syntax#" AS="RDF"?>
<RDF:RDF>
EOF
# RDF.2: Generate an entry for each package mentioned in Q2OUT:
for i in $Q1OUT
do
LINE=$(rpm -q $i --qf "$Q2FMT\n")
echo " <RDF:Description>"
for WORD in $LINE
do
TAG=$(echo $WORD | sed s/=.*//)
VALUE=$(echo $WORD | sed s/^.*=//)
echo " <RPM:$TAG>$VALUE</RPM:${TAG}>"
done
echo " </RDF:Description>"
done
# RDF.3: Generate RDF trailer
cat <<EOF
</RDF:RDF>
EOF
------------ 8< ------------ 8< ------------ 8< ------------ 8< ------------
-- Daniel.Veillard@w3.org | W3C MIT/LCS NE43-344 | Today's Bookmarks : Tel : +1 617 253 5884 | 545 Technology Square | Linux, WWW, rpm2html, Fax : +1 617 258 5999 | Cambridge, MA 02139 USA | badminton, Kaffe, http://www.w3.org/People/W3Cpeople.html#Veillard | HTTP-NG and Amaya.
This archive was generated by hypermail 2b29 : Thu May 10 2001 - 18:40:09 EDT