From 52768e37c2744c7027635d5de3ec16dea795d219 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sun, 3 Aug 2008 16:38:40 +0000 Subject: [PATCH] 2008-08-03 Robert Millan * util/grub.d/00_header.in: Be platform-agnostic. Probe for existence of modules instead of assuming which platform provides what. * util/update-grub.in: Likewise. --- ChangeLog | 6 ++++++ util/grub.d/00_header.in | 34 ++++++++++++++++++++++++++++------ util/update-grub.in | 29 ++++++++++++++--------------- 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5989ecb13..e60ca752a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-08-03 Robert Millan + + * util/grub.d/00_header.in: Be platform-agnostic. Probe for existence + of modules instead of assuming which platform provides what. + * util/update-grub.in: Likewise. + 2008-08-03 Robert Millan * kern/i386/pc/init.c (make_install_device): Check for `grub_prefix' diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index bf9507c88..007c0268c 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -16,10 +16,12 @@ # You should have received a copy of the GNU General Public License # along with GRUB. If not, see . +transform="@program_transform_name@" + prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ -platform=@platform@ +grub_prefix=`echo /boot/grub | sed ${transform}` . ${libdir}/grub/update-grub_lib @@ -37,20 +39,37 @@ set default=${GRUB_DEFAULT} set timeout=${GRUB_TIMEOUT} EOF -case ${platform}:${GRUB_TERMINAL} in - pc:gfxterm) +case x${GRUB_TERMINAL} in + xgfxterm) # Make the font accessible prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}` + + # Pick a video backend + video_backend= + for i in vbe ; do + if test -e ${grub_prefix}/$i.mod ; then + video_backend=$i + break + fi + done + if ! [ "${video_backend}" ] ; then + echo "No suitable backend could be found for gfxterm." >&2 ; exit 1 + fi + cat << EOF if font `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then set gfxmode=640x480 insmod gfxterm - insmod vbe + insmod ${video_backend} terminal gfxterm fi EOF ;; - *:serial) + xserial) + if ! test -e ${grub_prefix}/serial.mod ; then + echo "Serial terminal not available on this platform." >&2 ; exit 1 + fi + if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then echo "Warning, requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used." >&2 GRUB_SERIAL_COMMAND=serial @@ -58,7 +77,10 @@ EOF echo "${GRUB_SERIAL_COMMAND}" echo "terminal serial" ;; - *:*) + x) + # Just use the native terminal + ;; + x*) echo "terminal ${GRUB_TERMINAL}" ;; esac diff --git a/util/update-grub.in b/util/update-grub.in index 70607a50e..8c60c412f 100644 --- a/util/update-grub.in +++ b/util/update-grub.in @@ -26,7 +26,6 @@ sysconfdir=@sysconfdir@ grub_prefix=`echo /boot/grub | sed ${transform}` grub_cfg=${grub_prefix}/grub.cfg update_grub_dir=${sysconfdir}/grub.d -platform=@platform@ grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}` grub_probe=${sbindir}/`echo grub-probe | sed ${transform}` @@ -127,15 +126,15 @@ if test -f ${sysconfdir}/default/grub ; then . ${sysconfdir}/default/grub fi -# if ${GRUB_TERMINAL} is set, check it has a sane value. if undefined, -# fallback to our default -case ${platform}:${GRUB_TERMINAL} in - pc:) GRUB_TERMINAL=gfxterm ;; - ieee1275:) GRUB_TERMINAL=ofconsole ;; - *:) GRUB_TERMINAL=console ;; - pc:console | pc:serial | ieee1275:ofconsole | ieee1275:console | *:gfxterm) - ;; - *:*) echo "Invalid terminal \"${GRUB_TERMINAL}\"" >&2 ; exit 1 ;; +case x${GRUB_TERMINAL} in + x) + # If this platform supports gfxterm, try to use it. + if test -e ${grub_prefix}/gfxterm.mod ; then + GRUB_TERMINAL=gfxterm + fi + ;; + xconsole | xserial | xofconsole | xgfxterm) ;; + *) echo "Invalid terminal \"${GRUB_TERMINAL}\"" >&2 ; exit 1 ;; esac # check for terminals that require fonts @@ -144,16 +143,16 @@ case ${GRUB_TERMINAL} in if path=`font_path` ; then GRUB_FONT_PATH="${path}" else - # fallback to console - GRUB_TERMINAL=console + # fallback to the native terminal for this platform + unset GRUB_TERMINAL fi ;; esac # does our terminal support utf-8 ? -case ${platform}:${GRUB_TERMINAL} in - *:gfxterm) ;; - *:*) +case ${GRUB_TERMINAL} in + gfxterm) ;; + *) # make sure all our children behave in conformance with ascii.. export LANG=C ;;