#! /bin/sh
# An assumption is made here that RPMS will live in a directory called RPMS
# in the same directory as the page this script builds
# Title == the web pages name /pkgs

rm RPMS.html rpms.txt
rm base/{pkglist.*,srclist.*}

cd RPMS.FULL; rm *.rpm;
ln -sf ../RPMS/*.rpm .
ln -sf ../RPMS/0-devel/*.rpm .
ln -sf ../RPMS/APT4RPM/{*.rpm,0-devel/*.rpm} .
ln -sf ../RPMS/BASE/*.rpm .
ln -sf ../RPMS/GAMES/*.rpm .
ln -sf ../RPMS/GCC/{*.rpm,0-devel/*.rpm} .
ln -sf ../RPMS/GLIBC/{*.rpm,0-devel/*.rpm} .
ln -sf ../RPMS/GRAPHICS/{*.rpm,0-devel/*.rpm} .
ln -sf ../RPMS/GTK2/{*.rpm,0-devel/*.rpm,installed/*.rpm,installed/0-devel/*.rpm} .
ln -sf ../RPMS/KDE/{*.rpm,installed/*.rpm,installed/0-devel/*.rpm} .
ln -sf ../RPMS/KERNEL/{*.rpm,0-devel/*.rpm} .
#ln -sf ../RPMS/MythTV/{*.rpm,0-devel/*.rpm} .
#ln -sf ../RPMS/Voodoo-Graphics/*.rpm .
#ln -sf ../RPMS/Voodoo-Rush/*.rpm .
#ln -sf ../RPMS/Voodoo2/*.rpm .
ln -sf ../RPMS/Voodoo3/{*.rpm,0-devel/*.rpm} .
##ln -sf ../RPMS/Window_Managers/{*.rpm,e17/*.rpm,e17/not_req./*.rpm} .
#ln -sf ../RPMS/XFree86/{XFree86-4.8.0*.rpm,0-devel/*.rpm} .
ln -sf ../RPMS/Xorg/{*.rpm,0-devel/*.rpm,wm/*.rpm,wm/0-devel/*.rpm} .
#ln -sf ../RPMS/aTI-Fglrx/*.rpm .
#ln -sf ../RPMS/nVidia/*.rpm .
#ln -sf ../RPMS/ztest/*.rpm .

cd ../SRPMS.FULL; rm *.rpm;
ln -sf ../SRPMS/*.rpm .
#ln -sf ../SRPMS/0-devel/*.rpm .
ln -sf ../SRPMS/APT4RPM/*.rpm .
ln -sf ../SRPMS/BASE/*.rpm .
ln -sf ../SRPMS/GAMES/*.rpm .
ln -sf ../SRPMS/GCC/*.rpm .
ln -sf ../SRPMS/GLIBC/*.rpm .
ln -sf ../SRPMS/GRAPHICS/*.rpm .
ln -sf ../SRPMS/GTK2/{*.rpm,installed/*.rpm} .
ln -sf ../SRPMS/KDE/{*.rpm,installed/*.rpm} .
ln -sf ../SRPMS/KERNEL/*.rpm .
#ln -sf ../SRPMS/MythTV/*.rpm .
#ln -sf ../SRPMS/Voodoo-Graphics/*.rpm .
#ln -sf ../SRPMS/Voodoo-Rush/*.rpm .
#ln -sf ../SRPMS/Voodoo2/*.rpm .
ln -sf ../SRPMS/Voodoo3/*.rpm .
##ln -sf ../SRPMS/Window_Managers/{*.rpm,e17/*.rpm,e17/not_req./*.rpm} .
#ln -sf ../SRPMS/XFree86/*.rpm .
ln -sf ../SRPMS/Xorg/{*.rpm,wm/*.rpm} .
#ln -sf ../SRPMS/aTI-Fglrx/*.rpm .
#ln -sf ../SRPMS/nVidia/*.rpm .
#ln -sf ../SRPMS/ztest/*.rpm .
cd ..

genbasedir --meta=FULL --progress --flat --compresslevel=9 /pkgs FULL
genbasedir --meta=FULL --hashonly --progress --flat --compresslevel=9 /pkgs FULL

Title=RPMS
# location == absolute location of the rpms
location=RPMS.FULL
#
# Put the rpm names in a file to be sorted
# If you want to order the files on the web page run this once this 
# with the following line uncommented the edit rpms files for the
# order that you want then comment the ls line and run it again...
ls -1 $location/*.rpm>./rpms.txt

filelist=`cat ./rpms.txt`
echo $filelist

#exit
# Build Web page header
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">">$Title.html
echo "<HTML>" >> $Title.html
echo "<HEAD>" >> $Title.html
echo "<IMG SRC="http://www.alinux.tv/linux-os/unix.gif">" >> $Title.html
echo "<body text="#FFFFFF" bgcolor="#BABAFE" link="#FFFF00" vlink="#FFFF00" alink="#00FFFF" background="http://www.alinux.tv/linux-os/alinux-bg.jpg">" >> $Title.html
echo "<font face="Comic Sans MS,Arial,Verdana,Helvetica,Geneva,sans-serif"><font size=-1>" >> $Title.html
echo "<CENTER><A HREF="http://http://distro.ibiblio.org/peanut/current/pkgs/rpm-gen">Automated RPM description script version 0.6.</A></CENTER>" >> $Title.html
echo "<TITLE>RPM Descriptions</TITLE>" >> $Title.html
echo "  <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\">"  >> $Title.html
echo "</HEAD>" >> $Title.html
echo "<BODY>" >> $Title.html
echo "<BR>" >> $Title.html
echo "<PRE>" >> $Title.html
 
# Add each rpm's Summary and Description info
for i in $filelist;
 do
 echo "<a href=\"RPMS.FULL/"`basename $i`"\">"`basename $i`"</A>"  >> $Title.html
 rpm -qp --info $i >> $Title.html
 echo "<BR>"  >> $Title.html
 echo "" >> $Title.html
 done
echo "</PRE>" >> $Title.html
echo "</FONT></FONT>" >> $Title.html
echo "</BODY>" >> $Title.html
echo "</HTML>" >> $Title.html
