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