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.

175 lines
4.1 KiB

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