Blame SOURCES/0001-uefi-add-a-new-option-to-specify-the-os-name.patch

cfb861
From 3cd6171c44ef217acef059c871efc726eb9df062 Mon Sep 17 00:00:00 2001
cfb861
From: Gary Lin <glin@suse.com>
cfb861
Date: Thu, 28 Mar 2019 16:20:22 +0800
cfb861
Subject: [PATCH] uefi: add a new option to specify the os name
cfb861
cfb861
fu_uefi_get_esp_path_for_os() generates the path to the OS directory
cfb861
based on "ID" in /etc/os-release, and it may not work for some distros.
cfb861
cfb861
Take openSUSE as an example, the "ID" for openSUSE Leap is
cfb861
"opensuse-leap" and that for openSUSE Tumbleweed is "opensuse-tumbleweed".
cfb861
However, both of them use the same OS directory in the ESP, i.e.
cfb861
"/EFI/opensuse".
cfb861
cfb861
This commit adds a new build option, efi_os_dir, to allow the packager to
cfb861
specify the name of OS directory at build time instead of the runtime
cfb861
detection.
cfb861
cfb861
Signed-off-by: Gary Lin <glin@suse.com>
cfb861
---
cfb861
 meson_options.txt             | 1 +
cfb861
 plugins/uefi/fu-uefi-common.c | 4 ++++
cfb861
 plugins/uefi/meson.build      | 5 +++++
cfb861
 3 files changed, 10 insertions(+)
cfb861
cfb861
diff --git a/meson_options.txt b/meson_options.txt
cfb861
index 23ef8cdb..c1767205 100644
cfb861
--- a/meson_options.txt
cfb861
+++ b/meson_options.txt
cfb861
@@ -24,3 +24,4 @@ option('efi-ld', type : 'string', value : 'ld', description : 'the linker to use
cfb861
 option('efi-libdir', type : 'string', description : 'path to the EFI lib directory')
cfb861
 option('efi-ldsdir', type : 'string', description : 'path to the EFI lds directory')
cfb861
 option('efi-includedir', type : 'string', value : '/usr/include/efi', description : 'path to the EFI header directory')
cfb861
+option('efi_os_dir', type: 'string', description : 'the name of OS directory in ESP')
cfb861
diff --git a/plugins/uefi/fu-uefi-common.c b/plugins/uefi/fu-uefi-common.c
cfb861
index 2e3268aa..4d9d03d7 100644
cfb861
--- a/plugins/uefi/fu-uefi-common.c
cfb861
+++ b/plugins/uefi/fu-uefi-common.c
cfb861
@@ -246,6 +246,7 @@ gchar *
cfb861
 fu_uefi_get_esp_path_for_os (const gchar *esp_path)
cfb861
 {
cfb861
 	const gchar *os_release_id = NULL;
cfb861
+#ifndef EFI_OS_DIR
cfb861
 	g_autoptr(GError) error_local = NULL;
cfb861
 	g_autoptr(GHashTable) os_release = fwupd_get_os_release (&error_local);
cfb861
 	if (os_release != NULL) {
cfb861
@@ -255,6 +256,9 @@ fu_uefi_get_esp_path_for_os (const gchar *esp_path)
cfb861
 	}
cfb861
 	if (os_release_id == NULL)
cfb861
 		os_release_id = "unknown";
cfb861
+#else
cfb861
+	os_release_id = EFI_OS_DIR;
cfb861
+#endif
cfb861
 	return g_build_filename (esp_path, "EFI", os_release_id, NULL);
cfb861
 }
cfb861
 
cfb861
diff --git a/plugins/uefi/meson.build b/plugins/uefi/meson.build
cfb861
index 140418a8..21d4b6c8 100644
cfb861
--- a/plugins/uefi/meson.build
cfb861
+++ b/plugins/uefi/meson.build
cfb861
@@ -3,6 +3,11 @@ subdir('efi')
cfb861
 cargs = ['-DG_LOG_DOMAIN="FuPluginUefi"']
cfb861
 cargs += '-DEFI_APP_LOCATION_BUILD="' + app.full_path() + '"'
cfb861
 
cfb861
+efi_os_dir = get_option('efi_os_dir')
cfb861
+if efi_os_dir != ''
cfb861
+  cargs += '-DEFI_OS_DIR="' + efi_os_dir + '"'
cfb861
+endif
cfb861
+
cfb861
 shared_module('fu_plugin_uefi',
cfb861
   sources : [
cfb861
     'fu-plugin-uefi.c',
cfb861
-- 
cfb861
2.24.1
cfb861