nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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