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