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

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