15a2072
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a2072
From: Steve Langasek <steve.langasek@ubuntu.com>
15a2072
Date: Mon, 13 Jan 2014 12:13:12 +0000
15a2072
Subject: [PATCH] Output a menu entry for firmware setup on UEFI FastBoot
15a2072
 systems
15a2072
15a2072
If fastboot is enabled in the BIOS then often it is not possible to
15a2072
enter the firmware setup menu, add a menu entry for this.
15a2072
15a2072
hdegoede: Cherry picked the Ubuntu patch from:
15a2072
https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/patches/uefi_firmware_setup.patch
15a2072
Into the Fedora / RH grub version
15a2072
15a2072
According to:
15a2072
https://git.launchpad.net/~ubuntu-core-dev/grub/+git/ubuntu/tree/debian/copyright
15a2072
The patch is licensed under GPL-3+
15a2072
15a2072
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
15a2072
---
15a2072
 Makefile.util.def               |  6 ++++++
15a2072
 util/grub.d/30_uefi-firmware.in | 46 +++++++++++++++++++++++++++++++++++++++++
15a2072
 2 files changed, 52 insertions(+)
15a2072
 create mode 100644 util/grub.d/30_uefi-firmware.in
15a2072
15a2072
diff --git a/Makefile.util.def b/Makefile.util.def
15a2072
index 0fdfdd91fb0..5a8c390a1da 100644
15a2072
--- a/Makefile.util.def
15a2072
+++ b/Makefile.util.def
15a2072
@@ -529,6 +529,12 @@ script = {
15a2072
   installdir = grubconf;
15a2072
 };
15a2072
 
15a2072
+script = {
15a2072
+  name = '30_uefi-firmware';
15a2072
+  common = util/grub.d/30_uefi-firmware.in;
15a2072
+  installdir = grubconf;
15a2072
+};
15a2072
+
15a2072
 script = {
15a2072
   name = '40_custom';
15a2072
   common = util/grub.d/40_custom.in;
15a2072
diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in
15a2072
new file mode 100644
15a2072
index 00000000000..3c9f533d8c6
15a2072
--- /dev/null
15a2072
+++ b/util/grub.d/30_uefi-firmware.in
15a2072
@@ -0,0 +1,46 @@
15a2072
+#! /bin/sh
15a2072
+set -e
15a2072
+
15a2072
+# grub-mkconfig helper script.
15a2072
+# Copyright (C) 2012  Free Software Foundation, Inc.
15a2072
+#
15a2072
+# GRUB is free software: you can redistribute it and/or modify
15a2072
+# it under the terms of the GNU General Public License as published by
15a2072
+# the Free Software Foundation, either version 3 of the License, or
15a2072
+# (at your option) any later version.
15a2072
+#
15a2072
+# GRUB is distributed in the hope that it will be useful,
15a2072
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
15a2072
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15a2072
+# GNU General Public License for more details.
15a2072
+#
15a2072
+# You should have received a copy of the GNU General Public License
15a2072
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
15a2072
+
15a2072
+prefix="@prefix@"
15a2072
+exec_prefix="@exec_prefix@"
15a2072
+datarootdir="@datarootdir@"
15a2072
+
15a2072
+export TEXTDOMAIN=@PACKAGE@
15a2072
+export TEXTDOMAINDIR="@localedir@"
15a2072
+
15a2072
+. "@datadir@/@PACKAGE@/grub-mkconfig_lib"
15a2072
+
15a2072
+efi_vars_dir=/sys/firmware/efi/vars
15a2072
+EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c
15a2072
+OsIndications="$efi_vars_dir/OsIndicationsSupported-$EFI_GLOBAL_VARIABLE/data"
15a2072
+
15a2072
+if [ -e "$OsIndications" ] && \
15a2072
+   [ "$(( $(printf 0x%x \'"$(cat $OsIndications | cut -b1)") & 1 ))" = 1 ]; then
15a2072
+  LABEL="System setup"
15a2072
+
15a2072
+  gettext_printf "Adding boot menu entry for EFI firmware configuration\n" >&2
15a2072
+
15a2072
+  onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
15a2072
+
15a2072
+  cat << EOF
15a2072
+menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' {
15a2072
+	fwsetup
15a2072
+}
15a2072
+EOF
15a2072
+fi