0dc71c
From f01392a68f7f20bcc064a7d28e10805509701c4d Mon Sep 17 00:00:00 2001
0dc71c
From: Mark Hamzy <hamzy@us.ibm.com>
0dc71c
Date: Wed, 28 Mar 2012 14:46:41 -0500
0dc71c
Subject: [PATCH 089/143] Migrate PPC from Yaboot to Grub2
0dc71c
0dc71c
Add configuration support for serial terminal consoles.  This will set the
0dc71c
maximum screen size so that text is not overwritten.
0dc71c
---
0dc71c
 Makefile.util.def              |   7 +++
0dc71c
 util/grub.d/20_ppc_terminfo.in | 114 +++++++++++++++++++++++++++++++++++++++++
0dc71c
 2 files changed, 121 insertions(+)
0dc71c
 create mode 100644 util/grub.d/20_ppc_terminfo.in
0dc71c
0dc71c
diff --git a/Makefile.util.def b/Makefile.util.def
0dc71c
index a286a89..8f40e78 100644
0dc71c
--- a/Makefile.util.def
0dc71c
+++ b/Makefile.util.def
0dc71c
@@ -485,6 +485,13 @@ script = {
0dc71c
 };
0dc71c
 
0dc71c
 script = {
0dc71c
+  name = '20_ppc_terminfo';
0dc71c
+  common = util/grub.d/20_ppc_terminfo.in;
0dc71c
+  installdir = grubconf;
0dc71c
+  condition = COND_HOST_LINUX;
0dc71c
+};
0dc71c
+
0dc71c
+script = {
0dc71c
   name = '30_os-prober';
0dc71c
   common = util/grub.d/30_os-prober.in;
0dc71c
   installdir = grubconf;
0dc71c
diff --git a/util/grub.d/20_ppc_terminfo.in b/util/grub.d/20_ppc_terminfo.in
0dc71c
new file mode 100644
0dc71c
index 0000000..10d6658
0dc71c
--- /dev/null
0dc71c
+++ b/util/grub.d/20_ppc_terminfo.in
0dc71c
@@ -0,0 +1,114 @@
0dc71c
+#! /bin/sh
0dc71c
+set -e
0dc71c
+
0dc71c
+# grub-mkconfig helper script.
0dc71c
+# Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
0dc71c
+#
0dc71c
+# GRUB is free software: you can redistribute it and/or modify
0dc71c
+# it under the terms of the GNU General Public License as published by
0dc71c
+# the Free Software Foundation, either version 3 of the License, or
0dc71c
+# (at your option) any later version.
0dc71c
+#
0dc71c
+# GRUB is distributed in the hope that it will be useful,
0dc71c
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
0dc71c
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0dc71c
+# GNU General Public License for more details.
0dc71c
+#
0dc71c
+# You should have received a copy of the GNU General Public License
0dc71c
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
0dc71c
+
0dc71c
+prefix=@prefix@
0dc71c
+exec_prefix=@exec_prefix@
0dc71c
+bindir=@bindir@
0dc71c
+libdir=@libdir@
0dc71c
+. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
0dc71c
+
0dc71c
+export TEXTDOMAIN=@PACKAGE@
0dc71c
+export TEXTDOMAINDIR=@localedir@
0dc71c
+
0dc71c
+X=80
0dc71c
+Y=24
0dc71c
+TERMINAL=ofconsole
0dc71c
+
0dc71c
+argument () {
0dc71c
+  opt=$1
0dc71c
+  shift
0dc71c
+
0dc71c
+  if test $# -eq 0; then
0dc71c
+      echo "$0: option requires an argument -- '$opt'" 1>&2
0dc71c
+      exit 1
0dc71c
+  fi
0dc71c
+  echo $1
0dc71c
+}
0dc71c
+
0dc71c
+check_terminfo () {
0dc71c
+
0dc71c
+  while test $# -gt 0
0dc71c
+  do
0dc71c
+    option=$1
0dc71c
+    shift
0dc71c
+
0dc71c
+    case "$option" in
0dc71c
+    terminfo | TERMINFO)
0dc71c
+        ;;
0dc71c
+
0dc71c
+    -g)
0dc71c
+        NEWXY=`argument $option "$@"`
0dc71c
+        NEWX=`echo $NEWXY | cut -d x -f 1`
0dc71c
+        NEWY=`echo $NEWXY | cut -d x -f 2`
0dc71c
+
0dc71c
+        if [ ${NEWX} -ge 80 ] ; then
0dc71c
+          X=${NEWX}
0dc71c
+        else
0dc71c
+          echo "Warning: ${NEWX} is less than the minimum size of 80"
0dc71c
+        fi
0dc71c
+
0dc71c
+        if [ ${NEWY} -ge 24 ] ; then
0dc71c
+          Y=${NEWY}
0dc71c
+        else
0dc71c
+          echo "Warning: ${NEWY} is less than the minimum size of 24"
0dc71c
+        fi
0dc71c
+
0dc71c
+        shift
0dc71c
+        ;;
0dc71c
+
0dc71c
+    *)
0dc71c
+#       # accept console or ofconsole
0dc71c
+#       if [ "$option" != "console" -a "$option" != "ofconsole" ] ; then
0dc71c
+#         echo "Error: GRUB_TERMINFO unknown console: $option"
0dc71c
+#         exit 1
0dc71c
+#       fi
0dc71c
+#       # perfer console
0dc71c
+#       TERMINAL=console
0dc71c
+        # accept ofconsole
0dc71c
+        if [ "$option" != "ofconsole" ] ; then
0dc71c
+          echo "Error: GRUB_TERMINFO unknown console: $option"
0dc71c
+          exit 1
0dc71c
+        fi
0dc71c
+        # perfer console
0dc71c
+        TERMINAL=ofconsole
0dc71c
+        ;;
0dc71c
+    esac
0dc71c
+
0dc71c
+  done
0dc71c
+
0dc71c
+}
0dc71c
+
0dc71c
+if ! uname -m | grep -q ppc ; then
0dc71c
+  exit 0
0dc71c
+fi
0dc71c
+
0dc71c
+if [ "x${GRUB_TERMINFO}" != "x" ] ; then
0dc71c
+  F1=`echo ${GRUB_TERMINFO} | cut -d " " -f 1`
0dc71c
+
0dc71c
+  if [ "${F1}" != "terminfo" ] ; then
0dc71c
+    echo "Error: GRUB_TERMINFO is set to \"${GRUB_TERMINFO}\" The first word should be terminfo."
0dc71c
+    exit 1
0dc71c
+  fi
0dc71c
+
0dc71c
+  check_terminfo ${GRUB_TERMINFO}
0dc71c
+fi
0dc71c
+
0dc71c
+cat << EOF
0dc71c
+  terminfo -g ${X}x${Y} ${TERMINAL}
0dc71c
+EOF
0dc71c
-- 
0dc71c
1.9.3
0dc71c