Plan 9 from Bell Labs’s /usr/web/sources/plan9/sys/lib/dist/pc/mkfile

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


# /sys/lib/dist/pc/mkfile
<../defs

out=outside			# outside web server
s=/sys/lib/dist/pc
x=`{bind -b /sys/lib/dist/bin/$cputype /bin}

default:V: cddisk

SUB=`{ls sub inst}
boot.raw:DQ: proto $SUB
	rfork n
	rm -rf boot
	mkdir boot
	bind /dev/null /sys/log/timesync
	# make files writable for now.
	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
		strip init
		cd bin
		strip * */* >[2]/dev/null || status=''
	}
	sed 's!/.*!!' proto >proto.cp
	disk/mkfs -a -s boot proto.cp | tee >{wc -c >[1=2]} | 
		touchfs 1000000000 >$target

boot.bz2:DQ: boot.raw
	ls -l boot.raw
	bflz -n 32 <boot.raw >boot.bflz
	bzip2 -9 <boot.bflz >$target
	ls -l boot.bflz $target

root.bz2:DQ: boot.bz2
	{
		echo bzfilesystem
		cat boot.bz2
		dd -if /dev/zero -bs 1024 -count 1 >[2]/dev/null
	} >$target
	ls -l $target

/sys/src/9/pc/9pcflop.gz: root.bz2
	@{
		rfork n
		cd /sys/src/9/pc
		mk 'CONF=pcflop' 9pcflop.gz
	}

/sys/src/9/pc/9pccd.gz:
	@{
		cd /sys/src/9/pc
		mk 'CONF=pccd' 9pccd.gz
	}

# disk/format apparently uses stat to obtain a file's real name, so
# binding 9loadusb onto 9load will store the name 9loadusb in the
# generated fat filesystem.  the same is true for plan9.ini.cd and plan9.ini.

9load: /386/9load
	cp $prereq $target
	cp /386/9loaddebug 9loaddebug

# 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: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 $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

$scr/usbdisk:D: $scr/plan9.iso.bz2 /n/sources/plan9
	@ {
	rfork n
	if (~ $#scr 0 || ~ $scr '') {
		echo '$scr unset' >[1=2]
		exit not-set-up
	}
	cd $scr
	bind /dev/null /dev/cons
	bind /dev/null /dev/consctl
	{ mkusbboot -s 1900 -r /n/sources/plan9; mv image $target } >[2=1] |
		grep -v 'mkfs: /sys/lib/sysconfig/proto/.*can''t stat'
	exit ''
	}
$scr/usbdisk.bz2:D: $scr/usbdisk
	@ {
	bzip2 <$prereq >$target && rm -f $prereq
	ls -l $target
	targsz = `{{ls -s $target; echo 0} | awk '{print $1; exit}'}
	if (test $targsz -lt 80000) {
		echo $target implausibly small:	>[1=2]
		ls -l $target			>[1=2]
		rm -f $target
		exit $target-too-small
	}
	exit ''
	}

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: 9loaddebug # ndisk
	9fs $out
	dst=/n/$out/sys/lib/dist/web.protect
	cp 9loaddebug $dst
	# gzip -9 <ndisk > $dst/plan9.flp.gz
	# mk clean

test:V: 9loaddebug # ndisk
	cp 9loaddebug ../web.protect2/n9loaddebug
	# cp ndisk ../web.protect2/ndisk

cd0:D:	cddisk
	rm -f cd0
	disk/mk9660 -9cj -v 'Plan 9 4th Edition' -s . -p cd0.proto -b cddisk cd0

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].