Annotation of www/portstat.bld, Revision 1.1
1.1 ! marc 1: #! /bin/sh
! 2: #
! 3: # $OpenBSD$
! 4: #
! 5: # Build the OpenBSD port status web page.
! 6: # Uses the following files:
! 7: #
! 8: # portstat.hdr: <html>, <head> and the start of <body>
! 9: # portstat.tlr: contact info, </body>, </html>
! 10: # portstat.stat: The name, date of last change, and status
! 11: # of each port.
! 12: #
! 13: #set -e
! 14: prog=`basename $0`
! 15: work=$prog-$$
! 16: trap "rm -f $work; exit 1" 0 1 2 3 15
! 17:
! 18: if [ ! -f portstat.hdr ]; then
! 19: echo "$prog: missing file portstat.hdr"
! 20: exit 1
! 21: fi
! 22:
! 23: if [ ! -f portstat.tlr ]; then
! 24: echo "$prog: missing file portstat.tlr"
! 25: exit 1
! 26: fi
! 27:
! 28: if [ ! -f portstat.stat ]; then
! 29: echo "$prog: missing file portstat.stat"
! 30: exit 1
! 31: fi
! 32:
! 33: # Start with the boilerplate header
! 34: #
! 35: cat portstat.hdr > $work
! 36:
! 37: # Build the table of contents
! 38: #
! 39: echo " <p>Select from the following list of categories:" >> $work
! 40: echo " <dir compact>" >> $work
! 41: for f in /usr/ports/*; do
! 42: n=`basename $f`
! 43: if [ -d $f -a $n != CVS -a $n != distfiles ]; then
! 44: echo " <li><a href=#$n>$n</a>" >> $work
! 45: fi
! 46: done
! 47: echo " </dir>" >> $work
! 48:
! 49: # Now process each category
! 50: #
! 51: for f in /usr/ports/*; do
! 52: n=`basename $f`
! 53: if [ -d $f -a $n != CVS -a $n != distfiles ]; then
! 54:
! 55: # build the category header
! 56: #
! 57: echo " <hr>" >> $work
! 58: echo " <a name=$n></a>" >> $work
! 59: echo " <h3><font color=#0000e0>$n</font></h3>" >> $work
! 60: echo " <pre>" >> $work
! 61:
! 62: # Process the ports within this category
! 63: #
! 64: for d in $f/*; do
! 65: dd=`basename $d`
! 66: if [ -d $d -a $dd != CVS ]; then
! 67: info=`sed -n -e "/^$dd\\$/,/^\\$/p" portstat.stat`
! 68: if [ "$info" ]; then
! 69: echo " $info" >> $work
! 70: else
! 71: echo " $dd" >> $work
! 72: fi
! 73: echo "" >> $work
! 74: fi
! 75: done
! 76:
! 77: # add in the category trailer
! 78: #
! 79: echo " </pre>" >> $work
! 80: echo " <p align=center><a href=#top>return to top of page</a>" >> $work
! 81: fi
! 82: done
! 83:
! 84:
! 85: # Add in the trailer
! 86: #
! 87: cat portstat.tlr >> $work
! 88:
! 89: # Save any existing file then make the work file the current portstat.html.
! 90: #
! 91: if [ -f portstat.html ]; then
! 92: if [ -f portstat.html- ]; then
! 93: rm portstat.html-
! 94: fi
! 95: mv portstat.html portstat.html-
! 96: fi
! 97: mv $work portstat.html
! 98:
! 99: # that's all
! 100: #
! 101: exit 0