Browse Source

Plan 9 from Bell Labs 2013-07-30

David du Colombier 10 years ago
parent
commit
7e5007a44d

+ 11 - 3
rc/bin/mkusbboot

@@ -12,7 +12,8 @@ quantum=1000000
 # size of image in $quantum-byte units.  1900 is enough for production system
 # (fs, /n/boot, ~1.2GB); 900 is ample for our install image
 # (sources, /n/sources/plan9, ~370MB).
-size=1900
+defsize=1900
+size=()
 
 fn usage {
 	echo usage: $argv0 '[-b boot] [-p proto] [-r root] [-s 10⁶-bytes]' >[1=2]
@@ -46,7 +47,9 @@ if (! ~ $#* 0)
 if (~ $srcroot /n/*)
 	srcfs=`{ echo $srcroot | sed 's;^/n/([^/]+).*;\1;' }
 if (~ $srcfs sources)
-	size=900
+	defsize=900
+if (~ $#size 0)
+	size=$defsize
 
 # make empty disk image file of maximum size
 echo -n 'image: ' >[1=2]
@@ -67,7 +70,10 @@ disk/prep -bw -a^(9fat nvram fscfg fossil) plan9 >/dev/null
 echo -n 9fat... >[1=2]
 switch ($objtype) {
 case 386
-	k=/$objtype/9pccpuf.gz
+	# we don't normally keep gzipped kernels around,
+	# but usb can be flakey and slow, so we'll make one.
+	k=/tmp/9pccpuf.gz
+	gzip -9 </$objtype/9pccpuf >$k
 case amd64
 	k=/$objtype/9k8cpu
 case *
@@ -78,6 +84,8 @@ cp $boot /tmp/9load		# force format to record the name `9load'
 disk/format -b /386/pbslba -d -r 2 9fat /tmp/9load $k \
 	$syscfg/usb/plan9.ini >[2=1] |
 	grep -v '^(add .* at clust |Init|type |Adding file|used )'
+if (~ $objtype 386)
+	rm -f $k
 rm -f /tmp/9load
 cp /dev/zero nvram >[2]/dev/null
 cp /dev/zero fscfg >[2]/dev/null

+ 6 - 3
sys/lib/dist/cmd/bflz.c

@@ -230,11 +230,14 @@ cmprun(uchar *a, uchar *b, int len)
 int
 countrle(uchar *a)
 {
-	int i;
+	uchar a0;
+	uchar *p;
 
-	for(i=0; a[i]==a[0]; i++)
+	p = a;
+	a0 = *p;
+	while(*++p == a0)
 		;
-	return i;
+	return p - a;
 }
 
 void

+ 6 - 4
sys/lib/dist/cmd/mkfile

@@ -15,10 +15,12 @@ HFILES=
 BIN=/sys/lib/dist/bin/$objtype
 </sys/src/cmd/mkmany
 
-all:V:	bzfs!all
-install:V:	bzfs!install
-clean:V:	bzfs!clean
+all:V:		bzfs!all multi!all
+install:V:	bzfs!install multi!install
+clean:V:	bzfs!clean multi!clean
 
 bzfs!%:V:
-	cd bzfs; mk $stem; cd ..
+	@ { cd bzfs; mk $stem }
 
+multi!%:V:
+	@ { cd multi; mk $stem }

+ 3 - 4
sys/lib/dist/cmd/multi/mkfile

@@ -2,6 +2,7 @@ objtype=386
 </$objtype/mkfile
 
 TARG=multi
+BIN=/sys/lib/dist/bin/$objtype
 
 PIECES=\
 	aux/mouse\
@@ -57,9 +58,9 @@ PIECES=\
 	wc\
 	xd\
 
-8.multi:V: mkmulti mkfile
+$O.multi: mkmulti mkfile
 	mkmulti $PIECES 
-	ls -l 8.multi
+	ls -l $O.multi
 	ls -l /386/bin/$PIECES | awk '{s += $6} END{print s}'
 
 scripts:V:
@@ -71,6 +72,4 @@ scripts:V:
 		chmod +x ../../pc/multi/$b
 	}
 
-BIN=/sys/lib/dist/bin/$objtype
 </sys/src/cmd/mkmany
-

+ 13 - 12
sys/lib/dist/mkfile

@@ -11,13 +11,18 @@ ncd:V: $scr/plan9-new.iso.bz2
 ncd-dist:V: $scr/plan9-new.iso.bz2
 	mk $dist/web.protect/plan9-new.iso.bz2
 
-cd-dist:V: $scr/plan9.iso.bz2
-	mk $dist/web.protect/plan9.iso.bz2
+usb-dist:V: 
+	cd pc; mk usbdisk
 
-contrib-cd:V: $scr/contrib.iso.bz2
-	mk $dist/web.protect/contrib.iso.bz2
+#contrib-cd:V: $scr/contrib.iso.bz2
+#	mk $dist/web.protect/contrib.iso.bz2
+#$scr/contrib.iso:DV:
+#	rm -f $target
+#	disk/mk9660 -9cj -v 'Plan 9 Extras' -s /n/sources \
+#		-p ./contrib.proto $target
 
 $scr/%.iso:D: $src9/dist/replica/plan9.log
+	rfork n
 	@ { cd pc; mk cddisk }
 	rm -f $target
 	bind pc/cddisk cdstub/bootdisk.img
@@ -30,8 +35,9 @@ $scr/%.iso:D: $src9/dist/replica/plan9.log
 	echo 'CD:' $title
 	disk/mk9660 -9cj -v $title -s $src9 -B pbsraw -x 9load $target
 
-# copy compressed file from scratch space to the distribution, carefully
-$dist/web.protect/%.iso.bz2:	$scr/%.iso.bz2
+# copy (compressed) file from scratch space to the distribution, carefully
+# $dist/web.protect/%.iso.bz2:	$scr/%.iso.bz2
+$dist/web.protect/%:		$scr/%
 	>>$target.new
 	chmod +t $target.new		# waste write buf, not venti store
 	cp $prereq $target.new
@@ -82,7 +88,7 @@ odump:V:
 	disk/dump9660 -9cj -v 'Plan 9 4e Dumps' -s $src9 \
 		-p /sys/lib/sysconfig/proto/allproto $scr/distdump.iso
 
-cd.install:V:
+cd.install:DV:
 	bzip2 -9 <$scr/plan9.iso >web.protect/nplan9.iso.bz2
 
 D.install:V:
@@ -139,11 +145,6 @@ $scr/%.iso.bz2:D: $scr/%.iso
 			$stem.iso.bz2 >>/usr/web/plan9checksums.txt
 	}
 
-$scr/contrib.iso:DV:
-	rm -f $target
-	disk/mk9660 -9cj -v 'Plan 9 Extras' -s /n/sources \
-		-p ./contrib.proto $target
-
 rebuild:V:
 	chmod +l build.lock >>build.lock
 	lock build.lock rebuild

+ 36 - 27
sys/lib/dist/pc/mkfile

@@ -1,17 +1,18 @@
+# /sys/lib/dist/pc/mkfile
 out=outside			# outside web server
 s=/sys/lib/dist/pc
 x=`{bind -b /sys/lib/dist/bin/$cputype /bin}
 
-default:V: ndisk
-	ls -l ndisk
+default:V: cddisk
 
 SUB=`{ls sub inst}
-boot.raw:Q: proto $SUB
+boot.raw:DQ: proto $SUB
+	rfork n
 	rm -rf boot
 	mkdir boot
 	bind /dev/null /sys/log/timesync
 	# make files writable for now.
-	cat proto | sed 's!d000!d775!;s!000!664!;s!555!775!;s!444!664!' >proto.cp
+	sed 's!d000!d775!;s!000!664!;s!555!775!;s!444!664!' proto >proto.cp
 	disk/mkfs -a proto.cp | disk/mkext -d boot
 	@{
 		cd boot/386
@@ -19,18 +20,17 @@ boot.raw:Q: proto $SUB
 		cd bin
 		strip * */* >[2]/dev/null || status=''
 	}
-	cat proto | sed 's!/.*!!' >proto.cp
+	sed 's!/.*!!' proto >proto.cp
 	disk/mkfs -a -s boot proto.cp | tee >{wc -c >[1=2]} | 
-		touchfs 1000000000 >boot.raw
+		touchfs 1000000000 >$target
 
-boot.bz2:Q: boot.raw
+boot.bz2:DQ: boot.raw
 	ls -l boot.raw
-	bflz -n 32 < boot.raw >boot.bflz
-	ls -l boot.bflz
-	bzip2 -9 < boot.bflz >$target
-	ls -l $target
+	bflz -n 32 <boot.raw >boot.bflz
+	bzip2 -9 <boot.bflz >$target
+	ls -l boot.bflz $target
 
-root.bz2:Q: boot.bz2
+root.bz2:DQ: boot.bz2
 	{
 		echo bzfilesystem
 		cat boot.bz2
@@ -59,40 +59,49 @@ root.bz2:Q: boot.bz2
 	cp $prereq $target
 	cp /386/9loaddebug 9loaddebug
 
-ndisk: 9load /sys/src/9/pc/9pcflop.gz plan9.ini /lib/vgadb
-	dd -if /dev/zero -of ndisk -bs 1024 -count 1440 >[2]/dev/null
-	disk/format -f -b /386/pbs -d ndisk \
-		9load /sys/src/9/pc/9pcflop.gz plan9.ini /lib/vgadb
-	ls -l ndisk
+# 9load no longer loads from floppies, and even if it did, this
+# no longer works, since 9load+9pcflop.gz won't fit on a floppy:
+#	disk/format: data does not fit on disk (2849 2849)
+#ndisk: 9load /sys/src/9/pc/9pcflop.gz plan9.ini /lib/vgadb
+#	dd -if /dev/zero -of ndisk -bs 1024 -count 1440 >[2]/dev/null
+#	disk/format -f -b /386/pbs -d ndisk \
+#		9load /sys/src/9/pc/9pcflop.gz plan9.ini /lib/vgadb
+#	ls -l ndisk
 
 # cannot list both 9pcflop.gz and 9pccd.gz because they cannot be built 
 # in parallel.  stupid mk
-cddisk:DV: 9load /sys/src/9/pc/9pcflop.gz plan9.ini.cd /lib/vgadb
+cddisk:D: 9load /sys/src/9/pc/9pcflop.gz plan9.ini.cd /lib/vgadb
 	mk -a /sys/src/9/pc/9pccd.gz
 	mk -a /sys/src/9/pc/9pcflop.gz
 	rfork n
 	cp -x plan9.ini.cd subst/plan9.ini
-	dd -if /dev/zero -of cddisk -bs 1024 -count 2880 >[2]/dev/null
-	disk/format -t 3½QD -f -b /386/pbs -d cddisk \
-		/sys/src/9/pc/^(9pcflop.gz 9pccd.gz) \
-		subst/plan9.ini /lib/vgadb
-	ls -l cddisk
+	dd -if /dev/zero -of $target -bs 1024 -count 2880 >[2]/dev/null
+	disk/format -t 3½QD -f -b /386/pbs -d $target \
+		/sys/src/9/pc/^(9pcflop 9pccd)^.gz subst/plan9.ini /lib/vgadb
+	ls -l $target
+
+usbdisk:D: /n/sources/plan9
+	cd $scr
+	mkusbboot -s 1900 -r /n/sources/plan9 && mv image $target
+	gzip -9 $target
+	pwd
+	ls -l $target*
 
 clean:V:
 	if (! unmount 9load >[2]/dev/null)
 		;
 	rm -rf boot boot.bz2 boot.bflz boot.raw root.bz2 9pcflop ndisk 9load cddisk proto.cp 9loaddebug
 
-install:V: ndisk 9loaddebug
+install:V: 9loaddebug # ndisk
 	9fs $out
 	dst=/n/$out/sys/lib/dist/web.protect
 	cp 9loaddebug $dst
-	gzip -9 < ndisk > $dst/plan9.flp.gz
+	# gzip -9 <ndisk > $dst/plan9.flp.gz
 	# mk clean
 
-test:V: ndisk 9loaddebug
+test:V: 9loaddebug # ndisk
 	cp 9loaddebug ../web.protect2/n9loaddebug
-	cp ndisk ../web.protect2/ndisk
+	# cp ndisk ../web.protect2/ndisk
 
 cd0:D:	cddisk
 	rm -f cd0

+ 0 - 6
sys/lib/dist/pc/subst/plan9.ini

@@ -3,7 +3,6 @@
 [menu]
 menuitem=install, Install Plan 9 from this CD
 menuitem=cdboot, Boot Plan 9 from this CD
-# menuitem=debug, Boot Plan 9 from this CD and debug 9load
 
 [common]
 # very cautious settings to get started.
@@ -34,8 +33,3 @@ bootfile=sdD0!cdboot!9pcflop.gz
 [cdboot]
 bootargs=local!#S/sdD0/data
 bootfile=sdD0!cdboot!9pccd.gz
-
-# [debug]
-# bootargs=local!#S/sdD0/data
-# bootfile=sdD0!cdboot!9pccd.gz
-# *debugload=1

+ 2 - 1
sys/man/8/9boot

@@ -440,7 +440,8 @@ In prompt mode, the user is required to type
 a
 .IB bootfile
 in response to the
-.L "Boot from:"
+.L Boot
+.L from:
 prompt.
 .br
 .ne 4

+ 8 - 2
sys/man/8/mkusbboot

@@ -96,8 +96,11 @@ default
 architecture of the default kernel in the disk image
 .TP
 .B /tmp/9load
+files created while executing
 .PD 0
 .TP
+.B /tmp/9pccpuf.gz
+.TP
 .B /srv/fossil
 .TP
 .B /srv/fossil.open
@@ -105,7 +108,6 @@ architecture of the default kernel in the disk image
 .B /srv/fscons
 .TP
 .B /srv/fscons.open
-files created while executing
 .SH SOURCE
 .B /rc/bin/mkusbboot
 .SH SEE ALSO
@@ -123,7 +125,11 @@ Due to name clashes in
 should be run only on machines with no running
 .I fossil
 instance named
-.LR fossil .
+.LR fossil
+and thus no
+.BR /srv/fossil ,
+.BR /srv/fossil.open ,
+etc.
 .PP
 Not all BIOSes can reliably read from USB devices.
 Your mileage may vary.