mirror of the now-defunct rocklinux.org
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.

177 lines
4.3 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/powerpc/yaboot/stone_mod_yaboot.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  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; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. #
  23. # [MAIN] 70 yaboot Yaboot Boot Loader Setup
  24. create_kernel_list() {
  25. for x in `(cd /boot/ ; ls vmlinux* ) | sort` ; do
  26. if [ "$x" = vmlinux ] ; then
  27. label=linux
  28. else
  29. label=linux-${x/vmlinux_/}
  30. fi
  31. cat << EOT >> /etc/yaboot.conf
  32. image=$bootpath/$x
  33. label=$label
  34. root=$rootdev
  35. read-only
  36. EOT
  37. done
  38. }
  39. create_yaboot_conf() {
  40. cat << EOT > /etc/yaboot.conf
  41. # /etc/yaboot.conf created with the ROCK Linux yaboot stone module
  42. # The bootstrap partition
  43. boot=$bootstrapdev
  44. device=hd:
  45. # The partition with the yaboot binaries
  46. partition=$yabootpart
  47. # Initial mutli-boot menu delay
  48. delay=5
  49. # Second yaboot image chooser delay
  50. timeout=80
  51. install=$yabootpath/lib/yaboot/yaboot
  52. magicboot=$yabootpath/lib/yaboot/ofboot
  53. #fgcolor=black
  54. #bgcolor=green
  55. enablecdboot
  56. enablenetboot
  57. enableofboot
  58. EOT
  59. [ "$macosxpart" ] && \
  60. echo -e "\nmacosx=$macosxdev\n" \
  61. >> /etc/yaboot.conf
  62. create_kernel_list
  63. [ -n "$1" ] && gui_message "This is the new /etc/yaboot.conf file:
  64. $( cat /etc/yaboot.conf )"
  65. }
  66. yaboot_install()
  67. {
  68. # format the boostrap if not already done
  69. if hmount $bootstrapdev > /dev/null ; then
  70. humount
  71. else
  72. if gui_yesno "The boostrap device \
  73. $bootstrapdev is not yet HFS formated. \
  74. Format now?" ; then
  75. hformat $bootstrapdev
  76. else
  77. return
  78. fi
  79. fi
  80. # maybe an unpatched yaboot and no devfsd (e.g. during install)
  81. [ ! -c /dev/nvram ] && ln -s /dev/misc/nvram /dev/nvram
  82. yaboot_install_doit
  83. }
  84. yaboot_install_doit() {
  85. gui_cmd 'Installing Yaboot' "echo 'calling ybin' ; ybin"
  86. }
  87. device4()
  88. {
  89. dev="`grep \" $1 \" /proc/mounts | tail -n 1 | \
  90. cut -d ' ' -f 1`"
  91. try="`dirname $1`"
  92. if [ ! "$dev" ] ; then
  93. dev="`grep \" $try \" /proc/mounts | tail -n 1 | \
  94. cut -d ' ' -f 1`"
  95. fi
  96. if [ -h "$dev" ] ; then
  97. echo "/dev/`readlink $dev`"
  98. else
  99. echo $dev
  100. fi
  101. }
  102. realpath() {
  103. dir="`dirname $1`"
  104. file="`basename $1`"
  105. dir="`dirname $dir`/`readlink $dir`"
  106. dir="`echo $dir | sed 's,[^/]*/\.\./,,g'`"
  107. echo $dir/$file
  108. }
  109. yaboot_init() {
  110. bootstrappart="`pdisk -l /dev/discs/disc0/disc | \
  111. grep Apple_Bootstrap | sed -e "s/:.*//" -e "s/ //g"`"
  112. bootstrapdev="`realpath /dev/discs/disc0/part$bootstrappart`"
  113. rootdev="`device4 /`"
  114. bootdev="`device4 /boot`"
  115. yabootdev="`device4 /usr`"
  116. macosxpart="`pdisk -l /dev/discs/disc0/disc | grep Apple_HFS | head -n 1 | \
  117. sed -e "s/:.*//" -e "s/ //g"`"
  118. [ "$macosxpart" ] && macosxdev="`realpath /dev/discs/disc0/part$macosxpart`"
  119. if [ "$rootdev" = "$bootdev" ]
  120. then bootpath=/boot ; else bootpath="" ; fi
  121. if [ "$rootdev" = "$yabootdev" ]
  122. then yabootpath=/usr ; else yabootpath="" ; fi
  123. yabootpart="`echo $yabootdev | sed s/.*part//`"
  124. }
  125. yaboot_setup() {
  126. if gui_yesno "Do you want to install the yaboot bootloader now?"; then
  127. yaboot_init; create_yaboot_conf
  128. yaboot_init; yaboot_install
  129. fi
  130. }
  131. main() {
  132. while
  133. yaboot_init
  134. gui_menu yaboot 'Yaboot Boot Loader Setup' \
  135. "Bootstrap Device ...... $bootstrapdev" "" \
  136. "Yaboot partition:path . $yabootpart:$yabootpath" "" \
  137. "Root Device ........... $rootdev" "" \
  138. "Boot Device ........... $bootdev" "" \
  139. "MacOS X partition ..... $macosxdev" "" \
  140. '' '' \
  141. '(Re-)Create default /etc/yaboot.conf' 'create_yaboot_conf 1' \
  142. '(Re-)Install the yaboot boot chrp script and binary' 'yaboot_install' \
  143. '' '' \
  144. "Edit /etc/yaboot.conf (Config file)" \
  145. "gui_edit 'Yaboot Configurationp' /etc/yaboot.conf"
  146. do : ; done
  147. }