OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.1 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../yaboot/stone_mod_yaboot.sh
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2003 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- T2-COPYRIGHT-NOTE-END ---
  15. #
  16. # [MAIN] 70 yaboot Yaboot Boot Loader Setup
  17. # [SETUP] 90 yaboot
  18. create_kernel_list() {
  19. first=1
  20. for x in `(cd /boot/ ; ls vmlinux_* ) | sort -r` ; do
  21. if [ $first = 1 ] ; then
  22. label=linux ; first=0
  23. else
  24. label=linux-${x/vmlinux_/}
  25. fi
  26. ver=${x/vmlinux_}
  27. cat << EOT
  28. image=$bootpath/$x
  29. label=$label
  30. root=$rootdev
  31. initrd=$bootpath/initrd-${ver}.img
  32. read-only
  33. EOT
  34. done
  35. }
  36. create_yaboot_conf() {
  37. cat << EOT > /etc/yaboot.conf
  38. # /etc/yaboot.conf created with the T2 SDE Yaboot STONE module
  39. # The bootstrap partition
  40. boot=$bootstrapdev
  41. device=hd:
  42. # The partition with the yaboot binaries
  43. partition=$yabootpart
  44. # Initial multi-boot menu delay
  45. delay=5
  46. # Second yaboot image chooser delay
  47. timeout=80
  48. install=$yabootpath/lib/yaboot/yaboot
  49. magicboot=$yabootpath/lib/yaboot/ofboot
  50. #fgcolor=black
  51. #bgcolor=green
  52. enablecdboot
  53. enablenetboot
  54. enableofboot
  55. EOT
  56. [ "$macosxpart" ] && \
  57. echo -e "\nmacosx=$macosxdev\n" \
  58. >> /etc/yaboot.conf
  59. create_kernel_list >> /etc/yaboot.conf
  60. gui_message "This is the new /etc/yaboot.conf file:
  61. $( cat /etc/yaboot.conf )"
  62. }
  63. yaboot_install()
  64. {
  65. # format the boostrap if not already done
  66. if hmount $bootstrapdev > /dev/null ; then
  67. humount
  68. else
  69. if gui_yesno "The boostrap device \
  70. $bootstrapdev is not yet HFS formated. \
  71. Format now?" ; then
  72. hformat $bootstrapdev
  73. else
  74. return 1
  75. fi
  76. fi
  77. # maybe an unpatched yaboot and no devfsd (e.g. during install)
  78. [ ! -c /dev/nvram ] && ln -s /dev/misc/nvram /dev/nvram
  79. yaboot_install_doit
  80. }
  81. yaboot_install_doit() {
  82. gui_cmd 'Installing Yaboot' "echo 'calling ybin' ; ybin"
  83. }
  84. device4()
  85. {
  86. local dev="`sed -n 's,\([^ ]*\) / .*,\1,p' /proc/mounts | tail -n 1`"
  87. if [ ! "$dev" ] ; then # try the higher dentry
  88. local try="`dirname $1`"
  89. dev="`grep \" $try \" /proc/mounts | tail -n 1 | \
  90. cut -d ' ' -f 1`"
  91. fi
  92. if [ -h "$dev" ] ; then
  93. echo "/dev/`readlink $dev`"
  94. else
  95. echo $dev
  96. fi
  97. }
  98. realpath() {
  99. dir="`dirname $1`"
  100. file="`basename $1`"
  101. dir="`dirname $dir`/`readlink $dir`"
  102. dir="`echo $dir | sed 's,[^/]*/\.\./,,g'`"
  103. echo $dir/$file
  104. }
  105. main() {
  106. rootdev="`device4 /`"
  107. dev="${rootdev%%[0-9]*}"
  108. bootdev="`device4 /boot`"
  109. yabootdev="`device4 /usr`"
  110. bootstrappart="`parted $dev print | grep bootstrap | sed 's/ .*//'`"
  111. bootstrapdev="$dev$bootstrappart"
  112. macosxpart="`parted $dev print | grep "hfs+.*OS X" | head -n 1 | sed 's/ .*//'`"
  113. [ "$macosxpart" ] && macosxdev="$dev$macosxpart"
  114. if [ "$rootdev" = "$bootdev" ]
  115. then bootpath=/boot ; else bootpath="" ; fi
  116. if [ "$rootdev" = "$yabootdev" ]
  117. then yabootpath=/usr ; else yabootpath="" ; fi
  118. yabootpart="`echo $yabootdev | sed 's/[^0-9]*//'`"
  119. if [ ! -f /etc/yaboot.conf ] ; then
  120. if gui_yesno "Yaboot does not appear to be configured.
  121. Automatically install yaboot now?"; then
  122. create_yaboot_conf
  123. if ! yaboot_install; then
  124. gui_message "There was an error while installing yaboot."
  125. fi
  126. fi
  127. fi
  128. while
  129. gui_menu yaboot 'Yaboot Boot Loader Setup' \
  130. "Following settings only for expert use: (default)" ""\
  131. "Bootstrap Device ...... $bootstrapdev" "" \
  132. "Yaboot partition:path . $yabootpart:$yabootpath" "" \
  133. "Root Device ........... $rootdev" "" \
  134. "Boot Device ........... $bootdev" "" \
  135. "MacOS X partition ..... $macosxdev" "" \
  136. '' '' \
  137. '(Re-)Create default /etc/yaboot.conf' 'create_yaboot_conf' \
  138. '(Re-)Install the yaboot boot chrp script and binary' 'yaboot_install' \
  139. '' '' \
  140. "Edit /etc/yaboot.conf (Config file)" \
  141. "gui_edit 'Yaboot Configurationp' /etc/yaboot.conf"
  142. do : ; done
  143. }