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

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