#!/bin/sh # $FreeBSD$ # # create HTML showing numbers of packages vs errors. Run this in a directory # accessible to the web server. # # alpha is obsolete SUPPORTED_ARCHS="amd64 i386 ia64 sparc64" ROOT_DIRECTORY=/var/portbuild OUTFILE=`basename $0 | sed -e "s/^do//"`".html" TMPFILE=.${OUTFILE} # stylesheet seems like overkill for something this simple TABLEBGCOLOR="#F0F0F0" THCOLOR="#E0E0FF" TDCOLOR_DONE="lightgreen" TDCOLOR_NOT_DONE="lightyellow" # subroutines write_header () { echo "" > ${TMPFILE} echo "" >> ${TMPFILE} echo "FreeBSD package building statistics" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "

FreeBSD package building statistics

" >> ${TMPFILE} echo "

as of `date`

" >> ${TMPFILE} } write_table_begin () { echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} } write_row () { # first, gather data arch=$1 build=$2 directory=${ROOT_DIRECTORY}/${arch}/${build} branch=`echo $build | sed -e "s/-exp//"` if [ "$branch" = "4" ]; then indexfile=$directory/ports/INDEX else indexfile=$directory/ports/INDEX-$branch fi # work around the fact that 5-exp is really 6-exp-prime if [ ! -f $indexfile ]; then if [ -d $directory/ports ]; then indexfile=$directory/ports/`cd $directory/ports&&ls INDEX* 2> /dev/null | head -1` else # work around the fact that 4 is EOL and thus has no ports/ directory indexfile=$directory/logs/`cd $directory/logs&&ls INDEX* 2> /dev/null | head -1` fi fi # column: date of CVS checkout cvsdone=" " if [ -f $directory/cvsdone ]; then cvsdone="$(cat $directory/cvsdone | awk '{printf("%s %s\n",$2,$3)}')" if [ -z "$cvsdone" ]; then cvsdone=" " fi fi # column: datestamp and URL of latest log latest=" " if [ -d $directory/logs ]; then latest_suffix="$(cd $directory/logs; ls -rtTl | grep '\.log' | tail -1 | awk '{printf("%s\">%s %s\n",$10,$6,$7)}')" if [ "$latest_suffix" ]; then latest="" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} # note: ports/INDEX-n is copied to a file called errorlogs/INDEX echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} } write_table_end () { echo "
 cvs datelatest logINDEXbuild logspackageserrorsskippednot yet builtrunning?completed?
$arch-$build" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "$cvsdone$latest" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "$n_index" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "$n_logs" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "$n_packages" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "$n_errors$n_duds$n_not_yet_built$running_flag$completed_flag
" >> ${TMPFILE} echo "
" >> ${TMPFILE} } write_footer () { echo "

explanation of columns:

" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "

notes:

" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} echo "" >> ${TMPFILE} } # main write_header # display all the mainstream builds first for arch in ${SUPPORTED_ARCHS}; do # drop 4 as obsolete builds=`ls ${ROOT_DIRECTORY}/${arch} | grep '^[5-9]$' | sort` if [ ! -z "$builds" ]; then write_table_begin for build in ${builds}; do write_row ${arch} ${build} done write_table_end fi done # then display all -exp builds (probably only of interest to portmgr; # would break up the logical flow of the above) for arch in ${SUPPORTED_ARCHS}; do builds=`ls ${ROOT_DIRECTORY}/${arch} | grep '^[1-9]-exp$' | sort` if [ ! -z "$builds" ]; then write_table_begin for build in ${builds}; do write_row ${arch} ${build} done write_table_end fi done write_footer mv -f ${TMPFILE} ${OUTFILE}