grub-mkconfig multiple terminal support.

* util/grub-mkconfig.in: Handle multiple terminals correctly.
	* util/grub.d/00_header.in: Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-04-02 21:12:20 +02:00
parent 495442ed02
commit d5631db0f2
3 changed files with 110 additions and 87 deletions

6
ChangeLog.mtcfg Normal file
View file

@ -0,0 +1,6 @@
2010-04-02 Vladimir Serbinenko <phcoder@gmail.com>
grub-mkconfig multiple terminal support.
* util/grub-mkconfig.in: Handle multiple terminals correctly.
* util/grub.d/00_header.in: Likewise.

View file

@ -140,27 +140,31 @@ if [ "x${GRUB_TERMINAL}" != "x" ] ; then
GRUB_TERMINAL_OUTPUT="${GRUB_TERMINAL}"
fi
case x${GRUB_TERMINAL_OUTPUT} in
x | xgfxterm)
termoutdefault=0
if [ "x${GRUB_TERMINAL_OUTPUT}" == x ]; then
GRUB_TERMINAL_OUTPUT=gfxterm;
termoutdefault=1;
fi
for x in ${GRUB_TERMINAL_OUTPUT}; do
if [ x${x} == xgfxterm ]; then
# If this platform supports gfxterm, try to use it.
if test -e ${grub_prefix}/gfxterm.mod ; then
if ! test -e ${grub_prefix}/gfxterm.mod ; then
if [ "x$termoutdefault" != "x1" ]; then
echo "gfxterm isn't available on your platform" >&2 ; exit 1
fi
GRUB_TERMINAL_OUTPUT=
break;
fi
# FIXME: this should do something smarter than just loading first
# video backend.
GRUB_VIDEO_BACKEND=$(head -n 1 ${grub_prefix}/video.lst || true)
if [ -n "${GRUB_VIDEO_BACKEND}" ] ; then
GRUB_TERMINAL_OUTPUT=gfxterm
elif [ "${GRUB_TERMINAL_OUTPUT}" = "gfxterm" ] ; then
if [ -z "${GRUB_VIDEO_BACKEND}" ] ; then
if [ "x$termoutdefault" != "x1" ]; then
echo "No suitable backend could be found for gfxterm." >&2 ; exit 1
fi
GRUB_TERMINAL_OUTPUT=
fi
;;
xconsole | xserial | xofconsole) ;;
*) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
esac
# check for terminals that require fonts
case ${GRUB_TERMINAL_OUTPUT} in
gfxterm)
if [ -n "$GRUB_FONT" ] ; then
if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then
GRUB_FONT_PATH=${GRUB_FONT}
@ -186,14 +190,23 @@ case ${GRUB_TERMINAL_OUTPUT} in
done
fi
if [ -z "${GRUB_FONT_PATH}" ] ; then
# fallback to the native terminal for this platform
unset GRUB_TERMINAL_OUTPUT
if [ "x$termoutdefault" != "x1" ]; then
echo "No font for gfxterm found." >&2 ; exit 1
fi
;;
*)
GRUB_TERMINAL_OUTPUT=
fi
fi
done
for x in ${GRUB_TERMINAL_OUTPUT}; do
case "x${x}" in
xgfxterm) ;;
xconsole | xserial | xofconsole)
# make sure all our children behave in conformance with ascii..
export LANG=C
esac
export LANG=C;;
*) echo "Invalid output terminal \"${GRUB_TERMINAL_OUTPUT}\"" >&2 ; exit 1 ;;
esac
done
# These are defined in this script, export them here so that user can
# override them.

View file

@ -59,8 +59,18 @@ function savedefault {
}
EOF
case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
serial:* | *:serial)
serial=0;
gfxterm=0;
for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
if [ xserial = "x$x" ]; then
serial=1;
fi
if [ xgfxterm = "x$x" ]; then
gfxterm=1;
fi
done
if [ "x$serial" = x1 ]; then
if ! test -e ${grub_prefix}/serial.mod ; then
echo "Serial terminal not available on this platform." >&2 ; exit 1
fi
@ -70,8 +80,31 @@ case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
GRUB_SERIAL_COMMAND=serial
fi
echo "${GRUB_SERIAL_COMMAND}"
;;
esac
fi
if [ "x$gfxterm" = x1 ]; then
# Make the font accessible
prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}`
cat << EOF
if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
set gfxmode=${GRUB_GFXMODE}
insmod gfxterm
insmod ${GRUB_VIDEO_BACKEND}
EOF
if [ x$GRUB_THEME != x ] && [ -f $GRUB_THEME ] \
&& is_path_readable_by_grub $GRUB_THEME; then
echo "Found theme: $GRUB_THEME" >&2
prepare_grub_to_access_device `${grub_probe} --target=device $GRUB_THEME` | sed -e "s/^/ /"
cat << EOF
insmod gfxmenu
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
EOF
fi
cat << EOF
fi
EOF
fi
case x${GRUB_TERMINAL_INPUT} in
x)
@ -89,35 +122,6 @@ EOF
esac
case x${GRUB_TERMINAL_OUTPUT} in
xgfxterm)
# Make the font accessible
prepare_grub_to_access_device `${grub_probe} --target=device ${GRUB_FONT_PATH}`
cat << EOF
if loadfont `make_system_path_relative_to_its_root ${GRUB_FONT_PATH}` ; then
set gfxmode=${GRUB_GFXMODE}
insmod gfxterm
insmod ${GRUB_VIDEO_BACKEND}
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
EOF
if [ x$GRUB_THEME != x ] && [ -f $GRUB_THEME ] \
&& is_path_readable_by_grub $GRUB_THEME; then
echo "Found theme: $GRUB_THEME" >&2
prepare_grub_to_access_device `${grub_probe} --target=device $GRUB_THEME` | sed -e "s/^/ /"
cat << EOF
insmod gfxmenu
set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
set menuviewer=gfxmenu
EOF
fi
cat << EOF
fi
EOF
;;
x)
# Just use the native terminal
;;