From 0cb28681d1541e836d9eeaf6f8515f7f1cd5ffa474cf985fda01ab0b92bb60eb Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Mon, 8 Apr 2019 19:22:48 +0000 Subject: [PATCH] Accepting request 689521 from home:gary_lin:branches:Base:System - change the OS directory in ESP (bsc#1130056) - set the default shim binary for openSUSE/SLE (bsc#1130056) - Link fwupd*.efi.signed to fwupd*.efi as requested by fwupd (bsc#1129466) OBS-URL: https://build.opensuse.org/request/show/689521 OBS-URL: https://build.opensuse.org/package/show/Base:System/fwupd?expand=0&rev=47 --- fwupd-bsc1130056-change-esp-os-name.patch | 74 +++++++++++++++++++++++ fwupd-bsc1130056-change-shim-path.patch | 29 +++++++++ fwupd.changes | 10 +++ fwupd.spec | 14 +++++ 4 files changed, 127 insertions(+) create mode 100644 fwupd-bsc1130056-change-esp-os-name.patch create mode 100644 fwupd-bsc1130056-change-shim-path.patch diff --git a/fwupd-bsc1130056-change-esp-os-name.patch b/fwupd-bsc1130056-change-esp-os-name.patch new file mode 100644 index 0000000..492595a --- /dev/null +++ b/fwupd-bsc1130056-change-esp-os-name.patch @@ -0,0 +1,74 @@ +From 89552eec34eccda2d119465370d07be9fa53092e Mon Sep 17 00:00:00 2001 +From: Gary Lin +Date: Thu, 28 Mar 2019 16:20:22 +0800 +Subject: [PATCH] uefi: add a new option to specify the os name + +fu_uefi_get_esp_path_for_os() generates the path to the OS directory +based on "ID" in /etc/os-release, and it may not work for some distros. + +Take openSUSE as an example, the "ID" for openSUSE Leap is +"opensuse-leap" and that for openSUSE Tumbleweed is "opensuse-tumbleweed". +However, both of them use the same OS directory in the ESP, i.e. +"/EFI/opensuse". + +This commit adds a new build option, efi_os_dir, to allow the packager to +specify the name of OS directory at build time instead of the runtime +detection. + +Signed-off-by: Gary Lin +--- + meson_options.txt | 1 + + plugins/uefi/fu-uefi-common.c | 4 ++++ + plugins/uefi/meson.build | 5 +++++ + 3 files changed, 10 insertions(+) + +diff --git a/meson_options.txt b/meson_options.txt +index 889a888e..5d4163e8 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -28,3 +28,4 @@ option('efi-ld', type : 'string', value : 'ld', description : 'the linker to use + option('efi-libdir', type : 'string', description : 'path to the EFI lib directory') + option('efi-ldsdir', type : 'string', description : 'path to the EFI lds directory') + option('efi-includedir', type : 'string', value : '/usr/include/efi', description : 'path to the EFI header directory') ++option('efi_os_dir', type: 'string', description : 'the name of OS directory in ESP') +diff --git a/plugins/uefi/fu-uefi-common.c b/plugins/uefi/fu-uefi-common.c +index aa1d1105..fadb469f 100644 +--- a/plugins/uefi/fu-uefi-common.c ++++ b/plugins/uefi/fu-uefi-common.c +@@ -246,6 +246,7 @@ gchar * + fu_uefi_get_esp_path_for_os (const gchar *esp_path) + { + const gchar *os_release_id = NULL; ++#ifndef EFI_OS_DIR + g_autoptr(GError) error_local = NULL; + g_autoptr(GHashTable) os_release = fwupd_get_os_release (&error_local); + if (os_release != NULL) { +@@ -255,6 +256,9 @@ fu_uefi_get_esp_path_for_os (const gchar *esp_path) + } + if (os_release_id == NULL) + os_release_id = "unknown"; ++#else ++ os_release_id = EFI_OS_DIR; ++#endif + return g_build_filename (esp_path, "EFI", os_release_id, NULL); + } + +diff --git a/plugins/uefi/meson.build b/plugins/uefi/meson.build +index fd1b3976..8b742864 100644 +--- a/plugins/uefi/meson.build ++++ b/plugins/uefi/meson.build +@@ -3,6 +3,11 @@ subdir('efi') + cargs = ['-DG_LOG_DOMAIN="FuPluginUefi"'] + cargs += '-DEFI_APP_LOCATION_BUILD="' + app.full_path() + '"' + ++efi_os_dir = get_option('efi_os_dir') ++if efi_os_dir != '' ++ cargs += '-DEFI_OS_DIR="' + efi_os_dir + '"' ++endif ++ + install_data(['uefi.quirk'], + install_dir: join_paths(datadir, 'fwupd', 'quirks.d') + ) +-- +2.21.0 + diff --git a/fwupd-bsc1130056-change-shim-path.patch b/fwupd-bsc1130056-change-shim-path.patch new file mode 100644 index 0000000..115b56e --- /dev/null +++ b/fwupd-bsc1130056-change-shim-path.patch @@ -0,0 +1,29 @@ +From f8bbcefe3eed253cda0c86a4c2443292beca82ee Mon Sep 17 00:00:00 2001 +From: Gary Lin +Date: Thu, 28 Mar 2019 15:26:28 +0800 +Subject: [PATCH] Change the path to shim.efi + +For openSUSE/SLE, we use shim.efi instead of shimx64.efi. + +Signed-off-by: Gary Lin +--- + plugins/uefi/fu-uefi-bootmgr.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/plugins/uefi/fu-uefi-bootmgr.c b/plugins/uefi/fu-uefi-bootmgr.c +index 7bec311..22357d4 100644 +--- a/plugins/uefi/fu-uefi-bootmgr.c ++++ b/plugins/uefi/fu-uefi-bootmgr.c +@@ -319,7 +319,8 @@ fu_uefi_bootmgr_bootnext (const gchar *esp_path, FuUefiBootmgrFlags flags, GErro + return FALSE; + + /* test to make sure shim is there if we need it */ +- shim_app = fu_uefi_get_esp_app_path (esp_path, "shim", error); ++ shim_app = g_strdup_printf ("%s/shim.efi", ++ fu_uefi_get_esp_path_for_os (esp_path)); + if (shim_app == NULL) + return FALSE; + if (!g_file_test (shim_app, G_FILE_TEST_EXISTS)) { +-- +2.21.0 + diff --git a/fwupd.changes b/fwupd.changes index e7892e8..ce0be7e 100644 --- a/fwupd.changes +++ b/fwupd.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Thu Mar 28 07:31:49 UTC 2019 - Gary Ching-Pang Lin + +- Add fwupd-bsc1130056-change-esp-os-name.patch to change the + OS directory in ESP (bsc#1130056) +- Add fwupd-bsc1130056-change-shim-path.patch to set the default + shim binary for openSUSE/SLE (bsc#1130056) +- Link fwupd*.efi.signed to fwupd*.efi as requested by fwupd + (bsc#1129466) + ------------------------------------------------------------------- Tue Feb 5 23:00:20 UTC 2019 - Bernhard Voelker diff --git a/fwupd.spec b/fwupd.spec index 410b627..59f7fa3 100644 --- a/fwupd.spec +++ b/fwupd.spec @@ -35,6 +35,10 @@ License: GPL-2.0-or-later AND LGPL-2.1-or-later Group: System/Management URL: https://fwupd.org/ Source: %{name}-%{version}.tar.xz +# PATCH-FIX-UPSTREAM fwupd-bsc1130056-change-esp-os-name.patch bsc#1130056 +Patch1: fwupd-bsc1130056-change-esp-os-name.patch +# PATCH-FIX-OPENSUSE fwupd-bsc1130056-shim-path.patch bsc#1130056 +Patch2: fwupd-bsc1130056-change-shim-path.patch BuildRequires: dejavu-fonts BuildRequires: docbook-utils-minimal BuildRequires: gcab @@ -139,6 +143,8 @@ the local machine. %prep %setup -q +%patch1 -p1 +%patch2 -p1 for file in $(grep -l %{_bindir}/env . -r); do sed -i "s|%{_bindir}/env python3|%{_bindir}/python3|" $file done @@ -151,6 +157,8 @@ done -Dplugin_nvme=false \ -Dplugin_redfish=false \ -Dplugin_uefi=false \ +%else + -Defi_os_dir="%{efidir}" \ %endif %ifnarch %{ix86} x86_64 -Dplugin_dell=false \ @@ -173,6 +181,12 @@ ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcfwupd-offline-update # do not package tests rm -fr %{buildroot}%{_datadir}/installed-tests +%if %{with efi_fw_update} +# link fwupd*.efi.signed to fwupd*.efi (bsc#1129466) +FWUPD_EFI=`basename %{buildroot}/%{_libexecdir}/fwupd/efi/fwupd*.efi` +ln -s %{_libexecdir}/fwupd/efi/$FWUPD_EFI %{buildroot}/%{_libexecdir}/fwupd/efi/$FWUPD_EFI.signed +%endif + %post -n libfwupd2 -p /sbin/ldconfig %postun -n libfwupd2 -p /sbin/ldconfig %preun