shithub: riscv

ref: e2978c785ad240e254849ff944294e62651414e3
dir: /sys/lib/dist/mkfile/

View raw version
proto=/n/src9/sys/lib/sysconfig/proto/distproto
bootproto=/n/src9/sys/lib/sysconfig/proto/9bootproto

cd:V:	/tmp/9front.386.iso.gz

%.gz:D:	%
	gzip -9 < $prereq > $target

%.386.iso:
	@{
	objtype=386
	kernel=/n/src9/$objtype/9pc
	mk $target.$pid.pc.iso
	mv $target.$pid.pc.iso $target
	}

%.amd64.iso:
	@{
	objtype=amd64
	kernel=/n/src9/$objtype/9pc64
	mk $target.$pid.pc.iso
	mv $target.$pid.pc.iso $target
	}

%.amd64.qcow2:
	@{
	objtype=amd64
	kernel=/n/src9/$objtype/9pc64
	echo 'bootfile='^`{basename $kernel} > /env/plan9.ini
	fatfiles=(/386/9bootfat /env/plan9.ini $kernel)
	mb=3770
	mk $target.$pid.disk
	mv $target.$pid.disk $target
	}

%.arm64.qcow2: /n/src9/sys/src/boot/qemu/boot.scr
	@{
	objtype=arm64
	kernel=/n/src9/$objtype/9qemu.u
	> /env/plan9.ini {
		echo 'console=0'
	}
	fatfiles=(/n/src9/sys/src/boot/qemu/boot.scr /env/plan9.ini $kernel)
	mb=3770
	mk $target.$pid.disk
	mv $target.$pid.disk $target
	}

%.pi.img:
	@{
	objtype=arm
	bootcode=/sys/src/boot/bcm/^(bootcode.bin fixup_cd.dat start_cd.elf LICENCE.broadcom)
	kernels=/n/src9/$objtype/^(9pi 9pi2)
	> /env/config.txt {
		echo '[pi0]'
		echo 'kernel=9pi'
		echo '[pi1]'
		echo 'kernel=9pi'
		echo '[pi2]'
		echo 'kernel=9pi2'
		echo '[pi3]'
		echo 'kernel=9pi2'
		echo 'core_freq=250'
		echo '[all]'
		echo 'gpu_mem=16'
		echo 'enable_uart=1'
		echo 'boot_delay=1'
	}
	> /env/cmdline.txt {
		echo 'console=0'
	}
	fatfiles=(/env/config.txt /env/cmdline.txt $bootcode $kernels)
	mb=1885	# storage vendors idea of 2GB
	mk $target.$pid.disk
	mv $target.$pid.disk $target
	}

%.pi3.img:
	@{
	objtype=arm64
	bootcode=/sys/src/boot/bcm/^(bootcode.bin fixup_cd.dat start_cd.elf fixup4cd.dat start4cd.elf bcm2711-rpi-4-b.dtb LICENCE.broadcom)
	kernel=/n/src9/$objtype/^(9pi3 9pi4)
	> /env/config.txt {
		echo '[pi4]'
		echo 'kernel=9pi4'
		echo 'arm_64bit=1'
		echo '[pi3]'
		echo 'kernel=9pi3'
		echo 'arm_64bit=1'
		echo '[all]'
		echo 'gpu_mem=16'
		echo 'core_freq=250'
		echo 'enable_uart=1'
		echo 'boot_delay=1'
	}
	> /env/cmdline.txt {
		echo 'console=0'
	}
	fatfiles=(/env/config.txt /env/cmdline.txt $bootcode $kernel)
	mb=1885	# storage vendors idea of 2GB
	mk $target.$pid.disk
	mv $target.$pid.disk $target
	}

%.zynq.img:D:
	@{
	objtype=arm
	kernel=/n/src9/$objtype/9zynq
	echo 'bootfile='^`{basename $kernel} > /env/plan9.ini
	fatfiles=(/env/plan9.ini $kernel)
	mb=1885	# storage vendors idea of 2GB
	mk $target.$pid.disk
	mv $target.$pid.disk $target
	}

%.reform.img:D:	/n/src9/sys/src/boot/reform/flash.bin /n/src9/sys/src/boot/reform/boot.scr
	@{
	objtype=arm64
	kernel=/n/src9/$objtype/9reform.u
	> /env/plan9.ini {
		echo 'console=0'
	}
	fatfiles=(/n/src9/sys/src/boot/reform/boot.scr /env/plan9.ini $kernel)
	mb=1885	# storage vendors idea of 2GB
	mk $target.$pid.disk
	mv $target.$pid.disk $target && dd -trunc 0 -bs 1024 -oseek 33 -if /n/src9/sys/src/boot/reform/flash.bin -of $target 
	}

%.pc.iso:D:	$proto /n/src9/sys/lib/sysconfig/proto/9bootproto $kernel
	@{rfork n
	mk binds
	{grep -v '^bootfile=' /n/src9/cfg/plan9.ini
	echo 'bootfile='^`{echo $kernel | sed 's!^/n/src9!!'}} > /env/plan9.ini
	bind /env/plan9.ini /n/src9/cfg/plan9.ini
	disk/mk9660 -c9j -B 386/9bootiso -E 386/efiboot.fat \
		-p <{cat $proto $bootproto} \
		-s /n/src9 -v 'Plan 9 Front ('^$objtype^')' $target
	if(test -r /n/src9/386/9boothyb){
		dd -if /dev/zero -bs 2048 -count 1024 >> $target
		disk/partfs -m /n/partfs $target
		disk=/n/partfs/sdXX
		disk/mbr -m /n/src9/386/mbr $disk/data
		@{echo a p1 '$-1' '$'
			echo t p1 ESP
			echo A p1
			echo w
			echo q} | disk/fdisk -b $disk/data
		disk/format -b /n/src9/386/pbs -xd -t hard $disk/esp
		s = esp.$pid
		dossrv -f $disk/esp $s
		mount -c /srv/$s /n/esp
		cp /n/src9/386/9boothyb /n/esp/9bootfat
		mkdir /n/esp/efi
		mkdir /n/esp/efi/boot
		cp /n/src9/386/boot*.efi /n/esp/efi/boot
		unmount /n/esp
		rm -f /srv/$s
	}}

%.disk:D:	$proto $fatfiles
	@{rfork n
	mk binds
	rm -f $target
	s=`{basename $target}
	if(~ $target *.qcow2.*){
		disk/qcowfs -n `{echo $mb '*1048576' | pc} $target
		disk/partfs -m /n/$s /mnt/qcow/data
	}
	if not {
		dd -if /dev/zero -of $target -bs 1048576 -oseek $mb -count 1
		disk/partfs -m /n/$s $target
	}
	d=/n/$s/sdXX
	disk/mbr $d/data
	if(~ $target *.pi.img.* *.pi3.img.*){
		{
			echo 'a p1 . .+100M'
			echo 't p1 FAT32'
			echo 'a p2 . $'
			echo 't p2 PLAN9'
			echo 'A p1'
			echo 'p'
			echo 'w'
			echo 'q'
		} | disk/fdisk -b $d/data
		disk/prep -bw -a^(nvram fs) $d/plan9
		disk/format -d $d/dos $fatfiles
	}
	if not if(~ $target *.reform.img.* *.arm64.qcow2.*){
		{
			echo 'a p1 4M 100M'
			echo 't p1 FAT32'
			echo 'a p2 . $'
			echo 't p2 PLAN9'
			echo 'A p1'
			echo 'p'
			echo 'w'
			echo 'q'
		} | disk/fdisk -b $d/data
		disk/prep -bw -a^(nvram fs) $d/plan9
		disk/format -d $d/dos $fatfiles
	}
	if not if(~ $target *.amd64.qcow2.*){
		disk/mbr -m /386/mbr $d/data
		disk/fdisk -baw $d/data
		disk/prep -bw -a^(9fat nvram fs) $d/plan9
		disk/format -b /386/pbs -d -r 2 $d/9fat $fatfiles
	}
	if not {
		disk/fdisk -baw $d/data
		disk/prep -bw -a^(9fat nvram fs) $d/plan9
		disk/format -d -r 2 $d/9fat $fatfiles
	}
	hjfs -f $d/fs -n $s -S -r
	{
		echo echo on
		echo create /dist sys sys 775 d
		echo create /usr sys sys 775 d
		user=glenda
		echo newuser $user
		echo newuser adm +$user
		echo newuser sys +$user
		echo newuser upas +$user
		echo echo off
		sleep 1
	} >> /srv/$s.cmd
	mount -N -c /srv/$s /n/newfs
	disk/mkfs -z 4096 -U -s /n/src9 -d /n/newfs <{cat $proto $bootproto}
	echo sync >> /srv/$s.cmd
	echo halt >> /srv/$s.cmd
	while(test -e /srv/$s.cmd) sleep 1
	exit ''
	}

binds:V:
	test -d /n/src9/.git && bind /n/src9 /n/src9/dist/plan9front
	bind cfg /n/src9/cfg
	bind mail/lib /n/src9/mail/lib
	bind ndb /n/src9/lib/ndb
	bind -a adm/timezone /n/src9/adm/timezone
	aux/stub -d /n/src9/usr
	bind usr /n/src9/usr