[BACK]Return to portstat.bld CVS log [TXT][DIR] Up to [local] / www

File: [local] / www / Attic / portstat.bld (download)

Revision 1.2, Tue May 19 02:39:20 1998 UTC (26 years ago) by marc
Branch: MAIN
Changes since 1.1: +2 -1 lines

update port status page

#! /bin/sh
#
# $OpenBSD: portstat.bld,v 1.2 1998/05/19 02:39:20 marc Exp $
#
# Build the OpenBSD port status web page.
# Uses the following files:
#
#	portstat.hdr:		<html>, <head> and the start of <body>
#	portstat.tlr:		contact info, </body>, </html>
#	portstat.stat:		The name, date of last change, and status
#				of each port.
#
#set -e
prog=`basename $0`
work=$prog-$$
    trap "rm -f $work; exit 1" 0 1 2 3 15

if [ ! -f portstat.hdr ]; then
   echo "$prog: missing file portstat.hdr"
   exit 1
fi

if [ ! -f portstat.tlr ]; then
   echo "$prog: missing file portstat.tlr"
   exit 1
fi

if [ ! -f portstat.stat ]; then
   echo "$prog: missing file portstat.stat"
   exit 1
fi

# Start with the boilerplate header
#
cat portstat.hdr > $work

# Build the table of contents
#
echo "  <p>Select from the following list of categories:" >> $work
echo "   <dir compact>" >> $work
for f in /usr/ports/*; do
    n=`basename $f`
    if [ -d $f -a $n != CVS -a $n != distfiles ]; then
	echo "    <li><a href=#$n>$n</a>" >> $work
    fi
done
echo "   </dir>" >> $work

# Now process each category
#
for f in /usr/ports/*; do
    n=`basename $f`
    if [ -d $f -a $n != CVS -a $n != distfiles ]; then

	# build the category header
	#
	echo "  <hr>" >> $work
	echo "  <a name=$n></a>" >> $work
	echo "  <h3><font color=#0000e0>$n</font></h3>" >> $work
	echo "   <pre>" >> $work

	# Process the ports within this category
	#
	for d in $f/*; do
	    dd=`basename $d`
	    if [ -d $d -a $dd != CVS ]; then
		info=`sed -n -e "/^$dd\\$/,/^\\$/p" portstat.stat`
		if [ "$info" ]; then
		    echo "    $info" >> $work
		else
		    echo "    $dd" >> $work
		    echo "no status for $dd" >&2
		fi
		echo "" >> $work
	    fi
	done

	# add in the category trailer
	#
	echo "   </pre>" >> $work
	echo "  <p align=center><a href=#top>return to top of page</a>" >> $work
    fi
done


# Add in the trailer
#
cat portstat.tlr >> $work

# Save any existing file then make the work file the current portstat.html.
#
if [ -f portstat.html ]; then
   if [ -f portstat.html- ]; then
      rm portstat.html-
   fi
   mv portstat.html portstat.html-
fi
mv $work portstat.html

# that's all
#
exit 0