#!/bin/rc # Requirements: # - the Plan 9 CD images from Geoff Collyer (First, Second and Third Editions) and David du Colombier (Fourth Edition) # - the sourcesdump archive (2002-12-12 to 2015-01-15) from David du Colombier # - the LICENSE, NOTICE, README, etc. files from the Plan 9 Foundation # - Plan 9 with Fossil and Venti # - the fossil-mtime, fossil-muid and fossil-snap-time patches to Fossil # - the wstat tool from David du Colombier (alternatively, it should be possible to use the fossilcons instead) # hget http://9legacy.org/9legacy/patch/libventi-noarchive.diff | ape/patch -p0 # hget http://9legacy.org/9legacy/patch/libventi-redial.diff | ape/patch -p0 # hget http://9legacy.org/9legacy/patch/libventi-sha1.diff | ape/patch -p0 # cd /sys/src/libventi && mk install && mk clean # hget http://9legacy.org/9legacy/patch/fossil-libventi.diff | ape/patch -p0 # hget http://9legacy.org/9legacy/patch/fossil-wstat-qid.diff | ape/patch -p0 # hget http://9legacy.org/9legacy/patch/fossil-mtime.diff | ape/patch -p0 # hget http://9legacy.org/9legacy/patch/fossil-muid.diff | ape/patch -p0 # hget http://9legacy.org/9legacy/patch/fossil-snap-time.diff | ape/patch -p0 # cd /sys/src/cmd/fossil && mk install && mk clean fn isodate { smon='s/Jan/01/ s/Feb/02/ s/Mar/03/ s/Apr/04/ s/May/05/ s/Jun/06/ s/Jul/07/ s/Aug/08/ s/Sep/09/ s/Oct/10/ s/Nov/11/ s/Dec/12/' date=`{date $*} year=`{echo $date | sed 's/.* //'} mon=`{echo $date | sed -e 's/^....(...).*/\1/' -e $smon} day=`{echo $date | sed -e 's/^........(..).*/\1/'} if(test $day -le 9) day = 0$day echo -n $year-$mon-$day } fn dumpdate { smon='s/Jan/01/ s/Feb/02/ s/Mar/03/ s/Apr/04/ s/May/05/ s/Jun/06/ s/Jul/07/ s/Aug/08/ s/Sep/09/ s/Oct/10/ s/Nov/11/ s/Dec/12/' date=`{date $*} year=`{echo $date | sed 's/.* //'} mon=`{echo $date | sed -e 's/^....(...).*/\1/' -e $smon} day=`{echo $date | sed -e 's/^........(..).*/\1/'} if(test $day -le 9) day = 0$day echo -n $year/$mon^$day } fn yeardate { date=`{date $*} year=`{echo $date | sed 's/.* //'} echo -n $year } fn mount_release { if (! ~ $#* 1) { echo 'usage: mount version' >[1=2] exit usage } mount /srv/$1 $mnt } fn unmount_release { unmount $mnt } fn remove { if (~ $dst '') { echo 'fatal: dst is nil' >[1=2] exit fatal } rm -rf $dst/* } fn copy { if (! ~ $#* 1) { echo 'usage: copy mnt' >[1=2] exit usage } remove dircp $1 $dst } fn license { if (! ~ $#* 1) { echo 'usage: license version' >[1=2] exit usage } if (test -f $dst/notice && test $dst/notice -older $now) { mv $dst/notice $dst/notice.old } if (test -f $dst/NOTICE && test $dst/NOTICE -older $now) { mv $dst/NOTICE $dst/NOTICE.old } if (test -f $dst/sys/src/NOTICE && test $dst/sys/src/NOTICE -older $now) { mv $dst/sys/src/NOTICE $dst/sys/src/NOTICE.old } if (test -f $dst/LICENSE && test $dst/LICENSE -older $now) { mv $dst/LICENSE $dst/LICENSE.old } e=$1 if (echo $e | grep 4e-....-..-.. >/dev/null) { e=4e } if (test -f $dst/notice.old) { # 1e and 2e cp -x $src/license/LICENSE $dst/license cp -x $src/license/LICENSE.lucida.txt $dst/license.lucida cp -x $src/license/NOTICE.$e $dst/notice cp -x $src/license/README.$e $dst/readme chgrp -u sys $dst/license chgrp sys $dst/license chgrp -u sys $dst/license.lucida chgrp sys $dst/license.lucida chgrp -u sys $dst/notice chgrp sys $dst/notice chgrp -u sys $dst/readme chgrp sys $dst/readme } if (test -f $dst/NOTICE.old) { # 3e and 4e cp -x $src/license/LICENSE $dst/LICENSE cp -x $src/license/LICENSE.lucida.txt $dst/LICENSE.lucida cp -x $src/license/NOTICE.$e $dst/NOTICE cp -x $src/license/NOTICE.$e $dst/sys/src/NOTICE cp -x $src/license/README.$e $dst/README chgrp -u sys $dst/LICENSE chgrp sys $dst/LICENSE chgrp -u sys $dst/LICENSE.lucida chgrp sys $dst/LICENSE.lucida chgrp -u sys $dst/NOTICE chgrp sys $dst/NOTICE chgrp -u sys $dst/sys/src/NOTICE chgrp sys $dst/sys/src/NOTICE chgrp -u sys $dst/README chgrp sys $dst/README } } fn snap { if (! ~ $#* 1) { echo 'usage: snap file' >[1=2] exit usage } epoch=`{mtime $1 | awk '{print $1}'} touch -t $epoch $dst date=`{dumpdate $epoch} echo snap $date # withtout the "snap -t" change, but in this case /archive/yyyy/mmdd won't have the proper mtime # echo fsys main create /archive/`{yeardate $epoch} adm adm d555 >>/srv/fscons.outside # echo fsys main sync >>/srv/fscons.outside # echo fsys main snap -a -d /archive/$date >>/srv/fscons.outside echo fsys main sync >>/srv/fscons.outside echo fsys main snap -a -t $epoch >>/srv/fscons.outside } fn local_setup { mount -c /srv/fossil.other /n/other kill ramfs | rc rm -f /srv/ramfs ramfs -u -s mount -c /srv/ramfs /tmp } fn venti_setup { kill fossil | rc kill venti | rc rm -rf $fsdir mkdir $fsdir chmod +t $fsdir cd $fsdir dd -if /dev/zero -of arenas.img -bs 8192 -count 2621440 >[2]/dev/null dd -if /dev/zero -of isect.img -bs 8192 -count 32768 >[2]/dev/null dd -if /dev/zero -of bloom.img -bs 8192 -count 16384 >[2]/dev/null dd -if /dev/zero -of fossil.img -bs 8192 -count 1310720 >[2]/dev/null venti/fmtarenas arenas arenas.img venti/fmtisect isect isect.img venti/fmtbloom bloom.img fossil/flfmt -y fossil.img echo 'index main isect isect.img arenas arenas.img bloom bloom.img addr tcp!127.1!1735 httpaddr tcp!127.1!8001 webroot /sys/src/cmd/venti/srv/www' | venti/conf -w arenas.img venti/fmtindex arenas.img echo 'fsys main config fsys main open -AWPam -c 32768 fsys main snaptime -a none -t none srv -p fscons.outside srv fossil.outside' | fossil/conf -w fossil.img venti=tcp!127.1!1735 venti/venti -c arenas.img -m 10 fossil/fossil -f fossil.img -m 10 aux/clog /srv/fscons.outside /tmp/fossil.log & } fn prepare { mount -c /srv/fossil.outside /n/outside mkdir -p $dst } fn allusers { 9fs sources mkdir -p /n/outside/adm grep -v '^write:' /n/sources/adm/users /n/sources/adm/users.all | sed 's,/n/sources/adm/users(\.all)?:,,'| sort -u >/n/outside/adm/users touch -t $now /n/outside/adm/users touch -t $now /n/outside/adm echo users -r /active/adm/users >>/srv/fscons.outside unmount /n/sources } fn users { if (! ~ $#* 2) { echo 'usage: users version file' >[1=2] exit usage } mkdir -p /n/outside/adm switch ($1) { case 1e 2e echo 'adm:adm:adm: sys:sys:sys: tor:tor:tor: upas:upas:upas:' >/n/outside/adm/users case 3e echo 'adm:adm:adm: glenda:glenda:glenda: sys:sys:sys: upas:upas:upas:' >/n/outside/adm/users case 4e echo 'adm:adm:adm: glenda:glenda:glenda: presotto:presotto:presotto: rob:rob:rob: rsc:rsc:rsc: sys:sys:sys: upas:upas:upas:' >/n/outside/adm/users } chgrp -u adm /n/outside/adm /n/outside/adm/users chgrp adm /n/outside/adm /n/outside/adm/users epoch=`{mtime $2 | awk '{print $1}'} touch -t $epoch /n/outside/adm /n/outside/adm/users } fn 9660 { kill 9660srv | rc rm -f /srv/1e* /srv/2e* /srv/3e* /srv/4e* 9660srv -f $src/geoff/rls/plan9/1e.iso 1e-1992-09-21 9660srv -f $src/geoff/dist/1e/1e.iso 1e-1993-01-04 9660srv -f $src/geoff/rls/plan9/2e.iso 2e 9660srv -f $src/geoff/rls/plan9/3e.iso 3e 9660srv -f $src/geoff/rls/plan9/4e.iso 4e 9660srv -f $src/djc/plan9-4th-2002-04-27.iso 4e-2002-04-27 9660srv -f $src/djc/plan9-4th-2002-09-26.iso 4e-2002-09-26 9660srv -f $src/djc/plan9.iso 4e-latest } fn first { rls=( \ 1e-1992-09-21 \ 1e-1993-01-04 \ ) for (r in $rls) { echo $r mount_release $r users 1e $mnt copy $mnt license 1e snap $mnt unmount_release } } fn second { echo 2e mount_release 2e users 2e $mnt copy $mnt license 2e snap $mnt unmount_release } fn third { mount_release 3e rls=( \ 2000/0607 \ 2000/0612 \ 2000/0617 \ 2000/1014 \ 2001/0327 \ ) for (r in $rls) { echo $r users 3e $mnt/$r/386/9load copy $mnt/$r license 3e snap $mnt/$r/386/9load } unmount_release } fn fourth { mount_release 4e rls=( \ 2002/04271 \ 2002/0502 \ 2002/0523 \ 2002/0926 \ ) for (r in $rls) { echo $r users 4e $mnt copy $mnt/$r license 4e snap $mnt/$r/bootdisk.img } unmount_release } fn snapshots { 9fs sourcesdump mount -c /srv/outside /n/sourcesdump cd / tar xf $dump/sources-2002-12-12.tar.bz2 } fn dodiff { if (! ~ $#* 2) { echo 'usage: dodiff prev cur' >[1=2] exit usage } diff $1 $2 >$tmp/diff grep '^< ' $tmp/diff | awk '{print $2}' | grep -v '/$' >$tmp/rmfiles grep '^< ' $tmp/diff | awk '{print $2}' | grep '/$' | sort -r >$tmp/rmdirs # update metadata on directories (disabled because we prefer to use wstat, which also sets muid, so we do it after extracting the tar) # grep '^> ' $tmp/diff | grep '/ ' | awk '{print "if (test -d \x27"$2"\x27) chmod `{echo "$3" | sed \x27s/[0-9]+([0-9][0-9][0-9])$/\\1/\x27} \x27"$2"\x27"}' | rc # grep '^> ' $tmp/diff | grep '/ ' | awk '{print "if (test -d \x27"$2"\x27) touch -t "$4" \x27"$2"\x27"}' | rc # grep '^> ' $tmp/diff | grep '/ ' | awk '{print "if (test -d \x27"$2"\x27) chgrp -u "$6" \x27"$2"\x27"}' | rc # grep '^> ' $tmp/diff | grep '/ ' | awk '{print "if (test -d \x27"$2"\x27) chgrp "$7" \x27"$2"\x27"}' | rc # remove old files for (i in `{cat $tmp/rmfiles}) rm -f $i # remove empty directories for (i in `{cat $tmp/rmdirs}) rm -f $i } fn stat { if (test -f $tmp/diff) { # subsequent snapshots grep '^> ' $tmp/diff | grep -v ' 22000000555 ' | sed 's/''/''''/' | awk '{print "if (test -e \x27"$2"\x27) wstat \x27"$2"\x27 "$3" 0 "$4" "$6" "$7" "$8}' | rc } if not { # first snapshot cat $cur | grep -v ' 22000000555 ' | sed 's/''/''''/' | awk '{print "if (test -e \x27"$1"\x27) wstat \x27"$1"\x27 "$2" 0 "$3" "$5" "$6" "$7}' | rc } } fn snapshot { dir=/mnt/term/home/djc/sourcesdump tmp=/tmp/lsr.$pid rm -rf $tmp mkdir $tmp remove cd /n/outside prev='' for (i in $dir/lsr-*.me.bz2){ cur=`{echo $i | sed 's/\.bz2$//'} opwd=`{pwd} bunzip2 -c $i >$cur file=`{basename $cur | sed 's/\.me$//'} yyyy=`{echo $file | awk -F- '{print $2}'} mm=`{echo $file | awk -F- '{print $3}'} dd=`{echo $file | awk -F- '{print $4}'} if(~ $yyyy '' || ~ $mm '' || ~ $dd ''){ echo bad lsr: $file: $yyyy-$mm-$dd >[1=2] exit } tar=$dir/sources-$yyyy-$mm-$dd.tar.bz2 if (! test -f $tar){ echo no tar: $tar >[1=2] } if not { if(! ~ $prev ''){ dodiff $prev $cur rm -f $prev } prev=$cur echo $tar mkdir -p $tmp/n/sourcesdump/$yyyy/$mm^$dd bind -c $tmp/n/sourcesdump /n/sourcesdump bind -c /n/outside /n/sourcesdump/$yyyy/$mm^$dd cd / tar Txf $tar /n/sourcesdump/$yyyy/$mm^$dd cd /n/outside stat license 4e epoch=`{sed 1q $cur | awk '{print $3}'} if (test $epoch -ge 1420883405) # Sat 10 Jan 2015 09:50:05 AM UTC cp -x $src/license/README.4e-latest $dst/README echo fsys main sync >>/srv/fscons.outside echo fsys main snap -a -t $epoch >>/srv/fscons.outside unmount /n/sourcesdump/$yyyy/$mm^$dd unmount /n/sourcesdump rm -rf $tmp/n } } } fn trademark { epoch=1606262400 # November 25, 2020 if (test -f $dst/sys/lib/man/trademarks) { sed 's/Plan 9 is a trademark of .*/Plan 9 is a registered trademark of SouthSuite Inc./' <$dst/sys/lib/man/trademarks >/tmp/trademarks && mv /tmp/trademarks $dst/sys/lib/man/trademarks # sys/lib/man/trademarks 0664 958527089 1838 glenda sys rsc 0 wstat $dst/sys/lib/man/trademarks 0664 0 $epoch glenda sys none } if (test -f $dst/sys/doc/trademarks.ps) { cp $src/license/trademarks.4e-latest.ps $dst/sys/doc/trademarks.ps # sys/doc/trademarks.ps 0664 960837912 217896 glenda sys rsc 0 wstat $dst/sys/doc/trademarks.ps 0664 0 $epoch glenda sys none } echo fsys main sync >>/srv/fscons.outside echo fsys main snap -a -t $epoch >>/srv/fscons.outside } dump=/usr/djc/dump src=/usr/djc/plan9 dst=/n/outside/plan9 mnt=/n/9660 now=1616457600 # 2020-03-23 fsdir=/n/other/fossil touch -t $now $src/license/* chmod 444 $src/license/* local_setup venti_setup 9660 prepare allusers first second third fourth snapshot trademark exit mount /srv/fossil.outside /n/sourcesdump main/archive ls -l /n/sourcesdump/* mount /srv/fossil.outside /n/sources ls -l /n/sources/plan9 hget http://localhost:8001/index | tail -5 echo fsys main sync >>/srv/fscons.outside echo fsys main halt >>/srv/fscons.outside kill fossil | rc for (i in flushicache flushdcache kickicache kickdcache) hget http://localhost:8001/$i venti/sync kill venti | rc cd /n/other mv fossil fossil-sources chgrp -u djc fossil-sources fossil-sources/* chgrp sys fossil-sources fossil-sources/* tar cvf fossil-sources.tar fossil-sources && bzip2 fossil-sources.tar