dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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