code: mafs

ref: cfb63eceee23064149992ca27a04c9679d4c2cf0
dir: /build_mafs_isos.rc/

View raw version
#!/bin/rc
rfork en

# a copy of http://felloff.net/usr/cinap_lenrek/buildisos.rc to build
#	9front iso's including mafs
#
# git/clone git://git.9front.org/plan9front/plan9front ../../plan9front_mafs
# cd ../../plan9front_mafs
# git/import ../custom/mafs/*.patch
#
# to write to a usb disk sd6 from openbsd
# dd if=9front_mafs-9589.ba66d8f69edd895682f2661524a1d07612cb9ba8.amd64.iso of=/dev/rsd6c bs=1M
#
# TODO
# put the release files in contrib.9front.org /usr/9ferno/

www=`{pwd}
cd ../../plan9front_mafs

#archs=(amd64 386 arm arm64)
archs=(amd64)

release=9front_mafs-`{git/log -s | wc -l}^.^`{git/query HEAD}
echo release $release

rm -f $www/$release.*

. ./sys/lib/rootstub
. ./sys/lib/rootbind

# preclean
cd /sys/src
mk clean
cd /sys/src/boot
mk clean
cd /sys/src/9
mk clean

# build for cputype
cd /sys/src
mk install

# build everything
for(i in $archs)@{
	rfork en

	objtype=$i
	bind -c /n/src9/$i /$i

	# user
	cd /sys/src
	mk install

	# mafs
	cd $www
	mk install

	# kernel
	switch($objtype){
	case amd64
		cd /sys/src/9/pc64
		mk install
	case 386
		cd /sys/src/9/pc
		mk install
	case arm
		cd /sys/src/9/bcm
		mk 'CONF=pi' install
		mk 'CONF=pi2' install
	case arm64
		cd /sys/src/9/bcm64
		mk 'CONF=pi3' install
		mk 'CONF=pi4' install
		cd /sys/src/9/imx8
		mk 'CONF=reform' install
	}

	# bootloader
	switch($objtype){
	case 386 amd64
		cd /sys/src/boot/pc
		mk install
		cd /sys/src/boot/efi
		mk install
	case arm arm64
		cd /sys/src/boot/bcm
		mk
		cd /sys/src/boot/reform
		mk
	}
}

# postclean
cd /sys/src
mk clean
cd /sys/src/boot
mk clean
cd /sys/src/9
mk clean

# make manpage indices
cd /sys/man
mk

# release
#trackers=`{hget https://newtrackon.com/api/live | sed 12q}

#webseeds=(\
#	http://9front.org/iso/ \
#	http://lux.felloff.net/usr/cinap_lenrek/9front/ \
#)

fn mkdist {
	cd /sys/lib/dist
	mk $www/$1.gz
	cd $www
	chmod +t $1 $1.gz
	#ip/torrent -t^$trackers -w^$webseeds -c $1.gz > $1.gz.torrent
}

for(a in $archs){
	switch($a){
	case amd64
		mkdist $release.amd64.iso
	case 386
		mkdist $release.386.iso
	case arm
		mkdist $release.pi.img
	case arm64
		mkdist $release.pi3.img
		mkdist $release.reform.img
	}
}

cd $www

iso=$www^/^$release^.amd64.iso
fn mountiso {
	9660srv -f $iso 9front_mafs.amd64
	mount /srv/9front_mafs.amd64 /n/9front_mafs.amd64
	cd /n/9front_mafs.amd64
}

fn unmountiso {
	cd $www
	unmount /srv/9front_mafs.amd64 /n/9front_mafs.amd64;
	rm /srv/9front_mafs.amd64
	rm -rf /n/9front_mafs.amd64;
}

fn start9t {
	# ip/ipconfig -d # for networking from within vmx
	font=/lib/font/bit/vga/unicode.font;
	test -d '#X' && {
		for(i in '#X/'*){ test -f $i/ctl && echo quit > $i/ctl };
	}
	test -f /srv/vmx && rm /srv/vmx
	kill vmx|rc
	vmx -D -M 2G -d $iso -d /mnt/term/home/j/local/plan9/custom/9front.disk -n ea:deadbeefcafe!ether0 -w text /mnt/term/home/j/local/plan9/plan9front_mafs/amd64/9pc64
#	vmx -D -M 2G -d /mnt/term/home/j/local/plan9/custom/9front.disk -n ea:deadbeefcafe!ether0 -w text /mnt/term/home/j/local/plan9/plan9front_mafs/amd64/9pc64
}

fn start9 {
	font=/lib/font/bit/vga/unicode.font
	test -d '#X' && {
		for(i in '#X/'*){ test -f $i/ctl && echo quit > $i/ctl };
	}
	test -f /srv/vmx && rm /srv/vmx
	kill vmx|rc
	vmx -M 4G -D -d $iso -d /mnt/term/home/j/local/plan9/custom/9front.disk -n ea:deadbeefcafe!ether0 -w '800x600' /mnt/term/home/j/local/plan9/plan9front_mafs/amd64/9pc64
}
echo 'iso='^$iso