File efibootmgr-derhat.diff of Package efibootmgr

From: Raymund Will <rw@suse.com>
Subject: Make default '--loader' build-time configurable.
 
Each distribution uses a specific 'vendor'-directory in the 
'efi' directory on the EFI System Partition to store their
EFI loader.  There's little use in hardcoding the value
for just one in 'efibootmgr', which is displayed in '--help'
and used as default without '--loader'.

Simply use
  make OS_VENDOR=redhat EFI_LOADER=grub.efi
to get the previous value.  :)

Signed-off-by: Raymund Will <rw@suse.com>
---
 Makefile                    |    4 ++++
 src/efibootmgr/efibootmgr.c |   12 ++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,8 @@
   default: all
 
+  OS_VENDOR := vendor
+  EFI_LOADER := boot.efi
+
   SIGNING_KEY := jordan_hargrave
   RELEASE_DATE := "23-Jan-2013"
   RELEASE_MAJOR := 0
@@ -10,6 +13,7 @@
   RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_SUBLEVEL)$(RELEASE_EXTRALEVEL)
 
   CFLAGS = $(EXTRA_CFLAGS) -DEFIBOOTMGR_VERSION=\"$(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_SUBLEVEL)$(RELEASE_EXTRALEVEL)\" \
+	    -DDEFAULT_LOADER=\"\\\\efi\\\\$(OS_VENDOR)\\\\$(EFI_LOADER)\" \
 	    -Wall -g -D_FILE_OFFSET_BITS=64
 
   MODULES := src
--- a/src/efibootmgr/efibootmgr.c
+++ b/src/efibootmgr/efibootmgr.c
@@ -1,5 +1,6 @@
 /*
-  efibootmgr.c - Manipulates EFI variables as exported in /proc/efi/vars
+  efibootmgr.c - Manipulates EFI variables as exported in
+    /sys/firmware/efi/vars (previously was /proc/efi/vars)
 
   Copyright (C) 2001-2004 Dell, Inc. <Matt_Domsch@dell.com>
 
@@ -18,7 +19,7 @@
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
-  This must tie the EFI_DEVICE_PATH to /boot/efi/EFI/redhat/grub.efi
+  This must tie the EFI_DEVICE_PATH to /boot/efi/efi/<vendor>/<loader>.efi
   The  EFI_DEVICE_PATH will look something like:
     ACPI device path, length 12 bytes
     Hardware Device Path, PCI, length 6 bytes
@@ -55,6 +56,9 @@
 #define EFIBOOTMGR_VERSION "unknown (fix Makefile!)"
 #endif
 
+#ifndef DEFAULT_LOADER
+#define DEFAULT_LOADER  "unknown (fix Makefile!)"
+#endif
 
 typedef struct _var_entry {
 	struct dirent *name;
@@ -786,7 +790,7 @@ usage()
 	printf("\t-g | --gpt            force disk with invalid PMBR to be treated as GPT\n");
 	printf("\t-H | --acpi_hid XXXX  set the ACPI HID (used with -i)\n");
 	printf("\t-i | --iface name     create a netboot entry for the named interface\n");
-	printf("\t-l | --loader name     (defaults to \\EFI\\redhat\\grub.efi)\n");
+	printf("\t-l | --loader name     (defaults to \""DEFAULT_LOADER"\")\n");
 	printf("\t-L | --label label     Boot manager display label (defaults to \"Linux\")\n");
 	printf("\t-n | --bootnext XXXX   set BootNext to XXXX (hex)\n");
 	printf("\t-N | --delete-bootnext delete BootNext\n");
@@ -814,7 +818,7 @@ set_default_opts()
 	opts.active          = -1;   /* Don't set it */
 	opts.timeout         = -1;   /* Don't set it */
 	opts.edd10_devicenum = 0x80;
-	opts.loader          = "\\EFI\\redhat\\grub.efi";
+	opts.loader          = DEFAULT_LOADER;
 	opts.label           = "Linux";
 	opts.disk            = "/dev/sda";
 	opts.iface           = NULL;
openSUSE Build Service is sponsored by