Date: Sunday, March 4, 2018 @ 17:07:10 Author: archange Revision: 302439
Add patch for allowing different ESP mount point As well as a previous commit required to patch. Added: fwupd/trunk/capsule-changes.patch fwupd/trunk/config-esp-path.patch Modified: fwupd/trunk/PKGBUILD -----------------------+ PKGBUILD | 18 ++- capsule-changes.patch | 135 ++++++++++++++++++++++++++ config-esp-path.patch | 242 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 390 insertions(+), 5 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2018-03-04 16:22:40 UTC (rev 302438) +++ PKGBUILD 2018-03-04 17:07:10 UTC (rev 302439) @@ -4,7 +4,7 @@ pkgname=fwupd pkgver=1.0.5 -pkgrel=1 +pkgrel=2 pkgdesc='A simple daemon to allow session software to update firmware' arch=('x86_64') url='https://github.com/hughsie/fwupd' @@ -13,14 +13,22 @@ makedepends=('meson' 'valgrind' 'gtk-doc' 'help2man' 'python-pillow' 'gobject-introspection' 'python-cairo' 'ttf-dejavu' 'adobe-source-han-sans-cn-fonts' 'python-gobject') checkdepends=('umockdev') -source=(${pkgname}-${pkgver}.tar.gz::"${url}/archive/${pkgver}.tar.gz") -sha256sums=('236289aab278fc6611e0a425f7a186895d6755cfdbfd9f182c7bd4bb7fee0324') +source=(${pkgname}-${pkgver}.tar.gz::"${url}/archive/${pkgver}.tar.gz" + 'capsule-changes.patch' + 'config-esp-path.patch') +sha256sums=('236289aab278fc6611e0a425f7a186895d6755cfdbfd9f182c7bd4bb7fee0324' + '5361c6cfc2b7d0cb9a161b7082b780ba30b468347b6489dd32a83e7a376716ac' + '541b7d31eee9fc9386ad451bf92bb17f400216183bd76c554e7628c7006e90ba') +prepare() { + cd ${pkgname}-${pkgver} + patch -p1 -i ../capsule-changes.patch + patch -p1 -i ../config-esp-path.patch +} + build() { cd ${pkgname}-${pkgver} - arch-meson -D b_lto=false ../build - ninja -v -C ../build } Added: capsule-changes.patch =================================================================== --- capsule-changes.patch (rev 0) +++ capsule-changes.patch 2018-03-04 17:07:10 UTC (rev 302439) @@ -0,0 +1,135 @@ +From 02c469052f56dc088705484cbb9f0b788df23b08 Mon Sep 17 00:00:00 2001 +From: Mario Limonciello <mario.limoncie...@dell.com> +Date: Mon, 19 Feb 2018 13:11:27 -0600 +Subject: [PATCH] uefi: Report if UX capsule was supported in the report + metadata + +--- + plugins/uefi/fu-plugin-uefi.c | 47 +++++++++++++++++++------------------------ + 1 file changed, 21 insertions(+), 26 deletions(-) + +diff --git a/plugins/uefi/fu-plugin-uefi.c b/plugins/uefi/fu-plugin-uefi.c +index 1f59a99c..87950d7c 100644 +--- a/plugins/uefi/fu-plugin-uefi.c ++++ b/plugins/uefi/fu-plugin-uefi.c +@@ -29,6 +29,10 @@ + #include "fu-plugin.h" + #include "fu-plugin-vfuncs.h" + ++struct FuPluginData { ++ gboolean ux_capsule; ++}; ++ + /* drop when upgrading minimum required version of efivar to 33 */ + #if !defined (efi_guid_ux_capsule) + #define efi_guid_ux_capsule EFI_GUID(0x3b8c8162,0x188c,0x46a4,0xaec9,0xbe,0x43,0xf1,0xd6,0x56,0x97) +@@ -37,6 +41,8 @@ + void + fu_plugin_init (FuPlugin *plugin) + { ++ FuPluginData *data = fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); ++ data->ux_capsule = FALSE; + fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower"); + fu_plugin_add_report_metadata (plugin, "FwupdateVersion", LIBFWUP_LIBRARY_VERSION); + fu_plugin_add_report_metadata (plugin, "EfivarVersion", EFIVAR_LIBRARY_VERSION); +@@ -89,22 +95,6 @@ fu_plugin_uefi_find (fwup_resource_iter *iter, const gchar *guid_str, GError **e + return re_matched; + } + +-static fwup_resource * +-fu_plugin_uefi_find_raw (fwup_resource_iter *iter, efi_guid_t *guid) +-{ +- fwup_resource *re_matched = NULL; +- fwup_resource *re = NULL; +- while (fwup_resource_iter_next (iter, &re) > 0) { +- efi_guid_t *guid_tmp; +- fwup_get_guid (re, &guid_tmp); +- if (efi_guid_cmp (guid_tmp, guid) == 0) { +- re_matched = re; +- break; +- } +- } +- return re_matched; +-} +- + static void + _fwup_resource_iter_free (fwup_resource_iter *iter) + { +@@ -317,12 +307,6 @@ fu_plugin_uefi_update_splash (GError **error) + { 0, 0 } + }; + +- /* is this supported? */ +- fwup_resource_iter_create (&iter); +- re = fu_plugin_uefi_find_raw (iter, &efi_guid_ux_capsule); +- if (re == NULL) +- return TRUE; +- + /* get the boot graphics resource table data */ + #ifdef HAVE_FWUP_GET_BGRT_INFO + rc = fwup_get_ux_capsule_info (&screen_width, &screen_height); +@@ -381,6 +365,7 @@ fu_plugin_update (FuPlugin *plugin, + FwupdInstallFlags flags, + GError **error) + { ++ FuPluginData *data = fu_plugin_get_data (plugin); + fwup_resource *re = NULL; + guint64 hardware_instance = 0; /* FIXME */ + g_autoptr(fwup_resource_iter) iter = NULL; +@@ -402,9 +387,12 @@ fu_plugin_update (FuPlugin *plugin, + /* perform the update */ + g_debug ("Performing UEFI capsule update"); + fu_device_set_status (device, FWUPD_STATUS_SCHEDULING); +- if (!fu_plugin_uefi_update_splash (&error_splash)) { +- g_warning ("failed to upload BGRT splash text: %s", +- error_splash->message); ++ ++ if (data->ux_capsule) { ++ if (!fu_plugin_uefi_update_splash (&error_splash)) { ++ g_warning ("failed to upload UEFI UX capsule text: %s", ++ error_splash->message); ++ } + } + if (!fu_plugin_uefi_update_resource (re, hardware_instance, blob_fw, error)) + return FALSE; +@@ -508,6 +496,7 @@ fu_plugin_uefi_get_name_for_type (FuPlugin *plugin, guint32 uefi_type) + static void + fu_plugin_uefi_coldplug_resource (FuPlugin *plugin, fwup_resource *re) + { ++ FuPluginData *data = fu_plugin_get_data (plugin); + AsVersionParseFlag parse_flags; + efi_guid_t *guid_raw; + guint32 uefi_type; +@@ -523,7 +512,7 @@ fu_plugin_uefi_coldplug_resource (FuPlugin *plugin, fwup_resource *re) + /* detect the fake GUID used for uploading the image */ + fwup_get_guid (re, &guid_raw); + if (efi_guid_cmp (guid_raw, &efi_guid_ux_capsule) == 0) { +- g_debug ("skipping entry, detected fake BGRT"); ++ data->ux_capsule = TRUE; + return; + } + +@@ -596,10 +585,12 @@ fu_plugin_uefi_test_secure_boot (FuPlugin *plugin) + gboolean + fu_plugin_coldplug (FuPlugin *plugin, GError **error) + { ++ FuPluginData *data = fu_plugin_get_data (plugin); + fwup_resource *re; + gint supported; + g_autoptr(fwup_resource_iter) iter = NULL; + g_autofree gchar *name = NULL; ++ const gchar *ux_capsule_str = "Disabled"; + + /* supported = 0 : ESRT unspported + supported = 1 : unlocked, ESRT supported +@@ -645,6 +636,10 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) + + /* for debugging problems later */ + fu_plugin_uefi_test_secure_boot (plugin); ++ if (data->ux_capsule) ++ ux_capsule_str = "Enabled"; ++ g_debug ("UX Capsule support : %s", ux_capsule_str); ++ fu_plugin_add_report_metadata (plugin, "UEFIUXCapsule", ux_capsule_str); + + return TRUE; + } Added: config-esp-path.patch =================================================================== --- config-esp-path.patch (rev 0) +++ config-esp-path.patch 2018-03-04 17:07:10 UTC (rev 302439) @@ -0,0 +1,242 @@ +From 963dc4245c5b2e1a70fff23e388541badd15d9bb Mon Sep 17 00:00:00 2001 +From: Mario Limonciello <supe...@gmail.com> +Date: Tue, 27 Feb 2018 14:26:58 -0600 +Subject: [PATCH] uefi: Allow overriding ESP mount point via conf file (Fixes: + #421) (#422) + +* uefi: Allow overriding ESP mount point via conf file (Fixes: #421) +--- + contrib/fwupd.spec.in | 1 + + meson.build | 1 + + plugins/uefi/README.md | 13 +++++++++++++ + plugins/uefi/fu-plugin-uefi.c | 42 ++++++++++++++++++++++++++++++++++++++++++ + plugins/uefi/meson.build | 4 ++++ + plugins/uefi/uefi.conf | 5 +++++ + src/fu-plugin.c | 29 +++++++++++++++++++++++++++++ + src/fu-plugin.h | 3 ++- + src/meson.build | 1 + + 9 files changed, 98 insertions(+), 1 deletion(-) + create mode 100644 plugins/uefi/uefi.conf + +diff --git a/contrib/fwupd.spec.in b/contrib/fwupd.spec.in +index 8116f153..54a597b4 100644 +--- a/contrib/fwupd.spec.in ++++ b/contrib/fwupd.spec.in +@@ -187,6 +187,7 @@ mkdir -p --mode=0700 $RPM_BUILD_ROOT%{_localstatedir}/lib/fwupd/gnupg + %doc README.md AUTHORS NEWS + %license COPYING + %config(noreplace)%{_sysconfdir}/fwupd/daemon.conf ++%config(noreplace)%{_sysconfdir}/fwupd/uefi.conf + %dir %{_libexecdir}/fwupd + %{_libexecdir}/fwupd/fwupd + %{_bindir}/dfu-tool +diff --git a/meson.build b/meson.build +index c9a52b22..6fb5332f 100644 +--- a/meson.build ++++ b/meson.build +@@ -199,6 +199,7 @@ if get_option('plugin_uefi') + fwup = dependency('fwup', version : '>= 5') + if fwup.version().version_compare('>= 10') + conf.set('HAVE_FWUP_GET_BGRT_INFO', '1') ++ conf.set('HAVE_FWUP_CUSTOM_ESP', '1') + endif + efivar = dependency('efivar') + conf.set_quoted('EFIVAR_LIBRARY_VERSION', efivar.version()) +diff --git a/plugins/uefi/README.md b/plugins/uefi/README.md +index bdae04ba..28fb587b 100644 +--- a/plugins/uefi/README.md ++++ b/plugins/uefi/README.md +@@ -30,3 +30,16 @@ and compiling it with libsmbios support. + + When fwupd and fwupdate have been compiled with this support you will + be able to enable UEFI support on the device by using the `unlock` command. ++ ++Custom EFI System Partition location ++--------------------- ++`fwupdate` 10 and later allow using an EFI system partition location ++at runtime that is different than the location compiled into the library. ++ ++fwupd 1.0.6 and later can take advantage of this feature by allowing ++users to modify `/etc/fwupd/uefi.conf`. ++ ++An option titled *OverrideESPMountPoint* is available that can be ++uncommented and set to any valid directory on the system. ++ ++Setting an invalid directory will disable the fwupd plugin. +diff --git a/plugins/uefi/fu-plugin-uefi.c b/plugins/uefi/fu-plugin-uefi.c +index 87950d7c..1ecd5484 100644 +--- a/plugins/uefi/fu-plugin-uefi.c ++++ b/plugins/uefi/fu-plugin-uefi.c +@@ -31,6 +31,7 @@ + + struct FuPluginData { + gboolean ux_capsule; ++ gchar *esp_path; + }; + + /* drop when upgrading minimum required version of efivar to 33 */ +@@ -43,11 +44,19 @@ fu_plugin_init (FuPlugin *plugin) + { + FuPluginData *data = fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); + data->ux_capsule = FALSE; ++ data->esp_path = NULL; + fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower"); + fu_plugin_add_report_metadata (plugin, "FwupdateVersion", LIBFWUP_LIBRARY_VERSION); + fu_plugin_add_report_metadata (plugin, "EfivarVersion", EFIVAR_LIBRARY_VERSION); + } + ++void ++fu_plugin_destroy (FuPlugin *plugin) ++{ ++ FuPluginData *data = fu_plugin_get_data (plugin); ++ g_free (data->esp_path); ++} ++ + static gchar * + fu_plugin_uefi_guid_to_string (efi_guid_t *guid_raw) + { +@@ -388,6 +397,10 @@ fu_plugin_update (FuPlugin *plugin, + g_debug ("Performing UEFI capsule update"); + fu_device_set_status (device, FWUPD_STATUS_SCHEDULING); + ++#ifdef HAVE_FWUP_CUSTOM_ESP ++ if (data->esp_path != NULL) ++ fwup_set_esp_mountpoint (data->esp_path); ++#endif + if (data->ux_capsule) { + if (!fu_plugin_uefi_update_splash (&error_splash)) { + g_warning ("failed to upload UEFI UX capsule text: %s", +@@ -582,6 +595,31 @@ fu_plugin_uefi_test_secure_boot (FuPlugin *plugin) + fu_plugin_add_report_metadata (plugin, "SecureBoot", result_str); + } + ++static gboolean load_custom_esp (FuPlugin *plugin, GError **error) ++{ ++ FuPluginData *data = fu_plugin_get_data (plugin); ++ const gchar *key = "OverrideESPMountPoint"; ++ ++ data->esp_path = fu_plugin_get_config_value (plugin, key); ++ if (data->esp_path != NULL) { ++ if (!g_file_test (data->esp_path, G_FILE_TEST_IS_DIR)) { ++ g_set_error (error, ++ FWUPD_ERROR, ++ FWUPD_ERROR_INVALID_FILE, ++ "Invalid %s specified in %s config: %s", ++ fu_plugin_get_name (plugin), key, ++ data->esp_path); ++ ++ return FALSE; ++ } ++ g_debug ("%s set to %s", key, data->esp_path); ++ fu_plugin_add_report_metadata (plugin, key, ++ data->esp_path); ++ } ++ ++ return TRUE; ++} ++ + gboolean + fu_plugin_coldplug (FuPlugin *plugin, GError **error) + { +@@ -634,6 +672,10 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) + while (fwup_resource_iter_next (iter, &re) > 0) + fu_plugin_uefi_coldplug_resource (plugin, re); + ++ /* load any overriden options */ ++ if (!load_custom_esp (plugin, error)) ++ return FALSE; ++ + /* for debugging problems later */ + fu_plugin_uefi_test_secure_boot (plugin); + if (data->ux_capsule) +diff --git a/plugins/uefi/meson.build b/plugins/uefi/meson.build +index f30543e5..d5e03a77 100644 +--- a/plugins/uefi/meson.build ++++ b/plugins/uefi/meson.build +@@ -1,5 +1,9 @@ + cargs = ['-DG_LOG_DOMAIN="FuPluginUefi"'] + ++install_data(['uefi.conf'], ++ install_dir : join_paths(sysconfdir, 'fwupd') ++) ++ + shared_module('fu_plugin_uefi', + sources : [ + 'fu-plugin-uefi.c', +diff --git a/plugins/uefi/uefi.conf b/plugins/uefi/uefi.conf +new file mode 100644 +index 00000000..3a7982cf +--- /dev/null ++++ b/plugins/uefi/uefi.conf +@@ -0,0 +1,5 @@ ++[uefi] ++ ++# For fwupdate 10+ allow overriding ++# the compiled EFI system partition path ++#OverrideESPMountPoint= +diff --git a/src/fu-plugin.c b/src/fu-plugin.c +index 0c226cf6..f3cb3303 100644 +--- a/src/fu-plugin.c ++++ b/src/fu-plugin.c +@@ -1422,6 +1422,35 @@ fu_plugin_get_report_metadata (FuPlugin *plugin) + return priv->report_metadata; + } + ++/** ++ * fu_plugin_get_config_value: ++ * @plugin: a #FuPlugin ++ * @key: A settings key ++ * ++ * Return the value of a key if it's been configured ++ * ++ * Since: 1.0.6 ++ **/ ++gchar * ++fu_plugin_get_config_value (FuPlugin *plugin, const gchar *key) ++{ ++ g_autofree gchar *conf_file = NULL; ++ g_autofree gchar *conf_path = NULL; ++ g_autoptr(GKeyFile) keyfile = NULL; ++ const gchar *plugin_name; ++ ++ plugin_name = fu_plugin_get_name (plugin); ++ conf_file = g_strdup_printf ("%s.conf", plugin_name); ++ conf_path = g_build_filename (FWUPDCONFIGDIR, conf_file, NULL); ++ if (!g_file_test (conf_path, G_FILE_TEST_IS_REGULAR)) ++ return NULL; ++ keyfile = g_key_file_new (); ++ if (!g_key_file_load_from_file (keyfile, conf_path, ++ G_KEY_FILE_NONE, NULL)) ++ return NULL; ++ return g_key_file_get_string (keyfile, plugin_name, key, NULL); ++} ++ + static void + fu_plugin_class_init (FuPluginClass *klass) + { +diff --git a/src/fu-plugin.h b/src/fu-plugin.h +index 61f56b72..700076fb 100644 +--- a/src/fu-plugin.h ++++ b/src/fu-plugin.h +@@ -147,7 +147,8 @@ const gchar *fu_plugin_lookup_quirk_by_usb_device (FuPlugin *plugin, + void fu_plugin_add_report_metadata (FuPlugin *plugin, + const gchar *key, + const gchar *value); +- ++gchar *fu_plugin_get_config_value (FuPlugin *plugin, ++ const gchar *key); + G_END_DECLS + + #endif /* __FU_PLUGIN_H */ +diff --git a/src/meson.build b/src/meson.build +index 4d044aa4..66c4037c 100644 +--- a/src/meson.build ++++ b/src/meson.build +@@ -53,6 +53,7 @@ libfwupdprivate = static_library( + '-DLOCALSTATEDIR="' + localstatedir + '"', + '-DSYSFSFIRMWAREDIR="/sys/firmware"', + '-DFWUPDDATADIR="' + join_paths(datadir, 'fwupd') + '"', ++ '-DFWUPDCONFIGDIR="' + join_paths(default_sysconfdir, 'fwupd') + '"', + '-DFU_OFFLINE_DESTDIR=""', + ], + )