xref: /plan9/sys/lib/dist/pc/mkfile (revision 8ccc32ef0b9b7222ff49b683668eb07a18989e02)
1# /sys/lib/dist/pc/mkfile
2<../defs
3
4out=outside			# outside web server
5s=/sys/lib/dist/pc
6x=`{bind -b /sys/lib/dist/bin/$cputype /bin}
7
8default:V: cddisk
9
10SUB=`{ls sub inst}
11boot.raw:DQ: proto $SUB
12	rfork n
13	rm -rf boot
14	mkdir boot
15	bind /dev/null /sys/log/timesync
16	# make files writable for now.
17	sed 's!d000!d775!;s!000!664!;s!555!775!;s!444!664!' proto >proto.cp
18	disk/mkfs -a proto.cp | disk/mkext -d boot
19	@{
20		cd boot/386
21		strip init
22		cd bin
23		strip * */* >[2]/dev/null || status=''
24	}
25	sed 's!/.*!!' proto >proto.cp
26	disk/mkfs -a -s boot proto.cp | tee >{wc -c >[1=2]} |
27		touchfs 1000000000 >$target
28
29boot.bz2:DQ: boot.raw
30	ls -l boot.raw
31	bflz -n 32 <boot.raw >boot.bflz
32	bzip2 -9 <boot.bflz >$target
33	ls -l boot.bflz $target
34
35root.bz2:DQ: boot.bz2
36	{
37		echo bzfilesystem
38		cat boot.bz2
39		dd -if /dev/zero -bs 1024 -count 1 >[2]/dev/null
40	} >$target
41	ls -l $target
42
43/sys/src/9/pc/9pcflop.gz: root.bz2
44	@{
45		rfork n
46		cd /sys/src/9/pc
47		mk 'CONF=pcflop' 9pcflop.gz
48	}
49
50/sys/src/9/pc/9pccd.gz:
51	@{
52		cd /sys/src/9/pc
53		mk 'CONF=pccd' 9pccd.gz
54	}
55
56# disk/format apparently uses stat to obtain a file's real name, so
57# binding 9loadusb onto 9load will store the name 9loadusb in the
58# generated fat filesystem.  the same is true for plan9.ini.cd and plan9.ini.
59
609load: /386/9load
61	cp $prereq $target
62	cp /386/9loaddebug 9loaddebug
63
64# 9load no longer loads from floppies, and even if it did, this
65# no longer works, since 9load+9pcflop.gz won't fit on a floppy:
66#	disk/format: data does not fit on disk (2849 2849)
67#ndisk: 9load /sys/src/9/pc/9pcflop.gz plan9.ini /lib/vgadb
68#	dd -if /dev/zero -of ndisk -bs 1024 -count 1440 >[2]/dev/null
69#	disk/format -f -b /386/pbs -d ndisk \
70#		9load /sys/src/9/pc/9pcflop.gz plan9.ini /lib/vgadb
71#	ls -l ndisk
72
73# cannot list both 9pcflop.gz and 9pccd.gz because they cannot be built
74# in parallel.  stupid mk
75cddisk:D: 9load /sys/src/9/pc/9pcflop.gz plan9.ini.cd /lib/vgadb
76	mk -a /sys/src/9/pc/9pccd.gz
77	mk -a /sys/src/9/pc/9pcflop.gz
78	rfork n
79	cp -x plan9.ini.cd subst/plan9.ini
80	dd -if /dev/zero -of $target -bs 1024 -count 2880 >[2]/dev/null
81	disk/format -t 3½QD -f -b /386/pbs -d $target \
82		/sys/src/9/pc/^(9pcflop 9pccd)^.gz subst/plan9.ini /lib/vgadb
83	ls -l $target
84
85$scr/usbdisk:D: $scr/plan9.iso.bz2 /n/sources/plan9
86	@ {
87	rfork n
88	if (~ $#scr 0 || ~ $scr '') {
89		echo '$scr unset' >[1=2]
90		exit not-set-up
91	}
92	cd $scr
93	bind /dev/null /dev/cons
94	bind /dev/null /dev/consctl
95	{ mkusbboot -s 1900 -r /n/sources/plan9; mv image $target } >[2=1] |
96		grep -v 'mkfs: /sys/lib/sysconfig/proto/.*can''t stat'
97	exit ''
98	}
99$scr/usbdisk.bz2:D: $scr/usbdisk
100	@ {
101	bzip2 <$prereq >$target && rm -f $prereq
102	ls -l $target
103	targsz = `{{ls -s $target; echo 0} | awk '{print $1; exit}'}
104	if (test $targsz -lt 80000) {
105		echo $target implausibly small:	>[1=2]
106		ls -l $target			>[1=2]
107		rm -f $target
108		exit $target-too-small
109	}
110	exit ''
111	}
112
113clean:V:
114	if (! unmount 9load >[2]/dev/null)
115		;
116	rm -rf boot boot.bz2 boot.bflz boot.raw root.bz2 9pcflop ndisk 9load cddisk proto.cp 9loaddebug
117
118install:V: 9loaddebug # ndisk
119	9fs $out
120	dst=/n/$out/sys/lib/dist/web.protect
121	cp 9loaddebug $dst
122	# gzip -9 <ndisk > $dst/plan9.flp.gz
123	# mk clean
124
125test:V: 9loaddebug # ndisk
126	cp 9loaddebug ../web.protect2/n9loaddebug
127	# cp ndisk ../web.protect2/ndisk
128
129cd0:D:	cddisk
130	rm -f cd0
131	disk/mk9660 -9cj -v 'Plan 9 4th Edition' -s . -p cd0.proto -b cddisk cd0
132