Blame SOURCES/0089-Migrate-PPC-from-Yaboot-to-Grub2.patch

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