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