10_hurd.in 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #! /bin/sh
  2. set -e
  3. # grub-mkconfig helper script.
  4. # Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
  5. #
  6. # GRUB is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # GRUB is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. prefix="@prefix@"
  19. exec_prefix="@exec_prefix@"
  20. datarootdir="@datarootdir@"
  21. export TEXTDOMAIN=@PACKAGE@
  22. export TEXTDOMAINDIR="@localedir@"
  23. . "$pkgdatadir/grub-mkconfig_lib"
  24. CLASS="--class gnu --class os"
  25. if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
  26. OS=GNU
  27. else
  28. OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
  29. CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1|LC_ALL=C sed 's,[^[:alnum:]_],_,g') ${CLASS}"
  30. fi
  31. at_least_one=false
  32. all_of_them=true
  33. # FIXME: add l4 here?
  34. kernel=
  35. for i in /boot/gnumach* ; do
  36. if test -e $i ; then
  37. basename=`basename $i`
  38. dirname=`dirname $i`
  39. rel_dirname=`make_system_path_relative_to_its_root $dirname`
  40. gettext_printf "Found GNU Mach: %s" "$i" >&2
  41. echo >&2
  42. kernels="${kernels} ${rel_dirname}/${basename}"
  43. at_least_one=true
  44. fi
  45. done
  46. # FIXME: This works for ext2. For other filesystems we might need special-casing
  47. case "${GRUB_FS}" in
  48. *fs) hurd_fs="${GRUB_FS}" ;;
  49. *) hurd_fs="${GRUB_FS}fs" ;;
  50. esac
  51. for i in /hurd/${hurd_fs}.static /hurd/exec ; do
  52. if test -e "$i" ; then
  53. gettext_printf "Found Hurd module: %s" "$i" >&2
  54. echo >&2
  55. at_least_one=true
  56. else
  57. all_of_them=false
  58. fi
  59. done
  60. if ${at_least_one} ; then : ; else
  61. # no hurd here, aborting silently
  62. exit 0
  63. fi
  64. if ${all_of_them} && test -e /lib/ld.so.1 ; then : ; else
  65. gettext "Some Hurd stuff found, but not enough to boot." >&2
  66. echo >&2
  67. exit 1
  68. fi
  69. title_correction_code=
  70. hurd_entry () {
  71. kernel="$1"
  72. type="$2"
  73. kernel_base="`basename "${kernel}"`"
  74. if [ x$type != xsimple ] ; then
  75. if [ x$type = xrecovery ] ; then
  76. title="$(gettext_printf "%s, with Hurd %s (recovery mode)" "${OS}" "${kernel_base}")"
  77. oldtitle="$OS using $kernel_base (recovery mode)"
  78. else
  79. title="$(gettext_printf "%s, with Hurd %s" "${OS}" "${kernel_base}")"
  80. oldtitle="$OS using $kernel_base"
  81. fi
  82. if [ x"$oldtitle" = x"$GRUB_ACTUAL_DEFAULT" ]; then
  83. quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
  84. title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
  85. grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnuhurd-advanced-$boot_device_id>'gnuhurd-$kernel-$type-$(grub_get_device_id "${GRUB_DEVICE_BOOT}")'")"
  86. fi
  87. sed "s/^/$submenu_indentation/" << EOF
  88. menuentry '$(echo "$title" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnuhurd-$kernel-$type-$(grub_get_device_id "${GRUB_DEVICE_BOOT}")' {
  89. EOF
  90. else
  91. sed "s/^/$submenu_indentation/" << EOF
  92. menuentry '$(echo "$OS" | grub_quote)' ${CLASS} \$menuentry_id_option 'gnuhurd-simple-$(grub_get_device_id "${GRUB_DEVICE_BOOT}")' {
  93. EOF
  94. fi
  95. prepare_grub_to_access_device "${GRUB_DEVICE_BOOT}" | grub_add_tab|sed "s/^/$submenu_indentation/"
  96. message="$(gettext_printf "Loading GNU Mach ...")"
  97. if [ x$type = xrecovery ] ; then
  98. opts="-s"
  99. else
  100. opts=
  101. fi
  102. sed "s/^/$submenu_indentation/" << EOF
  103. echo '$(echo "$message" | grub_quote)'
  104. multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} $opts ${GRUB_CMDLINE_GNUMACH}
  105. EOF
  106. if [ x$type != xrecovery ] ; then
  107. save_default_entry | grub_add_tab| sed "s/^/$submenu_indentation/"
  108. fi
  109. prepare_grub_to_access_device "${GRUB_DEVICE}" | grub_add_tab| sed "s/^/$submenu_indentation/"
  110. message="$(gettext_printf "Loading the Hurd ...")"
  111. if [ x$type = xrecovery ] ; then
  112. opts=
  113. else
  114. opts="--readonly"
  115. fi
  116. sed "s/^/$submenu_indentation/" << EOF
  117. echo '$(echo "$message" | grub_quote)'
  118. module /hurd/${hurd_fs}.static ${hurd_fs} $opts \\
  119. --multiboot-command-line='\${kernel-command-line}' \\
  120. --host-priv-port='\${host-port}' \\
  121. --device-master-port='\${device-port}' \\
  122. --exec-server-task='\${exec-task}' -T typed '\${root}' \\
  123. '\$(task-create)' '\$(task-resume)'
  124. module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
  125. }
  126. EOF
  127. }
  128. title_correction_code=
  129. # Extra indentation to add to menu entries in a submenu. We're not in a submenu
  130. # yet, so it's empty. In a submenu it will be equal to '\t' (one tab).
  131. submenu_indentation=""
  132. is_top_level=true
  133. while [ "x$kernels" != "x" ] ; do
  134. kernel=`version_find_latest $kernels`
  135. if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
  136. hurd_entry "$kernel" simple
  137. submenu_indentation="$grub_tab"
  138. # TRANSLATORS: %s is replaced with an OS name
  139. echo "submenu '$(gettext_printf "Advanced options for %s" "${OS}" | grub_quote)' \$menuentry_id_option 'gnuhurd-advanced-$(grub_get_device_id "${GRUB_DEVICE_BOOT}")' {"
  140. is_top_level=false
  141. fi
  142. hurd_entry "$kernel" advanced
  143. hurd_entry "$kernel" recovery
  144. kernels=`echo $kernels | tr ' ' '\n' | fgrep -vx "$kernel" | tr '\n' ' '`
  145. done
  146. # If at least one kernel was found, then we need to
  147. # add a closing '}' for the submenu command.
  148. if [ x"$is_top_level" != xtrue ]; then
  149. echo '}'
  150. fi
  151. echo "$title_correction_code"