#!/bin/rc # Generate the contrib index page. Look for README and INDEX files. # Allows INDEX files to specify deep subdirs from a higher level. # README files get the first 16 lines printed. # Bug: deep references in INDEX are printed without the date. # Bug: contrib/list still uses /srv/sources; need to modify to check before 9fs. rfork n path = (/bin .) # speed hack # Avoid conflicts with other connections in /srv. prog=`{basename $0} rm /srv/wiki.$prog >[2] /dev/null srv 'net!plan9.bell-labs.com!wiki' wiki.$prog >[2] /dev/null || exit mount -c /srv/wiki.$prog /mnt/wiki rm /srv/sources.$prog >[2] /dev/null srv 'net!sources.cs.bell-labs.com!9fs' sources.$prog >[2] /dev/null || exit mount -n /srv/sources.$prog /n/sources lastupdate=`{sed '/^D/q' < /mnt/wiki/contrib_index/current | sed -n 's,^D,,p'} contrib=/n/sources/contrib/ cd $contrib || exit #idirs = `{ ls */INDEX |sed 's%/INDEX%%' } #idirs = (../extra fgb) # testing idirs = `{ls -d ../extra/ */ } # Main loop { echo Contrib Index echo D^$lastupdate echo Aanothy echo echo 'This is an automatically generated index of the packages part of the [Contrib] directory' echo 'in the [Sources repository]. Items marked as "From fgb''s contrib" can be downloaded' echo 'with the command' echo '! contrib/install user/package' echo 'contrib itself can be installed with' echo '! /n/sources/contrib/fgb/root/rc/bin/contrib/install fgb/contrib' echo echo 'Closer [Mirrors] may be available.' echo echo 'This page is regenerated daily, a bit after 3am US-Eastern. If the page looks' echo 'broken, please notify Anthony Sorace (a at 9srv dot net).' for(d in $idirs){ echo $d >[1=2] echo echo $d | tr a-z A-Z if (test -f $d'/README') { #grep '^author:' README | sed -e 's/@/ at /' -e 's/^author: //' fmt -jl 100 $d'/README' | sed 's/^/!/' | sed 16q } echo { if (test -s $d'/INDEX') { cat $d'/INDEX' | grep '^[^ :]+:.+$' | sed 's%^%INDEX='$d'/%' } subdirs = `{ ls $d^/*/INDEX >[2] /dev/null | sed 's/INDEX$//'} for(i in $subdirs ) { cat $i/INDEX | grep '^[^ :]+:.+$' | sed 's%^%INDEX='$i'%' } ls -l $d $subdirs | grep -v '(INDEX|README)' } | grep -v '^$' | awk ' /^INDEX=/ { $0 = substr($0,7) c = index($0,":") idx[substr($0,1,c-1)] = substr($0,c+1) pre[substr($0,1,c-1)] = " * " substr($0,1,c-1) " -" next } { if (idx[$10] == "") idx[$10] = " " d = "" if (substr($0,1,1) == "d") d = "/" pre[$10] = " * "$10 d " -" post[$10] = " ("$7" "$8" "$9")" } END { for (f in idx) print pre[f] " " idx[f] " " post[f] } ' | sort | sed 's%^ \*[^/]*/% *%' if (! ~ $d ../extra) { echo controut=`{ contrib/list $d | sed 1q } if (! ~ $controut $d'/*: no such replica') { echo ' From fgb''s contrib:' contrib/list $d | sed 's@^'$d'/@ *@' } } } } | { cat echo -n # Needed to 'commit' the write } > /mnt/wiki/new