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

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