diff --git a/contrib/ci/build_freebsd_package.sh b/contrib/ci/build_freebsd_package.sh index 60f56614ce04..01c5ef4ac7c5 100755 --- a/contrib/ci/build_freebsd_package.sh +++ b/contrib/ci/build_freebsd_package.sh @@ -32,16 +32,13 @@ if [ -z "$GITHUB_SHA" ] || [ -z "$GITHUB_REPOSITORY" ] || \ exit 1 fi -# Include-file of libefivar port uses GCC-specific builtin function -export CC=gcc - set -xe mkdir -p /usr/local/etc/pkg/repos/ # Fix meson flag problem https://www.mail-archive.com/freebsd-ports@freebsd.org/msg86617.html cp /etc/pkg/FreeBSD.conf /usr/local/etc/pkg/repos/FreeBSD.conf sed -i .old 's|url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly"|url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest"|' \ /usr/local/etc/pkg/repos/FreeBSD.conf -pkg install -y meson efivar +pkg install -y meson pkg upgrade -y meson cd /usr git clone https://github.com/3mdeb/freebsd-ports.git --depth 1 -b fwupd ports diff --git a/contrib/freebsd/Makefile b/contrib/freebsd/Makefile index a485e79ab5e5..1e094768c3b7 100644 --- a/contrib/freebsd/Makefile +++ b/contrib/freebsd/Makefile @@ -27,7 +27,8 @@ LIB_DEPENDS= libcurl.so:ftp/curl \ libjcat.so:textproc/libjcat \ libjson-glib-1.0.so:devel/json-glib \ libxmlb.so:textproc/libxmlb \ - libefiboot.so:devel/gnu-efi + libefiboot.so:devel/gnu-efi \ + libpolkit-gobject-1.so:sysutils/polkit RUN_DEPENDS= ${LOCALBASE}/libexec/fwupd/efi/fwupdx64.efi:sysutils/fwupd-efi @@ -52,7 +53,7 @@ MESON_ARGS= -Dgudev=false \ -Dplugin_realtek_mst=false \ -Dplugin_thunderbolt=false \ -Dplugin_tpm=false \ - -Dpolkit=false \ + -Dpolkit=true \ -Dsystemd=false \ -Dtests=false \ -Ddocs=gtkdoc \ diff --git a/libfwupdplugin/fu-efivar-freebsd.c b/libfwupdplugin/fu-efivar-freebsd.c index c4fe3da5ec00..c971fc14be3b 100644 --- a/libfwupdplugin/fu-efivar-freebsd.c +++ b/libfwupdplugin/fu-efivar-freebsd.c @@ -35,6 +35,8 @@ fu_efivar_delete_impl (const gchar *guid, const gchar *name, GError **error) efi_guid_t guidt; efi_str_to_guid (guid, &guidt); + if (!fu_efivar_exists_impl(guid, name)) + return TRUE; if (efi_del_variable (guidt, name) == 0) return TRUE; @@ -50,7 +52,7 @@ fu_efivar_delete_with_glob_impl (const gchar *guid, const gchar *name_glob, GErr { efi_guid_t *guidt = NULL; gchar *name = NULL; - gboolean rv = FALSE; + gboolean rv = TRUE; efi_guid_t guid_to_delete; efi_str_to_guid (guid, &guid_to_delete); @@ -98,8 +100,29 @@ fu_efivar_get_data_impl (const gchar *guid, const gchar *name, guint8 **data, gsize *data_sz, guint32 *attr, GError **error) { efi_guid_t guidt; + gboolean success; + guint8 *buf; + gssize sz = 0; + efi_str_to_guid (guid, &guidt); - return (efi_get_variable (guidt, name, data, data_sz, attr) != 0); + success = efi_get_variable (guidt, name, &buf, data_sz, attr) == 1; + if (data_sz != NULL) + sz = *data_sz; + if (success && sz) { + g_autofree guint8 *ret_buf = g_malloc0(sz); + memcpy(ret_buf, buf, sz); + *data = g_steal_pointer(&ret_buf); + } + + if (!success) { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + "failed to read efivar: %s", + name); + } + + return success; } diff --git a/meson.build b/meson.build index 34bcb1443920..d087ef15b7b6 100644 --- a/meson.build +++ b/meson.build @@ -285,7 +285,8 @@ if get_option('default_library') != 'static' platform_deps += cc.find_library('shlwapi') endif if host_machine.system() == 'freebsd' - platform_deps += dependency('efivar') + platform_deps += cc.find_library('efivar') + platform_deps += cc.find_library('geom') endif endif diff --git a/plugins/uefi-capsule/fu-plugin-uefi-capsule.c b/plugins/uefi-capsule/fu-plugin-uefi-capsule.c index d8d6e62b85bf..0158b67a19a5 100644 --- a/plugins/uefi-capsule/fu-plugin-uefi-capsule.c +++ b/plugins/uefi-capsule/fu-plugin-uefi-capsule.c @@ -537,7 +537,7 @@ fu_plugin_uefi_capsule_coldplug_device (FuPlugin *plugin, FuUefiDevice *dev, GEr /* set vendor ID as the BIOS vendor */ if (device_kind != FU_UEFI_DEVICE_KIND_FMP) { const gchar *dmi_vendor; - dmi_vendor = fu_context_get_hwid_value (ctx, FU_HWIDS_KEY_BIOS_VENDOR); + dmi_vendor = fu_context_get_hwid_value (ctx, FU_HWIDS_KEY_BASEBOARD_MANUFACTURER); if (dmi_vendor != NULL) { g_autofree gchar *vendor_id = g_strdup_printf ("DMI:%s", dmi_vendor); fu_device_add_vendor_id (FU_DEVICE (dev), vendor_id); diff --git a/plugins/uefi-capsule/fu-uefi-backend-freebsd.c b/plugins/uefi-capsule/fu-uefi-backend-freebsd.c index f0dde4ae8da9..6da26a8c5929 100644 --- a/plugins/uefi-capsule/fu-uefi-backend-freebsd.c +++ b/plugins/uefi-capsule/fu-uefi-backend-freebsd.c @@ -20,6 +20,7 @@ #include +#include "fu-kenv.h" #include "fu-uefi-common.h" #include "fu-uefi-device.h" #include "fu-uefi-backend.h" diff --git a/plugins/uefi-capsule/fu-uefi-common.c b/plugins/uefi-capsule/fu-uefi-common.c index a8bfb2058511..fb9f4fea64b7 100644 --- a/plugins/uefi-capsule/fu-uefi-common.c +++ b/plugins/uefi-capsule/fu-uefi-common.c @@ -32,7 +32,12 @@ fu_uefi_bootmgr_get_suffix (GError **error) }; g_autofree gchar *sysfsfwdir = fu_common_get_path (FU_PATH_KIND_SYSFSDIR_FW); g_autofree gchar *sysfsefidir = g_build_filename (sysfsfwdir, "efi", NULL); +#ifdef __linux__ firmware_bits = fu_uefi_read_file_as_uint64 (sysfsefidir, "fw_platform_size"); +#else + firmware_bits = 64; +#endif + if (firmware_bits == 0) { g_set_error (error, G_IO_ERROR,