mkini.awk 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. BEGIN{
  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. a["4e"] = ""
  15. while(getline <"/tmp/plan9.ini" > 0)
  16. a["4e"] = a["4e"] $0 "\n"
  17. if(a["menu"] == "" && haveold){
  18. a["menu"] = "menuitem=3e, Plan 9 Third Edition\n"
  19. a["3e"] = ""
  20. }
  21. if(a["common"] != ""){
  22. for(i in a)
  23. if(i != "4e" && i != "common" && i != "menu")
  24. a[i] = a["common"] a[i]
  25. delete a["common"]
  26. }
  27. bootdisk4e=ENVIRON["fs"]
  28. gsub("/dev/", "boot(args|disk|file)=local!#S/", bootdisk4e)
  29. if(!haveold)
  30. print a["4e"]
  31. else{
  32. print "[menu]"
  33. print "menuitem=4e, Plan 9 Fourth Edition"
  34. print a["menu"]
  35. print ""
  36. delete a["menu"]
  37. print "[4e]"
  38. print a["4e"]
  39. print ""
  40. delete a["4e"]
  41. for(i in a){
  42. # BUG: if rootdir is already there we should rewrite it
  43. # sometimes into /3e/whatwasthere
  44. if(a[i] ~ bootdisk4e && !(a[i] ~ /rootdir=/))
  45. a[i] = "rootdir=/root/3e\n" a[i]
  46. print "[" i "]"
  47. gsub(/9fat!9pcdisk/, "9fat!9pc3e", a[i])
  48. print a[i]
  49. print ""
  50. }
  51. }
  52. }