#!/bin/rc
path = (/bin .) # speed hack
rfork n
# Need to setup factota so 9fs can connect to sources
auth/factotum
cat /usr/$user/lib/sources.key > /mnt/factotum/ctl
# This is ugly like hell, but it's the only way I have found to make sure hung
# junk in /srv doesn't fuck me over
prog=`{basename $0}
rm /srv/wiki.$prog
srv 'net!plan9.bell-labs.com!wiki' wiki.$prog || exit
mount -c /srv/wiki.$prog /mnt/wiki
9fs 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 = `{ls -d ../extra/ */ }
# Main loop
{
echo Contrib Index
echo D^$lastupdate
echo Auriel
echo
echo 'This is an automatically generated index of the packages part of the [Contrib] directory in the [Sources repository].'
echo
echo 'Download mirrors: [9grid.de|http://www.9grid.de/magic/webls?dir=/sources/contrib/]'
for(d in $idirs){
echo
echo $d | tr a-z A-Z
if (test -f $d'/README') {
#grep '^author:' README | sed -e 's/@/ at /' -e 's/^author: //'
cat $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)
next
}
{
d = ""
if (substr($0,1,1) == "d")
d = "/"
print " * "$10 d" - " idx[$10] " ("$7" "$8" "$9")"
}
' | sort
}
} | {
sed 's%^ \*[^/]*/% *%';
echo -n # Needed to 'commit' the write
} > /mnt/wiki/new
|