#! /bin/sh # # $OpenBSD: portstat.bld,v 1.3 1998/10/07 21:15:46 marc Exp $ # # Build the OpenBSD port status web page. # Uses the following files: # # portstat.hdr: , and the start of # portstat.tlr: contact info, , # portstat.stat: The name, date of last change, and status # of each port. # #set -e prog=`basename $0` tmp=`mktemp /tmp/$prog-$$-XXXXXXXXXX` work=`mktemp $prog-$$-XXXXXXXXXX` trap "rm -f $work $tmp; 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 "

Select from the following list of categories:" >> $work echo "

" >> $work for f in /usr/ports/*; do n=`basename $f` if [ -d $f -a $n != CVS -a $n != distfiles ]; then echo "
  • $n" >> $work fi done echo "
  • " >> $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 "
    " >> $work echo " " >> $work echo "

    $n

    " >> $work echo "
    " >> $work
    
    	# Process the ports within this category
    	#
    	for d in $f/*; do
    	    dd=`basename $d`
    	    if [ -d $d -a $dd != CVS ]; then
    		cmt=`cat $d/pkg/COMMENT`
    		sed -n -e "/^$dd\$/,/^\$/p" portstat.stat > $tmp
    		info=`sed -e "s|^$dd|$dd - $cmt|" $tmp`
    		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 "   
    " >> $work echo "

    return to top of page" >> $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