xref: /plan9/sys/lib/dist/pc/inst/mkini.awk (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1BEGIN{
2	m = "common"
3	haveold = 0;
4	while(getline <"/n/9fat/plan9-3e.ini" > 0){
5		haveold = 1
6		if($0 ~ /\[.*\]/){
7			m = substr($0, 2, length($0)-2)
8			continue
9		}
10		if(m=="menu" && $0 ~ /^menuitem=4e,/)
11			continue
12		a[m] = a[m] $0 "\n"
13	}
14
15	a["4e"] = ""
16	while(getline <"/tmp/plan9.ini" > 0)
17		a["4e"] = a["4e"] $0 "\n"
18
19	if(a["menu"] == "" && haveold){
20		a["menu"] = "menuitem=3e, Plan 9 Third Edition\n"
21		a["3e"] = ""
22	}
23
24	if(a["common"] != ""){
25		for(i in a)
26			if(i != "4e" && i != "common" && i != "menu")
27				a[i] = a["common"] a[i]
28		delete a["common"]
29	}
30
31	bootdisk4e=ENVIRON["fs"]
32	gsub("/dev/", "boot(args|disk|file)=local!#S/", bootdisk4e)
33
34	if(!haveold)
35		print a["4e"]
36	else{
37		print "[menu]"
38		print "menuitem=4e, Plan 9 Fourth Edition"
39		print a["menu"]
40		print ""
41		delete a["menu"]
42
43		print "[4e]"
44		print a["4e"]
45		print ""
46		delete a["4e"]
47
48		for(i in a){
49			# BUG: if rootdir is already there we should rewrite it
50			# sometimes into /3e/whatwasthere
51			if(a[i] ~ bootdisk4e && !(a[i] ~ /rootdir=/))
52				a[i] = "rootdir=/root/3e\n" a[i]
53			print "[" i "]"
54			gsub(/9fat!9pcdisk/, "9fat!9pc3e", a[i])
55			print a[i]
56			print ""
57		}
58	}
59}
60