2N/A#! /bin/sh
2N/Aset -e
2N/A
2N/A# grub-mkconfig helper script.
2N/A# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
2N/A#
2N/A# GRUB is free software: you can redistribute it and/or modify
2N/A# it under the terms of the GNU General Public License as published by
2N/A# the Free Software Foundation, either version 3 of the License, or
2N/A# (at your option) any later version.
2N/A#
2N/A# GRUB is distributed in the hope that it will be useful,
2N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A# GNU General Public License for more details.
2N/A#
2N/A# You should have received a copy of the GNU General Public License
2N/A# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A
2N/Aprefix=@prefix@
2N/Aexec_prefix=@exec_prefix@
2N/Alibdir=@libdir@
2N/Adatarootdir=@datarootdir@
2N/A. ${libdir}/@PACKAGE@/grub-mkconfig_lib
2N/A
2N/ACLASS="--class gnu --class os"
2N/A
2N/Aif [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
2N/A OS=GNU
2N/Aelse
2N/A OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
2N/A CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
2N/Afi
2N/A
2N/Aat_least_one=false
2N/Aall_of_them=true
2N/A
2N/A# FIXME: add l4 here?
2N/Akernel=
2N/Afor i in /boot/gnumach* ; do
2N/A if test -e $i ; then
2N/A basename=`basename $i`
2N/A dirname=`dirname $i`
2N/A rel_dirname=`make_system_path_relative_to_its_root $dirname`
2N/A echo "Found GNU Mach: $i" >&2
2N/A kernels="${kernels} ${rel_dirname}/${basename}"
2N/A at_least_one=true
2N/A fi
2N/Adone
2N/A
2N/A# FIXME: This works for ext2. For other filesystems we might need special-casing
2N/Acase "${GRUB_FS}" in
2N/A *fs) hurd_fs="${GRUB_FS}" ;;
2N/A *) hurd_fs="${GRUB_FS}fs" ;;
2N/Aesac
2N/A
2N/Afor i in /hurd/${hurd_fs}.static /hurd/exec ; do
2N/A if test -e "$i" ; then
2N/A echo "Found Hurd module: $i" >&2
2N/A at_least_one=true
2N/A else
2N/A all_of_them=false
2N/A fi
2N/Adone
2N/A
2N/Aif ${at_least_one} ; then : ; else
2N/A # no hurd here, aborting silently
2N/A exit 0
2N/Afi
2N/A
2N/Aif ${all_of_them} && test -e /lib/ld.so.1 ; then : ; else
2N/A echo "Some Hurd stuff found, but not enough to boot." >&2
2N/A exit 1
2N/Afi
2N/A
2N/Afor kernel in ${kernels}
2N/Ado
2N/A kernel_base="`basename "${kernel}"`"
2N/A KERNEL="using ${kernel_base}"
2N/A
2N/A cat << EOF
2N/Amenuentry "${OS} ${KERNEL}" ${CLASS} {
2N/AEOF
2N/A prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
2N/A message="$(gettext_printf "Loading GNU Mach ...")"
2N/A cat << EOF
2N/A echo '$message'
2N/A multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/}
2N/AEOF
2N/A save_default_entry | sed -e "s/^/\t/"
2N/A prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
2N/A message="$(gettext_printf "Loading the Hurd ...")"
2N/A cat << EOF
2N/A echo '$message'
2N/A module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
2N/A --multiboot-command-line='\${kernel-command-line}' \\
2N/A --host-priv-port='\${host-port}' \\
2N/A --device-master-port='\${device-port}' \\
2N/A --exec-server-task='\${exec-task}' -T typed '\${root}' \\
2N/A '\$(task-create)' '\$(task-resume)'
2N/A module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
2N/A}
2N/AEOF
2N/A
2N/A cat << EOF
2N/Amenuentry "${OS} ${KERNEL} (recovery mode)" ${CLASS} {
2N/AEOF
2N/A prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
2N/A message="$(gettext_printf "Loading GNU Mach ...")"
2N/A cat << EOF
2N/A echo '$message'
2N/A multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} -s
2N/AEOF
2N/A prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
2N/A message="$(gettext_printf "Loading the Hurd ...")"
2N/A cat << EOF
2N/A echo '$message'
2N/A module /hurd/${hurd_fs}.static ${hurd_fs} \\
2N/A --multiboot-command-line='\${kernel-command-line}' \\
2N/A --host-priv-port='\${host-port}' \\
2N/A --device-master-port='\${device-port}' \\
2N/A --exec-server-task='\${exec-task}' -T typed '\${root}' \\
2N/A '\$(task-create)' '\$(task-resume)'
2N/A module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
2N/A}
2N/AEOF
2N/A
2N/Adone