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