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