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