#!/bin/rc -e rfork ne path=/bin fn fatal { echo $* exit $"* } fn usage { echo 'usage: contrib/install [-f] [-r root] user/name' >[1=2] exit usage } root='/' force=false while (~ $1 -*) { switch ($1) { case -f force=true case -r root=`{cleanname -d `{pwd} $2} shift case -* usage } shift } if (! ~ $#* 1 || ! ~ $1 */* ) usage usr=`{echo $1 | awk -F'/' '{print $1}'} name=`{echo $1 | awk -F'/' '{print $2}'} repl=/n/sources/contrib/$usr/replica/$name cfg=/dist/replica/$name if (test -x $cfg && ~ $force false) fatal $name is already installed if (! test -d /dist/replica -w) fatal cannot write in /dist/replica 9fs sources || fatal mount server failed if (! test -d $repl) fatal no such replica $repl dep=`{cat $repl/dep >[2]/dev/null} miss=() for (i in $dep) { r=`{echo $i | awk -F'/' '{print $2}'} if (! test -x /dist/replica/$i) miss=($miss $i) } if (! ~ $#miss 0) { if (~ $force false) fatal missing dependencies: $miss if not echo warning: missing dependencies: $miss } proto=`{grep $name\.proto $repl/db | awk '{print $1}'} x='$' cat > $cfg </dist/replica/client/$name.db >/dist/replica/client/$name.log >/dist/replica/client/$name.chg # are we bootstrapping? if (! test -x /bin/contrib/pull) exec /n/sources/contrib/fgb/root/rc/bin/contrib/pull $name if not exec /bin/contrib/pull $name