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