Description: Fall back to i386-pc if booted using EFI but -efi is missing
 It may be possible, particularly in recovery situations, to be booted using
 EFI on x86 when only the i386-pc target is installed.  There's nothing
 actually stopping us installing i386-pc from an EFI environment, and it's
 better than returning a confusing error.
Author: Colin Watson <cjwatson@ubuntu.com>
Forwarded: no
Last-Update: 2012-09-14

Index: b/util/grub-install.in
===================================================================
--- a/util/grub-install.in
+++ b/util/grub-install.in
@@ -292,7 +292,8 @@
 		    linux*)
 			modprobe -q efivars 2>/dev/null || true ;;
 		esac
-		if [ -d /sys/firmware/efi ]; then
+		if [ -d /sys/firmware/efi ] && \
+		   [ -d "${libdir}/@PACKAGE@/x86_64-efi" ]; then
 		    target="x86_64-efi"
 		else
 		    target=i386-pc
@@ -308,7 +309,8 @@
 		    linux*)
 			modprobe -q efivars 2>/dev/null || true ;;
 		esac
-		if [ -d /sys/firmware/efi ]; then
+		if [ -d /sys/firmware/efi ] && \
+		   [ -d "${libdir}/@PACKAGE@/i386-efi" ]; then
 		    target="i386-efi"
 		elif [ -e /proc/device-tree ]; then
 		    target=i386-pc
