From e6e2bf9d97285b9e7423e3f97093ec28991c599a Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 10 Jul 2018 12:11:25 -0500 Subject: [PATCH] trivial: Allow EFI application path to come from a different root --- plugins/uefi/fu-uefi-common.c | 4 +++- src/fu-common.c | 13 +++++++++++++ src/fu-common.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/uefi/fu-uefi-common.c b/plugins/uefi/fu-uefi-common.c index 404406be5..e184c00d3 100644 --- a/plugins/uefi/fu-uefi-common.c +++ b/plugins/uefi/fu-uefi-common.c @@ -87,6 +87,7 @@ fu_uefi_get_built_app_path (GError **error) const gchar *extension = ""; const gchar *suffix; g_autofree gchar *source_path = NULL; + g_autofree gchar *prefix = NULL; if (fu_uefi_secure_boot_enabled ()) extension = ".signed"; if (g_file_test (EFI_APP_LOCATION_BUILD, G_FILE_TEST_EXISTS)) @@ -94,8 +95,9 @@ fu_uefi_get_built_app_path (GError **error) suffix = fu_uefi_bootmgr_get_suffix (error); if (suffix == NULL) return NULL; + prefix = fu_common_get_path (FU_PATH_KIND_EFIAPPDIR); source_path = g_strdup_printf ("%s/fwupd%s.efi%s", - EFI_APP_LOCATION, + prefix, suffix, extension); if (!g_file_test (source_path, G_FILE_TEST_EXISTS)) { diff --git a/src/fu-common.c b/src/fu-common.c index ebc5dbba9..4d182491d 100644 --- a/src/fu-common.c +++ b/src/fu-common.c @@ -850,6 +850,19 @@ fu_common_get_path (FuPathKind path_kind) if (tmp != NULL) return g_build_filename (tmp, DATADIR, PACKAGE_NAME, NULL); return g_build_filename (DATADIR, PACKAGE_NAME, NULL); + /* /usr/libexec/fwupd/efi */ + case FU_PATH_KIND_EFIAPPDIR: + tmp = g_getenv ("FWUPD_EFIAPPDIR"); + if (tmp != NULL) + return g_strdup (tmp); +#ifdef EFI_APP_LOCATION + tmp = g_getenv ("SNAP"); + if (tmp != NULL) + return g_build_filename (tmp, EFI_APP_LOCATION, NULL); + return g_strdup (EFI_APP_LOCATION); +#else + return NULL; +#endif /* /etc/fwupd */ case FU_PATH_KIND_SYSCONFDIR_PKG: basedir = fu_common_get_path (FU_PATH_KIND_SYSCONFDIR); diff --git a/src/fu-common.h b/src/fu-common.h index c5263dd04..70d15c124 100644 --- a/src/fu-common.h +++ b/src/fu-common.h @@ -19,6 +19,7 @@ typedef enum { typedef enum { FU_PATH_KIND_CACHEDIR_PKG, FU_PATH_KIND_DATADIR_PKG, + FU_PATH_KIND_EFIAPPDIR, FU_PATH_KIND_LOCALSTATEDIR, FU_PATH_KIND_LOCALSTATEDIR_PKG, FU_PATH_KIND_PLUGINDIR_PKG,