first crack at a fossil+venti install (no fossil-only option). Reference: /n/atom/patch/applied/amd64fvinst Date: Thu Apr 3 21:51:10 CES 2014 Signed-off-by: quanstro@quanstro.net # rm /sys/lib/dist/amd64/install/copydist --- /sys/lib/dist/amd64/install/copydistf Thu Jan 1 00:00:00 1970 +++ /sys/lib/dist/amd64/install/copydistf Thu Apr 3 21:50:57 2014 @@ -0,0 +1,162 @@ +#!/bin/rc + +icfg='srv -p fscons +srv fossil +fsys main config $f +fsys main venti $vaddr +fsys main open -A -c 10000 +fsys main +snaptime -a 0500 +listen tcp!*!564 +' +ifcmds = ( + -c 'srv -d fossil' + -c 'srv -AWP fossil' + -c 'fsys main' + -c 'create /active/adm adm sys d775' + -c 'create /active/adm/users adm sys 664' + -c 'users -d' + -c 'users -w' +) + +fn fossilcmd { + echo $*>>/srv/fscons && sleep 0.1 +} + +fn copydistfossil { + f=$disk/fossil +{ + fossil/flfmt -b 8192 -h $vaddr $f || fail + { + echo -n $icfg | sed 's!\$f!'^ $f ^'!g + s!\$vaddr!' ^ $vaddr ^ '!g' + }| fossil/conf -w $f || fail + fossil/fossil -f $f $ifcmds || fail + tail -f /srv/fscons + mount -c /srv/fossil /n/inst || fail + mount -c /srv/boot /n/atom || fail + + fossilcmd create /active/usr sy sys d755 + fossilcmd uname $user $user + + disk/mkfs -kU -s /n/atom -d /n/inst <{echo +} || fail + + fossilcmd sync +}} + +fn checkip { + err=`{echo $vaddr | awk -F. ' + NF<2||NF>4 { + print "wrong number of octets" + exit 1 + } + { + for(i = 1; i <= NF; i++) + if($i > 256 || $i < 0){ + print "bad octet value" + exit 1 + } + } + ' } +} + +fn ventiaddr{ + vaddr=127.1 + pick 'configure non-local venti ip?' yns no + if(~ $cmd yes){ + while(){ + echo -n venti address ': ' + getcmd + vaddr = $cmd + checkip + ~ $#err 0 && break + echo bad ip: $#x>[1=2] + } + } +} + +fn setvconf{ + echo writing venti config to $1 + { + echo index main + for(type in $vtypes) + for(i in $$type) + echo $type $i + } | venti/conf -w $1 || fail +} + +fn magic{ + cmp -s <{dd -quiet 1 -bs 1024 -iseek 256 | + dd -quiet 1 -bs 4 -count 1 | xd -b | sed 1q} <{echo '0000000 ' ^ $1} +} + +fn bmagic{ + cmp -s <{dd -quiet 1 -bs 4 -count 1 | xd -b | sed 1q} <{echo '0000000 ' ^ $1} +} + +fn isarenas{ + magic 'a9 e4 a5 e7' +} + +fn isisect{ + magic 'd1 5c 5e c7' +} + +fn isbloom{ + bmagic 'b1 00 4e ad' +} + +fn ventifmts { + vtypes=(arenas isect bloom) + for(type in $vtypes){ + t = $type + $t = /dev/*/$type^* + if(~ $#$t 0 && ! ~ $type bloom) + fail no $type for venti + n=1 + for(i in $$t){ + cmd=yes + if(is$t<$i){ + echo $a is already a formatted venti $i partition + pick 'reformat '^$i yns no + } + if(~ $cmd yes){ + if(~ $type bloom){ + echo venti/fmt$type $i + venti/fmt$type $i || fail + } + if not{ + echo venti/fmt$type $type$#n $i + venti/fmt$type $type$#n $i || fail + } + } + n=($n 1) + } + } +} + +fn loopback{ + # yes, venti requires us to have a special ether medium. bogus! + grep -s '^127.0.0.1' /net/iproute || { +echo add loop + { + echo -n bind loopback /dev/null + echo -n add 127.0.0.1 255.255.255.255 + } > /net/ipifc/clone || fail + } +} + +ventiaddr +if(~ $vaddr 127.*){ + loopback + ventifmts + setvconf $arenas(1) + venti/fmtindex $arenas(1) + venti/venti -c $arenas(1) + vconf=$arenas(1) +} +if not + vconf=$vaddr +9fat: +echo 'venti='^$vaddr>>/n/9fat/plan9.ini # yee ha. +copydistfossil --- /sys/lib/dist/amd64/install/copydistk Thu Jan 1 00:00:00 1970 +++ /sys/lib/dist/amd64/install/copydistk Thu Apr 3 21:50:58 2014 @@ -0,0 +1,37 @@ +#!/bin/rc + +fn kfs { + disk/kfs -n inst $* +} +fn kfscmd { + disk/kfscmd -n inst $* +} + +fn copydistkfs { + kfs -b 8192 -r -f $disk/fs || fail + mount -c /srv/kfs.inst /n/inst || fail + mount -c /srv/boot /n/atom || fail + kfscmd allow || fail + sed s:installuser:$user:g/tmp/users || fail + bind /tmp/users /n/atom/adm/users || fail + disk/mkfs -kU -s /n/atom -d /n/inst <{ + echo 'adm d775 sys sys' + echo ' users 664 sys sys' + } + kfscmd user || fail + mount -c /srv/kfs.inst /n/inst || fail + + disk/mkfs -kU -s /n/atom -d /n/inst <{echo +} || fail + + d=/n/inst/usr/$user \ + if(! test -d $d){ + mkdir $d #|| fail + chgrp -u $user $d #|| fail + chgrp $user $d #|| fail + } + + kfscmd sync +# kfscmd halt +} + +copydistkfs --- /sys/lib/dist/amd64/install/main Thu Apr 3 21:50:59 2014 +++ /sys/lib/dist/amd64/install/main Thu Apr 3 21:51:00 2014 @@ -127,10 +127,10 @@ } fn pickfstype { - fses = (kfs) + fses = (kfs fossil+venti) fspartskfs = fs fspartsfossil = fs - fspartsfossil+venti = (venti isect arenas fossil) + fspartsfossil+venti = (isect arenas bloom fossil) pick 'filesys to install' fses $fses(1); fstype=$cmd eval 'fsparts=$' ^ fsparts$fstype @@ -138,6 +138,10 @@ case kfs d=`{echo $disk | sed 's!/dev/sd!!g'} bootargs='local!#S/' ^ $d ^ '/fs -B 10000' + case fossil+venti + echo warning: experimental ymmv >[1=2] + d=`{echo $disk | sed 's!/dev/sd!!g'} + bootargs='local!#S/' ^ $d ^ /fs } } @@ -297,6 +301,15 @@ # skip this step for now } +fn copydist { + switch($fstype){ + case kfs + copydistk + case fossil* + copydistf + } +} + init echo plan 9 install echo @@ -310,7 +323,7 @@ pickfstype makepartitions -copydist +copydist pickarches pick 'build full set of amd64 executables?' yns yes ~ $cmd yes && domkall