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

Annotation of www/portstat.bld, Revision 1.2

1.1       marc        1: #! /bin/sh
                      2: #
1.2     ! marc        3: # $OpenBSD: portstat.bld,v 1.1 1998/03/04 20:13:10 marc Exp $
1.1       marc        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
1.2     ! marc       72:                    echo "no status for $dd" >&2
1.1       marc       73:                fi
                     74:                echo "" >> $work
                     75:            fi
                     76:        done
                     77:
                     78:        # add in the category trailer
                     79:        #
                     80:        echo "   </pre>" >> $work
                     81:        echo "  <p align=center><a href=#top>return to top of page</a>" >> $work
                     82:     fi
                     83: done
                     84:
                     85:
                     86: # Add in the trailer
                     87: #
                     88: cat portstat.tlr >> $work
                     89:
                     90: # Save any existing file then make the work file the current portstat.html.
                     91: #
                     92: if [ -f portstat.html ]; then
                     93:    if [ -f portstat.html- ]; then
                     94:       rm portstat.html-
                     95:    fi
                     96:    mv portstat.html portstat.html-
                     97: fi
                     98: mv $work portstat.html
                     99:
                    100: # that's all
                    101: #
                    102: exit 0