From 52e75ba2b63f9ee7f1b74ec2f249731798f7a5f6 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Fri, 22 Nov 2019 13:21:19 -0600 Subject: [PATCH 01/74] fwupdtool: don't show a warning when calling `get-plugins` The plugins are not opened for this function so of course they won't set their build hashes. Fixes errors like this: `uefi should call fu_plugin_set_build_hash()` --- src/fu-engine.c | 24 ++++++++++++++---------- src/fu-plugin-private.h | 1 + src/fu-plugin.c | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/fu-engine.c b/src/fu-engine.c index a087354a1..7e7c336c2 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -4277,16 +4277,20 @@ fu_engine_plugin_set_coldplug_delay_cb (FuPlugin *plugin, guint duration, FuEngi void fu_engine_add_plugin (FuEngine *self, FuPlugin *plugin) { - /* plugin does not match built version */ - if (fu_plugin_get_build_hash (plugin) == NULL) { - const gchar *name = fu_plugin_get_name (plugin); - g_warning ("%s should call fu_plugin_set_build_hash()", name); - self->tainted = TRUE; - } else if (g_strcmp0 (fu_plugin_get_build_hash (plugin), FU_BUILD_HASH) != 0) { - const gchar *name = fu_plugin_get_name (plugin); - g_warning ("%s has incorrect built version %s", - name, fu_plugin_get_build_hash (plugin)); - self->tainted = TRUE; + if (fu_plugin_is_open (plugin)) { + /* plugin does not match built version */ + if (fu_plugin_get_build_hash (plugin) == NULL) { + const gchar *name = fu_plugin_get_name (plugin); + g_warning ("%s should call fu_plugin_set_build_hash()", + name); + self->tainted = TRUE; + } else if (g_strcmp0 (fu_plugin_get_build_hash (plugin), + FU_BUILD_HASH) != 0) { + const gchar *name = fu_plugin_get_name (plugin); + g_warning ("%s has incorrect built version %s", + name, fu_plugin_get_build_hash (plugin)); + self->tainted = TRUE; + } } fu_plugin_list_add (self->plugin_list, plugin); diff --git a/src/fu-plugin-private.h b/src/fu-plugin-private.h index 5aa6fa251..6d3ec43a1 100644 --- a/src/fu-plugin-private.h +++ b/src/fu-plugin-private.h @@ -13,6 +13,7 @@ #define FU_OFFLINE_TRIGGER_FILENAME FU_OFFLINE_DESTDIR "/system-update" FuPlugin *fu_plugin_new (void); +gboolean fu_plugin_is_open (FuPlugin *self); void fu_plugin_set_usb_context (FuPlugin *self, GUsbContext *usb_ctx); void fu_plugin_set_hwids (FuPlugin *self, diff --git a/src/fu-plugin.c b/src/fu-plugin.c index 22c11f0fb..210dc58b9 100644 --- a/src/fu-plugin.c +++ b/src/fu-plugin.c @@ -106,6 +106,23 @@ typedef gboolean (*FuPluginUdevDeviceAddedFunc) (FuPlugin *self, FuUdevDevice *device, GError **error); +/** + * fu_plugin_is_open: + * @self: A #FuPlugin + * + * Determines if the plugin is opened + * + * Returns: TRUE for opened, FALSE for not + * + * Since: 1.3.5 + **/ +gboolean +fu_plugin_is_open (FuPlugin *self) +{ + FuPluginPrivate *priv = GET_PRIVATE (self); + return priv->module != NULL; +} + /** * fu_plugin_get_name: * @self: A #FuPlugin From 0f54b542503789831377c6c653cc11b409223338 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Fri, 22 Nov 2019 14:38:10 -0600 Subject: [PATCH 02/74] trivial: plugins: only build coreboot when option set The option was set but wasn't being used. --- plugins/meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/meson.build b/plugins/meson.build index f759c360d..fc24bf30e 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -1,7 +1,6 @@ subdir('ata') subdir('dfu') subdir('colorhug') -subdir('coreboot') subdir('ebitdo') subdir('fastboot') subdir('jabra') @@ -73,3 +72,7 @@ endif if get_option('plugin_flashrom') subdir('flashrom') endif + +if get_option('plugin_coreboot') +subdir('coreboot') +endif From 0fe4914320e1c8f148860be784b67c746ee45d6c Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 16:56:38 +0000 Subject: [PATCH 03/74] Use the correct unlocker when using GRWLock Linux doesn't care if you use g_rw_lock_reader_unlock() on a write lock, but Windows really does. --- src/fu-device.c | 6 +++--- src/fu-history.c | 16 ++++++++-------- src/fu-idle.c | 4 ++-- src/fu-plugin.c | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/fu-device.c b/src/fu-device.c index ff2ba7c0b..ca9553470 100644 --- a/src/fu-device.c +++ b/src/fu-device.c @@ -585,7 +585,7 @@ void fu_device_add_parent_guid (FuDevice *self, const gchar *guid) { FuDevicePrivate *priv = GET_PRIVATE (self); - g_autoptr(GRWLockReaderLocker) locker = NULL; + g_autoptr(GRWLockWriterLocker) locker = NULL; g_return_if_fail (FU_IS_DEVICE (self)); g_return_if_fail (guid != NULL); @@ -1149,7 +1149,7 @@ void fu_device_remove_metadata (FuDevice *self, const gchar *key) { FuDevicePrivate *priv = GET_PRIVATE (self); - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&priv->metadata_mutex); + g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&priv->metadata_mutex); g_return_if_fail (FU_IS_DEVICE (self)); g_return_if_fail (key != NULL); g_return_if_fail (locker != NULL); @@ -1170,7 +1170,7 @@ void fu_device_set_metadata (FuDevice *self, const gchar *key, const gchar *value) { FuDevicePrivate *priv = GET_PRIVATE (self); - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&priv->metadata_mutex); + g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&priv->metadata_mutex); g_return_if_fail (FU_IS_DEVICE (self)); g_return_if_fail (key != NULL); g_return_if_fail (value != NULL); diff --git a/src/fu-history.c b/src/fu-history.c index c0bcaae2a..d1a010644 100644 --- a/src/fu-history.c +++ b/src/fu-history.c @@ -371,7 +371,7 @@ fu_history_load (FuHistory *self, GError **error) g_autofree gchar *dirname = NULL; g_autofree gchar *filename = NULL; g_autoptr(GFile) file = NULL; - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&self->db_mutex); + g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&self->db_mutex); /* already done */ if (self->db != NULL) @@ -462,7 +462,7 @@ fu_history_modify_device (FuHistory *self, FuDevice *device, GError **error) { gint rc; g_autoptr(sqlite3_stmt) stmt = NULL; - g_autoptr(GRWLockReaderLocker) locker = NULL; + g_autoptr(GRWLockWriterLocker) locker = NULL; g_return_val_if_fail (FU_IS_HISTORY (self), FALSE); g_return_val_if_fail (FU_IS_DEVICE (device), FALSE); @@ -513,7 +513,7 @@ fu_history_add_device (FuHistory *self, FuDevice *device, FwupdRelease *release, gint rc; g_autofree gchar *metadata = NULL; g_autoptr(sqlite3_stmt) stmt = NULL; - g_autoptr(GRWLockReaderLocker) locker = NULL; + g_autoptr(GRWLockWriterLocker) locker = NULL; g_return_val_if_fail (FU_IS_HISTORY (self), FALSE); g_return_val_if_fail (FU_IS_DEVICE (device), FALSE); @@ -593,7 +593,7 @@ fu_history_remove_all_with_state (FuHistory *self, { gint rc; g_autoptr(sqlite3_stmt) stmt = NULL; - g_autoptr(GRWLockReaderLocker) locker = NULL; + g_autoptr(GRWLockWriterLocker) locker = NULL; g_return_val_if_fail (FU_IS_HISTORY (self), FALSE); @@ -624,7 +624,7 @@ fu_history_remove_all (FuHistory *self, GError **error) { gint rc; g_autoptr(sqlite3_stmt) stmt = NULL; - g_autoptr(GRWLockReaderLocker) locker = NULL; + g_autoptr(GRWLockWriterLocker) locker = NULL; g_return_val_if_fail (FU_IS_HISTORY (self), FALSE); @@ -651,7 +651,7 @@ fu_history_remove_device (FuHistory *self, FuDevice *device, GError **error) { gint rc; g_autoptr(sqlite3_stmt) stmt = NULL; - g_autoptr(GRWLockReaderLocker) locker = NULL; + g_autoptr(GRWLockWriterLocker) locker = NULL; g_return_val_if_fail (FU_IS_HISTORY (self), FALSE); g_return_val_if_fail (FU_IS_DEVICE (device), FALSE); @@ -835,7 +835,7 @@ fu_history_clear_approved_firmware (FuHistory *self, GError **error) { gint rc; g_autoptr(sqlite3_stmt) stmt = NULL; - g_autoptr(GRWLockReaderLocker) locker = NULL; + g_autoptr(GRWLockWriterLocker) locker = NULL; g_return_val_if_fail (FU_IS_HISTORY (self), FALSE); @@ -865,7 +865,7 @@ fu_history_add_approved_firmware (FuHistory *self, { gint rc; g_autoptr(sqlite3_stmt) stmt = NULL; - g_autoptr(GRWLockReaderLocker) locker = NULL; + g_autoptr(GRWLockWriterLocker) locker = NULL; g_return_val_if_fail (FU_IS_HISTORY (self), FALSE); g_return_val_if_fail (checksum != NULL, FALSE); diff --git a/src/fu-idle.c b/src/fu-idle.c index a501089e0..5873e4c8e 100644 --- a/src/fu-idle.c +++ b/src/fu-idle.c @@ -118,7 +118,7 @@ fu_idle_reset (FuIdle *self) void fu_idle_uninhibit (FuIdle *self, guint32 token) { - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&self->items_mutex); + g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&self->items_mutex); g_return_if_fail (FU_IS_IDLE (self)); g_return_if_fail (token != 0); @@ -139,7 +139,7 @@ guint32 fu_idle_inhibit (FuIdle *self, const gchar *reason) { FuIdleItem *item; - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&self->items_mutex); + g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&self->items_mutex); g_return_val_if_fail (FU_IS_IDLE (self), 0); g_return_val_if_fail (reason != NULL, 0); diff --git a/src/fu-plugin.c b/src/fu-plugin.c index 210dc58b9..1fcb4c443 100644 --- a/src/fu-plugin.c +++ b/src/fu-plugin.c @@ -215,7 +215,7 @@ void fu_plugin_cache_add (FuPlugin *self, const gchar *id, gpointer dev) { FuPluginPrivate *priv = GET_PRIVATE (self); - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&priv->devices_mutex); + g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&priv->devices_mutex); g_return_if_fail (FU_IS_PLUGIN (self)); g_return_if_fail (id != NULL); g_return_if_fail (locker != NULL); @@ -235,7 +235,7 @@ void fu_plugin_cache_remove (FuPlugin *self, const gchar *id) { FuPluginPrivate *priv = GET_PRIVATE (self); - g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&priv->devices_mutex); + g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&priv->devices_mutex); g_return_if_fail (FU_IS_PLUGIN (self)); g_return_if_fail (id != NULL); g_return_if_fail (locker != NULL); From 17957ebf132c1612d6417e8fff387fa30c31d881 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 23 Nov 2019 11:20:12 +0000 Subject: [PATCH 04/74] Ensure the _get_type() gets the same ABI version as the constructor This was also causing the _get_type() symbol to be ignored for objects without any class methods except constructors. --- libfwupd/generate-version-script.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libfwupd/generate-version-script.py b/libfwupd/generate-version-script.py index 4b4ee26f1..bd3bf3b0a 100755 --- a/libfwupd/generate-version-script.py +++ b/libfwupd/generate-version-script.py @@ -47,10 +47,6 @@ class LdVersionScript: for node in cls.findall(XMLNS + 'function'): self._add_node(node) - # add the constructor - for node in cls.findall(XMLNS + 'constructor'): - self._add_node(node) - # choose the lowest version method for the _get_type symbol version_lowest = None if '{http://www.gtk.org/introspection/glib/1.0}get-type' not in cls.attrib: @@ -64,6 +60,13 @@ class LdVersionScript: if not version_lowest or version_tmp < version_lowest: version_lowest = version_tmp + # add the constructor + for node in cls.findall(XMLNS + 'constructor'): + version_tmp = self._add_node(node) + if version_tmp: + if not version_lowest or version_tmp < version_lowest: + version_lowest = version_tmp + # finally add the get_type symbol if version_lowest: self.releases[version_lowest].append(type_name) From fc1e267d336b3ae55bff2af9555feb5c67617c04 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 08:53:33 +0000 Subject: [PATCH 05/74] trivial: Allow compiling without --- libfwupd/fwupd-common.c | 6 ++++++ meson.build | 4 ++++ src/fu-engine.c | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/libfwupd/fwupd-common.c b/libfwupd/fwupd-common.c index 078b42b78..7fd29490c 100644 --- a/libfwupd/fwupd-common.c +++ b/libfwupd/fwupd-common.c @@ -13,7 +13,9 @@ #include #include +#ifdef HAVE_UTSNAME_H #include +#endif #include #if !GLIB_CHECK_VERSION(2,54,0) @@ -222,12 +224,15 @@ fwupd_build_user_agent_os_release (void) static gchar * fwupd_build_user_agent_system (void) { +#ifdef HAVE_UTSNAME_H struct utsname name_tmp; +#endif g_autofree gchar *locale = NULL; g_autofree gchar *os_release = NULL; g_autoptr(GPtrArray) ids = g_ptr_array_new_with_free_func (g_free); /* system, architecture and kernel, e.g. "Linux i686 4.14.5" */ +#ifdef HAVE_UTSNAME_H memset (&name_tmp, 0, sizeof(struct utsname)); if (uname (&name_tmp) >= 0) { g_ptr_array_add (ids, g_strdup_printf ("%s %s %s", @@ -235,6 +240,7 @@ fwupd_build_user_agent_system (void) name_tmp.machine, name_tmp.release)); } +#endif /* current locale, e.g. "en-gb" */ locale = g_strdup (setlocale (LC_MESSAGES, NULL)); diff --git a/meson.build b/meson.build index 8c5981526..9b6ebd7ff 100644 --- a/meson.build +++ b/meson.build @@ -222,6 +222,10 @@ if build_standalone and get_option('plugin_altos') libelf = dependency('libelf') endif +if cc.has_header('sys/utsname.h') + conf.set('HAVE_UTSNAME_H', '1') +endif + if build_standalone and get_option('plugin_uefi') cairo = dependency('cairo') fontconfig = cc.find_library('fontconfig') diff --git a/src/fu-engine.c b/src/fu-engine.c index 7e7c336c2..8da880ee4 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -14,7 +14,9 @@ #include #include #include +#ifdef HAVE_UTSNAME_H #include +#endif #include "fwupd-common-private.h" #include "fwupd-enums-private.h" @@ -1380,7 +1382,9 @@ fu_engine_get_report_metadata (FuEngine *self) { GHashTable *hash; gchar *btime; +#ifdef HAVE_UTSNAME_H struct utsname name_tmp; +#endif g_autoptr(GList) compile_keys = g_hash_table_get_keys (self->compile_versions); g_autoptr(GList) runtime_keys = g_hash_table_get_keys (self->runtime_versions); @@ -1402,12 +1406,14 @@ fu_engine_get_report_metadata (FuEngine *self) } /* kernel version is often important for debugging failures */ +#ifdef HAVE_UTSNAME_H memset (&name_tmp, 0, sizeof (struct utsname)); if (uname (&name_tmp) >= 0) { g_hash_table_insert (hash, g_strdup ("CpuArchitecture"), g_strdup (name_tmp.machine)); } +#endif /* add the kernel boot time so we can detect a reboot */ btime = fu_engine_get_boot_time (); @@ -4947,7 +4953,9 @@ fu_engine_idle_status_notify_cb (FuIdle *idle, GParamSpec *pspec, FuEngine *self static void fu_engine_init (FuEngine *self) { +#ifdef HAVE_UTSNAME_H struct utsname uname_tmp; +#endif self->percentage = 0; self->status = FWUPD_STATUS_IDLE; self->config = fu_config_new (); @@ -4983,9 +4991,11 @@ fu_engine_init (FuEngine *self) #endif /* optional kernel version */ +#ifdef HAVE_UTSNAME_H memset (&uname_tmp, 0, sizeof(uname_tmp)); if (uname (&uname_tmp) >= 0) fu_engine_add_runtime_version (self, "org.kernel", uname_tmp.release); +#endif g_hash_table_insert (self->compile_versions, g_strdup ("com.redhat.fwupdate"), From e7fbb248f91c3996c9fd6a3875f20d6900cce0f1 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 08:59:21 +0000 Subject: [PATCH 06/74] trivial: Allow compiling without --- meson.build | 3 +++ src/fu-io-channel.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/meson.build b/meson.build index 9b6ebd7ff..86021db5b 100644 --- a/meson.build +++ b/meson.build @@ -225,6 +225,9 @@ endif if cc.has_header('sys/utsname.h') conf.set('HAVE_UTSNAME_H', '1') endif +if cc.has_header('poll.h') + conf.set('HAVE_POLL_H', '1') +endif if build_standalone and get_option('plugin_uefi') cairo = dependency('cairo') diff --git a/src/fu-io-channel.c b/src/fu-io-channel.c index 2fa83c92e..dd7e798a9 100644 --- a/src/fu-io-channel.c +++ b/src/fu-io-channel.c @@ -12,7 +12,9 @@ #include #include #include +#ifdef HAVE_POLL_H #include +#endif #include #include "fwupd-error.h" @@ -481,6 +483,7 @@ fu_io_channel_unix_new (gint fd) FuIOChannel * fu_io_channel_new_file (const gchar *filename, GError **error) { +#ifdef HAVE_POLL_H gint fd = g_open (filename, O_RDWR | O_NONBLOCK, S_IRWXU); if (fd < 0) { g_set_error (error, @@ -490,4 +493,11 @@ fu_io_channel_new_file (const gchar *filename, GError **error) return NULL; } return fu_io_channel_unix_new (fd); +#else + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as is unavailable"); + return NULL; +#endif } From 4f642400f89055a512f08ff0c98d1cf59cae21a0 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:01:01 +0000 Subject: [PATCH 07/74] trivial: Allow compiling without --- meson.build | 3 +++ src/fu-udev-device.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/meson.build b/meson.build index 86021db5b..895d09118 100644 --- a/meson.build +++ b/meson.build @@ -225,6 +225,9 @@ endif if cc.has_header('sys/utsname.h') conf.set('HAVE_UTSNAME_H', '1') endif +if cc.has_header('sys/ioctl.h') + conf.set('HAVE_IOCTL_H', '1') +endif if cc.has_header('poll.h') conf.set('HAVE_POLL_H', '1') endif diff --git a/src/fu-udev-device.c b/src/fu-udev-device.c index 0d397877e..5d9d9c2ed 100644 --- a/src/fu-udev-device.c +++ b/src/fu-udev-device.c @@ -11,7 +11,9 @@ #include #include #include +#ifdef HAVE_IOCTL_H #include +#endif #include #include #include @@ -735,6 +737,7 @@ fu_udev_device_ioctl (FuUdevDevice *self, gint *rc, GError **error) { +#ifdef HAVE_IOCTL_H FuUdevDevicePrivate *priv = GET_PRIVATE (self); gint rc_tmp; @@ -762,6 +765,13 @@ fu_udev_device_ioctl (FuUdevDevice *self, return FALSE; } return TRUE; +#else + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as not found"); + return FALSE; +#endif } /** From 01c0badd386c5e917692622e2ca909993ee0a099 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:08:51 +0000 Subject: [PATCH 08/74] trivial: Allow compiling without getuid() --- meson.build | 3 +++ plugins/dell/fu-self-test.c | 2 ++ plugins/uefi/fu-self-test.c | 2 ++ plugins/uefi/fu-uefi-tool.c | 2 ++ src/fu-offline.c | 2 ++ src/fu-tool.c | 2 ++ 6 files changed, 13 insertions(+) diff --git a/meson.build b/meson.build index 895d09118..6b3b181d3 100644 --- a/meson.build +++ b/meson.build @@ -231,6 +231,9 @@ endif if cc.has_header('poll.h') conf.set('HAVE_POLL_H', '1') endif +if cc.has_function('getuid') + conf.set('HAVE_GETUID', '1') +endif if build_standalone and get_option('plugin_uefi') cairo = dependency('cairo') diff --git a/plugins/dell/fu-self-test.c b/plugins/dell/fu-self-test.c index 869cbf1b4..bb153cef9 100644 --- a/plugins/dell/fu-self-test.c +++ b/plugins/dell/fu-self-test.c @@ -103,11 +103,13 @@ fu_plugin_dell_tpm_func (void) g_assert_no_error (error); g_assert (ret); +#ifdef HAVE_GETUID if (tpm_server_running == NULL && (getuid () != 0 || geteuid () != 0)) { g_test_skip ("TPM tests require simulated TPM2.0 running or need root access with physical TPM"); return; } +#endif /* inject fake data (no TPM) */ tpm_out.ret = -2; diff --git a/plugins/uefi/fu-self-test.c b/plugins/uefi/fu-self-test.c index 5142f6d42..860bda291 100644 --- a/plugins/uefi/fu-self-test.c +++ b/plugins/uefi/fu-self-test.c @@ -52,11 +52,13 @@ fu_uefi_pcrs_2_0_func (void) const gchar *tpm_server_running = g_getenv ("TPM_SERVER_RUNNING"); g_setenv ("FWUPD_FORCE_TPM2", "1", TRUE); +#ifdef HAVE_GETUID if (tpm_server_running == NULL && (getuid () != 0 || geteuid () != 0)) { g_test_skip ("TPM2.0 tests require simulated TPM2.0 running or need root access with physical TPM"); return; } +#endif if (!fu_uefi_pcrs_setup (pcrs, &error)) { if (tpm_server_running == NULL && diff --git a/plugins/uefi/fu-uefi-tool.c b/plugins/uefi/fu-uefi-tool.c index 18bfca1dd..b358bd28f 100644 --- a/plugins/uefi/fu-uefi-tool.c +++ b/plugins/uefi/fu-uefi-tool.c @@ -113,9 +113,11 @@ main (int argc, char *argv[]) textdomain (GETTEXT_PACKAGE); /* ensure root user */ +#ifdef HAVE_GETUID if (getuid () != 0 || geteuid () != 0) /* TRANSLATORS: we're poking around as a power user */ g_printerr ("%s\n", _("This program may only work correctly as root")); +#endif /* get a action_list of the commands */ priv->context = g_option_context_new (NULL); diff --git a/src/fu-offline.c b/src/fu-offline.c index 84f148a1f..dbc15093d 100644 --- a/src/fu-offline.c +++ b/src/fu-offline.c @@ -164,11 +164,13 @@ main (int argc, char *argv[]) g_unlink (FU_OFFLINE_TRIGGER_FILENAME); /* ensure root user */ +#ifdef HAVE_GETUID if (getuid () != 0 || geteuid () != 0) { /* TRANSLATORS: the user needs to stop playing with stuff */ g_printerr ("%s\n", _("This tool can only be used by the root user")); return EXIT_FAILURE; } +#endif /* find plymouth, but not an error if not found */ priv->splash_cmd = g_find_program_in_path ("plymouth"); diff --git a/src/fu-tool.c b/src/fu-tool.c index 9bf54ada6..f20a07fed 100644 --- a/src/fu-tool.c +++ b/src/fu-tool.c @@ -1649,10 +1649,12 @@ main (int argc, char *argv[]) bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); +#ifdef HAVE_GETUID /* ensure root user */ if (interactive && (getuid () != 0 || geteuid () != 0)) /* TRANSLATORS: we're poking around as a power user */ g_printerr ("%s\n", _("This program may only work correctly as root")); +#endif /* create helper object */ priv->loop = g_main_loop_new (NULL, FALSE); From b026e456f3a40467cc1b340cb1e15d63eca49792 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:09:46 +0000 Subject: [PATCH 09/74] trivial: Allow compiling without HAVE_LC_MESSAGES --- libfwupd/fwupd-common.c | 2 ++ meson.build | 3 +++ 2 files changed, 5 insertions(+) diff --git a/libfwupd/fwupd-common.c b/libfwupd/fwupd-common.c index 7fd29490c..9c4d897f8 100644 --- a/libfwupd/fwupd-common.c +++ b/libfwupd/fwupd-common.c @@ -243,7 +243,9 @@ fwupd_build_user_agent_system (void) #endif /* current locale, e.g. "en-gb" */ +#ifdef HAVE_LC_MESSAGES locale = g_strdup (setlocale (LC_MESSAGES, NULL)); +#endif if (locale != NULL) { g_strdelimit (locale, ".", '\0'); g_strdelimit (locale, "_", '-'); diff --git a/meson.build b/meson.build index 6b3b181d3..e4781de39 100644 --- a/meson.build +++ b/meson.build @@ -234,6 +234,9 @@ endif if cc.has_function('getuid') conf.set('HAVE_GETUID', '1') endif +if cc.has_header_symbol('locale.h', 'LC_MESSAGES') + conf.set('HAVE_LC_MESSAGES', '1') +endif if build_standalone and get_option('plugin_uefi') cairo = dependency('cairo') From 8694dee4e7d62920cc576d5b67d965dd8f889932 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:16:34 +0000 Subject: [PATCH 10/74] trivial: Allow compiling without realpath() --- meson.build | 3 +++ plugins/dfu/dfu-self-test.c | 8 ++------ src/fu-common.c | 12 ++++++++++++ src/fu-test.c | 8 ++++---- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index e4781de39..a7cca430a 100644 --- a/meson.build +++ b/meson.build @@ -234,6 +234,9 @@ endif if cc.has_function('getuid') conf.set('HAVE_GETUID', '1') endif +if cc.has_function('realpath') + conf.set('HAVE_REALPATH', '1') +endif if cc.has_header_symbol('locale.h', 'LC_MESSAGES') conf.set('HAVE_LC_MESSAGES', '1') endif diff --git a/plugins/dfu/dfu-self-test.c b/plugins/dfu/dfu-self-test.c index 289066d1b..60fa60646 100644 --- a/plugins/dfu/dfu-self-test.c +++ b/plugins/dfu/dfu-self-test.c @@ -17,20 +17,16 @@ #include "dfu-target-private.h" #include "fu-test.h" +#include "fu-common.h" #include "fwupd-error.h" static gchar * dfu_test_get_filename (const gchar *filename) { - gchar *tmp; - char full_tmp[PATH_MAX]; g_autofree gchar *path = NULL; path = g_build_filename (TESTDATADIR, filename, NULL); - tmp = realpath (path, full_tmp); - if (tmp == NULL) - return NULL; - return g_strdup (full_tmp); + return fu_common_realpath (path, NULL); } static void diff --git a/src/fu-common.c b/src/fu-common.c index f324e927c..bc6bc50cc 100644 --- a/src/fu-common.c +++ b/src/fu-common.c @@ -1496,7 +1496,11 @@ fu_common_realpath (const gchar *filename, GError **error) g_return_val_if_fail (filename != NULL, NULL); +#ifdef HAVE_REALPATH if (realpath (filename, full_tmp) == NULL) { +#else + if (_fullpath (full_tmp, filename, sizeof(full_tmp)) == NULL) { +#endif g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, @@ -1504,6 +1508,14 @@ fu_common_realpath (const gchar *filename, GError **error) strerror (errno)); return NULL; } + if (!g_file_test (full_tmp, G_FILE_TEST_EXISTS)) { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_INVALID_DATA, + "cannot find path: %s", + full_tmp); + return NULL; + } return g_strdup (full_tmp); } diff --git a/src/fu-test.c b/src/fu-test.c index 2389bd181..9327cb91d 100644 --- a/src/fu-test.c +++ b/src/fu-test.c @@ -13,6 +13,7 @@ #include #include "fu-test.h" +#include "fu-common.h" static GMainLoop *_test_loop = NULL; static guint _test_loop_timeout_id = 0; @@ -54,13 +55,12 @@ fu_test_get_filename (const gchar *testdatadirs, const gchar *filename) { g_auto(GStrv) split = g_strsplit (testdatadirs, ":", -1); for (guint i = 0; split[i] != NULL; i++) { - gchar *tmp; - char full_tmp[PATH_MAX]; + g_autofree gchar *tmp = NULL; g_autofree gchar *path = NULL; path = g_build_filename (split[i], filename, NULL); - tmp = realpath (path, full_tmp); + tmp = fu_common_realpath (path, NULL); if (tmp != NULL) - return g_strdup (full_tmp); + return g_steal_pointer (&tmp); } return NULL; } From 633445dc102906c43f0722123cf343317bd3ffb1 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 23 Nov 2019 10:31:22 +0000 Subject: [PATCH 11/74] trivial: Allow compiling without --- meson.build | 3 +++ plugins/altos/fu-altos-device.c | 1 - plugins/dell-esrt/fu-plugin-dell-esrt.c | 1 - plugins/logitech-hidpp/fu-logitech-hidpp-common.c | 1 - plugins/thunderbolt/fu-self-test.c | 1 - src/fu-udev-device.c | 2 ++ 6 files changed, 5 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index a7cca430a..b8ee31a25 100644 --- a/meson.build +++ b/meson.build @@ -228,6 +228,9 @@ endif if cc.has_header('sys/ioctl.h') conf.set('HAVE_IOCTL_H', '1') endif +if cc.has_header('sys/errno.h') + conf.set('HAVE_ERRNO_H', '1') +endif if cc.has_header('poll.h') conf.set('HAVE_POLL_H', '1') endif diff --git a/plugins/altos/fu-altos-device.c b/plugins/altos/fu-altos-device.c index 403a5c893..ea0f26e90 100644 --- a/plugins/altos/fu-altos-device.c +++ b/plugins/altos/fu-altos-device.c @@ -10,7 +10,6 @@ #include #include #include -#include #include "fu-io-channel.h" #include "fu-altos-device.h" diff --git a/plugins/dell-esrt/fu-plugin-dell-esrt.c b/plugins/dell-esrt/fu-plugin-dell-esrt.c index bd8042024..ec66d390e 100644 --- a/plugins/dell-esrt/fu-plugin-dell-esrt.c +++ b/plugins/dell-esrt/fu-plugin-dell-esrt.c @@ -7,7 +7,6 @@ #include "config.h" -#include #include #include #include diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-common.c b/plugins/logitech-hidpp/fu-logitech-hidpp-common.c index 43b91cb88..fda6a17a1 100644 --- a/plugins/logitech-hidpp/fu-logitech-hidpp-common.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-common.c @@ -8,7 +8,6 @@ #include #include -#include #include #include "fu-logitech-hidpp-common.h" diff --git a/plugins/thunderbolt/fu-self-test.c b/plugins/thunderbolt/fu-self-test.c index c1ec688a8..cae122769 100644 --- a/plugins/thunderbolt/fu-self-test.c +++ b/plugins/thunderbolt/fu-self-test.c @@ -6,7 +6,6 @@ #include "config.h" -#include #include #include #include diff --git a/src/fu-udev-device.c b/src/fu-udev-device.c index 5d9d9c2ed..30e58efb3 100644 --- a/src/fu-udev-device.c +++ b/src/fu-udev-device.c @@ -10,7 +10,9 @@ #include #include +#ifdef HAVE_ERRNO_H #include +#endif #ifdef HAVE_IOCTL_H #include #endif From 1f68b021d18222f88fd9538ce9ee22578f760666 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 23 Nov 2019 10:33:18 +0000 Subject: [PATCH 12/74] trivial: Allow compiling without pwrite() --- meson.build | 3 +++ src/fu-udev-device.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/meson.build b/meson.build index b8ee31a25..740746b7f 100644 --- a/meson.build +++ b/meson.build @@ -243,6 +243,9 @@ endif if cc.has_header_symbol('locale.h', 'LC_MESSAGES') conf.set('HAVE_LC_MESSAGES', '1') endif +if cc.has_function('pwrite', args : '-D_XOPEN_SOURCE') + conf.set('HAVE_PWRITE', '1') +endif if build_standalone and get_option('plugin_uefi') cairo = dependency('cairo') diff --git a/src/fu-udev-device.c b/src/fu-udev-device.c index 30e58efb3..3c453b158 100644 --- a/src/fu-udev-device.c +++ b/src/fu-udev-device.c @@ -798,6 +798,7 @@ fu_udev_device_pwrite (FuUdevDevice *self, goffset port, guint8 data, GError **e g_return_val_if_fail (port != 0x0, FALSE); g_return_val_if_fail (priv->fd > 0, FALSE); +#ifdef HAVE_PWRITE if (pwrite (priv->fd, &data, 1, port) != 1) { g_set_error (error, G_IO_ERROR, @@ -808,6 +809,13 @@ fu_udev_device_pwrite (FuUdevDevice *self, goffset port, guint8 data, GError **e return FALSE; } return TRUE; +#else + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as pwrite() is unavailable"); + return FALSE; +#endif } /** @@ -833,6 +841,7 @@ fu_udev_device_pread (FuUdevDevice *self, goffset port, guint8 *data, GError **e g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (priv->fd > 0, FALSE); +#ifdef HAVE_PWRITE if (pread (priv->fd, data, 1, port) != 1) { g_set_error (error, G_IO_ERROR, @@ -843,6 +852,13 @@ fu_udev_device_pread (FuUdevDevice *self, goffset port, guint8 *data, GError **e return FALSE; } return TRUE; +#else + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as pread() is unavailable"); + return FALSE; +#endif } static void From d454485be38b935dea0a00e04d18b06b8a4dd3fe Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sat, 23 Nov 2019 09:17:40 -0600 Subject: [PATCH 13/74] trivial: remove version-format.md It's not being kept up to date, and superceded by https://fwupd.org/lvfs/docs/metainfo/version --- docs/version-format.md | 58 ------------------------------------------ 1 file changed, 58 deletions(-) delete mode 100644 docs/version-format.md diff --git a/docs/version-format.md b/docs/version-format.md deleted file mode 100644 index 40b3a8464..000000000 --- a/docs/version-format.md +++ /dev/null @@ -1,58 +0,0 @@ -Version Formats -=============== - -In some circumstances fwupd has to convert from a unsigned integer version -number into something that has either been used in documentation or has been -defined in some specification. -A good example here is the UEFI ESRT table, which specifies a `uint32_t` for -the version but does not specify how this should be formatted for the user. - -As is typical in underspecified specifications, vendors have converted the -integer in different ways. For instance, Dell uses version strings like 1.2.3 -and Microsoft use versions like 1.2.3.4. - -The fwudp daemon can match specific devices and apply the correct version style -using quirk files. The version format can also be specified in the firmware -`metainfo.xml` file so that the new version is correctly shown, and so that it -matches on the LVFS website. - -The current version formats supported by fwupd and the LVFS are: - - * `plain`: Use plain integer version numbers with no dots, e.g. `AABBCCDD` - * `quad`: Use Dell-style `AA.BB.CC.DD` version numbers - * `triplet`: Use Microsoft-style `AA.BB.CCDD` version numbers - * `pair`: Use two `AABB.CCDD` version numbers - * `bcd`: Use binary coded decimal notation - * `intel-me`: Use Intel ME-style notation (`aaa+11.bbbbb.CC.DDDD`) - * `intel-me2`: Use alternate Intel ME-style-style `A.B.CC.DDDD` notation - -These can be specified in quirk files like this: - - # Vendor Modelname - [Guid=5b92717b-2cad-4a96-a13b-9d65781df8bf] - VersionFormat = intel-me2 - -...or in metainfo.xml files like this: - - - intel-me2 - - -Runtime requirements --------------------- - -Versions of fwupd `< 1.2.0` can only support firmware updates with key values -`LVFS::VersionFormat` of `quad` and `triplet`. Additionally, on older versions -no quirk `VersionFormat` device fixups are supported. - -If want to use one of the additional version formats you should depend on a -specific version of fwupd in the firmware file: - - - org.freedesktop.fwupd - - -This is not *strictly* required, as the integer value can be used for update -calculations if the version is specified in hex (e.g. `0x12345678`) in the -`` tag, although the user might get a bit confused if the update -version does not match the update description. From 4fcf48606fedb338cc5453b7ab7c5d9fdae9f799 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sat, 23 Nov 2019 08:05:11 -0600 Subject: [PATCH 14/74] trivial: debian: ci: ignore library-not-linked-against-libc for more --- contrib/debian/lintian/fwupd | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/debian/lintian/fwupd b/contrib/debian/lintian/fwupd index 308555896..d09a559f7 100644 --- a/contrib/debian/lintian/fwupd +++ b/contrib/debian/lintian/fwupd @@ -4,6 +4,7 @@ fwupd binary: systemd-service-file-missing-install-key lib/systemd/system/fwupd. fwupd binary: systemd-service-file-missing-install-key lib/systemd/system/system-update.target.wants/fwupd-offline-update.service #see debian bug 896012 fwupd: library-not-linked-against-libc usr/lib/*/fwupd-plugins-3/libfu_plugin_upower.so +fwupd: library-not-linked-against-libc usr/lib/*/fwupd-plugins-3/libfu_plugin_uefi_recovery.so #EFI applications are PE executables fwupd: executable-not-elf-or-script usr/lib/fwupd/efi/*.efi fwupd: portable-executable-missing-security-features usr/lib/fwupd/efi/*.efi SafeSEH From 89a9e245f96cb91a75031e3356fcd0589bff5af4 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Fri, 22 Nov 2019 19:02:58 -0600 Subject: [PATCH 15/74] trivial: optionrom: remove unneeded includes --- plugins/optionrom/fu-self-test.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/optionrom/fu-self-test.c b/plugins/optionrom/fu-self-test.c index 5d04527fe..468c1b5bd 100644 --- a/plugins/optionrom/fu-self-test.c +++ b/plugins/optionrom/fu-self-test.c @@ -11,8 +11,6 @@ #include #include -#include "fu-keyring.h" -#include "fu-history.h" #include "fu-plugin-private.h" #include "fu-rom.h" #include "fu-test.h" From 00d6f4734fa9cd626fb6644a310843c5629cae1a Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 17:04:02 +0000 Subject: [PATCH 16/74] trivial: Don't assume that plugins end in .so --- src/fu-engine.c | 3 ++- src/fu-self-test.c | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/fu-engine.c b/src/fu-engine.c index 8da880ee4..a02d008b8 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -4373,6 +4373,7 @@ fu_engine_load_plugins (FuEngine *self, GError **error) const gchar *fn; g_autoptr(GDir) dir = NULL; g_autofree gchar *plugin_path = NULL; + g_autofree gchar *suffix = g_strdup_printf (".%s", G_MODULE_SUFFIX); /* search */ plugin_path = fu_common_get_path (FU_PATH_KIND_PLUGINDIR_PKG); @@ -4386,7 +4387,7 @@ fu_engine_load_plugins (FuEngine *self, GError **error) g_autoptr(GError) error_local = NULL; /* ignore non-plugins */ - if (!g_str_has_suffix (fn, ".so")) + if (!g_str_has_suffix (fn, suffix)) continue; /* is blacklisted */ diff --git a/src/fu-self-test.c b/src/fu-self-test.c index 491acf4c9..0d927c8bc 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -1192,7 +1192,7 @@ fu_engine_history_func (void) fu_engine_set_silo (engine, silo_empty); /* set up dummy plugin */ - ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test.so", &error); + ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test." G_MODULE_SUFFIX, &error); g_assert_no_error (error); g_assert (ret); fu_engine_add_plugin (engine, plugin); @@ -1322,7 +1322,7 @@ fu_engine_history_inherit (void) /* set up dummy plugin */ g_setenv ("FWUPD_PLUGIN_TEST", "fail", TRUE); - ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test.so", &error); + ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test." G_MODULE_SUFFIX, &error); g_assert_no_error (error); g_assert (ret); fu_engine_add_plugin (engine, plugin); @@ -1432,7 +1432,7 @@ fu_engine_history_error_func (void) /* set up dummy plugin */ g_setenv ("FWUPD_PLUGIN_TEST", "fail", TRUE); - ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test.so", &error); + ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test." G_MODULE_SUFFIX, &error); g_assert_no_error (error); g_assert (ret); fu_engine_add_plugin (engine, plugin); @@ -2271,7 +2271,7 @@ fu_plugin_hash_func (void) /* create a tainted plugin */ g_setenv ("FWUPD_PLUGIN_TEST", "build-hash", TRUE); - ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test.so", &error); + ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test." G_MODULE_SUFFIX, &error); g_assert_no_error (error); /* make sure it tainted now */ @@ -2304,7 +2304,7 @@ fu_plugin_module_func (void) /* create a fake device */ plugin = fu_plugin_new (); g_setenv ("FWUPD_PLUGIN_TEST", "registration", TRUE); - ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test.so", &error); + ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test." G_MODULE_SUFFIX, &error); g_assert_no_error (error); g_assert (ret); ret = fu_plugin_runner_startup (plugin, &error); @@ -3141,7 +3141,7 @@ fu_plugin_composite_func (void) /* set up dummy plugin */ g_setenv ("FWUPD_PLUGIN_TEST", "composite", TRUE); - ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test.so", &error); + ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test." G_MODULE_SUFFIX, &error); g_assert_no_error (error); g_assert_true (ret); fu_engine_add_plugin (engine, plugin); From b3d4d2ff68bfb4fb89ab484830b3d7b32703e5e9 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sat, 23 Nov 2019 15:00:24 -0600 Subject: [PATCH 17/74] trivial: fu-udev-device: add a to_string func for debugging --- src/fu-udev-device.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/fu-udev-device.c b/src/fu-udev-device.c index 3c453b158..23c98df3d 100644 --- a/src/fu-udev-device.c +++ b/src/fu-udev-device.c @@ -108,29 +108,30 @@ fu_udev_device_get_sysfs_attr_as_uint8 (GUdevDevice *udev_device, const gchar *n } static void -fu_udev_device_dump_internal (GUdevDevice *udev_device) +fu_udev_device_to_string (FuDevice *device, guint idt, GString *str) { + FuUdevDevice *self = FU_UDEV_DEVICE (device); + FuUdevDevicePrivate *priv = GET_PRIVATE (self); const gchar * const *keys; - keys = g_udev_device_get_property_keys (udev_device); - for (guint i = 0; keys[i] != NULL; i++) { - g_debug ("%s={%s}", keys[i], - g_udev_device_get_property (udev_device, keys[i])); - } - keys = g_udev_device_get_sysfs_attr_keys (udev_device); - for (guint i = 0; keys[i] != NULL; i++) { - g_debug ("%s=[%s]", keys[i], - g_udev_device_get_sysfs_attr (udev_device, keys[i])); - } -} - -void -fu_udev_device_dump (FuUdevDevice *self) -{ - FuUdevDevicePrivate *priv = GET_PRIVATE (self); if (priv->udev_device == NULL) return; - fu_udev_device_dump_internal (priv->udev_device); + + if (g_getenv ("FU_UDEV_DEVICE_DEBUG") == NULL) + return; + + keys = g_udev_device_get_property_keys (priv->udev_device); + for (guint i = 0; keys[i] != NULL; i++) { + fu_common_string_append_kv (str, idt, keys[i], + g_udev_device_get_property (priv->udev_device, + keys[i])); + } + keys = g_udev_device_get_sysfs_attr_keys (priv->udev_device); + for (guint i = 0; keys[i] != NULL; i++) { + fu_common_string_append_kv (str, idt, keys[i], + g_udev_device_get_sysfs_attr (priv->udev_device, + keys[i])); + } } static gboolean @@ -940,6 +941,7 @@ fu_udev_device_class_init (FuUdevDeviceClass *klass) device_class->incorporate = fu_udev_device_incorporate; device_class->open = fu_udev_device_open; device_class->close = fu_udev_device_close; + device_class->to_string = fu_udev_device_to_string; signals[SIGNAL_CHANGED] = g_signal_new ("changed", From 40bef88ce14d578b5aa504bb645f4a7f6eaed8d9 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 23 Nov 2019 12:40:43 +0000 Subject: [PATCH 18/74] Allow compiling GUsb as a subproject This allows us to get closer to compiling on FreeBSD. --- meson.build | 2 +- subprojects/.gitignore | 1 + subprojects/gusb.wrap | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 subprojects/gusb.wrap diff --git a/meson.build b/meson.build index 740746b7f..2d975f7f0 100644 --- a/meson.build +++ b/meson.build @@ -167,7 +167,7 @@ if build_standalone gmodule = dependency('gmodule-2.0') gudev = dependency('gudev-1.0', version : '>= 232') libxmlb = dependency('xmlb', version : '>= 0.1.13', fallback : ['libxmlb', 'libxmlb_dep']) -gusb = dependency('gusb', version : '>= 0.2.9') +gusb = dependency('gusb', version : '>= 0.2.9', fallback : ['gusb', 'gusb_dep']) sqlite = dependency('sqlite3') libarchive = dependency('libarchive') endif diff --git a/subprojects/.gitignore b/subprojects/.gitignore index 99292448a..94e3341fd 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -1,2 +1,3 @@ +gusb flashrom libxmlb diff --git a/subprojects/gusb.wrap b/subprojects/gusb.wrap new file mode 100644 index 000000000..9d331e370 --- /dev/null +++ b/subprojects/gusb.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory = gusb +url = https://github.com/hughsie/libgusb.git +revision = 43b327a1e213aff00833842c455a796a068077cd From 668ee21567333a05f4ad78f60d602242ae5edb73 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:17:46 +0000 Subject: [PATCH 19/74] trivial: Use prefixes for DATADIR in config.h for portability DATADIR is an enumerated type in MinGW, and the other names are very generic. --- libfwupd/fwupd-common.c | 4 ++-- libfwupd/fwupd-self-test.c | 10 +++++----- meson.build | 14 +++++++------- plugins/dfu/dfu-tool.c | 2 +- plugins/flashrom/fu-plugin-flashrom.c | 2 +- plugins/uefi/fu-plugin-uefi.c | 2 +- plugins/uefi/fu-uefi-tool.c | 2 +- src/fu-agent.c | 2 +- src/fu-common.c | 16 ++++++++-------- src/fu-main.c | 2 +- src/fu-offline.c | 2 +- src/fu-plugin.c | 2 +- src/fu-tool.c | 2 +- src/fu-util.c | 2 +- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/libfwupd/fwupd-common.c b/libfwupd/fwupd-common.c index 9c4d897f8..214b33515 100644 --- a/libfwupd/fwupd-common.c +++ b/libfwupd/fwupd-common.c @@ -328,8 +328,8 @@ fwupd_build_machine_id (const gchar *salt, GError **error) gsize sz = 0; /* one of these has to exist */ - fns[0] = g_build_filename (SYSCONFDIR, "machine-id", NULL); - fns[1] = g_build_filename (LOCALSTATEDIR, "lib", "dbus", "machine-id", NULL); + fns[0] = g_build_filename (FWUPD_SYSCONFDIR, "machine-id", NULL); + fns[1] = g_build_filename (FWUPD_LOCALSTATEDIR, "lib", "dbus", "machine-id", NULL); fns[2] = g_strdup ("/etc/machine-id"); fns[3] = g_strdup ("/var/lib/dbus/machine-id"); for (guint i = 0; fns[i] != NULL; i++) { diff --git a/libfwupd/fwupd-self-test.c b/libfwupd/fwupd-self-test.c index aa31fe425..305e89d42 100644 --- a/libfwupd/fwupd-self-test.c +++ b/libfwupd/fwupd-self-test.c @@ -147,7 +147,7 @@ fwupd_remote_download_func (void) g_autoptr(GError) error = NULL; remote = fwupd_remote_new (); - directory = g_build_filename (LOCALSTATEDIR, + directory = g_build_filename (FWUPD_LOCALSTATEDIR, "lib", "fwupd", "remotes.d", @@ -166,9 +166,9 @@ fwupd_remote_download_func (void) g_assert_cmpstr (fwupd_remote_get_title (remote), ==, "Linux Vendor Firmware Service"); g_assert_cmpstr (fwupd_remote_get_report_uri (remote), ==, "https://fwupd.org/lvfs/firmware/report"); g_assert_cmpstr (fwupd_remote_get_filename_cache (remote), ==, - LOCALSTATEDIR "/lib/fwupd/remotes.d/lvfs/metadata.xml.gz"); + FWUPD_LOCALSTATEDIR "/lib/fwupd/remotes.d/lvfs/metadata.xml.gz"); g_assert_cmpstr (fwupd_remote_get_filename_cache_sig (remote), ==, - LOCALSTATEDIR "/lib/fwupd/remotes.d/lvfs/metadata.xml.gz.asc"); + FWUPD_LOCALSTATEDIR "/lib/fwupd/remotes.d/lvfs/metadata.xml.gz.asc"); } /* verify we used the FirmwareBaseURI just for firmware */ @@ -183,7 +183,7 @@ fwupd_remote_baseuri_func (void) g_autoptr(GError) error = NULL; remote = fwupd_remote_new (); - directory = g_build_filename (LOCALSTATEDIR, + directory = g_build_filename (FWUPD_LOCALSTATEDIR, "lib", "fwupd", "remotes.d", @@ -219,7 +219,7 @@ fwupd_remote_nopath_func (void) g_autofree gchar *directory = NULL; remote = fwupd_remote_new (); - directory = g_build_filename (LOCALSTATEDIR, + directory = g_build_filename (FWUPD_LOCALSTATEDIR, "lib", "fwupd", "remotes.d", diff --git a/meson.build b/meson.build index 2d975f7f0..f48ff3f96 100644 --- a/meson.build +++ b/meson.build @@ -344,21 +344,21 @@ endif gnome = import('gnome') i18n = import('i18n') -conf.set_quoted('BINDIR', bindir) -conf.set_quoted('LIBEXECDIR', libexecdir) -conf.set_quoted('DATADIR', datadir) -conf.set_quoted('LOCALSTATEDIR', localstatedir) -conf.set_quoted('SYSCONFDIR', sysconfdir) +conf.set_quoted('FWUPD_BINDIR', bindir) +conf.set_quoted('FWUPD_LIBEXECDIR', libexecdir) +conf.set_quoted('FWUPD_DATADIR', datadir) +conf.set_quoted('FWUPD_LOCALSTATEDIR', localstatedir) +conf.set_quoted('FWUPD_SYSCONFDIR', sysconfdir) +conf.set_quoted('FWUPD_LOCALEDIR', localedir) if build_standalone plugin_dir = join_paths(libdir, 'fwupd-plugins-3') -conf.set_quoted('PLUGINDIR', plugin_dir) +conf.set_quoted('FWUPD_PLUGINDIR', plugin_dir) endif conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) conf.set_quoted('PACKAGE_NAME', meson.project_name()) conf.set_quoted('VERSION', meson.project_version()) -conf.set_quoted('LOCALEDIR', localedir) configure_file( output : 'config.h', configuration : conf diff --git a/plugins/dfu/dfu-tool.c b/plugins/dfu/dfu-tool.c index 91eb18410..12aa9742b 100644 --- a/plugins/dfu/dfu-tool.c +++ b/plugins/dfu/dfu-tool.c @@ -1240,7 +1240,7 @@ main (int argc, char *argv[]) setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, FWUPD_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); diff --git a/plugins/flashrom/fu-plugin-flashrom.c b/plugins/flashrom/fu-plugin-flashrom.c index dd08193ee..7ebe94e5d 100644 --- a/plugins/flashrom/fu-plugin-flashrom.c +++ b/plugins/flashrom/fu-plugin-flashrom.c @@ -175,7 +175,7 @@ fu_plugin_update_prepare (FuPlugin *plugin, /* if the original firmware doesn't exist, grab it now */ basename = g_strdup_printf ("flashrom-%s.bin", fu_device_get_id (device)); - firmware_orig = g_build_filename (LOCALSTATEDIR, "lib", "fwupd", + firmware_orig = g_build_filename (FWUPD_LOCALSTATEDIR, "lib", "fwupd", "builder", basename, NULL); if (!fu_common_mkdir_parent (firmware_orig, error)) return FALSE; diff --git a/plugins/uefi/fu-plugin-uefi.c b/plugins/uefi/fu-plugin-uefi.c index 34a422536..f60f4c3e9 100644 --- a/plugins/uefi/fu-plugin-uefi.c +++ b/plugins/uefi/fu-plugin-uefi.c @@ -94,7 +94,7 @@ static GBytes * fu_plugin_uefi_get_splash_data (guint width, guint height, GError **error) { const gchar * const *langs = g_get_language_names (); - const gchar *localedir = LOCALEDIR; + const gchar *localedir = FWUPD_LOCALEDIR; const gsize chunk_size = 1024 * 1024; gsize buf_idx = 0; gsize buf_sz = chunk_size; diff --git a/plugins/uefi/fu-uefi-tool.c b/plugins/uefi/fu-uefi-tool.c index b358bd28f..e3e49f2d9 100644 --- a/plugins/uefi/fu-uefi-tool.c +++ b/plugins/uefi/fu-uefi-tool.c @@ -108,7 +108,7 @@ main (int argc, char *argv[]) setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, FWUPD_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); diff --git a/src/fu-agent.c b/src/fu-agent.c index e91d7b197..b2cc5b82b 100644 --- a/src/fu-agent.c +++ b/src/fu-agent.c @@ -160,7 +160,7 @@ main (int argc, char *argv[]) setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, FWUPD_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); diff --git a/src/fu-common.c b/src/fu-common.c index bc6bc50cc..c72953712 100644 --- a/src/fu-common.c +++ b/src/fu-common.c @@ -963,8 +963,8 @@ fu_common_get_path (FuPathKind path_kind) return g_strdup (tmp); tmp = g_getenv ("SNAP_USER_DATA"); if (tmp != NULL) - return g_build_filename (tmp, LOCALSTATEDIR, NULL); - return g_build_filename (LOCALSTATEDIR, NULL); + return g_build_filename (tmp, FWUPD_LOCALSTATEDIR, NULL); + return g_build_filename (FWUPD_LOCALSTATEDIR, NULL); /* /sys/firmware */ case FU_PATH_KIND_SYSFSDIR_FW: tmp = g_getenv ("FWUPD_SYSFSFWDIR"); @@ -990,8 +990,8 @@ fu_common_get_path (FuPathKind path_kind) return g_strdup (tmp); tmp = g_getenv ("SNAP_USER_DATA"); if (tmp != NULL) - return g_build_filename (tmp, SYSCONFDIR, NULL); - return g_strdup (SYSCONFDIR); + return g_build_filename (tmp, FWUPD_SYSCONFDIR, NULL); + return g_strdup (FWUPD_SYSCONFDIR); /* /usr/lib//fwupd-plugins-3 */ case FU_PATH_KIND_PLUGINDIR_PKG: tmp = g_getenv ("FWUPD_PLUGINDIR"); @@ -999,8 +999,8 @@ fu_common_get_path (FuPathKind path_kind) return g_strdup (tmp); tmp = g_getenv ("SNAP"); if (tmp != NULL) - return g_build_filename (tmp, PLUGINDIR, NULL); - return g_build_filename (PLUGINDIR, NULL); + return g_build_filename (tmp, FWUPD_PLUGINDIR, NULL); + return g_build_filename (FWUPD_PLUGINDIR, NULL); /* /usr/share/fwupd */ case FU_PATH_KIND_DATADIR_PKG: tmp = g_getenv ("FWUPD_DATADIR"); @@ -1008,8 +1008,8 @@ fu_common_get_path (FuPathKind path_kind) return g_strdup (tmp); tmp = g_getenv ("SNAP"); if (tmp != NULL) - return g_build_filename (tmp, DATADIR, PACKAGE_NAME, NULL); - return g_build_filename (DATADIR, PACKAGE_NAME, NULL); + return g_build_filename (tmp, FWUPD_DATADIR, PACKAGE_NAME, NULL); + return g_build_filename (FWUPD_DATADIR, PACKAGE_NAME, NULL); /* /usr/libexec/fwupd/efi */ case FU_PATH_KIND_EFIAPPDIR: tmp = g_getenv ("FWUPD_EFIAPPDIR"); diff --git a/src/fu-main.c b/src/fu-main.c index 5ea3a59c0..0937a02c2 100644 --- a/src/fu-main.c +++ b/src/fu-main.c @@ -1531,7 +1531,7 @@ main (int argc, char *argv[]) setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, FWUPD_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); diff --git a/src/fu-offline.c b/src/fu-offline.c index dbc15093d..6c053a3a9 100644 --- a/src/fu-offline.c +++ b/src/fu-offline.c @@ -149,7 +149,7 @@ main (int argc, char *argv[]) setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, FWUPD_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); diff --git a/src/fu-plugin.c b/src/fu-plugin.c index 1fcb4c443..9da9e847e 100644 --- a/src/fu-plugin.c +++ b/src/fu-plugin.c @@ -1970,7 +1970,7 @@ fu_plugin_runner_update (FuPlugin *self, /* delete cab file */ release = fu_device_get_release_default (device_pending); tmp = fwupd_release_get_filename (release); - if (tmp != NULL && g_str_has_prefix (tmp, LIBEXECDIR)) { + if (tmp != NULL && g_str_has_prefix (tmp, FWUPD_LIBEXECDIR)) { g_autoptr(GError) error_delete = NULL; g_autoptr(GFile) file = NULL; file = g_file_new_for_path (tmp); diff --git a/src/fu-tool.c b/src/fu-tool.c index f20a07fed..d3f6d8cfc 100644 --- a/src/fu-tool.c +++ b/src/fu-tool.c @@ -1645,7 +1645,7 @@ main (int argc, char *argv[]) setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, FWUPD_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); diff --git a/src/fu-util.c b/src/fu-util.c index 0d6ad1f2e..6f747c8c1 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -2449,7 +2449,7 @@ main (int argc, char *argv[]) setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, FWUPD_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); From 6640b571bfe48cfa86be5fed4593c92672ad3a58 Mon Sep 17 00:00:00 2001 From: Leo Date: Sun, 24 Nov 2019 21:39:56 +0100 Subject: [PATCH 20/74] Fix shebangs on scripts --- data/tests/builder/startup.sh | 2 +- data/tests/spawn.sh | 2 +- plugins/flashrom/example/build.sh | 2 +- plugins/flashrom/example/random-tool | 2 +- plugins/flashrom/example/startup.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/data/tests/builder/startup.sh b/data/tests/builder/startup.sh index feee01ecd..aca0c4cc8 100755 --- a/data/tests/builder/startup.sh +++ b/data/tests/builder/startup.sh @@ -1,2 +1,2 @@ -#/bin/sh +#!/bin/sh cat source.bin | rev > firmware.bin diff --git a/data/tests/spawn.sh b/data/tests/spawn.sh index 3c5b04b35..11da2fd20 100755 --- a/data/tests/spawn.sh +++ b/data/tests/spawn.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh echo "this is a test" sleep 1 echo "this is another line1" diff --git a/plugins/flashrom/example/build.sh b/plugins/flashrom/example/build.sh index 83b9d0c42..8a56aebb0 100755 --- a/plugins/flashrom/example/build.sh +++ b/plugins/flashrom/example/build.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh appstream-util validate-relax com.Flashrom.Laptop.metainfo.xml tar -cf firmware.tar startup.sh random-tool gcab --create --nopath Flashrom-Laptop-1.2.3.cab firmware.tar com.Flashrom.Laptop.metainfo.xml diff --git a/plugins/flashrom/example/random-tool b/plugins/flashrom/example/random-tool index 039cc8db7..a8ddf06e5 100755 --- a/plugins/flashrom/example/random-tool +++ b/plugins/flashrom/example/random-tool @@ -1,2 +1,2 @@ -#/bin/sh +#!/bin/sh echo "hello from the sandbox" diff --git a/plugins/flashrom/example/startup.sh b/plugins/flashrom/example/startup.sh index 22742b96e..0e477fc1e 100755 --- a/plugins/flashrom/example/startup.sh +++ b/plugins/flashrom/example/startup.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh # do something with the old firmware sha1sum /boot/flashrom-librem15v3.bin From 6abe21efbd7ab281c340eb85c9be0c4850953a68 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sun, 24 Nov 2019 13:22:28 -0600 Subject: [PATCH 21/74] trivial: stop including fu-hash.h as part of fu-plugin-vfuncs.h Explicitly include it in all "in-tree" plugins. If headers are exported out of tree we will likely explicitly not export this header. --- plugins/altos/fu-plugin-altos.c | 1 + plugins/amt/fu-plugin-amt.c | 1 + plugins/ata/fu-plugin-ata.c | 1 + plugins/colorhug/fu-plugin-colorhug.c | 1 + plugins/coreboot/fu-plugin-coreboot.c | 1 + plugins/csr/fu-plugin-csr.c | 1 + plugins/dell-dock/fu-plugin-dell-dock.c | 1 + plugins/dell-esrt/fu-plugin-dell-esrt.c | 1 + plugins/dell/fu-plugin-dell.c | 1 + plugins/dell/fu-self-test.c | 1 + plugins/dfu/fu-plugin-dfu.c | 1 + plugins/ebitdo/fu-plugin-ebitdo.c | 1 + plugins/emmc/fu-plugin-emmc.c | 1 + plugins/fastboot/fu-plugin-fastboot.c | 1 + plugins/flashrom/fu-plugin-flashrom.c | 1 + plugins/jabra/fu-plugin-jabra.c | 1 + plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c | 1 + plugins/modem-manager/fu-plugin-modem-manager.c | 1 + plugins/nitrokey/fu-plugin-nitrokey.c | 1 + plugins/nvme/fu-plugin-nvme.c | 1 + plugins/optionrom/fu-plugin-optionrom.c | 1 + plugins/redfish/fu-plugin-redfish.c | 1 + plugins/rts54hid/fu-plugin-rts54hid.c | 1 + plugins/rts54hub/fu-plugin-rts54hub.c | 1 + plugins/solokey/fu-plugin-solokey.c | 1 + plugins/steelseries/fu-plugin-steelseries.c | 1 + plugins/superio/fu-plugin-superio.c | 1 + plugins/synaptics-cxaudio/fu-plugin-synaptics-cxaudio.c | 1 + plugins/synaptics-prometheus/fu-plugin-synaptics-prometheus.c | 1 + plugins/synaptics-rmi/fu-plugin-synaptics-rmi.c | 1 + plugins/synapticsmst/fu-plugin-synapticsmst.c | 1 + plugins/test/fu-plugin-test.c | 1 + plugins/thelio-io/fu-plugin-thelio-io.c | 1 + plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c | 1 + plugins/thunderbolt/fu-plugin-thunderbolt.c | 1 + plugins/thunderbolt/fu-thunderbolt-tool.c | 1 + plugins/uefi-recovery/fu-plugin-uefi-recovery.c | 1 + plugins/uefi/fu-plugin-uefi.c | 1 + plugins/upower/fu-plugin-upower.c | 1 + plugins/vli-usbhub/fu-plugin-vli-usbhub.c | 1 + plugins/wacom-raw/fu-plugin-wacom-raw.c | 1 + plugins/wacom-usb/fu-plugin-wacom-usb.c | 1 + src/fu-plugin-vfuncs.h | 1 - 43 files changed, 42 insertions(+), 1 deletion(-) diff --git a/plugins/altos/fu-plugin-altos.c b/plugins/altos/fu-plugin-altos.c index 0573b8d7c..9c6eae20f 100644 --- a/plugins/altos/fu-plugin-altos.c +++ b/plugins/altos/fu-plugin-altos.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-altos-device.h" #include "fu-altos-firmware.h" diff --git a/plugins/amt/fu-plugin-amt.c b/plugins/amt/fu-plugin-amt.c index 4bd1de4d1..a32dcc3b2 100644 --- a/plugins/amt/fu-plugin-amt.c +++ b/plugins/amt/fu-plugin-amt.c @@ -15,6 +15,7 @@ #include #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" typedef struct { uuid_le guid; diff --git a/plugins/ata/fu-plugin-ata.c b/plugins/ata/fu-plugin-ata.c index 80d0c3cb1..c4069059e 100644 --- a/plugins/ata/fu-plugin-ata.c +++ b/plugins/ata/fu-plugin-ata.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-ata-device.h" diff --git a/plugins/colorhug/fu-plugin-colorhug.c b/plugins/colorhug/fu-plugin-colorhug.c index e4dd60bbf..141c12b17 100644 --- a/plugins/colorhug/fu-plugin-colorhug.c +++ b/plugins/colorhug/fu-plugin-colorhug.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-colorhug-device.h" diff --git a/plugins/coreboot/fu-plugin-coreboot.c b/plugins/coreboot/fu-plugin-coreboot.c index 38446e0b7..a78368b3b 100644 --- a/plugins/coreboot/fu-plugin-coreboot.c +++ b/plugins/coreboot/fu-plugin-coreboot.c @@ -12,6 +12,7 @@ #include #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-device-metadata.h" #include "fu-device-private.h" #include "fu-plugin-coreboot.h" diff --git a/plugins/csr/fu-plugin-csr.c b/plugins/csr/fu-plugin-csr.c index e9169696d..919d631a2 100644 --- a/plugins/csr/fu-plugin-csr.c +++ b/plugins/csr/fu-plugin-csr.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-csr-device.h" diff --git a/plugins/dell-dock/fu-plugin-dell-dock.c b/plugins/dell-dock/fu-plugin-dell-dock.c index a86d5c4c8..ff3eac9fb 100644 --- a/plugins/dell-dock/fu-plugin-dell-dock.c +++ b/plugins/dell-dock/fu-plugin-dell-dock.c @@ -18,6 +18,7 @@ #include "fu-device.h" #include "fwupd-error.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-dell-dock-common.h" diff --git a/plugins/dell-esrt/fu-plugin-dell-esrt.c b/plugins/dell-esrt/fu-plugin-dell-esrt.c index ec66d390e..d40ba9096 100644 --- a/plugins/dell-esrt/fu-plugin-dell-esrt.c +++ b/plugins/dell-esrt/fu-plugin-dell-esrt.c @@ -15,6 +15,7 @@ #include #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" /* Whitelisted smbios class/select commands */ #define CLASS_ADMIN_PROP 10 diff --git a/plugins/dell/fu-plugin-dell.c b/plugins/dell/fu-plugin-dell.c index 5bb19d646..efd8498ac 100644 --- a/plugins/dell/fu-plugin-dell.c +++ b/plugins/dell/fu-plugin-dell.c @@ -17,6 +17,7 @@ #include "fwupd-common.h" #include "fu-plugin-dell.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-device-metadata.h" /* These are used to indicate the status of a previous DELL flash */ diff --git a/plugins/dell/fu-self-test.c b/plugins/dell/fu-self-test.c index bb153cef9..4c44cf47d 100644 --- a/plugins/dell/fu-self-test.c +++ b/plugins/dell/fu-self-test.c @@ -14,6 +14,7 @@ #include "fu-plugin-private.h" #include "fu-plugin-dell.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" static FuDevice * _find_device_by_id (GPtrArray *devices, const gchar *device_id) diff --git a/plugins/dfu/fu-plugin-dfu.c b/plugins/dfu/fu-plugin-dfu.c index caa59073f..afd7c787b 100644 --- a/plugins/dfu/fu-plugin-dfu.c +++ b/plugins/dfu/fu-plugin-dfu.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "dfu-device.h" diff --git a/plugins/ebitdo/fu-plugin-ebitdo.c b/plugins/ebitdo/fu-plugin-ebitdo.c index c63001ce9..66ad1b1ea 100644 --- a/plugins/ebitdo/fu-plugin-ebitdo.c +++ b/plugins/ebitdo/fu-plugin-ebitdo.c @@ -9,6 +9,7 @@ #include "fu-ebitdo-device.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-ebitdo-firmware.h" void diff --git a/plugins/emmc/fu-plugin-emmc.c b/plugins/emmc/fu-plugin-emmc.c index 0dd5a5d9f..d349bf96d 100644 --- a/plugins/emmc/fu-plugin-emmc.c +++ b/plugins/emmc/fu-plugin-emmc.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-emmc-device.h" diff --git a/plugins/fastboot/fu-plugin-fastboot.c b/plugins/fastboot/fu-plugin-fastboot.c index 8acb7ee22..07aa28cb6 100644 --- a/plugins/fastboot/fu-plugin-fastboot.c +++ b/plugins/fastboot/fu-plugin-fastboot.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-fastboot-device.h" diff --git a/plugins/flashrom/fu-plugin-flashrom.c b/plugins/flashrom/fu-plugin-flashrom.c index 7ebe94e5d..5a2c4fd58 100644 --- a/plugins/flashrom/fu-plugin-flashrom.c +++ b/plugins/flashrom/fu-plugin-flashrom.c @@ -24,6 +24,7 @@ #include #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "libflashrom.h" #define SELFCHECK_TRUE 1 diff --git a/plugins/jabra/fu-plugin-jabra.c b/plugins/jabra/fu-plugin-jabra.c index 8f5d8a9fa..7add28c7d 100644 --- a/plugins/jabra/fu-plugin-jabra.c +++ b/plugins/jabra/fu-plugin-jabra.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-jabra-device.h" diff --git a/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c b/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c index a87aea5bc..87f8f37ff 100644 --- a/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c +++ b/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c @@ -9,6 +9,7 @@ #include #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-logitech-hidpp-bootloader-nordic.h" #include "fu-logitech-hidpp-bootloader-texas.h" diff --git a/plugins/modem-manager/fu-plugin-modem-manager.c b/plugins/modem-manager/fu-plugin-modem-manager.c index ab5bbe879..de246ec54 100644 --- a/plugins/modem-manager/fu-plugin-modem-manager.c +++ b/plugins/modem-manager/fu-plugin-modem-manager.c @@ -10,6 +10,7 @@ #include #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-mm-device.h" #include "fu-mm-utils.h" diff --git a/plugins/nitrokey/fu-plugin-nitrokey.c b/plugins/nitrokey/fu-plugin-nitrokey.c index c80bbc52a..d2f697b5e 100644 --- a/plugins/nitrokey/fu-plugin-nitrokey.c +++ b/plugins/nitrokey/fu-plugin-nitrokey.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-nitrokey-device.h" #include "fu-nitrokey-common.h" diff --git a/plugins/nvme/fu-plugin-nvme.c b/plugins/nvme/fu-plugin-nvme.c index 303b7e222..325c0e5c3 100644 --- a/plugins/nvme/fu-plugin-nvme.c +++ b/plugins/nvme/fu-plugin-nvme.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-nvme-device.h" diff --git a/plugins/optionrom/fu-plugin-optionrom.c b/plugins/optionrom/fu-plugin-optionrom.c index fdd20d865..064558ca9 100644 --- a/plugins/optionrom/fu-plugin-optionrom.c +++ b/plugins/optionrom/fu-plugin-optionrom.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-optionrom-device.h" diff --git a/plugins/redfish/fu-plugin-redfish.c b/plugins/redfish/fu-plugin-redfish.c index 48ec3f768..e092b7c56 100644 --- a/plugins/redfish/fu-plugin-redfish.c +++ b/plugins/redfish/fu-plugin-redfish.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-redfish-client.h" #include "fu-redfish-common.h" diff --git a/plugins/rts54hid/fu-plugin-rts54hid.c b/plugins/rts54hid/fu-plugin-rts54hid.c index 83f6df698..3859f06c5 100644 --- a/plugins/rts54hid/fu-plugin-rts54hid.c +++ b/plugins/rts54hid/fu-plugin-rts54hid.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-rts54hid-device.h" #include "fu-rts54hid-module.h" diff --git a/plugins/rts54hub/fu-plugin-rts54hub.c b/plugins/rts54hub/fu-plugin-rts54hub.c index 09e87f40e..8abc2ab67 100644 --- a/plugins/rts54hub/fu-plugin-rts54hub.c +++ b/plugins/rts54hub/fu-plugin-rts54hub.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-rts54hub-device.h" diff --git a/plugins/solokey/fu-plugin-solokey.c b/plugins/solokey/fu-plugin-solokey.c index 5729b5399..c90731fd3 100644 --- a/plugins/solokey/fu-plugin-solokey.c +++ b/plugins/solokey/fu-plugin-solokey.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-solokey-device.h" #include "fu-solokey-firmware.h" diff --git a/plugins/steelseries/fu-plugin-steelseries.c b/plugins/steelseries/fu-plugin-steelseries.c index fa858ba29..16ba03919 100644 --- a/plugins/steelseries/fu-plugin-steelseries.c +++ b/plugins/steelseries/fu-plugin-steelseries.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-steelseries-device.h" diff --git a/plugins/superio/fu-plugin-superio.c b/plugins/superio/fu-plugin-superio.c index 29ad7d766..18ed82b88 100644 --- a/plugins/superio/fu-plugin-superio.c +++ b/plugins/superio/fu-plugin-superio.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-superio-it85-device.h" #include "fu-superio-it89-device.h" diff --git a/plugins/synaptics-cxaudio/fu-plugin-synaptics-cxaudio.c b/plugins/synaptics-cxaudio/fu-plugin-synaptics-cxaudio.c index ad91b0d0d..ab7685be3 100644 --- a/plugins/synaptics-cxaudio/fu-plugin-synaptics-cxaudio.c +++ b/plugins/synaptics-cxaudio/fu-plugin-synaptics-cxaudio.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-synaptics-cxaudio-device.h" #include "fu-synaptics-cxaudio-firmware.h" diff --git a/plugins/synaptics-prometheus/fu-plugin-synaptics-prometheus.c b/plugins/synaptics-prometheus/fu-plugin-synaptics-prometheus.c index 8f80f7171..4724d3438 100644 --- a/plugins/synaptics-prometheus/fu-plugin-synaptics-prometheus.c +++ b/plugins/synaptics-prometheus/fu-plugin-synaptics-prometheus.c @@ -10,6 +10,7 @@ #include "fu-synaprom-firmware.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" void fu_plugin_init (FuPlugin *plugin) diff --git a/plugins/synaptics-rmi/fu-plugin-synaptics-rmi.c b/plugins/synaptics-rmi/fu-plugin-synaptics-rmi.c index 39e2ddd3c..22b0c03d6 100644 --- a/plugins/synaptics-rmi/fu-plugin-synaptics-rmi.c +++ b/plugins/synaptics-rmi/fu-plugin-synaptics-rmi.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-synaptics-rmi-device.h" #include "fu-synaptics-rmi-firmware.h" diff --git a/plugins/synapticsmst/fu-plugin-synapticsmst.c b/plugins/synapticsmst/fu-plugin-synapticsmst.c index 748eab202..da45aed73 100644 --- a/plugins/synapticsmst/fu-plugin-synapticsmst.c +++ b/plugins/synapticsmst/fu-plugin-synapticsmst.c @@ -9,6 +9,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-synapticsmst-common.h" #include "fu-synapticsmst-device.h" diff --git a/plugins/test/fu-plugin-test.c b/plugins/test/fu-plugin-test.c index de1462678..61cea7fa1 100644 --- a/plugins/test/fu-plugin-test.c +++ b/plugins/test/fu-plugin-test.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" struct FuPluginData { GMutex mutex; diff --git a/plugins/thelio-io/fu-plugin-thelio-io.c b/plugins/thelio-io/fu-plugin-thelio-io.c index 0ab8cce28..c4089b8e9 100644 --- a/plugins/thelio-io/fu-plugin-thelio-io.c +++ b/plugins/thelio-io/fu-plugin-thelio-io.c @@ -8,6 +8,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-thelio-io-device.h" diff --git a/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c b/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c index bd13f74fa..75f6757c7 100644 --- a/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c +++ b/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c @@ -12,6 +12,7 @@ #include #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-device-metadata.h" #define BOLT_DBUS_SERVICE "org.freedesktop.bolt" diff --git a/plugins/thunderbolt/fu-plugin-thunderbolt.c b/plugins/thunderbolt/fu-plugin-thunderbolt.c index 7e11decad..bcae315a9 100644 --- a/plugins/thunderbolt/fu-plugin-thunderbolt.c +++ b/plugins/thunderbolt/fu-plugin-thunderbolt.c @@ -16,6 +16,7 @@ #include #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-device-metadata.h" #include "fu-thunderbolt-image.h" diff --git a/plugins/thunderbolt/fu-thunderbolt-tool.c b/plugins/thunderbolt/fu-thunderbolt-tool.c index a4675aab6..8581201b7 100644 --- a/plugins/thunderbolt/fu-thunderbolt-tool.c +++ b/plugins/thunderbolt/fu-thunderbolt-tool.c @@ -11,6 +11,7 @@ #include "fu-thunderbolt-image.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-test.h" static gsize diff --git a/plugins/uefi-recovery/fu-plugin-uefi-recovery.c b/plugins/uefi-recovery/fu-plugin-uefi-recovery.c index cd2103b2a..e74aada5f 100644 --- a/plugins/uefi-recovery/fu-plugin-uefi-recovery.c +++ b/plugins/uefi-recovery/fu-plugin-uefi-recovery.c @@ -8,6 +8,7 @@ #include "fu-device-metadata.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" void fu_plugin_init (FuPlugin *plugin) diff --git a/plugins/uefi/fu-plugin-uefi.c b/plugins/uefi/fu-plugin-uefi.c index f60f4c3e9..f91ead807 100644 --- a/plugins/uefi/fu-plugin-uefi.c +++ b/plugins/uefi/fu-plugin-uefi.c @@ -13,6 +13,7 @@ #include "fu-device-metadata.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-uefi-bgrt.h" #include "fu-uefi-common.h" diff --git a/plugins/upower/fu-plugin-upower.c b/plugins/upower/fu-plugin-upower.c index 51d4120f3..22d7741a6 100644 --- a/plugins/upower/fu-plugin-upower.c +++ b/plugins/upower/fu-plugin-upower.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #define MINIMUM_BATTERY_PERCENTAGE 30 diff --git a/plugins/vli-usbhub/fu-plugin-vli-usbhub.c b/plugins/vli-usbhub/fu-plugin-vli-usbhub.c index c555338c9..f5479fdd8 100644 --- a/plugins/vli-usbhub/fu-plugin-vli-usbhub.c +++ b/plugins/vli-usbhub/fu-plugin-vli-usbhub.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-vli-usbhub-device.h" #include "fu-vli-usbhub-firmware.h" diff --git a/plugins/wacom-raw/fu-plugin-wacom-raw.c b/plugins/wacom-raw/fu-plugin-wacom-raw.c index 41586f0d0..7fc381687 100644 --- a/plugins/wacom-raw/fu-plugin-wacom-raw.c +++ b/plugins/wacom-raw/fu-plugin-wacom-raw.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-wacom-aes-device.h" #include "fu-wacom-emr-device.h" #include "fu-wacom-common.h" diff --git a/plugins/wacom-usb/fu-plugin-wacom-usb.c b/plugins/wacom-usb/fu-plugin-wacom-usb.c index 5b8c8664e..76af9dc81 100644 --- a/plugins/wacom-usb/fu-plugin-wacom-usb.c +++ b/plugins/wacom-usb/fu-plugin-wacom-usb.c @@ -7,6 +7,7 @@ #include "config.h" #include "fu-plugin-vfuncs.h" +#include "fu-hash.h" #include "fu-wac-device.h" #include "fu-wac-firmware.h" diff --git a/src/fu-plugin-vfuncs.h b/src/fu-plugin-vfuncs.h index 316351c9a..ecf85c9aa 100644 --- a/src/fu-plugin-vfuncs.h +++ b/src/fu-plugin-vfuncs.h @@ -8,7 +8,6 @@ #include "fu-plugin.h" #include "fu-device.h" -#include "fu-hash.h" void fu_plugin_init (FuPlugin *plugin); void fu_plugin_destroy (FuPlugin *plugin); From 9b36a370ae1dd9b06d11fc42da9601637366719b Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sat, 23 Nov 2019 08:03:28 -0600 Subject: [PATCH 22/74] trivial: ci: pull lintian from unstable for now. Fixes E: fwupd: library-not-linked-against-libc usr/lib/x86_64-linux-gnu/fwupd-plugins-3/libfu_plugin_upower.so https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=945276 --- contrib/ci/Dockerfile-debian.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contrib/ci/Dockerfile-debian.in b/contrib/ci/Dockerfile-debian.in index 8800cdc8f..02c3e45ba 100644 --- a/contrib/ci/Dockerfile-debian.in +++ b/contrib/ci/Dockerfile-debian.in @@ -1,5 +1,19 @@ FROM %%%ARCH_PREFIX%%%debian:testing %%%OS%%% +RUN echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list +RUN echo 'Package: *\n\ +Pin: release a=testing\n\ +Pin-Priority: 900\n\ +\n\ +Package: *\n\ +Pin: release a=unstable\n\ +Pin-Priority: 800\n\ +\n\ +Package: lintian\n\ +Pin: release a=unstable\n\ +Pin-Priority: 901\n'\ + > /etc/apt/preferences +RUN cat /etc/apt/preferences RUN echo fubar > /etc/machine-id %%%ARCH_SPECIFIC_COMMAND%%% %%%INSTALL_DEPENDENCIES_COMMAND%%% From afdba37644966adeacac492054e1a64e1e9e9ca8 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 23 Nov 2019 12:57:35 +0000 Subject: [PATCH 23/74] trivial: Set the offline trigger using an environment variable This allows us to build a object that does not have a custom FU_OFFLINE_DESTDIR. --- plugins/dell/meson.build | 1 - plugins/optionrom/meson.build | 1 - plugins/synapticsmst/meson.build | 1 - plugins/thunderbolt/meson.build | 1 - src/fu-common.c | 5 +++++ src/fu-common.h | 2 ++ src/fu-offline.c | 5 +++-- src/fu-plugin-private.h | 2 -- src/fu-plugin.c | 14 ++++++++------ src/fu-self-test.c | 1 + src/meson.build | 10 ---------- 11 files changed, 19 insertions(+), 24 deletions(-) diff --git a/plugins/dell/meson.build b/plugins/dell/meson.build index 171154f81..5ab20e309 100644 --- a/plugins/dell/meson.build +++ b/plugins/dell/meson.build @@ -34,7 +34,6 @@ shared_module('fu_plugin_dell', if get_option('tests') testdatadir = join_paths(meson.current_source_dir(), 'tests') cargs += '-DTESTDATADIR="' + testdatadir + '"' - cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"' cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"' e = executable( 'dell-self-test', diff --git a/plugins/optionrom/meson.build b/plugins/optionrom/meson.build index 13dc22869..96dcc5f97 100644 --- a/plugins/optionrom/meson.build +++ b/plugins/optionrom/meson.build @@ -50,7 +50,6 @@ executable( ) if get_option('tests') - cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"' cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"' testdatadir = join_paths(meson.current_source_dir(), 'tests') cargs += '-DTESTDATADIR="' + testdatadir + '"' diff --git a/plugins/synapticsmst/meson.build b/plugins/synapticsmst/meson.build index eb2723737..05844d779 100644 --- a/plugins/synapticsmst/meson.build +++ b/plugins/synapticsmst/meson.build @@ -31,7 +31,6 @@ shared_module('fu_plugin_synapticsmst', ) if get_option('tests') - cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"' cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"' cargs += '-DSOURCEDIR="' + meson.current_source_dir() + '"' e = executable( diff --git a/plugins/thunderbolt/meson.build b/plugins/thunderbolt/meson.build index 42718abf6..87c6c8d11 100644 --- a/plugins/thunderbolt/meson.build +++ b/plugins/thunderbolt/meson.build @@ -50,7 +50,6 @@ install_data(['thunderbolt.conf'], ) # we use functions from 2.52 in the tests if get_option('tests') and umockdev.found() and gio.version().version_compare('>= 2.52') - cargs += '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"' cargs += '-DPLUGINBUILDDIR="' + meson.current_build_dir() + '"' e = executable( 'thunderbolt-self-test', diff --git a/src/fu-common.c b/src/fu-common.c index c72953712..99a5035be 100644 --- a/src/fu-common.c +++ b/src/fu-common.c @@ -1044,6 +1044,11 @@ fu_common_get_path (FuPathKind path_kind) return g_build_filename (tmp, NULL); basedir = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR); return g_build_filename (basedir, "cache", PACKAGE_NAME, NULL); + case FU_PATH_KIND_OFFLINE_TRIGGER: + tmp = g_getenv ("FWUPD_OFFLINE_TRIGGER"); + if (tmp != NULL) + return g_strdup (tmp); + return g_strdup ("/system-update"); case FU_PATH_KIND_POLKIT_ACTIONS: #ifdef POLKIT_ACTIONDIR return g_strdup (POLKIT_ACTIONDIR); diff --git a/src/fu-common.h b/src/fu-common.h index 7c1a0c89b..5bc1b3421 100644 --- a/src/fu-common.h +++ b/src/fu-common.h @@ -54,6 +54,7 @@ typedef guint FuEndianType; * @FU_PATH_KIND_SYSFSDIR_DRIVERS: The platform sysfs directory (IE /sys/bus/platform/drivers) * @FU_PATH_KIND_SYSFSDIR_TPM: The TPM sysfs directory (IE /sys/class/tpm) * @FU_PATH_KIND_POLKIT_ACTIONS: The directory for policy kit actions (IE /usr/share/polkit-1/actions/) + * @FU_PATH_KIND_OFFLINE_TRIGGER: The file for the offline trigger (IE /system-update) * * Path types to use when dynamically determining a path at runtime **/ @@ -70,6 +71,7 @@ typedef enum { FU_PATH_KIND_SYSFSDIR_DRIVERS, FU_PATH_KIND_SYSFSDIR_TPM, FU_PATH_KIND_POLKIT_ACTIONS, + FU_PATH_KIND_OFFLINE_TRIGGER, /*< private >*/ FU_PATH_KIND_LAST } FuPathKind; diff --git a/src/fu-offline.c b/src/fu-offline.c index 6c053a3a9..e84fb24c6 100644 --- a/src/fu-offline.c +++ b/src/fu-offline.c @@ -141,6 +141,7 @@ main (int argc, char *argv[]) guint cnt = 0; g_autofree gchar *link = NULL; g_autofree gchar *target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG); + g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER); g_autoptr(FuHistory) history = NULL; g_autoptr(FwupdClient) client = NULL; g_autoptr(GError) error = NULL; @@ -154,14 +155,14 @@ main (int argc, char *argv[]) textdomain (GETTEXT_PACKAGE); /* verify this is pointing to our cache */ - link = g_file_read_link (FU_OFFLINE_TRIGGER_FILENAME, NULL); + link = g_file_read_link (trigger, NULL); if (link == NULL) return EXIT_SUCCESS; if (g_strcmp0 (link, target) != 0) return EXIT_SUCCESS; /* do this first to avoid a loop if this tool segfaults */ - g_unlink (FU_OFFLINE_TRIGGER_FILENAME); + g_unlink (trigger); /* ensure root user */ #ifdef HAVE_GETUID diff --git a/src/fu-plugin-private.h b/src/fu-plugin-private.h index 6d3ec43a1..7a0c85af7 100644 --- a/src/fu-plugin-private.h +++ b/src/fu-plugin-private.h @@ -10,8 +10,6 @@ #include "fu-plugin.h" #include "fu-smbios.h" -#define FU_OFFLINE_TRIGGER_FILENAME FU_OFFLINE_DESTDIR "/system-update" - FuPlugin *fu_plugin_new (void); gboolean fu_plugin_is_open (FuPlugin *self); void fu_plugin_set_usb_context (FuPlugin *self, diff --git a/src/fu-plugin.c b/src/fu-plugin.c index 9da9e847e..cff8cf735 100644 --- a/src/fu-plugin.c +++ b/src/fu-plugin.c @@ -1011,12 +1011,13 @@ fu_plugin_runner_startup (FuPlugin *self, GError **error) static gboolean fu_plugin_runner_offline_invalidate (GError **error) { + g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER); g_autoptr(GError) error_local = NULL; g_autoptr(GFile) file1 = NULL; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - file1 = g_file_new_for_path (FU_OFFLINE_TRIGGER_FILENAME); + file1 = g_file_new_for_path (trigger); if (!g_file_query_exists (file1, NULL)) return TRUE; if (!g_file_delete (file1, NULL, &error_local)) { @@ -1024,7 +1025,7 @@ fu_plugin_runner_offline_invalidate (GError **error) FWUPD_ERROR, FWUPD_ERROR_INTERNAL, "Cannot delete %s: %s", - FU_OFFLINE_TRIGGER_FILENAME, + trigger, error_local->message); return FALSE; } @@ -1037,25 +1038,26 @@ fu_plugin_runner_offline_setup (GError **error) gint rc; g_autofree gchar *filename = NULL; g_autofree gchar *symlink_target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG); + g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); /* does already exist */ - filename = fu_common_realpath (FU_OFFLINE_TRIGGER_FILENAME, NULL); + filename = fu_common_realpath (trigger, NULL); if (g_strcmp0 (filename, symlink_target) == 0) { g_debug ("%s already points to %s, skipping creation", - FU_OFFLINE_TRIGGER_FILENAME, symlink_target); + trigger, symlink_target); return TRUE; } /* create symlink for the systemd-system-update-generator */ - rc = symlink (symlink_target, FU_OFFLINE_TRIGGER_FILENAME); + rc = symlink (symlink_target, trigger); if (rc < 0) { g_set_error (error, FWUPD_ERROR, FWUPD_ERROR_INTERNAL, "Failed to create symlink %s to %s: %s", - FU_OFFLINE_TRIGGER_FILENAME, + trigger, "/var/lib", strerror (errno)); return FALSE; } diff --git a/src/fu-self-test.c b/src/fu-self-test.c index 0d927c8bc..488555564 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -4187,6 +4187,7 @@ main (int argc, char **argv) g_setenv ("FWUPD_PLUGINDIR", TESTDATADIR_SRC, TRUE); g_setenv ("FWUPD_SYSCONFDIR", TESTDATADIR_SRC, TRUE); g_setenv ("FWUPD_SYSFSFWDIR", TESTDATADIR_SRC, TRUE); + g_setenv ("FWUPD_OFFLINE_TRIGGER", "/tmp/fwupd-self-test/system-update", TRUE); g_setenv ("FWUPD_LOCALSTATEDIR", "/tmp/fwupd-self-test/var", TRUE); /* ensure empty tree */ diff --git a/src/meson.build b/src/meson.build index 6b37c5b45..5c3020cf2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -106,9 +106,6 @@ fwupdmgr = executable( fwupd, libfwupdprivate, ], - c_args : [ - '-DFU_OFFLINE_DESTDIR=""', - ], install : true, install_dir : bindir ) @@ -164,9 +161,6 @@ fwupdagent = executable( fwupd, libfwupdprivate, ], - c_args : [ - '-DFU_OFFLINE_DESTDIR=""', - ], install : true, install_dir : join_paths(libexecdir, 'fwupd') ) @@ -230,9 +224,6 @@ fwupdtool = executable( fwupd, libfwupdprivate, ], - c_args : [ - '-DFU_OFFLINE_DESTDIR=""', - ], install : true, install_dir : join_paths(libexecdir, 'fwupd') ) @@ -359,7 +350,6 @@ if get_option('tests') '-DTESTDATADIR_DST="' + testdatadir_dst + '"', '-DTESTDATADIR="' + testdatadir_src + ':' + testdatadir_dst + '"', '-DPLUGINBUILDDIR="' + pluginbuilddir + '"', - '-DFU_OFFLINE_DESTDIR="/tmp/fwupd-self-test"', ], ) test('fu-self-test', e, is_parallel:false, timeout:180) From 1665837e78c4c6a5e88fab65fcb023488add9cc9 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:23:59 +0000 Subject: [PATCH 24/74] Make gudev a compile-time option This should make it nearly possible to build fwupd on FreeBSD. --- meson.build | 7 ++++++- meson_options.txt | 1 + plugins/meson.build | 25 ++++++++++++++----------- src/fu-engine.c | 22 ++++++++++++++++++++++ src/fu-plugin.h | 3 ++- src/fu-udev-device.c | 34 +++++++++++++++++++++++++++++++--- src/fu-udev-device.h | 6 ++++++ src/fu-usb-device.c | 7 +++++++ src/fu-usb-device.h | 2 +- src/fu-util.c | 1 - src/meson.build | 5 ++++- 11 files changed, 94 insertions(+), 19 deletions(-) diff --git a/meson.build b/meson.build index f48ff3f96..a37c1e7b8 100644 --- a/meson.build +++ b/meson.build @@ -165,7 +165,12 @@ if gio.version().version_compare ('>= 2.55.0') endif if build_standalone gmodule = dependency('gmodule-2.0') -gudev = dependency('gudev-1.0', version : '>= 232') +if get_option('gudev') + gudev = dependency('gudev-1.0', version : '>= 232') + conf.set('HAVE_GUDEV', '1') +else + gudev = dependency('', required : false) +endif libxmlb = dependency('xmlb', version : '>= 0.1.13', fallback : ['libxmlb', 'libxmlb_dep']) gusb = dependency('gusb', version : '>= 0.2.9', fallback : ['gusb', 'gusb_dep']) sqlite = dependency('sqlite3') diff --git a/meson_options.txt b/meson_options.txt index 71b50c6a9..17c30446a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -7,6 +7,7 @@ option('gtkdoc', type : 'boolean', value : false, description : 'enable develope option('introspection', type : 'boolean', value : true, description : 'generate GObject Introspection data') option('lvfs', type : 'boolean', value : true, description : 'enable LVFS remotes') option('man', type : 'boolean', value : true, description : 'enable man pages') +option('gudev', type : 'boolean', value : true, description : 'enable GUdev support') option('pkcs7', type : 'boolean', value : true, description : 'enable the PKCS7 verification support') option('plugin_altos', type : 'boolean', value : true, description : 'enable altos support') option('plugin_amt', type : 'boolean', value : true, description : 'enable Intel AMT support') diff --git a/plugins/meson.build b/plugins/meson.build index fc24bf30e..73f74eb20 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -1,4 +1,3 @@ -subdir('ata') subdir('dfu') subdir('colorhug') subdir('ebitdo') @@ -6,31 +5,35 @@ subdir('fastboot') subdir('jabra') subdir('steelseries') subdir('dell-dock') -subdir('logitech-hidpp') subdir('nitrokey') -subdir('optionrom') subdir('rts54hid') subdir('rts54hub') subdir('solokey') subdir('synaptics-cxaudio') subdir('synaptics-prometheus') subdir('test') -subdir('thelio-io') subdir('upower') -subdir('wacom-raw') subdir('wacom-usb') +subdir('vli-usbhub') + +if get_option('gudev') +subdir('ata') +subdir('logitech-hidpp') +subdir('optionrom') subdir('superio') subdir('synaptics-rmi') -subdir('vli-usbhub') +subdir('thelio-io') +subdir('wacom-raw') +endif # depends on dfu subdir('csr') -if get_option('plugin_emmc') +if get_option('plugin_emmc') and get_option('gudev') subdir('emmc') endif -if get_option('plugin_nvme') +if get_option('plugin_nvme') and get_option('gudev') subdir('nvme') endif @@ -38,7 +41,7 @@ if get_option('plugin_modem_manager') subdir('modem-manager') endif -if get_option('plugin_altos') +if get_option('plugin_altos') and get_option('gudev') subdir('altos') endif @@ -46,7 +49,7 @@ if get_option('plugin_amt') subdir('amt') endif -if get_option('plugin_thunderbolt') +if get_option('plugin_thunderbolt') and get_option('gudev') subdir('thunderbolt') subdir('thunderbolt-power') endif @@ -60,7 +63,7 @@ subdir('dell') subdir('dell-esrt') endif -if get_option('plugin_synaptics') +if get_option('plugin_synaptics') and get_option('gudev') subdir('synapticsmst') endif diff --git a/src/fu-engine.c b/src/fu-engine.c index a02d008b8..0fa154974 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -11,7 +11,9 @@ #include #include #include +#ifdef HAVE_GUDEV #include +#endif #include #include #ifdef HAVE_UTSNAME_H @@ -61,7 +63,9 @@ struct _FuEngine GObject parent_instance; FuAppFlags app_flags; GUsbContext *usb_ctx; +#ifdef HAVE_GUDEV GUdevClient *gudev_client; +#endif FuConfig *config; FuDeviceList *device_list; FwupdStatus status; @@ -76,7 +80,9 @@ struct _FuEngine FuPluginList *plugin_list; GPtrArray *plugin_filter; GPtrArray *udev_subsystems; +#ifdef HAVE_GUDEV GHashTable *udev_changed_ids; /* sysfs:FuEngineUdevChangedHelper */ +#endif FuSmbios *smbios; FuHwids *hwids; FuQuirks *quirks; @@ -4080,6 +4086,7 @@ fu_engine_recoldplug_delay_cb (gpointer user_data) return FALSE; } +#ifdef HAVE_GUDEV static void fu_engine_udev_device_add (FuEngine *self, GUdevDevice *udev_device) { @@ -4251,6 +4258,7 @@ fu_engine_enumerate_udev (FuEngine *self) g_list_free (devices); } } +#endif static void fu_engine_plugin_recoldplug_cb (FuPlugin *plugin, FuEngine *self) @@ -4262,7 +4270,9 @@ fu_engine_plugin_recoldplug_cb (FuPlugin *plugin, FuEngine *self) if (self->app_flags & FU_APP_FLAGS_NO_IDLE_SOURCES) { g_debug ("doing direct recoldplug"); fu_engine_plugins_coldplug (self, TRUE); +#ifdef HAVE_GUDEV fu_engine_enumerate_udev (self); +#endif return; } g_debug ("scheduling a recoldplug"); @@ -4688,6 +4698,7 @@ fu_engine_update_history_database (FuEngine *self, GError **error) return TRUE; } +#ifdef HAVE_GUDEV static void fu_engine_udev_uevent_cb (GUdevClient *gudev_client, const gchar *action, @@ -4707,6 +4718,7 @@ fu_engine_udev_uevent_cb (GUdevClient *gudev_client, return; } } +#endif static void fu_engine_ensure_client_certificate (FuEngine *self) @@ -4844,6 +4856,7 @@ fu_engine_load (FuEngine *self, FuEngineLoadFlags flags, GError **error) G_CALLBACK (fu_engine_device_changed_cb), self); +#ifdef HAVE_GUDEV /* udev watches can only be set up in _init() so set up client now */ if (self->udev_subsystems->len > 0) { g_auto(GStrv) udev_subsystems = g_new0 (gchar *, self->udev_subsystems->len + 1); @@ -4855,6 +4868,7 @@ fu_engine_load (FuEngine *self, FuEngineLoadFlags flags, GError **error) g_signal_connect (self->gudev_client, "uevent", G_CALLBACK (fu_engine_udev_uevent_cb), self); } +#endif fu_engine_set_status (self, FWUPD_STATUS_LOADING); @@ -4873,9 +4887,11 @@ fu_engine_load (FuEngine *self, FuEngineLoadFlags flags, GError **error) if ((flags & FU_ENGINE_LOAD_FLAG_NO_ENUMERATE) == 0) g_usb_context_enumerate (self->usb_ctx); +#ifdef HAVE_GUDEV /* coldplug udev devices */ if ((flags & FU_ENGINE_LOAD_FLAG_NO_ENUMERATE) == 0) fu_engine_enumerate_udev (self); +#endif /* update the db for devices that were updated during the reboot */ if (!fu_engine_update_history_database (self, error)) @@ -4969,8 +4985,10 @@ fu_engine_init (FuEngine *self) self->plugin_list = fu_plugin_list_new (); self->plugin_filter = g_ptr_array_new_with_free_func (g_free); self->udev_subsystems = g_ptr_array_new_with_free_func (g_free); +#ifdef HAVE_GUDEV self->udev_changed_ids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) fu_engine_udev_changed_helper_free); +#endif self->runtime_versions = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); self->compile_versions = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); self->approved_firmware = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -5022,8 +5040,10 @@ fu_engine_finalize (GObject *obj) g_object_unref (self->usb_ctx); if (self->silo != NULL) g_object_unref (self->silo); +#ifdef HAVE_GUDEV if (self->gudev_client != NULL) g_object_unref (self->gudev_client); +#endif if (self->coldplug_id != 0) g_source_remove (self->coldplug_id); @@ -5037,7 +5057,9 @@ fu_engine_finalize (GObject *obj) g_object_unref (self->device_list); g_ptr_array_unref (self->plugin_filter); g_ptr_array_unref (self->udev_subsystems); +#ifdef HAVE_GUDEV g_hash_table_unref (self->udev_changed_ids); +#endif g_hash_table_unref (self->runtime_versions); g_hash_table_unref (self->compile_versions); g_hash_table_unref (self->approved_firmware); diff --git a/src/fu-plugin.h b/src/fu-plugin.h index ca2dda388..ed52200d3 100644 --- a/src/fu-plugin.h +++ b/src/fu-plugin.h @@ -8,7 +8,6 @@ #include #include -#include #include "fu-common.h" #include "fu-common-guid.h" @@ -18,7 +17,9 @@ #include "fu-quirks.h" #include "fu-hwids.h" #include "fu-usb-device.h" +#ifdef HAVE_GUDEV #include "fu-udev-device.h" +#endif #include "fwupd-common.h" #define FU_TYPE_PLUGIN (fu_plugin_get_type ()) diff --git a/src/fu-udev-device.c b/src/fu-udev-device.c index 23c98df3d..82dfef8df 100644 --- a/src/fu-udev-device.c +++ b/src/fu-udev-device.c @@ -84,6 +84,7 @@ fu_udev_device_emit_changed (FuUdevDevice *self) static guint32 fu_udev_device_get_sysfs_attr_as_uint32 (GUdevDevice *udev_device, const gchar *name) { +#ifdef HAVE_GUDEV guint64 tmp = fu_common_strtoull (g_udev_device_get_sysfs_attr (udev_device, name)); if (tmp > G_MAXUINT32) { g_warning ("reading %s for %s overflowed", @@ -92,11 +93,15 @@ fu_udev_device_get_sysfs_attr_as_uint32 (GUdevDevice *udev_device, const gchar * return G_MAXUINT32; } return tmp; +#else + return G_MAXUINT32; +#endif } static guint8 fu_udev_device_get_sysfs_attr_as_uint8 (GUdevDevice *udev_device, const gchar *name) { +#ifdef HAVE_GUDEV guint64 tmp = fu_common_strtoull (g_udev_device_get_sysfs_attr (udev_device, name)); if (tmp > G_MAXUINT8) { g_warning ("reading %s for %s overflowed", @@ -105,6 +110,9 @@ fu_udev_device_get_sysfs_attr_as_uint8 (GUdevDevice *udev_device, const gchar *n return G_MAXUINT8; } return tmp; +#else + return G_MAXUINT8; +#endif } static void @@ -140,10 +148,12 @@ fu_udev_device_probe (FuDevice *device, GError **error) FuUdevDeviceClass *klass = FU_UDEV_DEVICE_GET_CLASS (device); FuUdevDevice *self = FU_UDEV_DEVICE (device); FuUdevDevicePrivate *priv = GET_PRIVATE (self); +#ifdef HAVE_GUDEV const gchar *tmp; g_autofree gchar *subsystem = NULL; g_autoptr(GUdevDevice) udev_parent = NULL; g_autoptr(GUdevDevice) parent_i2c = NULL; +#endif /* nothing to do */ if (priv->udev_device == NULL) @@ -154,6 +164,7 @@ fu_udev_device_probe (FuDevice *device, GError **error) priv->model = fu_udev_device_get_sysfs_attr_as_uint32 (priv->udev_device, "device"); priv->revision = fu_udev_device_get_sysfs_attr_as_uint8 (priv->udev_device, "revision"); +#ifdef HAVE_GUDEV /* fallback to the parent */ udev_parent = g_udev_device_get_parent (priv->udev_device); if (udev_parent != NULL && @@ -303,6 +314,7 @@ fu_udev_device_probe (FuDevice *device, GError **error) "i2c", NULL); if (parent_i2c != NULL) fu_device_add_flag (device, FWUPD_DEVICE_FLAG_INTERNAL); +#endif /* subclassed */ if (klass->probe != NULL) { @@ -325,13 +337,16 @@ fu_udev_device_set_dev (FuUdevDevice *self, GUdevDevice *udev_device) g_set_object (&priv->udev_device, udev_device); if (priv->udev_device == NULL) return; +#ifdef HAVE_GUDEV priv->subsystem = g_strdup (g_udev_device_get_subsystem (priv->udev_device)); priv->device_file = g_strdup (g_udev_device_get_device_file (priv->udev_device)); +#endif } guint fu_udev_device_get_slot_depth (FuUdevDevice *self, const gchar *subsystem) { +#ifdef HAVE_GUDEV GUdevDevice *udev_device = fu_udev_device_get_dev (FU_UDEV_DEVICE (self)); g_autoptr(GUdevDevice) device_tmp = NULL; @@ -344,6 +359,7 @@ fu_udev_device_get_slot_depth (FuUdevDevice *self, const gchar *subsystem) return i; g_set_object (&device_tmp, parent); } +#endif return 0; } @@ -431,11 +447,13 @@ fu_udev_device_get_device_file (FuUdevDevice *self) const gchar * fu_udev_device_get_sysfs_path (FuUdevDevice *self) { +#ifdef HAVE_GUDEV FuUdevDevicePrivate *priv = GET_PRIVATE (self); g_return_val_if_fail (FU_IS_UDEV_DEVICE (self), NULL); - if (priv->udev_device == NULL) - return NULL; - return g_udev_device_get_sysfs_path (priv->udev_device); + if (priv->udev_device != NULL) + return g_udev_device_get_sysfs_path (priv->udev_device); +#endif + return NULL; } /** @@ -492,6 +510,7 @@ fu_udev_device_get_revision (FuUdevDevice *self) return priv->revision; } +#ifdef HAVE_GUDEV static GString * fu_udev_device_get_parent_subsystems (FuUdevDevice *self) { @@ -514,6 +533,7 @@ fu_udev_device_get_parent_subsystems (FuUdevDevice *self) g_string_truncate (str, str->len - 1); return str; } +#endif /** * fu_udev_device_set_physical_id: @@ -532,6 +552,7 @@ fu_udev_device_get_parent_subsystems (FuUdevDevice *self) gboolean fu_udev_device_set_physical_id (FuUdevDevice *self, const gchar *subsystem, GError **error) { +#ifdef HAVE_GUDEV FuUdevDevicePrivate *priv = GET_PRIVATE (self); const gchar *tmp; g_autofree gchar *physical_id = NULL; @@ -605,6 +626,13 @@ fu_udev_device_set_physical_id (FuUdevDevice *self, const gchar *subsystem, GErr /* success */ fu_device_set_physical_id (FU_DEVICE (self), physical_id); return TRUE; +#else + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as is unavailable"); + return FALSE; +#endif } /** diff --git a/src/fu-udev-device.h b/src/fu-udev-device.h index 733ebfa80..90daa3319 100644 --- a/src/fu-udev-device.h +++ b/src/fu-udev-device.h @@ -7,7 +7,13 @@ #pragma once #include + +#ifdef HAVE_GUDEV #include +#else +#define G_UDEV_TYPE_DEVICE G_TYPE_OBJECT +#define GUdevDevice GObject +#endif #include "fu-plugin.h" diff --git a/src/fu-usb-device.c b/src/fu-usb-device.c index 078cf4f9d..3bce0015d 100644 --- a/src/fu-usb-device.c +++ b/src/fu-usb-device.c @@ -441,6 +441,7 @@ fu_usb_device_set_dev (FuUsbDevice *device, GUsbDevice *usb_device) GUdevDevice * fu_usb_device_find_udev_device (FuUsbDevice *device, GError **error) { +#ifdef HAVE_GUDEV FuUsbDevicePrivate *priv = GET_PRIVATE (device); g_autoptr(GList) devices = NULL; g_autoptr(GUdevClient) gudev_client = g_udev_client_new (NULL); @@ -473,6 +474,12 @@ fu_usb_device_find_udev_device (FuUsbDevice *device, GError **error) "could not find sysfs device for %u:%u", g_usb_device_get_bus (priv->usb_device), g_usb_device_get_address (priv->usb_device)); +#else + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as is unavailable"); +#endif return NULL; } diff --git a/src/fu-usb-device.h b/src/fu-usb-device.h index a9457f4da..a5a738afe 100644 --- a/src/fu-usb-device.h +++ b/src/fu-usb-device.h @@ -8,9 +8,9 @@ #include #include -#include #include "fu-plugin.h" +#include "fu-udev-device.h" #define FU_TYPE_USB_DEVICE (fu_usb_device_get_type ()) G_DECLARE_DERIVABLE_TYPE (FuUsbDevice, fu_usb_device, FU, USB_DEVICE, FuDevice) diff --git a/src/fu-util.c b/src/fu-util.c index 6f747c8c1..c241a0a20 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/src/meson.build b/src/meson.build index 5c3020cf2..e59d29f82 100644 --- a/src/meson.build +++ b/src/meson.build @@ -30,10 +30,13 @@ libfwupdprivate_src = [ 'fu-smbios.c', 'fu-srec-firmware.c', 'fu-test.c', - 'fu-udev-device.c', 'fu-usb-device.c', ] +if get_option('gudev') + libfwupdprivate_src += 'fu-udev-device.c' +endif + if get_option('gpg') keyring_src += 'fu-keyring-gpg.c' keyring_deps += gpgme From 802be8b1b3e11f20e521d3ef4485c44de01fefbd Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sun, 24 Nov 2019 13:24:34 -0600 Subject: [PATCH 25/74] trivial: fu-plugin-vfuncs: Add GTK documentation for all vfuncs --- src/fu-plugin-vfuncs.h | 259 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) diff --git a/src/fu-plugin-vfuncs.h b/src/fu-plugin-vfuncs.h index ecf85c9aa..1db5e5b5d 100644 --- a/src/fu-plugin-vfuncs.h +++ b/src/fu-plugin-vfuncs.h @@ -9,70 +9,329 @@ #include "fu-plugin.h" #include "fu-device.h" +/** + * SECTION:fu-plugin-vfuncs + * @short_description: Virtual functions for plugins + * + * Optional functions that a plugin can implement. If implemented they will + * be automatically called by the daemon as part of the plugin lifecycle. + * + * See also: #FuPlugin + */ + + +/** + * fu_plugin_init: + * @plugin: A #FuPlugin + * + * Initializes the plugin. + * Sets up any static data structures fo the plugin. + * Most plugins should call fu_plugin_set_build_hash in here. + * + * Since: 0.8.0 + **/ void fu_plugin_init (FuPlugin *plugin); + +/** + * fu_plugin_destroy: + * @plugin: A #FuPlugin + * + * Destroys the plugin. + * Any allocated memory should be freed here. + * + * Since: 0.8.0 + **/ void fu_plugin_destroy (FuPlugin *plugin); + +/** + * fu_plugin_startup: + * @plugin: A #FuPlugin + * @error: A #GError + * + * Tries to start the plugin. + * Returns: TRUE for success or FALSE for failure. + * + * Any plugins not intended for the system or that have failure communicating + * with the device should return FALSE. + * Any allocated memory should be freed here. + * + * Since: 0.8.0 + **/ gboolean fu_plugin_startup (FuPlugin *plugin, GError **error); +/** + * fu_plugin_coldplug: + * @plugin: A #FuPlugin + * @error: A #GError + * + * Probes for devices. + * + * Since: 0.8.0 + **/ gboolean fu_plugin_coldplug (FuPlugin *plugin, GError **error); +/** + * fu_plugin_coldplug_prepare: + * @plugin: A #FuPlugin + * @error: A #GError + * + * Prepares to probe for devices. + * + * Since: 0.8.0 + **/ gboolean fu_plugin_coldplug_prepare (FuPlugin *plugin, GError **error); +/** + * fu_plugin_coldplug_cleanup: + * @plugin: A #FuPlugin + * @error: A #GError + * + * Cleans up from probe for devices. + * + * Since: 0.8.0 + **/ gboolean fu_plugin_coldplug_cleanup (FuPlugin *plugin, GError **error); +/** + * fu_plugin_recoldplug: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @flags: A #FuPluginVerifyFlags + * @error: A #GError or NULL + * + * Re-runs the coldplug routine for devices. + * + * Since: 1.0.4 + **/ gboolean fu_plugin_recoldplug (FuPlugin *plugin, GError **error); +/** + * fu_plugin_update: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @blob_fw: A #GBytes + * @flags: A #FwupdInstallFlags + * @error: A #GError or NULL + * + * Updates the firmware on the device with blob_fw + * + * Since: 0.9.7 + **/ gboolean fu_plugin_update (FuPlugin *plugin, FuDevice *dev, GBytes *blob_fw, FwupdInstallFlags flags, GError **error); +/** + * fu_plugin_verify: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @flags: A #FuPluginVerifyFlags + * @error: A #GError or NULL + * + * Verifies the firmware on the device matches the value stored in the database + * + * Since: 0.8.0 + **/ gboolean fu_plugin_verify (FuPlugin *plugin, FuDevice *dev, FuPluginVerifyFlags flags, GError **error); +/** + * fu_plugin_unlock: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @error: A #GError or NULL + * + * Unlocks the device for writes. + * + * Since: 0.8.0 + **/ gboolean fu_plugin_unlock (FuPlugin *plugin, FuDevice *dev, GError **error); +/** + * fu_plugin_activate: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @error: A #GError or NULL + * + * Activates the new firmware on the device. + * + * This is intended for devices that it is not safe to immediately activate + * the firmware. It may be called at a more convenient time instead. + * + * Since: 1.2.6 + **/ gboolean fu_plugin_activate (FuPlugin *plugin, FuDevice *dev, GError **error); +/** + * fu_plugin_clear_results: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @error: A #GError or NULL + * + * Clears stored update results for the device. + * + * Since: 0.8.0 + **/ gboolean fu_plugin_clear_results (FuPlugin *plugin, FuDevice *dev, GError **error); +/** + * fu_plugin_get_results: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @error: A #GError or NULL + * + * Obtains historical update results for the device. + * + * Since: 0.8.0 + **/ gboolean fu_plugin_get_results (FuPlugin *plugin, FuDevice *dev, GError **error); +/** + * fu_plugin_update_attach: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @error: A #GError or NULL + * + * Swaps the device from bootloader mode to runtime mode. + * + * Since: 1.0.2 + **/ gboolean fu_plugin_update_attach (FuPlugin *plugin, FuDevice *dev, GError **error); +/** + * fu_plugin_update_detach: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @error: A #GError or NULL + * + * Swaps the device from runtime mode to bootloader mode. + * + * Since: 1.0.2 + **/ gboolean fu_plugin_update_detach (FuPlugin *plugin, FuDevice *dev, GError **error); +/** + * fu_plugin_update_prepare: + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @error: A #GError or NULL + * + * Prepares the device to receive an update. + * + * Since: 0.8.0 + **/ gboolean fu_plugin_update_prepare (FuPlugin *plugin, FwupdInstallFlags flags, FuDevice *dev, GError **error); +/** + * fu_plugin_update_cleanup + * @plugin: A #FuPlugin + * @dev: A #FuDevice + * @error: A #GError or NULL + * + * Cleans up the device after receiving an update. + * + * Since: 0.8.0 + **/ gboolean fu_plugin_update_cleanup (FuPlugin *plugin, FwupdInstallFlags flags, FuDevice *dev, GError **error); +/** + * fu_plugin_composite_prepare + * @plugin: A #FuPlugin + * @devices: A #GPtrArray of #FuDevice + * @error: A #GError or NULL + * + * Function run before updating group of composite devices. + * + * Since: 1.0.9 + **/ gboolean fu_plugin_composite_prepare (FuPlugin *plugin, GPtrArray *devices, GError **error); +/** + * fu_plugin_composite_cleanup + * @plugin: A #FuPlugin + * @devices: A #GPtrArray of #FuDevice + * @error: A #GError or NULL + * + * Function run after updating group of composite devices. + * + * Since: 1.0.9 + **/ gboolean fu_plugin_composite_cleanup (FuPlugin *plugin, GPtrArray *devices, GError **error); +/** + * fu_plugin_usb_device_added + * @plugin: A #FuPlugin + * @device: A #FuUsbDevice + * @error: A #GError or NULL + * + * Function run after USB device added to daemon. + * + * Since: 1.0.2 + **/ gboolean fu_plugin_usb_device_added (FuPlugin *plugin, FuUsbDevice *device, GError **error); +/** + * fu_plugin_udev_device_added + * @plugin: A #FuPlugin + * @device: A #FuUdevDevice + * @error: A #GError or NULL + * + * Function run after Udev device added to daemon. + * + * Since: 1.1.2 + **/ gboolean fu_plugin_udev_device_added (FuPlugin *plugin, FuUdevDevice *device, GError **error); +/** + * fu_plugin_udev_device_changed + * @plugin: A #FuPlugin + * @device: A #FuUdevDevice + * @error: A #GError or NULL + * + * Function run when Udev device changed. + * + * Since: 1.1.2 + **/ gboolean fu_plugin_udev_device_changed (FuPlugin *plugin, FuUdevDevice *device, GError **error); +/** + * fu_plugin_device_removed + * @plugin: A #FuPlugin + * @device: A #FuDevice + * @error: A #GError or NULL + * + * Function run when device removed. + * + * Since: 1.1.2 + **/ gboolean fu_plugin_device_removed (FuPlugin *plugin, FuDevice *device, GError **error); +/** + * fu_plugin_device_removed + * @plugin: A #FuPlugin + * @device: A #FuDevice + * + * Function run when device registered from another plugin. + * + * Since: 0.9.7 + **/ void fu_plugin_device_registered (FuPlugin *plugin, FuDevice *dev); From c5efb215190711e56547a9075b5750e2e4c497a2 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 25 Nov 2019 07:45:18 -0600 Subject: [PATCH 26/74] fu-util-common: Invert default behavior for reboot and shutdown prompts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current behavior for the prompt: ``` Y … Restart & Update y … Restart & Update N … Tool abort & Update complete after next Power cycle n …Tool abort & Update complete after next Power cycle 0 … Pause -> (Push anykey) -> Restart & Update * … Pause -> (Push anykey) -> Restart & Update “”(Enter Only) … Restart & Update ``` If someone just keeps pressing enter without reading the system will reboot which might lead to data loss. Set the default scenario to abort reboot, so they can just see the message to reboot instead. --- src/fu-util-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fu-util-common.c b/src/fu-util-common.c index 72ffdefc7..b67655027 100644 --- a/src/fu-util-common.c +++ b/src/fu-util-common.c @@ -438,7 +438,7 @@ fu_util_prompt_complete (FwupdDeviceFlags flags, gboolean prompt, GError **error _("An update requires the system to shutdown to complete."), /* TRANSLATORS: shutdown to apply the update */ _("Shutdown now?")); - if (!fu_util_prompt_for_boolean (TRUE)) + if (!fu_util_prompt_for_boolean (FALSE)) return TRUE; } return fu_util_update_shutdown (error); @@ -450,7 +450,7 @@ fu_util_prompt_complete (FwupdDeviceFlags flags, gboolean prompt, GError **error _("An update requires a reboot to complete."), /* TRANSLATORS: reboot to apply the update */ _("Restart now?")); - if (!fu_util_prompt_for_boolean (TRUE)) + if (!fu_util_prompt_for_boolean (FALSE)) return TRUE; } return fu_util_update_reboot (error); From 98ad926196f242e4c087975418aec02499294b8e Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 25 Nov 2019 15:19:30 +0000 Subject: [PATCH 27/74] Create a REV_00 instance ID as this may be what the vendor needs to target --- src/fu-udev-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fu-udev-device.c b/src/fu-udev-device.c index 82dfef8df..bac4e9846 100644 --- a/src/fu-udev-device.c +++ b/src/fu-udev-device.c @@ -283,7 +283,7 @@ fu_udev_device_probe (FuDevice *device, GError **error) } /* add GUIDs in order of priority */ - if (priv->vendor != 0x0000 && priv->model != 0x0000 && priv->revision != 0x00) { + if (priv->vendor != 0x0000 && priv->model != 0x0000) { g_autofree gchar *devid = NULL; devid = g_strdup_printf ("%s\\VEN_%04X&DEV_%04X&REV_%02X", subsystem, priv->vendor, From 28ab968cbfd4616458026e76d482c58561a328da Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 25 Nov 2019 08:40:40 +0000 Subject: [PATCH 28/74] synaptics-rmi: Use the build ID as the version number to match the vendor tool --- plugins/synaptics-rmi/fu-synaptics-rmi-device.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/synaptics-rmi/fu-synaptics-rmi-device.c b/plugins/synaptics-rmi/fu-synaptics-rmi-device.c index 9346a20d5..b2a53fa43 100644 --- a/plugins/synaptics-rmi/fu-synaptics-rmi-device.c +++ b/plugins/synaptics-rmi/fu-synaptics-rmi-device.c @@ -574,11 +574,8 @@ fu_synaptics_rmi_device_setup (FuDevice *device, GError **error) } /* set versions */ - fw_ver = g_strdup_printf ("%u.%u.%u", - f01_basic->data[2], - f01_basic->data[3], - priv->flash.build_id); - fu_device_set_version (device, fw_ver, FWUPD_VERSION_FORMAT_TRIPLET); + fw_ver = g_strdup_printf ("%u", priv->flash.build_id); + fu_device_set_version (device, fw_ver, FWUPD_VERSION_FORMAT_PLAIN); bl_ver = g_strdup_printf ("%u.0", priv->flash.bootloader_id[1]); fu_device_set_version_bootloader (device, bl_ver); From 56ac823af9d78cf941df90c5d28b42c582727ede Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 25 Nov 2019 13:44:49 +0000 Subject: [PATCH 29/74] Set the protocol per-device not per-plugin Some plugins have devices with more than one protocol. Logically the protocol belongs to the device, not the plugin, and in the future we could use this to further check firmware that's about to be deployed. This is also not exported into libfwupd (yet?) as it's remains a debug-feature only -- protocols are not actually required for devices to be added. --- plugins/altos/fu-altos-device.c | 1 + plugins/altos/fu-plugin-altos.c | 1 - plugins/ata/fu-ata-device.c | 1 + plugins/ata/fu-plugin-ata.c | 1 - plugins/colorhug/fu-colorhug-device.c | 1 + plugins/colorhug/fu-plugin-colorhug.c | 1 - plugins/csr/fu-csr-device.c | 3 +- plugins/csr/fu-plugin-csr.c | 1 - plugins/dell-dock/fu-dell-dock-i2c-ec.c | 1 + plugins/dell-dock/fu-dell-dock-i2c-mst.c | 1 + plugins/dell-dock/fu-dell-dock-i2c-tbt.c | 6 ++- plugins/dell-dock/fu-dell-dock-status.c | 1 + plugins/dell-dock/fu-plugin-dell-dock.c | 2 - plugins/dfu/dfu-device.c | 7 +++ plugins/dfu/fu-plugin-dfu.c | 2 - plugins/ebitdo/fu-ebitdo-device.c | 1 + plugins/ebitdo/fu-plugin-ebitdo.c | 1 - plugins/emmc/fu-emmc-device.c | 1 + plugins/emmc/fu-plugin-emmc.c | 1 - plugins/fastboot/fu-fastboot-device.c | 1 + plugins/fastboot/fu-plugin-fastboot.c | 1 - plugins/flashrom/fu-plugin-flashrom.c | 2 +- .../fu-logitech-hidpp-peripheral.c | 2 + .../logitech-hidpp/fu-plugin-logitech-hidpp.c | 2 - plugins/nvme/fu-nvme-device.c | 1 + plugins/nvme/fu-plugin-nvme.c | 1 - plugins/redfish/fu-plugin-redfish.c | 1 - plugins/redfish/fu-redfish-client.c | 1 + plugins/rts54hid/fu-plugin-rts54hid.c | 1 - plugins/rts54hid/fu-rts54hid-device.c | 1 + plugins/rts54hub/fu-plugin-rts54hub.c | 1 - plugins/rts54hub/fu-rts54hub-device.c | 1 + plugins/solokey/fu-plugin-solokey.c | 1 - plugins/solokey/fu-solokey-device.c | 1 + plugins/superio/fu-plugin-superio.c | 1 - plugins/superio/fu-superio-device.c | 1 + .../fu-plugin-synaptics-prometheus.c | 1 - .../synaptics-prometheus/fu-synaprom-config.c | 1 + .../synaptics-prometheus/fu-synaprom-device.c | 1 + .../synaptics-rmi/fu-plugin-synaptics-rmi.c | 1 - .../synaptics-rmi/fu-synaptics-rmi-device.c | 1 + plugins/synapticsmst/fu-plugin-synapticsmst.c | 1 - plugins/synapticsmst/fu-synapticsmst-device.c | 1 + plugins/test/fu-plugin-test.c | 2 +- plugins/thunderbolt/fu-plugin-thunderbolt.c | 2 +- plugins/uefi/fu-plugin-uefi.c | 1 - plugins/uefi/fu-uefi-device.c | 1 + plugins/vli-usbhub/fu-plugin-vli-usbhub.c | 1 - plugins/vli-usbhub/fu-vli-usbhub-device.c | 1 + plugins/wacom-raw/fu-plugin-wacom-raw.c | 1 - plugins/wacom-raw/fu-wacom-device.c | 1 + plugins/wacom-usb/fu-plugin-wacom-usb.c | 1 - plugins/wacom-usb/fu-wac-device.c | 1 + src/fu-device.c | 54 +++++++++++++++++++ src/fu-device.h | 3 ++ src/fu-plugin.h | 2 - 56 files changed, 98 insertions(+), 34 deletions(-) diff --git a/plugins/altos/fu-altos-device.c b/plugins/altos/fu-altos-device.c index ea0f26e90..cd477cb09 100644 --- a/plugins/altos/fu-altos-device.c +++ b/plugins/altos/fu-altos-device.c @@ -545,6 +545,7 @@ fu_altos_device_init (FuAltosDevice *self) fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_vendor (FU_DEVICE (self), "altusmetrum.org"); fu_device_set_summary (FU_DEVICE (self), "A USB hardware random number generator"); + fu_device_set_protocol (FU_DEVICE (self), "org.altusmetrum.altos"); /* requires manual step */ if (!fu_device_has_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER)) diff --git a/plugins/altos/fu-plugin-altos.c b/plugins/altos/fu-plugin-altos.c index 9c6eae20f..636e6a277 100644 --- a/plugins/altos/fu-plugin-altos.c +++ b/plugins/altos/fu-plugin-altos.c @@ -16,7 +16,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.altusmetrum.altos"); fu_plugin_set_device_gtype (plugin, FU_TYPE_ALTOS_DEVICE); fu_plugin_add_firmware_gtype (plugin, "altos", FU_TYPE_ALTOS_FIRMWARE); } diff --git a/plugins/ata/fu-ata-device.c b/plugins/ata/fu-ata-device.c index 1ec2dcb26..a9a577e15 100644 --- a/plugins/ata/fu-ata-device.c +++ b/plugins/ata/fu-ata-device.c @@ -661,6 +661,7 @@ fu_ata_device_init (FuAtaDevice *self) fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_summary (FU_DEVICE (self), "ATA Drive"); fu_device_add_icon (FU_DEVICE (self), "drive-harddisk"); + fu_device_set_protocol (FU_DEVICE (self), "org.t13.ata"); fu_udev_device_set_readonly (FU_UDEV_DEVICE (self), TRUE); } diff --git a/plugins/ata/fu-plugin-ata.c b/plugins/ata/fu-plugin-ata.c index c4069059e..2675ae4d2 100644 --- a/plugins/ata/fu-plugin-ata.c +++ b/plugins/ata/fu-plugin-ata.c @@ -16,6 +16,5 @@ fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); fu_plugin_add_udev_subsystem (plugin, "block"); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.t13.ata"); fu_plugin_set_device_gtype (plugin, FU_TYPE_ATA_DEVICE); } diff --git a/plugins/colorhug/fu-colorhug-device.c b/plugins/colorhug/fu-colorhug-device.c index 792d36b19..36f05774b 100644 --- a/plugins/colorhug/fu-colorhug-device.c +++ b/plugins/colorhug/fu-colorhug-device.c @@ -455,6 +455,7 @@ fu_colorhug_device_init (FuColorhugDevice *self) { /* this is the application code */ self->start_addr = CH_EEPROM_ADDR_RUNCODE; + fu_device_set_protocol (FU_DEVICE (self), "com.hughski.colorhug"); fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE); } diff --git a/plugins/colorhug/fu-plugin-colorhug.c b/plugins/colorhug/fu-plugin-colorhug.c index 141c12b17..29166317b 100644 --- a/plugins/colorhug/fu-plugin-colorhug.c +++ b/plugins/colorhug/fu-plugin-colorhug.c @@ -15,6 +15,5 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.hughski.colorhug"); fu_plugin_set_device_gtype (plugin, FU_TYPE_COLORHUG_DEVICE); } diff --git a/plugins/csr/fu-csr-device.c b/plugins/csr/fu-csr-device.c index 6d736fed2..4d9ac5cbf 100644 --- a/plugins/csr/fu-csr-device.c +++ b/plugins/csr/fu-csr-device.c @@ -548,8 +548,9 @@ fu_csr_device_close (FuUsbDevice *device, GError **error) } static void -fu_csr_device_init (FuCsrDevice *device) +fu_csr_device_init (FuCsrDevice *self) { + fu_device_set_protocol (FU_DEVICE (self), "com.qualcomm.dfu"); } static void diff --git a/plugins/csr/fu-plugin-csr.c b/plugins/csr/fu-plugin-csr.c index 919d631a2..bb9eed724 100644 --- a/plugins/csr/fu-plugin-csr.c +++ b/plugins/csr/fu-plugin-csr.c @@ -15,6 +15,5 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.qualcomm.dfu"); fu_plugin_set_device_gtype (plugin, FU_TYPE_CSR_DEVICE); } diff --git a/plugins/dell-dock/fu-dell-dock-i2c-ec.c b/plugins/dell-dock/fu-dell-dock-i2c-ec.c index 956cddebb..deada5c43 100644 --- a/plugins/dell-dock/fu-dell-dock-i2c-ec.c +++ b/plugins/dell-dock/fu-dell-dock-i2c-ec.c @@ -988,6 +988,7 @@ fu_dell_dock_ec_init (FuDellDockEc *self) { self->data = g_new0 (FuDellDockDockDataStructure, 1); self->raw_versions = g_new0 (FuDellDockDockPackageFWVersion, 1); + fu_device_set_protocol (FU_DEVICE (self), "com.dell.dock"); } static void diff --git a/plugins/dell-dock/fu-dell-dock-i2c-mst.c b/plugins/dell-dock/fu-dell-dock-i2c-mst.c index ae8ca5c3b..de729209e 100644 --- a/plugins/dell-dock/fu-dell-dock-i2c-mst.c +++ b/plugins/dell-dock/fu-dell-dock-i2c-mst.c @@ -972,6 +972,7 @@ fu_dell_dock_mst_finalize (GObject *object) static void fu_dell_dock_mst_init (FuDellDockMst *self) { + fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.mst"); } static void diff --git a/plugins/dell-dock/fu-dell-dock-i2c-tbt.c b/plugins/dell-dock/fu-dell-dock-i2c-tbt.c index ccb635dfa..c55c49f9f 100644 --- a/plugins/dell-dock/fu-dell-dock-i2c-tbt.c +++ b/plugins/dell-dock/fu-dell-dock-i2c-tbt.c @@ -280,8 +280,10 @@ fu_dell_dock_tbt_finalize (GObject *object) } static void -fu_dell_dock_tbt_init (FuDellDockTbt *device) -{} +fu_dell_dock_tbt_init (FuDellDockTbt *self) +{ + fu_device_set_protocol (FU_DEVICE (self), "com.intel.thunderbolt"); +} static void fu_dell_dock_tbt_class_init (FuDellDockTbtClass *klass) diff --git a/plugins/dell-dock/fu-dell-dock-status.c b/plugins/dell-dock/fu-dell-dock-status.c index 6afa38dac..cfe124c2e 100644 --- a/plugins/dell-dock/fu-dell-dock-status.c +++ b/plugins/dell-dock/fu-dell-dock-status.c @@ -142,6 +142,7 @@ fu_dell_dock_status_finalize (GObject *object) static void fu_dell_dock_status_init (FuDellDockStatus *self) { + fu_device_set_protocol (FU_DEVICE (self), "com.dell.dock"); } static void diff --git a/plugins/dell-dock/fu-plugin-dell-dock.c b/plugins/dell-dock/fu-plugin-dell-dock.c index ff3eac9fb..5e9f45f25 100644 --- a/plugins/dell-dock/fu-plugin-dell-dock.c +++ b/plugins/dell-dock/fu-plugin-dell-dock.c @@ -33,8 +33,6 @@ fu_plugin_init (FuPlugin *plugin) /* currently slower performance, but more reliable in corner cases */ fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_BETTER_THAN, "synapticsmst"); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.dell.dock"); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.synaptics.mst"); } static gboolean diff --git a/plugins/dfu/dfu-device.c b/plugins/dfu/dfu-device.c index 2f8d52036..ace26b3aa 100644 --- a/plugins/dfu/dfu-device.c +++ b/plugins/dfu/dfu-device.c @@ -332,6 +332,13 @@ dfu_device_add_targets (DfuDevice *device, GError **error) priv->version = DFU_VERSION_DFU_1_1; } + /* set expected protocol */ + if (priv->version == DFU_VERSION_DFUSE) { + fu_device_set_protocol (FU_DEVICE (device), "com.st.dfuse"); + } else { + fu_device_set_protocol (FU_DEVICE (device), "org.usb.dfu"); + } + /* fix up the transfer size */ if (priv->transfer_size == 0xffff) { priv->transfer_size = 0x0400; diff --git a/plugins/dfu/fu-plugin-dfu.c b/plugins/dfu/fu-plugin-dfu.c index afd7c787b..fd42b2a13 100644 --- a/plugins/dfu/fu-plugin-dfu.c +++ b/plugins/dfu/fu-plugin-dfu.c @@ -15,7 +15,5 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.usb.dfu"); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.st.dfuse"); fu_plugin_set_device_gtype (plugin, DFU_TYPE_DEVICE); } diff --git a/plugins/ebitdo/fu-ebitdo-device.c b/plugins/ebitdo/fu-ebitdo-device.c index 4dd9941d4..75b6d076f 100644 --- a/plugins/ebitdo/fu-ebitdo-device.c +++ b/plugins/ebitdo/fu-ebitdo-device.c @@ -578,6 +578,7 @@ fu_ebitdo_device_prepare_firmware (FuDevice *device, static void fu_ebitdo_device_init (FuEbitdoDevice *self) { + fu_device_set_protocol (FU_DEVICE (self), "com.8bitdo"); } static void diff --git a/plugins/ebitdo/fu-plugin-ebitdo.c b/plugins/ebitdo/fu-plugin-ebitdo.c index 66ad1b1ea..4f40dc71e 100644 --- a/plugins/ebitdo/fu-plugin-ebitdo.c +++ b/plugins/ebitdo/fu-plugin-ebitdo.c @@ -16,7 +16,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.8bitdo"); fu_plugin_set_device_gtype (plugin, FU_TYPE_EBITDO_DEVICE); fu_plugin_add_firmware_gtype (plugin, "8bitdo", FU_TYPE_EBITDO_FIRMWARE); } diff --git a/plugins/emmc/fu-emmc-device.c b/plugins/emmc/fu-emmc-device.c index e9068c444..19c6b03b2 100644 --- a/plugins/emmc/fu-emmc-device.c +++ b/plugins/emmc/fu-emmc-device.c @@ -478,6 +478,7 @@ fu_emmc_device_write_firmware (FuDevice *device, static void fu_emmc_device_init (FuEmmcDevice *self) { + fu_device_set_protocol (FU_DEVICE (self), "org.jedec.mmc"); fu_device_add_icon (FU_DEVICE (self), "media-memory"); } diff --git a/plugins/emmc/fu-plugin-emmc.c b/plugins/emmc/fu-plugin-emmc.c index d349bf96d..d85079c6d 100644 --- a/plugins/emmc/fu-plugin-emmc.c +++ b/plugins/emmc/fu-plugin-emmc.c @@ -16,6 +16,5 @@ fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); fu_plugin_add_udev_subsystem (plugin, "block"); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.jedec.mmc"); fu_plugin_set_device_gtype (plugin, FU_TYPE_EMMC_DEVICE); } diff --git a/plugins/fastboot/fu-fastboot-device.c b/plugins/fastboot/fu-fastboot-device.c index 8dc56e3a2..8edbe6556 100644 --- a/plugins/fastboot/fu-fastboot-device.c +++ b/plugins/fastboot/fu-fastboot-device.c @@ -694,6 +694,7 @@ fu_fastboot_device_init (FuFastbootDevice *self) { /* this is a safe default, even using USBv1 */ self->blocksz = 512; + fu_device_set_protocol (FU_DEVICE (self), "com.google.fastboot"); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); fu_device_set_remove_delay (FU_DEVICE (self), FASTBOOT_REMOVE_DELAY_RE_ENUMERATE); diff --git a/plugins/fastboot/fu-plugin-fastboot.c b/plugins/fastboot/fu-plugin-fastboot.c index 07aa28cb6..13fcdf564 100644 --- a/plugins/fastboot/fu-plugin-fastboot.c +++ b/plugins/fastboot/fu-plugin-fastboot.c @@ -15,6 +15,5 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.google.fastboot"); fu_plugin_set_device_gtype (plugin, FU_TYPE_FASTBOOT_DEVICE); } diff --git a/plugins/flashrom/fu-plugin-flashrom.c b/plugins/flashrom/fu-plugin-flashrom.c index 5a2c4fd58..5b9546591 100644 --- a/plugins/flashrom/fu-plugin-flashrom.c +++ b/plugins/flashrom/fu-plugin-flashrom.c @@ -41,7 +41,6 @@ fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.flashrom"); } void @@ -101,6 +100,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) g_autoptr(FuDevice) dev = fu_device_new (); fu_device_set_id (dev, device_id); fu_device_set_quirks (dev, fu_plugin_get_quirks (plugin)); + fu_device_set_protocol (dev, "org.flashrom"); fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_INTERNAL); fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_name (dev, fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_PRODUCT_NAME)); diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c index e079981ee..bc9c18b01 100644 --- a/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-peripheral.c @@ -588,6 +588,7 @@ fu_logitech_hidpp_peripheral_setup (FuDevice *device, GError **error) self->is_updatable = TRUE; fu_device_remove_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); } + fu_device_set_protocol (FU_DEVICE (device), "com.logitech.unifyingsigned"); } idx = fu_logitech_hidpp_peripheral_feature_get_idx (self, HIDPP_FEATURE_DFU); if (idx != 0x00) { @@ -1020,6 +1021,7 @@ fu_logitech_hidpp_peripheral_init (FuLogitechHidPpPeripheral *self) self->feature_index = g_ptr_array_new_with_free_func (g_free); fu_device_add_parent_guid (FU_DEVICE (self), "HIDRAW\\VEN_046D&DEV_C52B"); fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE); + fu_device_set_protocol (FU_DEVICE (self), "com.logitech.unifying"); /* there are a lot of unifying peripherals, but not all respond * well to opening -- so limit to ones with issued updates */ diff --git a/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c b/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c index 87f8f37ff..8e25ad9cf 100644 --- a/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c +++ b/plugins/logitech-hidpp/fu-plugin-logitech-hidpp.c @@ -35,8 +35,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.logitech.unifying"); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.logitech.unifyingsigned"); fu_plugin_add_udev_subsystem (plugin, "hidraw"); fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_CONFLICTS, "unifying"); diff --git a/plugins/nvme/fu-nvme-device.c b/plugins/nvme/fu-nvme-device.c index 8e598010a..3d263806f 100644 --- a/plugins/nvme/fu-nvme-device.c +++ b/plugins/nvme/fu-nvme-device.c @@ -431,6 +431,7 @@ fu_nvme_device_init (FuNvmeDevice *self) fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_summary (FU_DEVICE (self), "NVM Express Solid State Drive"); fu_device_add_icon (FU_DEVICE (self), "drive-harddisk"); + fu_device_set_protocol (FU_DEVICE (self), "org.nvmexpress"); fu_udev_device_set_readonly (FU_UDEV_DEVICE (self), TRUE); } diff --git a/plugins/nvme/fu-plugin-nvme.c b/plugins/nvme/fu-plugin-nvme.c index 325c0e5c3..52e6b25d2 100644 --- a/plugins/nvme/fu-plugin-nvme.c +++ b/plugins/nvme/fu-plugin-nvme.c @@ -16,6 +16,5 @@ fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); fu_plugin_add_udev_subsystem (plugin, "nvme"); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.nvmexpress"); fu_plugin_set_device_gtype (plugin, FU_TYPE_NVME_DEVICE); } diff --git a/plugins/redfish/fu-plugin-redfish.c b/plugins/redfish/fu-plugin-redfish.c index e092b7c56..b98f00b1c 100644 --- a/plugins/redfish/fu-plugin-redfish.c +++ b/plugins/redfish/fu-plugin-redfish.c @@ -121,7 +121,6 @@ fu_plugin_init (FuPlugin *plugin) { FuPluginData *data = fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); data->client = fu_redfish_client_new (); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.dmtf.redfish"); fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); } diff --git a/plugins/redfish/fu-redfish-client.c b/plugins/redfish/fu-redfish-client.c index 5e44eb2d5..268eff361 100644 --- a/plugins/redfish/fu-redfish-client.c +++ b/plugins/redfish/fu-redfish-client.c @@ -123,6 +123,7 @@ fu_redfish_client_coldplug_member (FuRedfishClient *self, id = g_strdup_printf ("Redfish-Inventory-%s", json_object_get_string_member (member, "Id")); fu_device_set_id (dev, id); + fu_device_set_protocol (dev, "org.dmtf.redfish"); fu_device_add_guid (dev, guid); if (json_object_has_member (member, "Name")) diff --git a/plugins/rts54hid/fu-plugin-rts54hid.c b/plugins/rts54hid/fu-plugin-rts54hid.c index 3859f06c5..2550fe7b8 100644 --- a/plugins/rts54hid/fu-plugin-rts54hid.c +++ b/plugins/rts54hid/fu-plugin-rts54hid.c @@ -16,7 +16,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.realtek.rts54"); fu_plugin_set_device_gtype (plugin, FU_TYPE_RTS54HID_DEVICE); /* register the custom types */ diff --git a/plugins/rts54hid/fu-rts54hid-device.c b/plugins/rts54hid/fu-rts54hid-device.c index c239ae6af..118bc7535 100644 --- a/plugins/rts54hid/fu-rts54hid-device.c +++ b/plugins/rts54hid/fu-rts54hid-device.c @@ -377,6 +377,7 @@ fu_rts54hid_device_write_firmware (FuDevice *device, static void fu_rts54hid_device_init (FuRts54HidDevice *self) { + fu_device_set_protocol (FU_DEVICE (self), "com.realtek.rts54"); } static void diff --git a/plugins/rts54hub/fu-plugin-rts54hub.c b/plugins/rts54hub/fu-plugin-rts54hub.c index 8abc2ab67..410ca3b23 100644 --- a/plugins/rts54hub/fu-plugin-rts54hub.c +++ b/plugins/rts54hub/fu-plugin-rts54hub.c @@ -15,6 +15,5 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.realtek.rts54"); fu_plugin_set_device_gtype (plugin, FU_TYPE_RTS54HUB_DEVICE); } diff --git a/plugins/rts54hub/fu-rts54hub-device.c b/plugins/rts54hub/fu-rts54hub-device.c index 8bd04d97f..57e6cff5d 100644 --- a/plugins/rts54hub/fu-rts54hub-device.c +++ b/plugins/rts54hub/fu-rts54hub-device.c @@ -416,6 +416,7 @@ fu_rts54hub_device_prepare_firmware (FuDevice *device, static void fu_rts54hub_device_init (FuRts54HubDevice *self) { + fu_device_set_protocol (FU_DEVICE (self), "com.realtek.rts54"); fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE); } diff --git a/plugins/solokey/fu-plugin-solokey.c b/plugins/solokey/fu-plugin-solokey.c index c90731fd3..c266ff226 100644 --- a/plugins/solokey/fu-plugin-solokey.c +++ b/plugins/solokey/fu-plugin-solokey.c @@ -16,7 +16,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.solokeys"); fu_plugin_set_device_gtype (plugin, FU_TYPE_SOLOKEY_DEVICE); fu_plugin_add_firmware_gtype (plugin, "solokey", FU_TYPE_SOLOKEY_FIRMWARE); } diff --git a/plugins/solokey/fu-solokey-device.c b/plugins/solokey/fu-solokey-device.c index 15a04852c..47c8438df 100644 --- a/plugins/solokey/fu-solokey-device.c +++ b/plugins/solokey/fu-solokey-device.c @@ -484,6 +484,7 @@ fu_solokey_device_init (FuSolokeyDevice *self) self->cid = 0xffffffff; fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_USER_REPLUG); + fu_device_set_protocol (FU_DEVICE (self), "com.solokeys"); fu_device_set_name (FU_DEVICE (self), "Solo Secure"); fu_device_set_summary (FU_DEVICE (self), "An open source FIDO2 security key"); fu_device_add_icon (FU_DEVICE (self), "applications-internet"); diff --git a/plugins/superio/fu-plugin-superio.c b/plugins/superio/fu-plugin-superio.c index 18ed82b88..b0156ae88 100644 --- a/plugins/superio/fu-plugin-superio.c +++ b/plugins/superio/fu-plugin-superio.c @@ -90,7 +90,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "tw.com.ite.superio"); } gboolean diff --git a/plugins/superio/fu-superio-device.c b/plugins/superio/fu-superio-device.c index c3179785c..348b8b95d 100644 --- a/plugins/superio/fu-superio-device.c +++ b/plugins/superio/fu-superio-device.c @@ -396,6 +396,7 @@ fu_superio_device_init (FuSuperioDevice *self) fu_device_set_physical_id (FU_DEVICE (self), "/dev/port"); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_INTERNAL); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE); + fu_device_set_protocol (FU_DEVICE (self), "tw.com.ite.superio"); fu_device_set_summary (FU_DEVICE (self), "Embedded Controller"); fu_device_add_icon (FU_DEVICE (self), "computer"); } diff --git a/plugins/synaptics-prometheus/fu-plugin-synaptics-prometheus.c b/plugins/synaptics-prometheus/fu-plugin-synaptics-prometheus.c index 4724d3438..7a6d4596c 100644 --- a/plugins/synaptics-prometheus/fu-plugin-synaptics-prometheus.c +++ b/plugins/synaptics-prometheus/fu-plugin-synaptics-prometheus.c @@ -16,7 +16,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.synaptics.prometheus"); fu_plugin_set_device_gtype (plugin, FU_TYPE_SYNAPROM_DEVICE); fu_plugin_add_firmware_gtype (plugin, "synaprom", FU_TYPE_SYNAPROM_FIRMWARE); } diff --git a/plugins/synaptics-prometheus/fu-synaprom-config.c b/plugins/synaptics-prometheus/fu-synaprom-config.c index b874f4b8c..af553c65b 100644 --- a/plugins/synaptics-prometheus/fu-synaprom-config.c +++ b/plugins/synaptics-prometheus/fu-synaprom-config.c @@ -203,6 +203,7 @@ fu_synaprom_config_write_firmware (FuDevice *device, static void fu_synaprom_config_init (FuSynapromConfig *self) { + fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.prometheus.config"); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_logical_id (FU_DEVICE (self), "cfg"); fu_device_set_name (FU_DEVICE (self), "Prometheus IOTA Config"); diff --git a/plugins/synaptics-prometheus/fu-synaprom-device.c b/plugins/synaptics-prometheus/fu-synaprom-device.c index d20d0bb73..ad1816dd8 100644 --- a/plugins/synaptics-prometheus/fu-synaprom-device.c +++ b/plugins/synaptics-prometheus/fu-synaprom-device.c @@ -436,6 +436,7 @@ fu_synaprom_device_init (FuSynapromDevice *self) { fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_CAN_VERIFY); + fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.prometheus"); fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE); fu_device_set_name (FU_DEVICE (self), "Prometheus"); fu_device_set_summary (FU_DEVICE (self), "Fingerprint reader"); diff --git a/plugins/synaptics-rmi/fu-plugin-synaptics-rmi.c b/plugins/synaptics-rmi/fu-plugin-synaptics-rmi.c index 22b0c03d6..366bcd488 100644 --- a/plugins/synaptics-rmi/fu-plugin-synaptics-rmi.c +++ b/plugins/synaptics-rmi/fu-plugin-synaptics-rmi.c @@ -16,7 +16,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.synaptics.rmi"); fu_plugin_add_udev_subsystem (plugin, "hidraw"); fu_plugin_set_device_gtype (plugin, FU_TYPE_SYNAPTICS_RMI_DEVICE); fu_plugin_add_firmware_gtype (plugin, "rmi", FU_TYPE_SYNAPTICS_RMI_FIRMWARE); diff --git a/plugins/synaptics-rmi/fu-synaptics-rmi-device.c b/plugins/synaptics-rmi/fu-synaptics-rmi-device.c index b2a53fa43..fb13197d7 100644 --- a/plugins/synaptics-rmi/fu-synaptics-rmi-device.c +++ b/plugins/synaptics-rmi/fu-synaptics-rmi-device.c @@ -993,6 +993,7 @@ static void fu_synaptics_rmi_device_init (FuSynapticsRmiDevice *self) { FuSynapticsRmiDevicePrivate *priv = GET_PRIVATE (self); + fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.rmi"); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_name (FU_DEVICE (self), "Touchpad"); fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE); diff --git a/plugins/synapticsmst/fu-plugin-synapticsmst.c b/plugins/synapticsmst/fu-plugin-synapticsmst.c index da45aed73..dd1ac2aa5 100644 --- a/plugins/synapticsmst/fu-plugin-synapticsmst.c +++ b/plugins/synapticsmst/fu-plugin-synapticsmst.c @@ -171,7 +171,6 @@ fu_plugin_init (FuPlugin *plugin) fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); fu_plugin_add_udev_subsystem (plugin, "drm"); /* used for uevent only */ fu_plugin_add_udev_subsystem (plugin, "drm_dp_aux_dev"); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.synaptics.mst"); } void diff --git a/plugins/synapticsmst/fu-synapticsmst-device.c b/plugins/synapticsmst/fu-synapticsmst-device.c index 169972bfc..15d6dd1b3 100644 --- a/plugins/synapticsmst/fu-synapticsmst-device.c +++ b/plugins/synapticsmst/fu-synapticsmst-device.c @@ -68,6 +68,7 @@ fu_synapticsmst_device_finalize (GObject *object) static void fu_synapticsmst_device_init (FuSynapticsmstDevice *self) { + fu_device_set_protocol (FU_DEVICE (self), "com.synaptics.mst"); fu_device_set_vendor (FU_DEVICE (self), "Synaptics"); fu_device_set_summary (FU_DEVICE (self), "Multi-Stream Transport Device"); fu_device_add_icon (FU_DEVICE (self), "video-display"); diff --git a/plugins/test/fu-plugin-test.c b/plugins/test/fu-plugin-test.c index 61cea7fa1..a8b935910 100644 --- a/plugins/test/fu-plugin-test.c +++ b/plugins/test/fu-plugin-test.c @@ -20,7 +20,6 @@ fu_plugin_init (FuPlugin *plugin) fu_plugin_set_build_hash (plugin, "invalid"); else fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.acme.test"); fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); g_debug ("init"); } @@ -43,6 +42,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) fu_device_add_icon (device, "preferences-desktop-keyboard"); fu_device_add_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (device, FWUPD_DEVICE_FLAG_CAN_VERIFY); + fu_device_set_protocol (device, "com.acme.test"); fu_device_set_summary (device, "A fake webcam"); fu_device_set_vendor (device, "ACME Corp."); fu_device_set_vendor_id (device, "USB:0x046D"); diff --git a/plugins/thunderbolt/fu-plugin-thunderbolt.c b/plugins/thunderbolt/fu-plugin-thunderbolt.c index bcae315a9..0b35095bc 100644 --- a/plugins/thunderbolt/fu-plugin-thunderbolt.c +++ b/plugins/thunderbolt/fu-plugin-thunderbolt.c @@ -407,6 +407,7 @@ fu_plugin_thunderbolt_add (FuPlugin *plugin, GUdevDevice *device) if (is_host) fu_device_set_summary (dev, "Unmatched performance for high-speed I/O"); fu_device_add_icon (dev, "thunderbolt"); + fu_device_set_protocol (dev, "com.intel.thunderbolt"); fu_device_set_quirks (dev, fu_plugin_get_quirks (plugin)); vendor = g_udev_device_get_sysfs_attr (device, "vendor_name"); @@ -640,7 +641,6 @@ fu_plugin_init (FuPlugin *plugin) const gchar *subsystems[] = { "thunderbolt", NULL }; fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.intel.thunderbolt"); data->udev = g_udev_client_new (subsystems); g_signal_connect (data->udev, "uevent", G_CALLBACK (udev_uevent_cb), plugin); diff --git a/plugins/uefi/fu-plugin-uefi.c b/plugins/uefi/fu-plugin-uefi.c index f91ead807..ec590423d 100644 --- a/plugins/uefi/fu-plugin-uefi.c +++ b/plugins/uefi/fu-plugin-uefi.c @@ -37,7 +37,6 @@ fu_plugin_init (FuPlugin *plugin) FuPluginData *data = fu_plugin_alloc_data (plugin, sizeof (FuPluginData)); data->bgrt = fu_uefi_bgrt_new (); fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower"); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.uefi.capsule"); fu_plugin_add_compile_version (plugin, "com.redhat.efivar", EFIVAR_LIBRARY_VERSION); fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); } diff --git a/plugins/uefi/fu-uefi-device.c b/plugins/uefi/fu-uefi-device.c index 692699aad..c444de6aa 100644 --- a/plugins/uefi/fu-uefi-device.c +++ b/plugins/uefi/fu-uefi-device.c @@ -721,6 +721,7 @@ fu_uefi_device_probe (FuDevice *device, GError **error) static void fu_uefi_device_init (FuUefiDevice *self) { + fu_device_set_protocol (FU_DEVICE (self), "org.uefi.capsule"); } static void diff --git a/plugins/vli-usbhub/fu-plugin-vli-usbhub.c b/plugins/vli-usbhub/fu-plugin-vli-usbhub.c index f5479fdd8..3944dfb2c 100644 --- a/plugins/vli-usbhub/fu-plugin-vli-usbhub.c +++ b/plugins/vli-usbhub/fu-plugin-vli-usbhub.c @@ -17,7 +17,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.vli.usbhub"); fu_plugin_set_device_gtype (plugin, FU_TYPE_VLI_USBHUB_DEVICE); fu_plugin_add_firmware_gtype (plugin, "vli-usbhub", FU_TYPE_VLI_USBHUB_FIRMWARE); fu_plugin_add_firmware_gtype (plugin, "vli-usbhub-pd", FU_TYPE_VLI_USBHUB_PD_FIRMWARE); diff --git a/plugins/vli-usbhub/fu-vli-usbhub-device.c b/plugins/vli-usbhub/fu-vli-usbhub-device.c index 78fd85728..13c7655a9 100644 --- a/plugins/vli-usbhub/fu-vli-usbhub-device.c +++ b/plugins/vli-usbhub/fu-vli-usbhub-device.c @@ -1498,6 +1498,7 @@ fu_vli_usbhub_device_init (FuVliUsbhubDevice *self) self->spi_cmd_read_id = 0x9f; self->spi_cmd_read_id_sz = 2; fu_device_add_icon (FU_DEVICE (self), "audio-card"); + fu_device_set_protocol (FU_DEVICE (self), "com.vli.usbhub"); fu_device_set_firmware_size_max (FU_DEVICE (self), 0x20000); fu_device_set_remove_delay (FU_DEVICE (self), FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE); } diff --git a/plugins/wacom-raw/fu-plugin-wacom-raw.c b/plugins/wacom-raw/fu-plugin-wacom-raw.c index 7fc381687..3aef4af16 100644 --- a/plugins/wacom-raw/fu-plugin-wacom-raw.c +++ b/plugins/wacom-raw/fu-plugin-wacom-raw.c @@ -16,7 +16,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.wacom.raw"); fu_plugin_add_udev_subsystem (plugin, "hidraw"); /* register the custom types */ diff --git a/plugins/wacom-raw/fu-wacom-device.c b/plugins/wacom-raw/fu-wacom-device.c index 82f265ef9..3092c4c0a 100644 --- a/plugins/wacom-raw/fu-wacom-device.c +++ b/plugins/wacom-raw/fu-wacom-device.c @@ -339,6 +339,7 @@ fu_wacom_device_set_quirk_kv (FuDevice *device, static void fu_wacom_device_init (FuWacomDevice *self) { + fu_device_set_protocol (FU_DEVICE (self), "com.wacom.raw"); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_INTERNAL); } diff --git a/plugins/wacom-usb/fu-plugin-wacom-usb.c b/plugins/wacom-usb/fu-plugin-wacom-usb.c index 76af9dc81..988806523 100644 --- a/plugins/wacom-usb/fu-plugin-wacom-usb.c +++ b/plugins/wacom-usb/fu-plugin-wacom-usb.c @@ -16,7 +16,6 @@ void fu_plugin_init (FuPlugin *plugin) { fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); - fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.wacom.usb"); fu_plugin_set_device_gtype (plugin, FU_TYPE_WAC_DEVICE); fu_plugin_add_firmware_gtype (plugin, "wacom", FU_TYPE_WAC_FIRMWARE); } diff --git a/plugins/wacom-usb/fu-wac-device.c b/plugins/wacom-usb/fu-wac-device.c index 7959bc83b..29ad61bfd 100644 --- a/plugins/wacom-usb/fu-wac-device.c +++ b/plugins/wacom-usb/fu-wac-device.c @@ -850,6 +850,7 @@ fu_wac_device_init (FuWacDevice *self) self->checksums = g_array_new (FALSE, FALSE, sizeof(guint32)); self->configuration = 0xffff; self->firmware_index = 0xffff; + fu_device_set_protocol (FU_DEVICE (self), "com.wacom.usb"); fu_device_add_icon (FU_DEVICE (self), "input-tablet"); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_set_install_duration (FU_DEVICE (self), 10); diff --git a/src/fu-device.c b/src/fu-device.c index ca9553470..768d054b1 100644 --- a/src/fu-device.c +++ b/src/fu-device.c @@ -36,6 +36,7 @@ typedef struct { gchar *equivalent_id; gchar *physical_id; gchar *logical_id; + gchar *protocol; FuDevice *alternate; FuDevice *parent; /* noref */ FuQuirks *quirks; @@ -65,6 +66,7 @@ enum { PROP_PROGRESS, PROP_PHYSICAL_ID, PROP_LOGICAL_ID, + PROP_PROTOCOL, PROP_QUIRKS, PROP_LAST }; @@ -91,6 +93,9 @@ fu_device_get_property (GObject *object, guint prop_id, case PROP_LOGICAL_ID: g_value_set_string (value, priv->logical_id); break; + case PROP_PROTOCOL: + g_value_set_string (value, priv->protocol); + break; case PROP_QUIRKS: g_value_set_object (value, priv->quirks); break; @@ -118,6 +123,9 @@ fu_device_set_property (GObject *object, guint prop_id, case PROP_LOGICAL_ID: fu_device_set_logical_id (self, g_value_get_string (value)); break; + case PROP_PROTOCOL: + fu_device_set_protocol (self, g_value_get_string (value)); + break; case PROP_QUIRKS: fu_device_set_quirks (self, g_value_get_object (value)); break; @@ -1411,6 +1419,42 @@ fu_device_set_logical_id (FuDevice *self, const gchar *logical_id) priv->logical_id = g_strdup (logical_id); } +/** + * fu_device_get_protocol: + * @self: A #FuDevice + * + * Gets the protocol ID on the device. + * + * Returns: a string value e.g. `org.hughski.colorhug`, or %NULL + * + * Since: 1.3.5 + **/ +const gchar * +fu_device_get_protocol (FuDevice *self) +{ + FuDevicePrivate *priv = GET_PRIVATE (self); + g_return_val_if_fail (FU_IS_DEVICE (self), NULL); + return priv->protocol; +} + +/** + * fu_device_set_protocol: + * @self: A #FuDevice + * @protocol: a defined protocol ID, e.g. `org.hughski.colorhug` + * + * Sets the protocol ID on the device. + * + * Since: 1.3.5 + **/ +void +fu_device_set_protocol (FuDevice *self, const gchar *protocol) +{ + FuDevicePrivate *priv = GET_PRIVATE (self); + g_return_if_fail (FU_IS_DEVICE (self)); + g_free (priv->protocol); + priv->protocol = g_strdup (protocol); +} + /** * fu_device_set_physical_id: * @self: A #FuDevice @@ -1729,6 +1773,8 @@ fu_device_add_string (FuDevice *self, guint idt, GString *str) fu_common_string_append_kv (str, idt + 1, "PhysicalId", priv->physical_id); if (priv->logical_id != NULL) fu_common_string_append_kv (str, idt + 1, "LogicalId", priv->logical_id); + if (priv->protocol != NULL) + fu_common_string_append_kv (str, idt + 1, "Protocol", priv->protocol); if (priv->size_min > 0) { g_autofree gchar *sz = g_strdup_printf ("%" G_GUINT64_FORMAT, priv->size_min); fu_common_string_append_kv (str, idt + 1, "FirmwareSizeMin", sz); @@ -2456,6 +2502,8 @@ fu_device_incorporate (FuDevice *self, FuDevice *donor) fu_device_set_physical_id (self, priv_donor->physical_id); if (priv->logical_id == NULL && priv_donor->logical_id != NULL) fu_device_set_logical_id (self, priv_donor->logical_id); + if (priv->protocol == NULL && priv_donor->protocol != NULL) + fu_device_set_protocol (self, priv_donor->protocol); if (priv->quirks == NULL) fu_device_set_quirks (self, fu_device_get_quirks (donor)); g_rw_lock_reader_lock (&priv_donor->parent_guids_mutex); @@ -2535,6 +2583,11 @@ fu_device_class_init (FuDeviceClass *klass) G_PARAM_STATIC_NAME); g_object_class_install_property (object_class, PROP_LOGICAL_ID, pspec); + pspec = g_param_spec_string ("protocol", NULL, NULL, NULL, + G_PARAM_READWRITE | + G_PARAM_STATIC_NAME); + g_object_class_install_property (object_class, PROP_PROTOCOL, pspec); + pspec = g_param_spec_uint ("progress", NULL, NULL, 0, 100, 0, G_PARAM_READWRITE | @@ -2586,6 +2639,7 @@ fu_device_finalize (GObject *object) g_free (priv->equivalent_id); g_free (priv->physical_id); g_free (priv->logical_id); + g_free (priv->protocol); G_OBJECT_CLASS (fu_device_parent_class)->finalize (object); } diff --git a/src/fu-device.h b/src/fu-device.h index 475a8c913..7cd710090 100644 --- a/src/fu-device.h +++ b/src/fu-device.h @@ -186,6 +186,9 @@ void fu_device_set_physical_id (FuDevice *self, const gchar *fu_device_get_logical_id (FuDevice *self); void fu_device_set_logical_id (FuDevice *self, const gchar *logical_id); +const gchar *fu_device_get_protocol (FuDevice *self); +void fu_device_set_protocol (FuDevice *self, + const gchar *protocol); void fu_device_add_flag (FuDevice *self, FwupdDeviceFlags flag); const gchar *fu_device_get_custom_flags (FuDevice *self); diff --git a/src/fu-plugin.h b/src/fu-plugin.h index ed52200d3..52bf44c9a 100644 --- a/src/fu-plugin.h +++ b/src/fu-plugin.h @@ -71,7 +71,6 @@ typedef enum { * @FU_PLUGIN_RULE_RUN_BEFORE: Order the plugin before another * @FU_PLUGIN_RULE_BETTER_THAN: Is better than another plugin * @FU_PLUGIN_RULE_INHIBITS_IDLE: The plugin inhibits the idle shutdown - * @FU_PLUGIN_RULE_SUPPORTS_PROTOCOL: The plugin supports a well known protocol * * The rules used for ordering plugins. * Plugins are expected to add rules in fu_plugin_initialize(). @@ -82,7 +81,6 @@ typedef enum { FU_PLUGIN_RULE_RUN_BEFORE, FU_PLUGIN_RULE_BETTER_THAN, FU_PLUGIN_RULE_INHIBITS_IDLE, - FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, /*< private >*/ FU_PLUGIN_RULE_LAST } FuPluginRule; From 52e15b8fb39c1fbfe94cbef00973ba25ca71482a Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 25 Nov 2019 17:42:32 +0000 Subject: [PATCH 30/74] =?UTF-8?q?vli-usbhub:=20Whitelist=20the=20PD=20and?= =?UTF-8?q?=20I=C2=B2C=20devices?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On advice from VIA. --- plugins/vli-usbhub/fu-vli-usbhub-device.c | 14 +++++---- plugins/vli-usbhub/vli-usbhub-lenovo.quirk | 34 +++++++++++++--------- plugins/vli-usbhub/vli-usbhub.quirk | 4 +-- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/plugins/vli-usbhub/fu-vli-usbhub-device.c b/plugins/vli-usbhub/fu-vli-usbhub-device.c index 13c7655a9..e5bdffd7d 100644 --- a/plugins/vli-usbhub/fu-vli-usbhub-device.c +++ b/plugins/vli-usbhub/fu-vli-usbhub-device.c @@ -964,12 +964,16 @@ fu_vli_usbhub_device_setup (FuDevice *device, GError **error) } /* detect the PD child */ - if (!fu_vli_usbhub_device_pd_setup (self, error)) - return FALSE; + if (fu_device_has_custom_flag (device, "has-shared-spi-pd")) { + if (!fu_vli_usbhub_device_pd_setup (self, error)) + return FALSE; + } - /* detect the PD child */ - if (!fu_vli_usbhub_device_i2c_setup (self, error)) - return FALSE; + /* detect the I²C child */ + if (fu_device_has_custom_flag (device, "has-shared-spi-i2c")) { + if (!fu_vli_usbhub_device_i2c_setup (self, error)) + return FALSE; + } /* success */ return TRUE; diff --git a/plugins/vli-usbhub/vli-usbhub-lenovo.quirk b/plugins/vli-usbhub/vli-usbhub-lenovo.quirk index b43cc9856..c20c1ed7d 100644 --- a/plugins/vli-usbhub/vli-usbhub-lenovo.quirk +++ b/plugins/vli-usbhub/vli-usbhub-lenovo.quirk @@ -17,10 +17,10 @@ Flags = usb2 # Lenovo TR Dock [DeviceInstanceId=USB\VID_17EF&PID_307F] Plugin = vli_usbhub -Flags = usb3 +Flags = usb3,has-shared-spi-i2c [DeviceInstanceId=USB\VID_17EF&PID_3080] Plugin = vli_usbhub -Flags = usb2 +Flags = usb2,has-shared-spi-i2c # Lenovo CS13 KG Dock [DeviceInstanceId=USB\VID_17EF&PID_1010] @@ -109,20 +109,20 @@ Flags = usb2 # Lenovo Travel hub Gen2 [DeviceInstanceId=USB\VID_17EF&PID_721D] Plugin = vli_usbhub -Flags = usb3 +Flags = usb3,has-shared-spi-pd [DeviceInstanceId=USB\VID_17EF&PID_7225] Plugin = vli_usbhub -Flags = usb2 +Flags = usb2,has-shared-spi-pd -# Lenovo Mini dock -[DeviceInstanceId=USB\VID_17EF&PID_3074] +# Lenovo USB-C Mini dock +[DeviceInstanceId=USB\VID_17EF&PID_3094] Plugin = vli_usbhub -Flags = usb3 +Flags = usb3,has-shared-spi-pd [DeviceInstanceId=USB\VID_17EF&PID_3095] Plugin = vli_usbhub -Flags = usb2 +Flags = usb2,has-shared-spi-pd -# Lenovo Lenovo Travel Hub 1in3 +# Lenovo Travel Hub 1in3 [DeviceInstanceId=USB\VID_17EF&PID_7228] Plugin = vli_usbhub Flags = usb3 @@ -130,15 +130,23 @@ Flags = usb3 Plugin = vli_usbhub Flags = usb2 -# Lenovo Lenovo 1转7 Hub +# Lenovo USB-C 7-in-1 Hub [DeviceInstanceId=USB\VID_17EF&PID_722A] Plugin = vli_usbhub -Flags = usb3 +Flags = usb3,has-shared-spi-pd [DeviceInstanceId=USB\VID_17EF&PID_7229] Plugin = vli_usbhub -Flags = usb2 +Flags = usb2,has-shared-spi-pd -# Lenovo Lenovo Gen2 dock +# Lenovo USB-C to 4 USB-A Hub +[DeviceInstanceId=USB\VID_17EF&PID_1039] +Plugin = vli_usbhub +Flags = usb3,has-shared-spi-pd +[DeviceInstanceId=USB\VID_17EF&PID_103A] +Plugin = vli_usbhub +Flags = usb2,has-shared-spi-pd + +# Lenovo Gen2 dock [DeviceInstanceId=USB\VID_17EF&PID_A391] Plugin = vli_usbhub Flags = tier1,usb3 diff --git a/plugins/vli-usbhub/vli-usbhub.quirk b/plugins/vli-usbhub/vli-usbhub.quirk index 39701ac3c..0742d4b06 100644 --- a/plugins/vli-usbhub/vli-usbhub.quirk +++ b/plugins/vli-usbhub/vli-usbhub.quirk @@ -38,10 +38,10 @@ Flags = usb2 # VL820 [DeviceInstanceId=USB\VID_2109&PID_0820] Plugin = vli_usbhub -Flags = usb3 +Flags = usb3,has-shared-spi-pd [DeviceInstanceId=USB\VID_2109&PID_2820] Plugin = vli_usbhub -Flags = usb2 +Flags = usb2,has-shared-spi-pd # A25Lxxx [Guid=VLI_USBHUB\\SPI_3730] From 23c6359d13b5ed8202484f22afa14d7cd80e0fed Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 25 Nov 2019 13:42:03 +0000 Subject: [PATCH 31/74] Allow plugins to set the parent during construction --- src/fu-device.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/fu-device.c b/src/fu-device.c index 768d054b1..bf88ca610 100644 --- a/src/fu-device.c +++ b/src/fu-device.c @@ -68,6 +68,7 @@ enum { PROP_LOGICAL_ID, PROP_PROTOCOL, PROP_QUIRKS, + PROP_PARENT, PROP_LAST }; @@ -99,6 +100,9 @@ fu_device_get_property (GObject *object, guint prop_id, case PROP_QUIRKS: g_value_set_object (value, priv->quirks); break; + case PROP_PARENT: + g_value_set_object (value, priv->parent); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -110,6 +114,7 @@ fu_device_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { FuDevice *self = FU_DEVICE (object); + FuDevicePrivate *priv = GET_PRIVATE (self); switch (prop_id) { case PROP_STATUS: fu_device_set_status (self, g_value_get_uint (value)); @@ -129,6 +134,10 @@ fu_device_set_property (GObject *object, guint prop_id, case PROP_QUIRKS: fu_device_set_quirks (self, g_value_get_object (value)); break; + case PROP_PARENT: + /* noref */ + priv->parent = g_value_get_object (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2599,6 +2608,13 @@ fu_device_class_init (FuDeviceClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_NAME); g_object_class_install_property (object_class, PROP_QUIRKS, pspec); + + pspec = g_param_spec_object ("parent", NULL, NULL, + FU_TYPE_DEVICE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_NAME); + g_object_class_install_property (object_class, PROP_PARENT, pspec); } static void From 0df243ad44b6add849f36c43b5194cd696440073 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 25 Nov 2019 13:42:49 +0000 Subject: [PATCH 32/74] synaptics-prometheus: Set the composite parent at construction time --- .../synaptics-prometheus/fu-synaprom-config.c | 88 ++++--------------- 1 file changed, 17 insertions(+), 71 deletions(-) diff --git a/plugins/synaptics-prometheus/fu-synaprom-config.c b/plugins/synaptics-prometheus/fu-synaprom-config.c index af553c65b..ad3d6ef97 100644 --- a/plugins/synaptics-prometheus/fu-synaprom-config.c +++ b/plugins/synaptics-prometheus/fu-synaprom-config.c @@ -15,7 +15,6 @@ struct _FuSynapromConfig { FuDevice parent_instance; - FuSynapromDevice *device; guint32 configid1; /* config ID1 */ guint32 configid2; /* config ID2 */ }; @@ -57,15 +56,10 @@ typedef struct __attribute__((packed)) { G_DEFINE_TYPE (FuSynapromConfig, fu_synaprom_config, FU_TYPE_DEVICE) -enum { - PROP_0, - PROP_DEVICE, - PROP_LAST -}; - static gboolean fu_synaprom_config_setup (FuDevice *device, GError **error) { + FuDevice *parent = fu_device_get_parent (device); FuSynapromConfig *self = FU_SYNAPROM_CONFIG (device); FuSynapromCmdIotaFind cmd = { 0x0 }; FuSynapromIotaConfigVersion cfg; @@ -79,7 +73,8 @@ fu_synaprom_config_setup (FuDevice *device, GError **error) cmd.flags = GUINT16_TO_LE((guint16)FU_SYNAPROM_CMD_IOTA_FIND_FLAGS_READMAX); request = fu_synaprom_request_new (FU_SYNAPROM_CMD_IOTA_FIND, &cmd, sizeof(cmd)); reply = fu_synaprom_reply_new (sizeof(FuSynapromReplyIotaFindHdr) + FU_SYNAPROM_MAX_IOTA_READ_SIZE); - if (!fu_synaprom_device_cmd_send (self->device, request, reply, 5000, error)) + if (!fu_synaprom_device_cmd_send (FU_SYNAPROM_DEVICE (parent), + request, reply, 5000, error)) return FALSE; if (reply->len < sizeof(hdr) + sizeof(cfg)) { g_set_error (error, @@ -188,7 +183,7 @@ fu_synaprom_config_write_firmware (FuDevice *device, FwupdInstallFlags flags, GError **error) { - FuSynapromConfig *self = FU_SYNAPROM_CONFIG (device); + FuDevice *parent = fu_device_get_parent (device); g_autoptr(GBytes) fw = NULL; /* get default image */ @@ -197,7 +192,7 @@ fu_synaprom_config_write_firmware (FuDevice *device, return FALSE; /* I assume the CFG/MFW difference is detected in the device...*/ - return fu_synaprom_device_write_fw (self->device, fw, error); + return fu_synaprom_device_write_fw (FU_SYNAPROM_DEVICE (parent), fw, error); } static void @@ -209,85 +204,48 @@ fu_synaprom_config_init (FuSynapromConfig *self) fu_device_set_name (FU_DEVICE (self), "Prometheus IOTA Config"); } -static void -fu_synaprom_config_finalize (GObject *obj) -{ - FuSynapromConfig *self = FU_SYNAPROM_CONFIG (obj); - g_object_unref (self->device); - G_OBJECT_CLASS (fu_synaprom_config_parent_class)->finalize (obj); -} - static void fu_synaprom_config_constructed (GObject *obj) { FuSynapromConfig *self = FU_SYNAPROM_CONFIG (obj); + FuDevice *parent = fu_device_get_parent (FU_DEVICE (self)); g_autofree gchar *devid = NULL; /* append the firmware kind to the generated GUID */ devid = g_strdup_printf ("USB\\VID_%04X&PID_%04X-cfg", - fu_usb_device_get_vid (FU_USB_DEVICE (self->device)), - fu_usb_device_get_pid (FU_USB_DEVICE (self->device))); + fu_usb_device_get_vid (FU_USB_DEVICE (parent)), + fu_usb_device_get_pid (FU_USB_DEVICE (parent))); fu_device_add_instance_id (FU_DEVICE (self), devid); G_OBJECT_CLASS (fu_synaprom_config_parent_class)->constructed (obj); } -static void -fu_synaprom_config_get_property (GObject *obj, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - FuSynapromConfig *self = FU_SYNAPROM_CONFIG (obj); - switch (prop_id) { - case PROP_DEVICE: - g_value_set_object (value, self->device); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); - break; - } -} - -static void -fu_synaprom_config_set_property (GObject *obj, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - FuSynapromConfig *self = FU_SYNAPROM_CONFIG (obj); - switch (prop_id) { - case PROP_DEVICE: - g_set_object (&self->device, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); - break; - } -} - static gboolean fu_synaprom_config_open (FuDevice *device, GError **error) { - FuSynapromConfig *self = FU_SYNAPROM_CONFIG (device); - return fu_device_open (FU_DEVICE (self->device), error); + FuDevice *parent = fu_device_get_parent (device); + return fu_device_open (parent, error); } static gboolean fu_synaprom_config_close (FuDevice *device, GError **error) { - FuSynapromConfig *self = FU_SYNAPROM_CONFIG (device); - return fu_device_close (FU_DEVICE (self->device), error); + FuDevice *parent = fu_device_get_parent (device); + return fu_device_close (parent, error); } static gboolean fu_synaprom_config_attach (FuDevice *device, GError **error) { - FuSynapromConfig *self = FU_SYNAPROM_CONFIG (device); - return fu_device_attach (FU_DEVICE (self->device), error); + FuDevice *parent = fu_device_get_parent (device); + return fu_device_attach (parent, error); } static gboolean fu_synaprom_config_detach (FuDevice *device, GError **error) { - FuSynapromConfig *self = FU_SYNAPROM_CONFIG (device); - return fu_device_detach (FU_DEVICE (self->device), error); + FuDevice *parent = fu_device_get_parent (device); + return fu_device_detach (parent, error); } static void @@ -295,12 +253,7 @@ fu_synaprom_config_class_init (FuSynapromConfigClass *klass) { FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass); - GParamSpec *pspec; - object_class->constructed = fu_synaprom_config_constructed; - object_class->finalize = fu_synaprom_config_finalize; - object_class->get_property = fu_synaprom_config_get_property; - object_class->set_property = fu_synaprom_config_set_property; klass_device->write_firmware = fu_synaprom_config_write_firmware; klass_device->prepare_firmware = fu_synaprom_config_prepare_firmware; klass_device->open = fu_synaprom_config_open; @@ -308,13 +261,6 @@ fu_synaprom_config_class_init (FuSynapromConfigClass *klass) klass_device->setup = fu_synaprom_config_setup; klass_device->attach = fu_synaprom_config_attach; klass_device->detach = fu_synaprom_config_detach; - - pspec = g_param_spec_object ("device", NULL, NULL, - FU_TYPE_SYNAPROM_DEVICE, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | - G_PARAM_STATIC_NAME); - g_object_class_install_property (object_class, PROP_DEVICE, pspec); } FuSynapromConfig * @@ -322,7 +268,7 @@ fu_synaprom_config_new (FuSynapromDevice *device) { FuSynapromConfig *self; self = g_object_new (FU_TYPE_SYNAPROM_CONFIG, - "device", device, + "parent", device, NULL); return FU_SYNAPROM_CONFIG (self); } From 741e1e5323a401729e9c1cc622ed988c711823e2 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 25 Nov 2019 13:43:14 +0000 Subject: [PATCH 33/74] vli_usbhub: Set the composite parent at construction time --- plugins/vli-usbhub/fu-vli-usbhub-i2c-device.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/plugins/vli-usbhub/fu-vli-usbhub-i2c-device.c b/plugins/vli-usbhub/fu-vli-usbhub-i2c-device.c index a7a89b006..59a10c2ca 100644 --- a/plugins/vli-usbhub/fu-vli-usbhub-i2c-device.c +++ b/plugins/vli-usbhub/fu-vli-usbhub-i2c-device.c @@ -18,7 +18,6 @@ struct _FuVliUsbhubI2cDevice { FuDevice parent_instance; - FuVliUsbhubDevice *parent; FuVliUsbhubI2cChip chip; }; @@ -36,10 +35,10 @@ static gboolean fu_vli_usbhub_i2c_device_setup (FuDevice *device, GError **error) { FuVliUsbhubI2cDevice *self = FU_VLI_USBHUB_I2C_DEVICE (device); + FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE (fu_device_get_parent (device)); guint8 buf[11] = { 0x0 }; g_autofree gchar *instance_id = NULL; g_autofree gchar *version = NULL; - g_autoptr(FuVliUsbhubDevice) parent = g_steal_pointer (&self->parent); /* get versions */ if (!fu_vli_usbhub_device_i2c_read (parent, @@ -254,20 +253,10 @@ fu_vli_usbhub_i2c_device_init (FuVliUsbhubI2cDevice *self) fu_device_set_summary (FU_DEVICE (self), "I²C Dock Management Device"); } -static void -fu_vli_usbhub_i2c_device_finalize (GObject *object) -{ - FuVliUsbhubI2cDevice *self = FU_VLI_USBHUB_I2C_DEVICE (object); - g_clear_object (&self->parent); - G_OBJECT_CLASS (fu_vli_usbhub_i2c_device_parent_class)->finalize (object); -} - static void fu_vli_usbhub_i2c_device_class_init (FuVliUsbhubI2cDeviceClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); FuDeviceClass *klass_device = FU_DEVICE_CLASS (klass); - object_class->finalize = fu_vli_usbhub_i2c_device_finalize; klass_device->to_string = fu_vli_usbhub_i2c_device_to_string; klass_device->probe = fu_vli_usbhub_i2c_device_probe; klass_device->setup = fu_vli_usbhub_i2c_device_setup; @@ -279,7 +268,8 @@ fu_vli_usbhub_i2c_device_class_init (FuVliUsbhubI2cDeviceClass *klass) FuDevice * fu_vli_usbhub_i2c_device_new (FuVliUsbhubDevice *parent) { - FuVliUsbhubI2cDevice *self = g_object_new (FU_TYPE_VLI_USBHUB_I2C_DEVICE, NULL); - self->parent = g_object_ref (parent); + FuVliUsbhubI2cDevice *self = g_object_new (FU_TYPE_VLI_USBHUB_I2C_DEVICE, + "parent", parent, + NULL); return FU_DEVICE (self); } From be956bdb6661a5d559a40dab45a5424b42ce3b3e Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 25 Nov 2019 20:41:00 +0000 Subject: [PATCH 34/74] Allow setting the device flags using GObject properties --- libfwupd/fwupd-device.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libfwupd/fwupd-device.c b/libfwupd/fwupd-device.c index 33c4e9e0e..d735b9dd4 100644 --- a/libfwupd/fwupd-device.c +++ b/libfwupd/fwupd-device.c @@ -61,6 +61,7 @@ typedef struct { enum { PROP_0, PROP_VERSION_FORMAT, + PROP_FLAGS, PROP_LAST }; @@ -875,7 +876,10 @@ fwupd_device_set_flags (FwupdDevice *device, guint64 flags) { FwupdDevicePrivate *priv = GET_PRIVATE (device); g_return_if_fail (FWUPD_IS_DEVICE (device)); + if (priv->flags == flags) + return; priv->flags = flags; + g_object_notify (G_OBJECT (device), "flags"); } /** @@ -892,7 +896,12 @@ fwupd_device_add_flag (FwupdDevice *device, FwupdDeviceFlags flag) { FwupdDevicePrivate *priv = GET_PRIVATE (device); g_return_if_fail (FWUPD_IS_DEVICE (device)); + if (flag == 0) + return; + if ((priv->flags & flag) > 0) + return; priv->flags |= flag; + g_object_notify (G_OBJECT (device), "flags"); } /** @@ -909,7 +918,12 @@ fwupd_device_remove_flag (FwupdDevice *device, FwupdDeviceFlags flag) { FwupdDevicePrivate *priv = GET_PRIVATE (device); g_return_if_fail (FWUPD_IS_DEVICE (device)); + if (flag == 0) + return; + if ((priv->flags & flag) == 0) + return; priv->flags &= ~flag; + g_object_notify (G_OBJECT (device), "flags"); } /** @@ -1880,6 +1894,9 @@ fwupd_device_get_property (GObject *object, guint prop_id, case PROP_VERSION_FORMAT: g_value_set_uint (value, priv->version_format); break; + case PROP_FLAGS: + g_value_set_uint64 (value, priv->flags); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1895,6 +1912,9 @@ fwupd_device_set_property (GObject *object, guint prop_id, case PROP_VERSION_FORMAT: fwupd_device_set_version_format (self, g_value_get_uint (value)); break; + case PROP_FLAGS: + fwupd_device_set_flags (self, g_value_get_uint64 (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1918,6 +1938,14 @@ fwupd_device_class_init (FwupdDeviceClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_NAME); g_object_class_install_property (object_class, PROP_VERSION_FORMAT, pspec); + + pspec = g_param_spec_uint64 ("flags", NULL, NULL, + FWUPD_DEVICE_FLAG_NONE, + FWUPD_DEVICE_FLAG_UNKNOWN, + FWUPD_DEVICE_FLAG_NONE, + G_PARAM_READWRITE | + G_PARAM_STATIC_NAME); + g_object_class_install_property (object_class, PROP_FLAGS, pspec); } static void From cb59a44f286cd21ef0f7f1a85d82538c111d7967 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 25 Nov 2019 20:42:08 +0000 Subject: [PATCH 35/74] synaptics-prometheus: Mirror the _IS_BOOTLOADER from device to config --- .../synaptics-prometheus/fu-synaprom-config.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/synaptics-prometheus/fu-synaprom-config.c b/plugins/synaptics-prometheus/fu-synaprom-config.c index ad3d6ef97..3a4c7c278 100644 --- a/plugins/synaptics-prometheus/fu-synaprom-config.c +++ b/plugins/synaptics-prometheus/fu-synaprom-config.c @@ -248,6 +248,18 @@ fu_synaprom_config_detach (FuDevice *device, GError **error) return fu_device_detach (parent, error); } +static void +fu_synaprom_config_flags_notify_cb (FuDevice *parent, GParamSpec *pspec, FuDevice *device) +{ + if (fu_device_has_flag (parent, FWUPD_DEVICE_FLAG_IS_BOOTLOADER)) { + g_debug ("parent set IS_BOOTLOADER, mirroring to child"); + fu_device_add_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER); + } else { + g_debug ("parent unset IS_BOOTLOADER, mirroring to child"); + fu_device_remove_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER); + } +} + static void fu_synaprom_config_class_init (FuSynapromConfigClass *klass) { @@ -270,5 +282,11 @@ fu_synaprom_config_new (FuSynapromDevice *device) self = g_object_new (FU_TYPE_SYNAPROM_CONFIG, "parent", device, NULL); + + /* mirror the bootloader flag on the parent to the child */ + if (fu_device_has_flag (FU_DEVICE (device), FWUPD_DEVICE_FLAG_IS_BOOTLOADER)) + fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER); + g_signal_connect (device, "notify::flags", + G_CALLBACK (fu_synaprom_config_flags_notify_cb), self); return FU_SYNAPROM_CONFIG (self); } From 0bf1c330aac9dba1c80c75734beb9d59248a4e27 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 25 Nov 2019 13:53:30 -0600 Subject: [PATCH 36/74] trivial: fix compile failure without gudev --- src/fu-udev-device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fu-udev-device.c b/src/fu-udev-device.c index bac4e9846..558d83246 100644 --- a/src/fu-udev-device.c +++ b/src/fu-udev-device.c @@ -118,6 +118,7 @@ fu_udev_device_get_sysfs_attr_as_uint8 (GUdevDevice *udev_device, const gchar *n static void fu_udev_device_to_string (FuDevice *device, guint idt, GString *str) { +#ifdef HAVE_GUDEV FuUdevDevice *self = FU_UDEV_DEVICE (device); FuUdevDevicePrivate *priv = GET_PRIVATE (self); const gchar * const *keys; @@ -140,6 +141,7 @@ fu_udev_device_to_string (FuDevice *device, guint idt, GString *str) g_udev_device_get_sysfs_attr (priv->udev_device, keys[i])); } +#endif } static gboolean From 1a680f3b189eeb62cb34041bb1f33feaa38bc32d Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 25 Nov 2019 19:44:53 -0600 Subject: [PATCH 37/74] trivial: add missing gtk-doc fields for many files in src/ --- src/fu-archive.c | 8 +- src/fu-chunk.c | 32 ++- src/fu-common-cab.c | 2 + src/fu-common-version.c | 12 ++ src/fu-common.c | 140 ++++++++++++- src/fu-device-locker.c | 4 + src/fu-device.c | 81 ++++++- src/fu-dfu-firmware.c | 36 +++- src/fu-firmware-common.c | 10 + src/fu-firmware-image.c | 1 - src/fu-firmware.c | 11 +- src/fu-firmware.h | 2 +- src/fu-history.c | 127 ++++++++++- src/fu-hwids.c | 21 ++ src/fu-ihex-firmware.c | 16 ++ src/fu-io-channel.c | 4 + src/fu-plugin.c | 441 ++++++++++++++++++++++++++++++++++++++- src/fu-plugin.h | 2 +- src/fu-progressbar.c | 53 +++++ src/fu-quirks.c | 9 +- src/fu-smbios.c | 16 +- src/fu-srec-firmware.c | 28 +++ src/fu-test.c | 38 ++++ src/fu-udev-device.c | 11 + 24 files changed, 1068 insertions(+), 37 deletions(-) diff --git a/src/fu-archive.c b/src/fu-archive.c index 605344da0..14781d74d 100644 --- a/src/fu-archive.c +++ b/src/fu-archive.c @@ -59,6 +59,8 @@ fu_archive_init (FuArchive *self) * Finds the blob referenced by filename * * Returns: (transfer none): a #GBytes, or %NULL if the filename was not found + * + * Since: 1.2.2 **/ GBytes * fu_archive_lookup_by_fn (FuArchive *self, const gchar *fn, GError **error) @@ -82,7 +84,7 @@ fu_archive_lookup_by_fn (FuArchive *self, const gchar *fn, GError **error) /** * fu_archive_iterate: * @self: A #FuArchive - * @callback: A #FuArchiveIterateFunc. + * @callback: (scope call): A #FuArchiveIterateFunc. * @user_data: User data. * @error: A #GError, or %NULL * @@ -90,6 +92,8 @@ fu_archive_lookup_by_fn (FuArchive *self, const gchar *fn, GError **error) * of the files found. If any @callback returns %FALSE scanning is aborted. * * Returns: True if no @callback returned FALSE + * + * Since: 1.3.4 */ gboolean fu_archive_iterate (FuArchive *self, @@ -225,6 +229,8 @@ fu_archive_load (FuArchive *self, GBytes *blob, FuArchiveFlags flags, GError **e * Parses @data as an archive and decompresses all files to memory blobs. * * Returns: a #FuArchive, or %NULL if the archive was invalid in any way. + * + * Since: 1.2.2 **/ FuArchive * fu_archive_new (GBytes *data, FuArchiveFlags flags, GError **error) diff --git a/src/fu-chunk.c b/src/fu-chunk.c index 5b7dc91e8..ebc453ba0 100644 --- a/src/fu-chunk.c +++ b/src/fu-chunk.c @@ -12,6 +12,14 @@ #include "fu-chunk.h" +/** + * SECTION:fu-chunk + * @short_description: A packet of chunked data + * + * An object that represents a packet of data. + * + */ + /** * fu_chunk_new: * @idx: the packet number @@ -23,6 +31,8 @@ * Creates a new packet of chunked data. * * Return value: (transfer full): a #FuChunk + * + * Since: 1.1.2 **/ FuChunk * fu_chunk_new (guint32 idx, @@ -47,6 +57,8 @@ fu_chunk_new (guint32 idx, * Converts the chunked packet to a string representation. * * Return value: (transfer full): A string + * + * Since: 1.1.2 **/ gchar * fu_chunk_to_string (FuChunk *item) @@ -76,6 +88,8 @@ fu_chunk_to_string (FuChunk *item) * Converts all the chunked packets in an array to a string representation. * * Return value: (transfer full): A string + * + * Since: 1.0.1 **/ gchar * fu_chunk_array_to_string (GPtrArray *chunks) @@ -101,13 +115,15 @@ fu_chunk_array_to_string (GPtrArray *chunks) * cross a package boundary and is less that a specific transfer size. * * Return value: (element-type FuChunk): array of packets + * + * Since: 1.1.2 **/ GPtrArray * fu_chunk_array_new (const guint8 *data, - guint32 data_sz, - guint32 addr_start, - guint32 page_sz, - guint32 packet_sz) + guint32 data_sz, + guint32 addr_start, + guint32 page_sz, + guint32 packet_sz) { GPtrArray *segments = NULL; guint32 page_old = G_MAXUINT32; @@ -182,12 +198,14 @@ fu_chunk_array_new (const guint8 *data, * cross a package boundary and is less that a specific transfer size. * * Return value: (element-type FuChunk): array of packets + * + * Since: 1.1.2 **/ GPtrArray * fu_chunk_array_new_from_bytes (GBytes *blob, - guint32 addr_start, - guint32 page_sz, - guint32 packet_sz) + guint32 addr_start, + guint32 page_sz, + guint32 packet_sz) { gsize sz; const guint8 *data = g_bytes_get_data (blob, &sz); diff --git a/src/fu-common-cab.c b/src/fu-common-cab.c index a8cc0099a..8fda335f0 100644 --- a/src/fu-common-cab.c +++ b/src/fu-common-cab.c @@ -383,6 +383,8 @@ fu_common_cab_set_container_checksum_cb (XbBuilderFixup *self, * Create an AppStream silo from a cabinet archive. * * Returns: a #XbSilo, or %NULL on error + * + * Since: 1.2.0 **/ XbSilo * fu_common_cab_build_silo (GBytes *blob, guint64 size_max, GError **error) diff --git a/src/fu-common-version.c b/src/fu-common-version.c index be4422156..e454e3067 100644 --- a/src/fu-common-version.c +++ b/src/fu-common-version.c @@ -355,6 +355,18 @@ fu_common_version_convert_base (FwupdVersionFormat fmt) return fmt; } +/** + * fu_common_version_verify_format: + * @version: A string, e.g. "0x1234" + * @fmt: a #FwupdVersionFormat + * @error: A #GError or %NULL + * + * Verifies if a version matches the input format. + * + * Returns: TRUE or FALSE + * + * Since: 1.2.9 + **/ gboolean fu_common_version_verify_format (const gchar *version, FwupdVersionFormat fmt, diff --git a/src/fu-common.c b/src/fu-common.c index 99a5035be..fb4b93a4c 100644 --- a/src/fu-common.c +++ b/src/fu-common.c @@ -39,6 +39,8 @@ * Recursively removes a directory. * * Returns: %TRUE for success, %FALSE otherwise + * + * Since: 0.9.7 **/ gboolean fu_common_rmtree (const gchar *directory, GError **error) @@ -113,7 +115,9 @@ fu_common_get_file_list_internal (GPtrArray *files, const gchar *directory, GErr * If any path under @directory cannot be accessed due to permissions an error * will be returned. * - * Returns: (element-type: utf8) (transfer container): array of files, or %NULL for error + * Returns: (transfer container): array of files, or %NULL for error + * + * Since: 1.0.6 **/ GPtrArray * fu_common_get_files_recursive (const gchar *path, GError **error) @@ -131,6 +135,8 @@ fu_common_get_files_recursive (const gchar *path, GError **error) * Creates any required directories, including any parent directories. * * Returns: %TRUE for success + * + * Since: 0.9.7 **/ gboolean fu_common_mkdir_parent (const gchar *filename, GError **error) @@ -160,6 +166,8 @@ fu_common_mkdir_parent (const gchar *filename, GError **error) * required. * * Returns: %TRUE for success + * + * Since: 0.9.5 **/ gboolean fu_common_set_contents_bytes (const gchar *filename, GBytes *bytes, GError **error) @@ -188,6 +196,8 @@ fu_common_set_contents_bytes (const gchar *filename, GBytes *bytes, GError **err * Reads a blob of data from a file. * * Returns: a #GBytes, or %NULL for failure + * + * Since: 0.9.7 **/ GBytes * fu_common_get_contents_bytes (const gchar *filename, GError **error) @@ -211,6 +221,8 @@ fu_common_get_contents_bytes (const gchar *filename, GError **error) * Note: this will close the fd when done * * Returns: (transfer full): a #GBytes, or %NULL + * + * Since: 0.9.5 **/ GBytes * fu_common_get_contents_fd (gint fd, gsize count, GError **error) @@ -270,6 +282,8 @@ fu_common_extract_archive_entry (struct archive_entry *entry, const gchar *dir) * Extracts an achive to a directory. * * Returns: %TRUE for success + * + * Since: 0.9.7 **/ gboolean fu_common_extract_archive (GBytes *blob, const gchar *dir, GError **error) @@ -353,6 +367,17 @@ fu_common_add_argv (GPtrArray *argv, const gchar *fmt, ...) g_ptr_array_add (argv, g_strdup (split[i])); } +/** + * fu_common_find_program_in_path: + * @basename: The program to search + * @error: A #GError, or %NULL + * + * Looks for a program in the PATH variable + * + * Returns: a new #gchar, or %NULL for error + * + * Since: 1.1.2 + **/ gchar * fu_common_find_program_in_path (const gchar *basename, GError **error) { @@ -411,6 +436,8 @@ fu_common_test_namespace_support (GError **error) * 5. The temporary location is deleted * * Returns: a new #GBytes, or %NULL for error + * + * Since: 0.9.7 **/ GBytes * fu_common_firmware_builder (GBytes *bytes, @@ -631,6 +658,8 @@ fu_common_spawn_cancelled_cb (GCancellable *cancellable, FuCommonSpawnHelper *he * standard error will be forwarded to @handler_cb as whole lines. * * Returns: %TRUE for success + * + * Since: 0.9.7 **/ gboolean fu_common_spawn_sync (const gchar * const * argv, @@ -688,6 +717,8 @@ fu_common_spawn_sync (const gchar * const * argv, * @endian: A #FuEndianType, e.g. %G_LITTLE_ENDIAN * * Writes a value to a buffer using a specified endian. + * + * Since: 1.0.3 **/ void fu_common_write_uint16 (guint8 *buf, guint16 val_native, FuEndianType endian) @@ -713,6 +744,8 @@ fu_common_write_uint16 (guint8 *buf, guint16 val_native, FuEndianType endian) * @endian: A #FuEndianType, e.g. %G_LITTLE_ENDIAN * * Writes a value to a buffer using a specified endian. + * + * Since: 1.0.3 **/ void fu_common_write_uint32 (guint8 *buf, guint32 val_native, FuEndianType endian) @@ -739,6 +772,8 @@ fu_common_write_uint32 (guint8 *buf, guint32 val_native, FuEndianType endian) * Read a value from a buffer using a specified endian. * * Returns: a value in host byte-order + * + * Since: 1.0.3 **/ guint16 fu_common_read_uint16 (const guint8 *buf, FuEndianType endian) @@ -766,6 +801,8 @@ fu_common_read_uint16 (const guint8 *buf, FuEndianType endian) * Read a value from a buffer using a specified endian. * * Returns: a value in host byte-order + * + * Since: 1.0.3 **/ guint32 fu_common_read_uint32 (const guint8 *buf, FuEndianType endian) @@ -793,6 +830,8 @@ fu_common_read_uint32 (const guint8 *buf, FuEndianType endian) * prefixed with "0x" where they are parsed as base 16. * * Returns: integer value, or 0x0 for error + * + * Since: 1.1.2 **/ guint64 fu_common_strtoull (const gchar *str) @@ -814,6 +853,8 @@ fu_common_strtoull (const gchar *str) * Removes leading and trailing whitespace from a constant string. * * Returns: newly allocated string + * + * Since: 1.1.2 **/ gchar * fu_common_strstrip (const gchar *str) @@ -890,6 +931,8 @@ fu_common_error_array_matches_any (GPtrArray *errors, FwupdError *error_codes) * completely bespoke error where required. * * Returns: (transfer full): a #GError, never %NULL + * + * Since: 1.0.8 **/ GError * fu_common_error_array_get_best (GPtrArray *errors) @@ -948,6 +991,8 @@ fu_common_error_array_get_best (GPtrArray *errors) * environment variables, for instance %FWUPD_DATADIR. * * Returns: a system path, or %NULL if invalid + * + * Since: 1.0.8 **/ gchar * fu_common_get_path (FuPathKind path_kind) @@ -1154,6 +1199,17 @@ fu_common_strwidth (const gchar *text) return width; } +/** + * fu_common_string_append_kv: + * @str: A #GString + * @idt: The indent + * @key: A string to append + * @value: a string to append + * + * Appends a key and string value to a string + * + * Since: 1.2.4 + */ void fu_common_string_append_kv (GString *str, guint idt, const gchar *key, const gchar *value) { @@ -1192,6 +1248,17 @@ fu_common_string_append_kv (GString *str, guint idt, const gchar *key, const gch } } +/** + * fu_common_string_append_ku: + * @str: A #GString + * @idt: The indent + * @key: A string to append + * @value: guint64 + * + * Appends a key and unsigned integer to a string + * + * Since: 1.2.4 + */ void fu_common_string_append_ku (GString *str, guint idt, const gchar *key, guint64 value) { @@ -1199,6 +1266,17 @@ fu_common_string_append_ku (GString *str, guint idt, const gchar *key, guint64 v fu_common_string_append_kv (str, idt, key, tmp); } +/** + * fu_common_string_append_kx: + * @str: A #GString + * @idt: The indent + * @key: A string to append + * @value: guint64 + * + * Appends a key and hex integer to a string + * + * Since: 1.2.4 + */ void fu_common_string_append_kx (GString *str, guint idt, const gchar *key, guint64 value) { @@ -1206,6 +1284,17 @@ fu_common_string_append_kx (GString *str, guint idt, const gchar *key, guint64 v fu_common_string_append_kv (str, idt, key, tmp); } +/** + * fu_common_string_append_kb: + * @str: A #GString + * @idt: The indent + * @key: A string to append + * @value: Boolean + * + * Appends a key and boolean value to a string + * + * Since: 1.2.4 + */ void fu_common_string_append_kb (GString *str, guint idt, const gchar *key, gboolean value) { @@ -1368,6 +1457,8 @@ fu_common_bytes_align (GBytes *bytes, gsize blksz, gchar padval) * Checks if a byte array are just empty (0xff) bytes. * * Return value: %TRUE if @bytes is empty + * + * Since: 1.2.6 **/ gboolean fu_common_bytes_is_empty (GBytes *bytes) @@ -1392,6 +1483,8 @@ fu_common_bytes_is_empty (GBytes *bytes) * Compares the buffers for equality. * * Return value: %TRUE if @buf1 and @buf2 are identical + * + * Since: 1.3.2 **/ gboolean fu_common_bytes_compare_raw (const guint8 *buf1, gsize bufsz1, @@ -1437,6 +1530,8 @@ fu_common_bytes_compare_raw (const guint8 *buf1, gsize bufsz1, * Compares the buffers for equality. * * Return value: %TRUE if @bytes1 and @bytes2 are identical + * + * Since: 1.2.6 **/ gboolean fu_common_bytes_compare (GBytes *bytes1, GBytes *bytes2, GError **error) @@ -1463,6 +1558,8 @@ fu_common_bytes_compare (GBytes *bytes1, GBytes *bytes2, GError **error) * Pads a GBytes to a given @sz with `0xff`. * * Return value: (transfer full): a #GBytes + * + * Since: 1.3.1 **/ GBytes * fu_common_bytes_pad (GBytes *bytes, gsize sz) @@ -1493,6 +1590,8 @@ fu_common_bytes_pad (GBytes *bytes, gsize sz) * Finds the canonicalized absolute filename for a path. * * Return value: A filename, or %NULL if invalid or not found + * + * Since: 1.2.6 **/ gchar * fu_common_realpath (const gchar *filename, GError **error) @@ -1536,6 +1635,8 @@ fu_common_realpath (const gchar *filename, GError **error) * to the last token. * * Return value: a newly-allocated NULL-terminated array of strings + * + * Since: 1.3.1 **/ gchar ** fu_common_strnsplit (const gchar *str, gsize sz, @@ -1571,6 +1672,8 @@ fu_common_strnsplit (const gchar *str, gsize sz, * malicious data from a device or firmware could cause memory corruption. * * Return value: %TRUE if the bytes were copied, %FALSE otherwise + * + * Since: 1.3.1 **/ gboolean fu_memcpy_safe (guint8 *dst, gsize dst_sz, gsize dst_offset, @@ -1633,6 +1736,8 @@ fu_memcpy_safe (guint8 *dst, gsize dst_sz, gsize dst_offset, * malicious data from a device or firmware could cause memory corruption. * * Return value: %TRUE if @value was set, %FALSE otherwise + * + * Since: 1.3.3 **/ gboolean fu_common_read_uint8_safe (const guint8 *buf, @@ -1667,6 +1772,8 @@ fu_common_read_uint8_safe (const guint8 *buf, * malicious data from a device or firmware could cause memory corruption. * * Return value: %TRUE if @value was set, %FALSE otherwise + * + * Since: 1.3.3 **/ gboolean fu_common_read_uint16_safe (const guint8 *buf, @@ -1702,6 +1809,8 @@ fu_common_read_uint16_safe (const guint8 *buf, * malicious data from a device or firmware could cause memory corruption. * * Return value: %TRUE if @value was set, %FALSE otherwise + * + * Since: 1.3.3 **/ gboolean fu_common_read_uint32_safe (const guint8 *buf, @@ -1721,12 +1830,31 @@ fu_common_read_uint32_safe (const guint8 *buf, return TRUE; } +/** + * fu_byte_array_append_uint8: + * @array: A #GByteArray + * @data: #guint8 + * + * Adds a 8 bit integer to a byte array + * + * Since: 1.3.1 + **/ void fu_byte_array_append_uint8 (GByteArray *array, guint8 data) { g_byte_array_append (array, &data, sizeof(data)); } +/** + * fu_byte_array_append_uint16: + * @array: A #GByteArray + * @data: #guint16 + * @endian: #FuEndianType + * + * Adds a 16 bit integer to a byte array + * + * Since: 1.3.1 + **/ void fu_byte_array_append_uint16 (GByteArray *array, guint16 data, FuEndianType endian) { @@ -1735,6 +1863,16 @@ fu_byte_array_append_uint16 (GByteArray *array, guint16 data, FuEndianType endia g_byte_array_append (array, buf, sizeof(buf)); } +/** + * fu_byte_array_append_uint32: + * @array: A #GByteArray + * @data: #guint32 + * @endian: #FuEndianType + * + * Adds a 32 bit integer to a byte array + * + * Since: 1.3.1 + **/ void fu_byte_array_append_uint32 (GByteArray *array, guint32 data, FuEndianType endian) { diff --git a/src/fu-device-locker.c b/src/fu-device-locker.c index 1e639d472..5e54dec7a 100644 --- a/src/fu-device-locker.c +++ b/src/fu-device-locker.c @@ -84,6 +84,8 @@ fu_device_locker_init (FuDeviceLocker *self) * Think of this object as the device ownership. * * Returns: a #FuDeviceLocker, or %NULL if the @open_func failed. + * + * Since: 1.0.0 **/ FuDeviceLocker * fu_device_locker_new (gpointer device, GError **error) @@ -130,6 +132,8 @@ fu_device_locker_new (gpointer device, GError **error) * Think of this object as the device ownership. * * Returns: a #FuDeviceLocker, or %NULL if the @open_func failed. + * + * Since: 1.0.0 **/ FuDeviceLocker * fu_device_locker_new_full (gpointer device, diff --git a/src/fu-device.c b/src/fu-device.c index bf88ca610..e08f38c6e 100644 --- a/src/fu-device.c +++ b/src/fu-device.c @@ -324,6 +324,16 @@ fu_device_set_priority (FuDevice *self, guint priority) priv->priority = priority; } +/** + * fu_device_get_equivalent_id: + * @self: A #FuDevice + * + * Gets any equivalent ID for a device + * + * Returns: (transfer none): a #gchar or NULL + * + * Since: 0.6.1 + **/ const gchar * fu_device_get_equivalent_id (FuDevice *self) { @@ -332,6 +342,15 @@ fu_device_get_equivalent_id (FuDevice *self) return priv->equivalent_id; } +/** + * fu_device_set_equivalent_id: + * @self: A #FuDevice + * @equivalent_id: A string + * + * Sets any equivalent ID for a device + * + * Since: 0.6.1 + **/ void fu_device_set_equivalent_id (FuDevice *self, const gchar *equivalent_id) { @@ -342,7 +361,7 @@ fu_device_set_equivalent_id (FuDevice *self, const gchar *equivalent_id) } /** - * fu_device_get_alternate: + * fu_device_get_alternate_id: * @self: A #FuDevice * * Gets any alternate device ID. An alternate device may be linked to the primary @@ -361,9 +380,9 @@ fu_device_get_alternate_id (FuDevice *self) } /** - * fu_device_set_alternate: + * fu_device_set_alternate_id: * @self: A #FuDevice - * @alternate: Another #FuDevice + * @alternate_id: Another #FuDevice * * Sets any alternate device ID. An alternate device may be linked to the primary * device in some way. @@ -447,6 +466,19 @@ fu_device_get_parent (FuDevice *self) return priv->parent; } +/** + * fu_device_set_parent: + * @self: A #FuDevice + * @parent: A #FuDevice + * + * Sets any parent device. An parent device is logically "above" the current + * device and this may be reflected in client tools. + * + * This information also allows the plugin to optionally verify the parent + * device, for instance checking the parent device firmware version. + * + * Since: 1.0.8 + **/ void fu_device_set_parent (FuDevice *self, FuDevice *parent) { @@ -795,6 +827,16 @@ fu_device_set_quirk_kv (FuDevice *self, return FALSE; } +/** + * fu_device_get_specialized_gtype: + * @self: A #FuDevice + * + * Gets the specialized type of the device + * + * Returns:#GType + * + * Since: 1.3.3 + **/ GType fu_device_get_specialized_gtype (FuDevice *self) { @@ -948,7 +990,17 @@ fu_device_has_guid (FuDevice *self, const gchar *guid) return fwupd_device_has_guid (FWUPD_DEVICE (self), guid); } -/* private */ +/** + * fu_device_add_instance_id_full: + * @self: A #FuDevice + * @instance_id: A Instance ID, e.g. `WacomAES` + * @flags: A #FuDeviceInstanceFlags + * + * Adds an instance ID with all paramters set + * + * + * Since: 1.2.9 + **/ void fu_device_add_instance_id_full (FuDevice *self, const gchar *instance_id, @@ -1511,6 +1563,16 @@ fu_device_get_physical_id (FuDevice *self) return priv->physical_id; } +/** + * fu_device_add_flag: + * @self: A #FuDevice + * @flag: A #FwupdDeviceFlags + * + * Adds a device flag to the device + * + * Since: 0.1.0 + **/ + void fu_device_add_flag (FuDevice *self, FwupdDeviceFlags flag) { @@ -2126,6 +2188,7 @@ fu_device_reload (FuDevice *self, GError **error) /** * fu_device_prepare: * @self: A #FuDevice + * @flags: A #FwupdInstallFlags * @error: A #GError * * Prepares a device for update. A different plugin can handle each of @@ -2154,6 +2217,7 @@ fu_device_prepare (FuDevice *self, FwupdInstallFlags flags, GError **error) /** * fu_device_cleanup: * @self: A #FuDevice + * @flags: A #FwupdInstallFlags * @error: A #GError * * Cleans up a device after an update. A different plugin can handle each of @@ -2467,8 +2531,6 @@ fu_device_activate (FuDevice *self, GError **error) * This should be done in case the backing device has changed, for instance if * a USB device has been replugged. * - * Returns: %TRUE for success - * * Since: 1.1.2 **/ void @@ -2660,6 +2722,13 @@ fu_device_finalize (GObject *object) G_OBJECT_CLASS (fu_device_parent_class)->finalize (object); } +/** + * fu_device_new: + * + * Creates a new #Fudevice + * + * Since: 0.1.0 + **/ FuDevice * fu_device_new (void) { diff --git a/src/fu-dfu-firmware.c b/src/fu-dfu-firmware.c index 59c1e5a1c..bc9e47950 100644 --- a/src/fu-dfu-firmware.c +++ b/src/fu-dfu-firmware.c @@ -11,6 +11,15 @@ #include "fu-common.h" #include "fu-dfu-firmware.h" +/** + * SECTION:fu-dfu-firmware + * @short_description: DFU firmware image + * + * An object that represents a DFU firmware image. + * + * See also: #FuFirmware + */ + typedef struct { guint16 vid; guint16 pid; @@ -39,6 +48,8 @@ fu_dfu_firmware_to_string (FuFirmware *firmware, guint idt, GString *str) * Gets the vendor ID, or 0xffff for no restriction. * * Return value: integer + * + * Since: 1.3.3 **/ guint16 fu_dfu_firmware_get_vid (FuDfuFirmware *self) @@ -55,6 +66,8 @@ fu_dfu_firmware_get_vid (FuDfuFirmware *self) * Gets the product ID, or 0xffff for no restriction. * * Return value: integer + * + * Since: 1.3.3 **/ guint16 fu_dfu_firmware_get_pid (FuDfuFirmware *self) @@ -71,6 +84,8 @@ fu_dfu_firmware_get_pid (FuDfuFirmware *self) * Gets the device ID, or 0xffff for no restriction. * * Return value: integer + * + * Since: 1.3.3 **/ guint16 fu_dfu_firmware_get_release (FuDfuFirmware *self) @@ -87,6 +102,8 @@ fu_dfu_firmware_get_release (FuDfuFirmware *self) * Gets the file format version with is 0x0100 by default. * * Return value: integer + * + * Since: 1.3.3 **/ guint16 fu_dfu_firmware_get_version (FuDfuFirmware *self) @@ -102,6 +119,8 @@ fu_dfu_firmware_get_version (FuDfuFirmware *self) * @vid: vendor ID, or 0xffff if the firmware should match any vendor * * Sets the vendor ID. + * + * Since: 1.3.3 **/ void fu_dfu_firmware_set_vid (FuDfuFirmware *self, guint16 vid) @@ -117,6 +136,8 @@ fu_dfu_firmware_set_vid (FuDfuFirmware *self, guint16 vid) * @pid: product ID, or 0xffff if the firmware should match any product * * Sets the product ID. + * + * Since: 1.3.3 **/ void fu_dfu_firmware_set_pid (FuDfuFirmware *self, guint16 pid) @@ -129,9 +150,11 @@ fu_dfu_firmware_set_pid (FuDfuFirmware *self, guint16 pid) /** * fu_dfu_firmware_set_release: * @self: a #FuDfuFirmware - * @release: device ID, or 0xffff if the firmware should match any release + * @release: release, or 0xffff if the firmware should match any release * - * Sets the device ID. + * Sets the release for the dfu firmware. + * + * Since: 1.3.3 **/ void fu_dfu_firmware_set_release (FuDfuFirmware *self, guint16 release) @@ -147,6 +170,8 @@ fu_dfu_firmware_set_release (FuDfuFirmware *self, guint16 release) * @version: integer * * Sets the file format version. + * + * Since: 1.3.3 **/ void fu_dfu_firmware_set_version (FuDfuFirmware *self, guint16 version) @@ -366,6 +391,13 @@ fu_dfu_firmware_class_init (FuDfuFirmwareClass *klass) klass_firmware->write = fu_dfu_firmware_write; } +/** + * fu_dfu_firmware_new: + * + * Creates a new #FuFirmware of sub type Dfu + * + * Since: 1.3.3 + **/ FuFirmware * fu_dfu_firmware_new (void) { diff --git a/src/fu-firmware-common.c b/src/fu-firmware-common.c index 79b7c2638..a7f9a2a1b 100644 --- a/src/fu-firmware-common.c +++ b/src/fu-firmware-common.c @@ -22,6 +22,8 @@ * length of @data. Checking the size must be done in the caller. * * Return value: A parsed value, or 0 for error + * + * Since: 1.3.1 **/ guint8 fu_firmware_strparse_uint4 (const gchar *data) @@ -42,6 +44,8 @@ fu_firmware_strparse_uint4 (const gchar *data) * length of @data. Checking the size must be done in the caller. * * Return value: A parsed value, or 0 for error + * + * Since: 1.3.1 **/ guint8 fu_firmware_strparse_uint8 (const gchar *data) @@ -62,6 +66,8 @@ fu_firmware_strparse_uint8 (const gchar *data) * length of @data. Checking the size must be done in the caller. * * Return value: A parsed value, or 0 for error + * + * Since: 1.3.1 **/ guint16 fu_firmware_strparse_uint16 (const gchar *data) @@ -82,6 +88,8 @@ fu_firmware_strparse_uint16 (const gchar *data) * length of @data. Checking the size must be done in the caller. * * Return value: A parsed value, or 0 for error + * + * Since: 1.3.1 **/ guint32 fu_firmware_strparse_uint24 (const gchar *data) @@ -102,6 +110,8 @@ fu_firmware_strparse_uint24 (const gchar *data) * length of @data. Checking the size must be done in the caller. * * Return value: A parsed value, or 0 for error + * + * Since: 1.3.1 **/ guint32 fu_firmware_strparse_uint32 (const gchar *data) diff --git a/src/fu-firmware-image.c b/src/fu-firmware-image.c index 42fcd75e4..ffacfa782 100644 --- a/src/fu-firmware-image.c +++ b/src/fu-firmware-image.c @@ -354,7 +354,6 @@ fu_firmware_image_class_init (FuFirmwareImageClass *klass) /** * fu_firmware_image_new: - * @id: Optional ID * @bytes: Optional #GBytes * * Creates an empty firmware_image object. diff --git a/src/fu-firmware.c b/src/fu-firmware.c index 148642042..d2ddcd76e 100644 --- a/src/fu-firmware.c +++ b/src/fu-firmware.c @@ -17,6 +17,7 @@ * @short_description: a firmware file * * An object that represents a firmware file. + * See also: #FuDfuFirmware, #FuIhexFirmware, #FuSrecFirmware */ typedef struct { @@ -66,7 +67,7 @@ fu_firmware_set_version (FuFirmware *self, const gchar *version) /** * fu_firmware_tokenize: * @self: A #FuFirmware - * @image: A #GBytes + * @fw: A #GBytes * @flags: some #FwupdInstallFlags, e.g. %FWUPD_INSTALL_FLAG_FORCE * @error: A #GError, or %NULL * @@ -98,7 +99,7 @@ fu_firmware_tokenize (FuFirmware *self, GBytes *fw, /** * fu_firmware_parse_full: * @self: A #FuFirmware - * @image: A #GBytes + * @fw: A #GBytes * @addr_start: Start address, useful for ignoring a bootloader * @addr_end: End address, useful for ignoring config bytes * @flags: some #FwupdInstallFlags, e.g. %FWUPD_INSTALL_FLAG_FORCE @@ -142,7 +143,7 @@ fu_firmware_parse_full (FuFirmware *self, /** * fu_firmware_parse: * @self: A #FuFirmware - * @image: A #GBytes + * @fw: A #GBytes * @flags: some #FwupdInstallFlags, e.g. %FWUPD_INSTALL_FLAG_FORCE * @error: A #GError, or %NULL * @@ -259,7 +260,7 @@ fu_firmware_add_image (FuFirmware *self, FuFirmwareImage *img) /** * fu_firmware_get_images: - * @self: a #FuPlugin + * @self: a #FuFirmware * * Returns all the images in the firmware. * @@ -520,7 +521,7 @@ fu_firmware_new (void) /** * fu_firmware_new_from_bytes: - * @self: A #GBytes image + * @fw: A #GBytes image * * Creates a firmware object with the provided image set as default. * diff --git a/src/fu-firmware.h b/src/fu-firmware.h index dd2e904a5..e6b3e65c1 100644 --- a/src/fu-firmware.h +++ b/src/fu-firmware.h @@ -68,7 +68,7 @@ gboolean fu_firmware_write_file (FuFirmware *self, GError **error); void fu_firmware_add_image (FuFirmware *self, - FuFirmwareImage *image); + FuFirmwareImage *img); GPtrArray *fu_firmware_get_images (FuFirmware *self); FuFirmwareImage *fu_firmware_get_image_by_id (FuFirmware *self, const gchar *id, diff --git a/src/fu-history.c b/src/fu-history.c index d1a010644..372d8ced1 100644 --- a/src/fu-history.c +++ b/src/fu-history.c @@ -457,6 +457,18 @@ fu_history_get_device_flags_filtered (FuDevice *device) return flags; } +/** + * fu_history_modify_device: + * @self: A #FuHistory + * @device: A #FuDevice + * @error: A #GError or NULL + * + * Modify a device in the history database + * + * Returns: @TRUE if successful, @FALSE for failure + * + * Since: 1.0.4 + **/ gboolean fu_history_modify_device (FuHistory *self, FuDevice *device, GError **error) { @@ -505,6 +517,19 @@ fu_history_modify_device (FuHistory *self, FuDevice *device, GError **error) return fu_history_stmt_exec (self, stmt, NULL, error); } +/** + * fu_history_add_device: + * @self: A #FuHistory + * @device: A #FuDevice + * @release: A #FuRelease + * @error: A #GError or NULL + * + * Adds a device to the history database + * + * Returns: @TRUE if successful, @FALSE for failure + * + * Since: 1.0.4 + **/ gboolean fu_history_add_device (FuHistory *self, FuDevice *device, FwupdRelease *release, GError **error) { @@ -586,6 +611,19 @@ fu_history_add_device (FuHistory *self, FuDevice *device, FwupdRelease *release, return fu_history_stmt_exec (self, stmt, NULL, error); } +/** + * fu_history_remove_all_with_state: + * @self: A #FuHistory + * @update_state: A #FwupdUpdateState + * @error: A #GError or NULL + * + * Remove all devices from the history database that match + * state update_state + * + * Returns: @TRUE if successful, @FALSE for failure + * + * Since: 1.0.4 + **/ gboolean fu_history_remove_all_with_state (FuHistory *self, FwupdUpdateState update_state, @@ -619,6 +657,17 @@ fu_history_remove_all_with_state (FuHistory *self, return fu_history_stmt_exec (self, stmt, NULL, error); } +/** + * fu_history_remove_all: + * @self: A #FuHistory + * @error: A #GError or NULL + * + * Remove all devices from the history database + * + * Returns: @TRUE if successful, @FALSE for failure + * + * Since: 1.0.4 + **/ gboolean fu_history_remove_all (FuHistory *self, GError **error) { @@ -646,6 +695,18 @@ fu_history_remove_all (FuHistory *self, GError **error) return fu_history_stmt_exec (self, stmt, NULL, error); } +/** + * fu_history_remove_device: + * @self: A #FuHistory + * @device: A #FuDevice + * @error: A #GError or NULL + * + * Remove a device from the history database + * + * Returns: @TRUE if successful, @FALSE for failure + * + * Since: 1.0.4 + **/ gboolean fu_history_remove_device (FuHistory *self, FuDevice *device, GError **error) { @@ -678,6 +739,19 @@ fu_history_remove_device (FuHistory *self, FuDevice *device, GError **error) return fu_history_stmt_exec (self, stmt, NULL, error); } + +/** + * fu_history_get_device_by_id: + * @self: A #FuHistory + * @device_id: A string + * @error: A #GError or NULL + * + * Returns the device from the history database or NULL if not found + * + * Returns: (transfer full): a #FuDevice + * + * Since: 1.0.4 + **/ FuDevice * fu_history_get_device_by_id (FuHistory *self, const gchar *device_id, GError **error) { @@ -735,7 +809,17 @@ fu_history_get_device_by_id (FuHistory *self, const gchar *device_id, GError **e } return g_object_ref (g_ptr_array_index (array_tmp, 0)); } - +/** + * fu_history_get_devices: + * @self: A #FuHistory + * @error: A #GError or NULL + * + * Gets the devices in the history database. + * + * Returns: (element-type #FuDevice) (transfer container): devices + * + * Since: 1.0.4 + **/ GPtrArray * fu_history_get_devices (FuHistory *self, GError **error) { @@ -788,6 +872,17 @@ fu_history_get_devices (FuHistory *self, GError **error) return array; } +/** + * fu_history_get_approved_firmware: + * @self: A #FuHistory + * @error: A #GError or NULL + * + * Returns approved firmware records. + * + * Returns: (transfer full) (element-type gchar *): records + * + * Since: 1.2.6 + **/ GPtrArray * fu_history_get_approved_firmware (FuHistory *self, GError **error) { @@ -830,6 +925,17 @@ fu_history_get_approved_firmware (FuHistory *self, GError **error) return g_steal_pointer (&array); } +/** + * fu_history_clear_approved_firmware: + * @self: A #FuHistory + * @error: A #GError or NULL + * + * Clear all approved firmware records + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.2.6 + **/ gboolean fu_history_clear_approved_firmware (FuHistory *self, GError **error) { @@ -858,6 +964,18 @@ fu_history_clear_approved_firmware (FuHistory *self, GError **error) return fu_history_stmt_exec (self, stmt, NULL, error); } +/** + * fu_history_add_approved_firmware: + * @self: A #FuHistory + * @checksum: a string + * @error: A #GError or NULL + * + * Add an approved firmware record to the database + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.2.6 + **/ gboolean fu_history_add_approved_firmware (FuHistory *self, const gchar *checksum, @@ -915,6 +1033,13 @@ fu_history_finalize (GObject *object) G_OBJECT_CLASS (fu_history_parent_class)->finalize (object); } +/** + * fu_history_new: + * + * Creates a new #FuHistory + * + * Since: 1.0.4 + **/ FuHistory * fu_history_new (void) { diff --git a/src/fu-hwids.c b/src/fu-hwids.c index a64c6a2af..f587620d1 100644 --- a/src/fu-hwids.c +++ b/src/fu-hwids.c @@ -36,6 +36,8 @@ G_DEFINE_TYPE (FuHwids, fu_hwids, G_TYPE_OBJECT) * for display. * * Returns: the string, e.g. `1.2.3`, or %NULL if not found + * + * Since: 0.9.3 **/ const gchar * fu_hwids_get_value (FuHwids *self, const gchar *key) @@ -51,6 +53,8 @@ fu_hwids_get_value (FuHwids *self, const gchar *key) * Finds out if a hardware GUID exists. * * Returns: %TRUE if the GUID exists + * + * Since: 0.9.3 **/ gboolean fu_hwids_has_guid (FuHwids *self, const gchar *guid) @@ -65,6 +69,8 @@ fu_hwids_has_guid (FuHwids *self, const gchar *guid) * Returns all the defined HWIDs * * Returns: (transfer none) (element-type utf-8): An array of GUIDs + * + * Since: 0.9.3 **/ GPtrArray * fu_hwids_get_guids (FuHwids *self) @@ -108,6 +114,8 @@ fu_hwids_get_guid_for_str (const gchar *str, GError **error) * Gets the replacement key for a well known value. * * Returns: the replacement value, e.g. `Manufacturer&ProductName`, or %NULL for error. + * + * Since: 0.9.3 **/ const gchar * fu_hwids_get_replace_keys (FuHwids *self, const gchar *key) @@ -197,6 +205,8 @@ fu_hwids_get_replace_keys (FuHwids *self, const gchar *key) * Gets the replacement values for a HardwareID key or plain key. * * Returns: a string, e.g. `LENOVO&ThinkPad T440s`, or %NULL for error. + * + * Since: 0.9.3 **/ gchar * fu_hwids_get_replace_values (FuHwids *self, const gchar *keys, GError **error) @@ -235,6 +245,8 @@ fu_hwids_get_replace_values (FuHwids *self, const gchar *keys, GError **error) * Gets the GUID for a specific key. * * Returns: a string, or %NULL for error. + * + * Since: 0.9.3 **/ gchar * fu_hwids_get_guid (FuHwids *self, const gchar *keys, GError **error) @@ -316,6 +328,8 @@ fu_hwids_convert_integer_cb (FuSmbios *smbios, * Reads all the SMBIOS values from the hardware. * * Returns: %TRUE for success + * + * Since: 0.9.3 **/ gboolean fu_hwids_setup (FuHwids *self, FuSmbios *smbios, GError **error) @@ -440,6 +454,13 @@ fu_hwids_init (FuHwids *self) self->array_guids = g_ptr_array_new_with_free_func (g_free); } +/** + * fu_hwids_new: + * + * Creates a new #FuHwids + * + * Since: 0.9.3 + **/ FuHwids * fu_hwids_new (void) { diff --git a/src/fu-ihex-firmware.c b/src/fu-ihex-firmware.c index a8c15df8a..32dd070f1 100644 --- a/src/fu-ihex-firmware.c +++ b/src/fu-ihex-firmware.c @@ -14,6 +14,15 @@ #include "fu-firmware-common.h" #include "fu-ihex-firmware.h" +/** + * SECTION:fu-ihex-firmware + * @short_description: Ihex firmware image + * + * An object that represents a Ihex firmware image. + * + * See also: #FuFirmware + */ + struct _FuIhexFirmware { FuFirmware parent_instance; GPtrArray *records; @@ -434,6 +443,13 @@ fu_ihex_firmware_class_init (FuIhexFirmwareClass *klass) klass_firmware->write = fu_ihex_firmware_write; } +/** + * fu_ihex_firmware_new: + * + * Creates a new #FuFirmware of sub type Ihex + * + * Since: 1.3.1 + **/ FuFirmware * fu_ihex_firmware_new (void) { diff --git a/src/fu-io-channel.c b/src/fu-io-channel.c index dd7e798a9..3a68f67fd 100644 --- a/src/fu-io-channel.c +++ b/src/fu-io-channel.c @@ -461,6 +461,8 @@ fu_io_channel_init (FuIOChannel *self) * Creates a new object to write and read from. * * Returns: a #FuIOChannel + * + * Since: 1.2.2 **/ FuIOChannel * fu_io_channel_unix_new (gint fd) @@ -479,6 +481,8 @@ fu_io_channel_unix_new (gint fd) * Creates a new object to write and read from. * * Returns: a #FuIOChannel + * + * Since: 1.2.2 **/ FuIOChannel * fu_io_channel_new_file (const gchar *filename, GError **error) diff --git a/src/fu-plugin.c b/src/fu-plugin.c index cff8cf735..80e57cc26 100644 --- a/src/fu-plugin.c +++ b/src/fu-plugin.c @@ -141,6 +141,15 @@ fu_plugin_get_name (FuPlugin *self) return priv->name; } +/** + * fu_plugin_set_name: + * @self: A #FuPlugin + * @name: A string + * + * Sets the plugin name. + * + * Since: 0.8.0 + **/ void fu_plugin_set_name (FuPlugin *self, const gchar *name) { @@ -171,6 +180,16 @@ fu_plugin_set_build_hash (FuPlugin *self, const gchar *build_hash) priv->build_hash = g_strdup (build_hash); } +/** + * fu_plugin_get_build_hash: + * @self: A #FuPlugin + * + * Gets the build hash a plugin was generated with. + * + * Returns: (transfer none): a #gchar, or %NULL for unset. + * + * Since: 1.2.4 + **/ const gchar * fu_plugin_get_build_hash (FuPlugin *self) { @@ -303,6 +322,15 @@ fu_plugin_get_usb_context (FuPlugin *self) return priv->usb_ctx; } +/** + * fu_plugin_set_usb_context: + * @self: A #FuPlugin + * @usb_ctx: A #FGUsbContext + * + * Sets the shared USB context for a plugin + * + * Since: 0.8.0 + **/ void fu_plugin_set_usb_context (FuPlugin *self, GUsbContext *usb_ctx) { @@ -346,6 +374,16 @@ fu_plugin_set_enabled (FuPlugin *self, gboolean enabled) priv->enabled = enabled; } +/** + * fu_plugin_guess_name_from_fn: + * @filename: filename to guess + * + * Tries to guess the name of the plugin from a filename + * + * Returns: (transfer full): the guessed name of the plugin + * + * Since: 1.0.8 + **/ gchar * fu_plugin_guess_name_from_fn (const gchar *filename) { @@ -359,6 +397,18 @@ fu_plugin_guess_name_from_fn (const gchar *filename) return name; } +/** + * fu_plugin_open: + * @self: A #FuPlugin + * @filename: The shared object filename to open + * @error: A #GError or NULL + * + * Opens the plugin module + * + * Returns: TRUE for success, FALSE for fail + * + * Since: 0.8.0 + **/ gboolean fu_plugin_open (FuPlugin *self, const gchar *filename, GError **error) { @@ -557,7 +607,7 @@ fu_plugin_get_hwid_replace_value (FuPlugin *self, const gchar *keys, GError **er * Returns all the HWIDs defined in the system. All hardware IDs on a * specific system can be shown using the `fwupdmgr hwids` command. * - * Returns: (transfer none) (element-type utf-8): An array of GUIDs + * Returns: (transfer none) (element-type utf8): An array of GUIDs * * Since: 1.1.1 **/ @@ -695,6 +745,15 @@ fu_plugin_get_smbios_data (FuPlugin *self, guint8 structure_type) return fu_smbios_get_data (priv->smbios, structure_type, NULL); } +/** + * fu_plugin_set_hwids: + * @self: A #FuPlugin + * @hwids: A #FuHwids + * + * Sets the hwids for a plugin + * + * Since: 0.9.7 + **/ void fu_plugin_set_hwids (FuPlugin *self, FuHwids *hwids) { @@ -702,6 +761,15 @@ fu_plugin_set_hwids (FuPlugin *self, FuHwids *hwids) g_set_object (&priv->hwids, hwids); } +/** + * fu_plugin_set_udev_subsystems: + * @self: A #FuPlugin + * @udev_subsystems: A #GPtrArray + * + * Sets the udev subsystems used by a plugin + * + * Since: 1.1.2 + **/ void fu_plugin_set_udev_subsystems (FuPlugin *self, GPtrArray *udev_subsystems) { @@ -711,6 +779,15 @@ fu_plugin_set_udev_subsystems (FuPlugin *self, GPtrArray *udev_subsystems) priv->udev_subsystems = g_ptr_array_ref (udev_subsystems); } +/** + * fu_plugin_set_quirks: + * @self: A #FuPlugin + * @quirks: A #FuQuirks + * + * Sets the quirks for a plugin + * + * Since: 1.0.1 + **/ void fu_plugin_set_quirks (FuPlugin *self, FuQuirks *quirks) { @@ -736,6 +813,15 @@ fu_plugin_get_quirks (FuPlugin *self) return priv->quirks; } +/** + * fu_plugin_set_runtime_versions: + * @self: A #FuPlugin + * @runtime_versions: A #GHashTables + * + * Sets the runtime versions for a plugin + * + * Since: 1.0.7 + **/ void fu_plugin_set_runtime_versions (FuPlugin *self, GHashTable *runtime_versions) { @@ -766,6 +852,15 @@ fu_plugin_add_runtime_version (FuPlugin *self, g_strdup (version)); } +/** + * fu_plugin_set_compile_versions: + * @self: A #FuPlugin + * @compile_versions: A #GHashTables + * + * Sets the compile time versions for a plugin + * + * Since: 1.0.7 + **/ void fu_plugin_set_compile_versions (FuPlugin *self, GHashTable *compile_versions) { @@ -828,7 +923,7 @@ fu_plugin_lookup_quirk_by_id (FuPlugin *self, const gchar *group, const gchar *k * an integer value. Values are assumed base 10, unless prefixed with "0x" * where they are parsed as base 16. * - * Returns: (transfer none): value from the database, or 0 if not found + * Returns: guint64 id or 0 if not found * * Since: 1.1.2 **/ @@ -838,6 +933,15 @@ fu_plugin_lookup_quirk_by_id_as_uint64 (FuPlugin *self, const gchar *group, cons return fu_common_strtoull (fu_plugin_lookup_quirk_by_id (self, group, key)); } +/** + * fu_plugin_set_smbios: + * @self: A #FuPlugin + * @smbios: A #FuSmbios + * + * Sets the smbios for a plugin + * + * Since: 1.0.0 + **/ void fu_plugin_set_smbios (FuPlugin *self, FuSmbios *smbios) { @@ -971,6 +1075,17 @@ fu_plugin_device_read_firmware (FuPlugin *self, FuDevice *device, GError **error return fu_device_attach (device, error); } +/** + * fu_plugin_runner_startup: + * @self: a #FuPlugin + * @error: a #GError or NULL + * + * Runs the startup routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_startup (FuPlugin *self, GError **error) { @@ -1188,6 +1303,17 @@ fu_plugin_runner_device_array_generic (FuPlugin *self, GPtrArray *devices, return TRUE; } +/** + * fu_plugin_runner_coldplug: + * @self: a #FuPlugin + * @error: a #GError or NULL + * + * Runs the coldplug routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_coldplug (FuPlugin *self, GError **error) { @@ -1224,6 +1350,17 @@ fu_plugin_runner_coldplug (FuPlugin *self, GError **error) return TRUE; } +/** + * fu_plugin_runner_recoldplug: + * @self: a #FuPlugin + * @error: a #GError or NULL + * + * Runs the recoldplug routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.0.4 + **/ gboolean fu_plugin_runner_recoldplug (FuPlugin *self, GError **error) { @@ -1261,6 +1398,17 @@ fu_plugin_runner_recoldplug (FuPlugin *self, GError **error) return TRUE; } +/** + * fu_plugin_runner_coldplug_prepare: + * @self: a #FuPlugin + * @error: a #GError or NULL + * + * Runs the coldplug_prepare routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_coldplug_prepare (FuPlugin *self, GError **error) { @@ -1298,6 +1446,17 @@ fu_plugin_runner_coldplug_prepare (FuPlugin *self, GError **error) return TRUE; } +/** + * fu_plugin_runner_coldplug_cleanup: + * @self: a #FuPlugin + * @error: a #GError or NULL + * + * Runs the coldplug_cleanup routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_coldplug_cleanup (FuPlugin *self, GError **error) { @@ -1335,6 +1494,18 @@ fu_plugin_runner_coldplug_cleanup (FuPlugin *self, GError **error) return TRUE; } +/** + * fu_plugin_runner_composite_prepare: + * @self: a #FuPlugin + * @devices: a #GPtrArray of devices + * @error: a #GError or NULL + * + * Runs the composite_prepare routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.0.9 + **/ gboolean fu_plugin_runner_composite_prepare (FuPlugin *self, GPtrArray *devices, GError **error) { @@ -1343,6 +1514,18 @@ fu_plugin_runner_composite_prepare (FuPlugin *self, GPtrArray *devices, GError * error); } +/** + * fu_plugin_runner_composite_cleanup: + * @self: a #FuPlugin + * @devices: a #GPtrArray of devices + * @error: a #GError or NULL + * + * Runs the composite_cleanup routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.0.9 + **/ gboolean fu_plugin_runner_composite_cleanup (FuPlugin *self, GPtrArray *devices, GError **error) { @@ -1351,6 +1534,17 @@ fu_plugin_runner_composite_cleanup (FuPlugin *self, GPtrArray *devices, GError * error); } +/** + * fu_plugin_runner_update_prepare: + * @self: a #FuPlugin + * @error: a #GError or NULL + * + * Runs the update_prepare routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.1.2 + **/ gboolean fu_plugin_runner_update_prepare (FuPlugin *self, FwupdInstallFlags flags, FuDevice *device, GError **error) @@ -1360,6 +1554,17 @@ fu_plugin_runner_update_prepare (FuPlugin *self, FwupdInstallFlags flags, FuDevi error); } +/** + * fu_plugin_runner_update_cleanup: + * @self: a #FuPlugin + * @error: a #GError or NULL + * + * Runs the update_cleanup routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.1.2 + **/ gboolean fu_plugin_runner_update_cleanup (FuPlugin *self, FwupdInstallFlags flags, FuDevice *device, GError **error) @@ -1369,6 +1574,18 @@ fu_plugin_runner_update_cleanup (FuPlugin *self, FwupdInstallFlags flags, FuDevi error); } +/** + * fu_plugin_runner_update_attach: + * @self: a #FuPlugin + * @device: a #FuDevice + * @error: a #GError or NULL + * + * Runs the update_attach routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.1.2 + **/ gboolean fu_plugin_runner_update_attach (FuPlugin *self, FuDevice *device, GError **error) { @@ -1378,6 +1595,18 @@ fu_plugin_runner_update_attach (FuPlugin *self, FuDevice *device, GError **error error); } +/** + * fu_plugin_runner_update_detach: + * @self: a #FuPlugin + * @device: A #FuDevice + * @error: a #GError or NULL + * + * Runs the update_detach routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.1.2 + **/ gboolean fu_plugin_runner_update_detach (FuPlugin *self, FuDevice *device, GError **error) { @@ -1387,6 +1616,17 @@ fu_plugin_runner_update_detach (FuPlugin *self, FuDevice *device, GError **error error); } +/** + * fu_plugin_runner_update_reload: + * @self: a #FuPlugin + * @error: a #GError or NULL + * + * Runs reload routine for a device + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.1.2 + **/ gboolean fu_plugin_runner_update_reload (FuPlugin *self, FuDevice *device, GError **error) { @@ -1412,6 +1652,8 @@ fu_plugin_runner_update_reload (FuPlugin *self, FuDevice *device, GError **error * Registers the udev subsystem to be watched by the daemon. * * Plugins can use this method only in fu_plugin_init() + * + * Since: 1.1.2 **/ void fu_plugin_add_udev_subsystem (FuPlugin *self, const gchar *subsystem) @@ -1447,6 +1689,18 @@ fu_plugin_set_device_gtype (FuPlugin *self, GType device_gtype) priv->device_gtype = device_gtype; } +/** + * fu_plugin_add_firmware_gtype: + * @self: a #FuPlugin + * @id: A string describing the type + * @gtype: a #GType `FU_TYPE_DEVICE` + * + * Adds a firmware #GType which is used when creating devices. + * * + * Plugins can use this method only in fu_plugin_init() + * + * Since: 1.3.3 + **/ void fu_plugin_add_firmware_gtype (FuPlugin *self, const gchar *id, GType gtype) { @@ -1540,6 +1794,18 @@ fu_plugin_udev_device_added (FuPlugin *self, FuUdevDevice *device, GError **erro return TRUE; } +/** + * fu_plugin_runner_usb_device_added: + * @self: a #FuPlugin + * @device: a #FuUsbDevice + * @error: a #GError or NULL + * + * Call the usb_device_added routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.0.2 + **/ gboolean fu_plugin_runner_usb_device_added (FuPlugin *self, FuUsbDevice *device, GError **error) { @@ -1583,6 +1849,18 @@ fu_plugin_runner_usb_device_added (FuPlugin *self, FuUsbDevice *device, GError * return TRUE; } +/** + * fu_plugin_runner_udev_device_added: + * @self: a #FuPlugin + * @device: a #FuUdevDevice + * @error: a #GError or NULL + * + * Call the udev_device_added routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.0.2 + **/ gboolean fu_plugin_runner_udev_device_added (FuPlugin *self, FuUdevDevice *device, GError **error) { @@ -1626,6 +1904,18 @@ fu_plugin_runner_udev_device_added (FuPlugin *self, FuUdevDevice *device, GError return TRUE; } +/** + * fu_plugin_runner_udev_device_changed: + * @self: a #FuPlugin + * @device: a #FuUdevDevice + * @error: a #GError or NULL + * + * Call the udev_device_changed routine for the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.0.2 + **/ gboolean fu_plugin_runner_udev_device_changed (FuPlugin *self, FuUdevDevice *device, GError **error) { @@ -1663,6 +1953,15 @@ fu_plugin_runner_udev_device_changed (FuPlugin *self, FuUdevDevice *device, GErr return TRUE; } +/** + * fu_plugin_runner_device_removed: + * @self: a #FuPlugin + * @device: a #FuDevice + * + * Call the device_removed routine for the plugin + * + * Since: 1.1.2 + **/ void fu_plugin_runner_device_removed (FuPlugin *self, FuDevice *device) { @@ -1675,6 +1974,15 @@ fu_plugin_runner_device_removed (FuPlugin *self, FuDevice *device) g_warning ("%s", error_local->message); } +/** + * fu_plugin_runner_device_register: + * @self: a #FuPlugin + * @device: a #FuDevice + * + * Call the device_registered routine for the plugin + * + * Since: 0.9.7 + **/ void fu_plugin_runner_device_register (FuPlugin *self, FuDevice *device) { @@ -1699,13 +2007,28 @@ fu_plugin_runner_device_register (FuPlugin *self, FuDevice *device) } } +/** + * fu_plugin_runner_schedule_update: + * @self: a #FuPlugin + * @device: a #FuDevice + * @release: A #FwupdRelease + * @blob_cab: A #GBytes + * @flags: #FwupdInstallFlags + * @error: A #GError or NULL + * + * Schedule an offline update with the plugin + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_schedule_update (FuPlugin *self, - FuDevice *device, - FwupdRelease *release, - GBytes *blob_cab, - FwupdInstallFlags flags, - GError **error) + FuDevice *device, + FwupdRelease *release, + GBytes *blob_cab, + FwupdInstallFlags flags, + GError **error) { gchar tmpname[] = {"XXXXXX.cab"}; g_autofree gchar *dirname = NULL; @@ -1766,6 +2089,19 @@ fu_plugin_runner_schedule_update (FuPlugin *self, return fu_plugin_runner_offline_setup (error); } +/** + * fu_plugin_runner_verify: + * @self: a #FuPlugin + * @device: a #FuDevice + * @flags: #FuPluginVerifyFlags + * @error: A #GError or NULL + * + * Call into the plugin's verify routine + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_verify (FuPlugin *self, FuDevice *device, @@ -1839,6 +2175,18 @@ fu_plugin_runner_verify (FuPlugin *self, return TRUE; } +/** + * fu_plugin_runner_activate: + * @self: a #FuPlugin + * @device: a #FuDevice + * @error: A #GError or NULL + * + * Call into the plugin's activate routine + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.2.6 + **/ gboolean fu_plugin_runner_activate (FuPlugin *self, FuDevice *device, GError **error) { @@ -1868,6 +2216,18 @@ fu_plugin_runner_activate (FuPlugin *self, FuDevice *device, GError **error) return TRUE; } +/** + * fu_plugin_runner_unlock: + * @self: a #FuPlugin + * @device: a #FuDevice + * @error: A #GError or NULL + * + * Call into the plugin's unlock routine + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_unlock (FuPlugin *self, FuDevice *device, GError **error) { @@ -1898,6 +2258,20 @@ fu_plugin_runner_unlock (FuPlugin *self, FuDevice *device, GError **error) return TRUE; } +/** + * fu_plugin_runner_update: + * @self: a #FuPlugin + * @device: a #FuDevice + * @blob_fw: A #GBytes + * @flags: A #FwupdInstallFlags + * @error: A #GError or NULL + * + * Call into the plugin's update routine + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_update (FuPlugin *self, FuDevice *device, @@ -1989,6 +2363,18 @@ fu_plugin_runner_update (FuPlugin *self, return TRUE; } +/** + * fu_plugin_runner_clear_results: + * @self: a #FuPlugin + * @device: a #FuDevice + * @error: A #GError or NULL + * + * Call into the plugin's clear results routine + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_clear_results (FuPlugin *self, FuDevice *device, GError **error) { @@ -2026,6 +2412,18 @@ fu_plugin_runner_clear_results (FuPlugin *self, FuDevice *device, GError **error return TRUE; } +/** + * fu_plugin_runner_get_results: + * @self: a #FuPlugin + * @device: a #FuDevice + * @error: A #GError or NULL + * + * Call into the plugin's get results routine + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 0.8.0 + **/ gboolean fu_plugin_runner_get_results (FuPlugin *self, FuDevice *device, GError **error) { @@ -2071,6 +2469,8 @@ fu_plugin_runner_get_results (FuPlugin *self, FuDevice *device, GError **error) * numbers. * * Returns: the integer value + * + * Since: 1.0.0 **/ guint fu_plugin_get_order (FuPlugin *self) @@ -2086,6 +2486,8 @@ fu_plugin_get_order (FuPlugin *self) * * Sets the plugin order, where higher numbers are run after lower * numbers. + * + * Since: 1.0.0 **/ void fu_plugin_set_order (FuPlugin *self, guint order) @@ -2101,6 +2503,8 @@ fu_plugin_set_order (FuPlugin *self, guint order) * Gets the plugin priority, where higher numbers are better. * * Returns: the integer value + * + * Since: 1.1.1 **/ guint fu_plugin_get_priority (FuPlugin *self) @@ -2115,6 +2519,8 @@ fu_plugin_get_priority (FuPlugin *self) * @priority: a integer value * * Sets the plugin priority, where higher numbers are better. + * + * Since: 1.0.0 **/ void fu_plugin_set_priority (FuPlugin *self, guint priority) @@ -2135,6 +2541,8 @@ fu_plugin_set_priority (FuPlugin *self, guint priority) * * NOTE: The depsolver is iterative and may not solve overly-complicated rules; * If depsolving fails then fwupd will not start. + * + * Since: 1.0.0 **/ void fu_plugin_add_rule (FuPlugin *self, FuPluginRule rule, const gchar *name) @@ -2152,6 +2560,8 @@ fu_plugin_add_rule (FuPlugin *self, FuPluginRule rule, const gchar *name) * Gets the plugin IDs that should be run after this plugin. * * Returns: (element-type utf8) (transfer none): the list of plugin names, e.g. ['appstream'] + * + * Since: 1.0.0 **/ GPtrArray * fu_plugin_get_rules (FuPlugin *self, FuPluginRule rule) @@ -2169,6 +2579,8 @@ fu_plugin_get_rules (FuPlugin *self, FuPluginRule rule) * Gets the plugin IDs that should be run after this plugin. * * Returns: %TRUE if the name exists for the specific rule + * + * Since: 1.0.0 **/ gboolean fu_plugin_has_rule (FuPlugin *self, FuPluginRule rule, const gchar *name) @@ -2193,6 +2605,8 @@ fu_plugin_has_rule (FuPlugin *self, FuPluginRule rule, const gchar *name) * * Any data included here will be sent to the metadata server after user * confirmation. + * + * Since: 1.0.4 **/ void fu_plugin_add_report_metadata (FuPlugin *self, const gchar *key, const gchar *value) @@ -2208,6 +2622,8 @@ fu_plugin_add_report_metadata (FuPlugin *self, const gchar *key, const gchar *va * Returns the list of additional metadata to be added when filing a report. * * Returns: (transfer none): the map of report metadata + * + * Since: 1.0.4 **/ GHashTable * fu_plugin_get_report_metadata (FuPlugin *self) @@ -2255,6 +2671,8 @@ fu_plugin_get_config_value (FuPlugin *self, const gchar *key) * Compares two plugins by their names. * * Returns: 1, 0 or -1 if @plugin1 is greater, equal, or less than @plugin2. + * + * Since: 1.0.8 **/ gint fu_plugin_name_compare (FuPlugin *plugin1, FuPlugin *plugin2) @@ -2272,6 +2690,8 @@ fu_plugin_name_compare (FuPlugin *plugin1, FuPlugin *plugin2) * Compares two plugins by their depsolved order. * * Returns: 1, 0 or -1 if @plugin1 is greater, equal, or less than @plugin2. + * + * Since: 1.0.8 **/ gint fu_plugin_order_compare (FuPlugin *plugin1, FuPlugin *plugin2) @@ -2403,6 +2823,13 @@ fu_plugin_finalize (GObject *object) G_OBJECT_CLASS (fu_plugin_parent_class)->finalize (object); } +/** + * fu_plugin_new: + * + * Creates a new #FuPlugin + * + * Since: 0.8.0 + **/ FuPlugin * fu_plugin_new (void) { diff --git a/src/fu-plugin.h b/src/fu-plugin.h index 52bf44c9a..a72482ee5 100644 --- a/src/fu-plugin.h +++ b/src/fu-plugin.h @@ -109,7 +109,7 @@ void fu_plugin_set_coldplug_delay (FuPlugin *self, guint duration); void fu_plugin_set_device_gtype (FuPlugin *self, GType device_gtype); -void fu_plugin_add_firmware_gtype (FuPlugin *plugin, +void fu_plugin_add_firmware_gtype (FuPlugin *self, const gchar *id, GType gtype); gpointer fu_plugin_cache_lookup (FuPlugin *self, diff --git a/src/fu-progressbar.c b/src/fu-progressbar.c index 8eb9dbd5e..22cb9bcc6 100644 --- a/src/fu-progressbar.c +++ b/src/fu-progressbar.c @@ -200,6 +200,15 @@ fu_progressbar_refresh (FuProgressbar *self, FwupdStatus status, guint percentag } } +/** + * fu_progressbar_set_title: + * @self: A #FuProgressbar + * @title: A string + * + * Sets progressbar title + * + * Since: 0.9.7 + **/ void fu_progressbar_set_title (FuProgressbar *self, const gchar *title) { @@ -266,6 +275,16 @@ fu_progressbar_spin_start (FuProgressbar *self) self->timer_id = g_timeout_add (40, fu_progressbar_spin_cb, self); } +/** + * fu_progressbar_update: + * @self: A #FuProgressbar + * @status: A #FwupdStatus + * @percentage: unsigned integer + * + * Refreshes a progressbar + * + * Since: 0.9.7 + **/ void fu_progressbar_update (FuProgressbar *self, FwupdStatus status, guint percentage) { @@ -314,6 +333,15 @@ fu_progressbar_update (FuProgressbar *self, FwupdStatus status, guint percentage self->percentage = percentage; } +/** + * fu_progressbar_set_interactive: + * @self: A #FuProgressbar + * @interactive: #gboolean + * + * Marks the progressbar as interactive or not + * + * Since: 0.9.7 + **/ void fu_progressbar_set_interactive (FuProgressbar *self, gboolean interactive) { @@ -321,6 +349,15 @@ fu_progressbar_set_interactive (FuProgressbar *self, gboolean interactive) self->interactive = interactive; } +/** + * fu_progressbar_set_length_status: + * @self: A #FuProgressbar + * @len: unsigned integer + * + * Sets the length of the progressbar status + * + * Since: 0.9.7 + **/ void fu_progressbar_set_length_status (FuProgressbar *self, guint len) { @@ -329,6 +366,15 @@ fu_progressbar_set_length_status (FuProgressbar *self, guint len) self->length_status = len; } +/** + * fu_progressbar_set_length_percentage: + * @self: A #FuProgressbar + * @len: unsigned integer + * + * Sets the length of the progressba percentage + * + * Since: 0.9.7 + **/ void fu_progressbar_set_length_percentage (FuProgressbar *self, guint len) { @@ -366,6 +412,13 @@ fu_progressbar_finalize (GObject *obj) G_OBJECT_CLASS (fu_progressbar_parent_class)->finalize (obj); } +/** + * fu_progressbar_new: + * + * Creates a new #FuProgressbar + * + * Since: 0.9.7 + **/ FuProgressbar * fu_progressbar_new (void) { diff --git a/src/fu-quirks.c b/src/fu-quirks.c index 6d97f79a8..3a171cbcc 100644 --- a/src/fu-quirks.c +++ b/src/fu-quirks.c @@ -300,9 +300,9 @@ fu_quirks_lookup_by_id (FuQuirks *self, const gchar *group, const gchar *key) /** * fu_quirks_lookup_by_id_iter: - * @self: A #FuPlugin - * @guid: a GUID - * @iter_cb: A #FuQuirksIter + * @self: A #FuQuirks + * @group: string of group to lookup + * @iter_cb: (scope async): A #FuQuirksIter * @user_data: user data passed to @iter_cb * * Looks up all entries in the hardware database using a GUID value. @@ -370,6 +370,7 @@ fu_quirks_lookup_by_id_iter (FuQuirks *self, const gchar *group, /** * fu_quirks_load: (skip) * @self: A #FuQuirks + * @load_flags: A #FuQuirksLoadFlags * @error: A #GError, or %NULL * * Loads the various files that define the hardware quirks used in plugins. @@ -413,6 +414,8 @@ fu_quirks_finalize (GObject *obj) * Creates a new quirks object. * * Return value: a new #FuQuirks + * + * Since: 1.0.1 **/ FuQuirks * fu_quirks_new (void) diff --git a/src/fu-smbios.c b/src/fu-smbios.c index 9d725bac2..559020213 100644 --- a/src/fu-smbios.c +++ b/src/fu-smbios.c @@ -127,6 +127,8 @@ fu_smbios_setup_from_data (FuSmbios *self, const guint8 *buf, gsize sz, GError * * Reads all the SMBIOS values from a DMI blob. * * Returns: %TRUE for success + * + * Since: 1.0.0 **/ gboolean fu_smbios_setup_from_file (FuSmbios *self, const gchar *filename, GError **error) @@ -228,7 +230,7 @@ fu_smbios_parse_ep64 (FuSmbios *self, const gchar *buf, gsize sz, GError **error } /** - * fu_smbios_setup: + * fu_smbios_setup_from_path: * @self: A #FuSmbios * @path: A path, e.g. `/sys/firmware/dmi/tables` * @error: A #GError or %NULL @@ -236,6 +238,8 @@ fu_smbios_parse_ep64 (FuSmbios *self, const gchar *buf, gsize sz, GError **error * Reads all the SMBIOS values from a specific path. * * Returns: %TRUE for success + * + * Since: 1.0.0 **/ gboolean fu_smbios_setup_from_path (FuSmbios *self, const gchar *path, GError **error) @@ -308,6 +312,8 @@ fu_smbios_setup_from_path (FuSmbios *self, const gchar *path, GError **error) * Reads all the SMBIOS values from the hardware. * * Returns: %TRUE for success + * + * Since: 1.0.0 **/ gboolean fu_smbios_setup (FuSmbios *self, GError **error) @@ -327,6 +333,8 @@ fu_smbios_setup (FuSmbios *self, GError **error) * Dumps the parsed SMBIOS data to a string. * * Returns: a UTF-8 string + * + * Since: 1.0.0 **/ gchar * fu_smbios_to_string (FuSmbios *self) @@ -371,6 +379,8 @@ fu_smbios_get_item_for_type (FuSmbios *self, guint8 type) * Reads a SMBIOS data blob, which includes the SMBIOS section header. * * Returns: (transfer full): a #GBytes, or %NULL if invalid or not found + * + * Since: 1.0.0 **/ GBytes * fu_smbios_get_data (FuSmbios *self, guint8 type, GError **error) @@ -401,6 +411,8 @@ fu_smbios_get_data (FuSmbios *self, guint8 type, GError **error) * https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf * * Returns: a string, or %NULL if invalid or not found + * + * Since: 1.0.0 **/ const gchar * fu_smbios_get_string (FuSmbios *self, guint8 type, guint8 offset, GError **error) @@ -486,6 +498,8 @@ fu_smbios_init (FuSmbios *self) * Creates a new object to parse SMBIOS data. * * Returns: a #FuSmbios + * + * Since: 1.0.0 **/ FuSmbios * fu_smbios_new (void) diff --git a/src/fu-srec-firmware.c b/src/fu-srec-firmware.c index d8e29b945..1cd5b8398 100644 --- a/src/fu-srec-firmware.c +++ b/src/fu-srec-firmware.c @@ -14,6 +14,15 @@ #include "fu-firmware-common.h" #include "fu-srec-firmware.h" +/** + * SECTION:fu-srec-firmware + * @short_description: SREC firmware image + * + * An object that represents a SREC firmware image. + * + * See also: #FuFirmware + */ + struct _FuSrecFirmware { FuFirmware parent_instance; GPtrArray *records; @@ -48,6 +57,18 @@ fu_srec_firmware_record_free (FuSrecFirmwareRecord *rcd) g_free (rcd); } +/** + * fu_srec_firmware_record_new: + * @ln: unsigned integer + * @kind: #FuFirmwareSrecRecordKind + * @addr: unsigned integer + * + * Returns a single firmware record + * + * Returns: (transfer full) (element-type FuSrecFirmwareRecord): records + * + * Since: 1.3.2 + **/ FuSrecFirmwareRecord * fu_srec_firmware_record_new (guint ln, FuFirmareSrecRecordKind kind, guint32 addr) { @@ -372,6 +393,13 @@ fu_srec_firmware_class_init (FuSrecFirmwareClass *klass) klass_firmware->tokenize = fu_srec_firmware_tokenize; } +/** + * fu_srec_firmware_new: + * + * Creates a new #FuFirmware of sub type Srec + * + * Since: 1.3.2 + **/ FuFirmware * fu_srec_firmware_new (void) { diff --git a/src/fu-test.c b/src/fu-test.c index 9327cb91d..8968c744e 100644 --- a/src/fu-test.c +++ b/src/fu-test.c @@ -26,6 +26,14 @@ fu_test_hang_check_cb (gpointer user_data) return G_SOURCE_REMOVE; } +/** + * fu_test_loop_run_with_timeout: + * @timeout_ms: The timeout in milliseconds + * + * Quits the test loop after a timeout + * + * Since: 0.9.1 + **/ void fu_test_loop_run_with_timeout (guint timeout_ms) { @@ -36,6 +44,13 @@ fu_test_loop_run_with_timeout (guint timeout_ms) g_main_loop_run (_test_loop); } +/** + * fu_test_loop_quit: + * + * Quits the test loop + * + * Since: 0.9.1 + **/ void fu_test_loop_quit (void) { @@ -50,6 +65,17 @@ fu_test_loop_quit (void) } } +/** + * fu_test_get_filename: + * @testdatadirs: semicolon delimitted list of directories + * @filename: the filename to look for + * + * Returns the first path that matches filename in testdatadirs + * + * Returns: (transfer full): full path to file or NULL + * + * Since: 0.9.1 + **/ gchar * fu_test_get_filename (const gchar *testdatadirs, const gchar *filename) { @@ -65,6 +91,18 @@ fu_test_get_filename (const gchar *testdatadirs, const gchar *filename) return NULL; } +/** + * fu_test_compare_lines: + * @txt1: First line to compare + * @txt2: second line to compare + * @error: A #GError or #NULL + * + * Compare two lines. + * + * Returns: #TRUE if identical, #FALSE if not (diff is set in error) + * + * Since: 1.0.4 + **/ gboolean fu_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error) { diff --git a/src/fu-udev-device.c b/src/fu-udev-device.c index 558d83246..b04445237 100644 --- a/src/fu-udev-device.c +++ b/src/fu-udev-device.c @@ -345,6 +345,17 @@ fu_udev_device_set_dev (FuUdevDevice *self, GUdevDevice *udev_device) #endif } +/** + * fu_udev_device_get_slot_depth: + * @self: A #FuUdevDevice + * @subsystem: a subsystem + * + * Determine how far up a chain a given device is + * + * Returns: unsigned integer + * + * Since: 1.2.4 + **/ guint fu_udev_device_get_slot_depth (FuUdevDevice *self, const gchar *subsystem) { From 4a7bb8d98a69580cdc4ae8abd0bf83bfc56c31d2 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 25 Nov 2019 19:52:57 -0600 Subject: [PATCH 38/74] trivial: fu-udev-device: remove a prototype that was missed in b3d4d2ff --- src/fu-udev-device.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fu-udev-device.h b/src/fu-udev-device.h index 90daa3319..71bc670ad 100644 --- a/src/fu-udev-device.h +++ b/src/fu-udev-device.h @@ -45,7 +45,6 @@ guint fu_udev_device_get_slot_depth (FuUdevDevice *self, gboolean fu_udev_device_set_physical_id (FuUdevDevice *self, const gchar *subsystem, GError **error); -void fu_udev_device_dump (FuUdevDevice *self); void fu_udev_device_set_readonly (FuUdevDevice *self, gboolean readonly); From f1a4d870637640c98cbe02bc39de656b423a5141 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 25 Nov 2019 19:54:31 -0600 Subject: [PATCH 39/74] Add missing documentation from the plugin interface Also update the structure as the documentation doesn't only describe libfwupd. --- contrib/ci/ubuntu.sh | 2 +- contrib/fwupd.spec.in | 2 +- .../libfwupd-docs.xml => fwupd-docs.xml} | 18 ++++++++++++++++++ docs/libfwupd/clean.sh | 5 ----- docs/libfwupd/libfwupd.types | 6 ------ docs/libfwupd/meson.build | 11 ----------- docs/meson.build | 12 +++++++++++- 7 files changed, 31 insertions(+), 25 deletions(-) rename docs/{libfwupd/libfwupd-docs.xml => fwupd-docs.xml} (94%) delete mode 100644 docs/libfwupd/clean.sh delete mode 100644 docs/libfwupd/libfwupd.types delete mode 100644 docs/libfwupd/meson.build diff --git a/contrib/ci/ubuntu.sh b/contrib/ci/ubuntu.sh index 8be1673ff..b0dcddcd0 100755 --- a/contrib/ci/ubuntu.sh +++ b/contrib/ci/ubuntu.sh @@ -15,7 +15,7 @@ ninja -C build test -v #make docs available outside of docker ninja -C build install -v mkdir -p dist/docs -cp build/docs/libfwupd/* dist/docs -R +cp build/docs/* dist/docs -R #run static analysis (these mostly won't be critical) ninja -C build scan-build -v diff --git a/contrib/fwupd.spec.in b/contrib/fwupd.spec.in index 5692e2821..60f9c6770 100644 --- a/contrib/fwupd.spec.in +++ b/contrib/fwupd.spec.in @@ -370,7 +370,7 @@ rm ${RPM_BUILD_ROOT}%{_sbindir}/flashrom %files devel %{_datadir}/gir-1.0/Fwupd-2.0.gir -%{_datadir}/gtk-doc/html/libfwupd +%{_datadir}/gtk-doc/html/fwupd %{_datadir}/vala/vapi %{_includedir}/fwupd-1 %{_libdir}/libfwupd*.so diff --git a/docs/libfwupd/libfwupd-docs.xml b/docs/fwupd-docs.xml similarity index 94% rename from docs/libfwupd/libfwupd-docs.xml rename to docs/fwupd-docs.xml index ec27ea641..1852fb312 100644 --- a/docs/libfwupd/libfwupd-docs.xml +++ b/docs/fwupd-docs.xml @@ -41,13 +41,31 @@ Functionality available to plugins. + + + + + + + + + + + + + + + + + + diff --git a/docs/libfwupd/clean.sh b/docs/libfwupd/clean.sh deleted file mode 100644 index 87ebedbe6..000000000 --- a/docs/libfwupd/clean.sh +++ /dev/null @@ -1,5 +0,0 @@ -rm -f *.txt -rm -rf html/ -rm -rf xml/ -rm -rf tmpl/ -rm -f *.stamp diff --git a/docs/libfwupd/libfwupd.types b/docs/libfwupd/libfwupd.types deleted file mode 100644 index 0fbcf8158..000000000 --- a/docs/libfwupd/libfwupd.types +++ /dev/null @@ -1,6 +0,0 @@ -fwupd_client_get_type -fwupd_device_get_type -fwupd_quirks_get_type -fwupd_release_get_type -fwupd_remote_get_type -fwupd_result_get_type diff --git a/docs/libfwupd/meson.build b/docs/libfwupd/meson.build deleted file mode 100644 index a69b5bab9..000000000 --- a/docs/libfwupd/meson.build +++ /dev/null @@ -1,11 +0,0 @@ -gnome.gtkdoc( - 'libfwupd', - src_dir : [ - join_paths(meson.source_root(), 'libfwupd'), - join_paths(meson.source_root(), 'src'), - join_paths(meson.build_root(), 'libfwupd'), - join_paths(meson.build_root(), 'src'), - ], - main_xml : 'libfwupd-docs.xml', - install : true -) diff --git a/docs/meson.build b/docs/meson.build index 378ee9ffc..ffad58d47 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -1 +1,11 @@ -subdir('libfwupd') +gnome.gtkdoc( + 'fwupd', + src_dir : [ + join_paths(meson.source_root(), 'libfwupd'), + join_paths(meson.source_root(), 'src'), + join_paths(meson.build_root(), 'libfwupd'), + join_paths(meson.build_root(), 'src'), + ], + main_xml : 'fwupd-docs.xml', + install : true +) From 28e8b953d05e861bd971a15612948d26c674a92b Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 26 Nov 2019 08:25:45 +0000 Subject: [PATCH 40/74] Revert "synaptics-rmi: Use the build ID as the version number to match the vendor tool" This reverts commit 28ab968cbfd4616458026e76d482c58561a328da as Synaptics deviced that vmajor and vminor would actually be useful. --- plugins/synaptics-rmi/fu-synaptics-rmi-device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/synaptics-rmi/fu-synaptics-rmi-device.c b/plugins/synaptics-rmi/fu-synaptics-rmi-device.c index fb13197d7..c480e7181 100644 --- a/plugins/synaptics-rmi/fu-synaptics-rmi-device.c +++ b/plugins/synaptics-rmi/fu-synaptics-rmi-device.c @@ -574,8 +574,11 @@ fu_synaptics_rmi_device_setup (FuDevice *device, GError **error) } /* set versions */ - fw_ver = g_strdup_printf ("%u", priv->flash.build_id); - fu_device_set_version (device, fw_ver, FWUPD_VERSION_FORMAT_PLAIN); + fw_ver = g_strdup_printf ("%u.%u.%u", + f01_basic->data[2], + f01_basic->data[3], + priv->flash.build_id); + fu_device_set_version (device, fw_ver, FWUPD_VERSION_FORMAT_TRIPLET); bl_ver = g_strdup_printf ("%u.0", priv->flash.bootloader_id[1]); fu_device_set_version_bootloader (device, bl_ver); From 5c508de1731cf95c36fa1d0ffe7848336d580606 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:57:34 +0000 Subject: [PATCH 41/74] trivial: Allow compiling without This also allows us to add a Win32 implementation if required in the future. --- libfwupd/fwupd-self-test.c | 7 +++++++ meson.build | 3 +++ plugins/uefi/fu-uefi-device.c | 5 +++-- plugins/uefi/fu-uefi-vars.c | 3 +-- src/fu-common.c | 27 +++++++++++++++++++++++++++ src/fu-common.h | 2 ++ src/fu-engine.c | 5 ++--- src/fu-test.c | 3 +-- 8 files changed, 46 insertions(+), 9 deletions(-) diff --git a/libfwupd/fwupd-self-test.c b/libfwupd/fwupd-self-test.c index 305e89d42..cc56c8cc3 100644 --- a/libfwupd/fwupd-self-test.c +++ b/libfwupd/fwupd-self-test.c @@ -7,7 +7,9 @@ #include "config.h" #include +#ifdef HAVE_FNMATCH_H #include +#endif #include "fwupd-client.h" #include "fwupd-common.h" @@ -27,8 +29,13 @@ fu_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error) return TRUE; /* matches a pattern */ +#ifdef HAVE_FNMATCH_H if (fnmatch (txt2, txt1, FNM_NOESCAPE) == 0) return TRUE; +#else + if (g_strcmp0 (txt1, txt2) == 0) + return TRUE; +#endif /* save temp files and diff them */ if (!g_file_set_contents ("/tmp/a", txt1, -1, error)) diff --git a/meson.build b/meson.build index a37c1e7b8..00566d376 100644 --- a/meson.build +++ b/meson.build @@ -239,6 +239,9 @@ endif if cc.has_header('poll.h') conf.set('HAVE_POLL_H', '1') endif +if cc.has_header('fnmatch.h') + conf.set('HAVE_FNMATCH_H', '1') +endif if cc.has_function('getuid') conf.set('HAVE_GETUID', '1') endif diff --git a/plugins/uefi/fu-uefi-device.c b/plugins/uefi/fu-uefi-device.c index c444de6aa..4c085316b 100644 --- a/plugins/uefi/fu-uefi-device.c +++ b/plugins/uefi/fu-uefi-device.c @@ -10,10 +10,11 @@ #include #include #include -#include #include "fu-device-metadata.h" +#include "fu-common.h" + #include "fu-uefi-common.h" #include "fu-uefi-device.h" #include "fu-uefi-devpath.h" @@ -462,7 +463,7 @@ fu_uefi_device_cleanup_esp (FuDevice *device, GError **error) pattern = g_build_filename (esp_path, "EFI/*/fw/fwupd-*.cap", NULL); for (guint i = 0; i < files->len; i++) { const gchar *fn = g_ptr_array_index (files, i); - if (fnmatch (pattern, fn, 0) == 0) { + if (fu_common_fnmatch (pattern, fn)) { g_autoptr(GFile) file = g_file_new_for_path (fn); g_debug ("deleting %s", fn); if (!g_file_delete (file, NULL, error)) diff --git a/plugins/uefi/fu-uefi-vars.c b/plugins/uefi/fu-uefi-vars.c index 7bbeb8a2c..2bf304acf 100644 --- a/plugins/uefi/fu-uefi-vars.c +++ b/plugins/uefi/fu-uefi-vars.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -154,7 +153,7 @@ fu_uefi_vars_delete_with_glob (const gchar *guid, const gchar *name_glob, GError return FALSE; nameguid_glob = g_strdup_printf ("%s-%s", name_glob, guid); while ((fn = g_dir_read_name (dir)) != NULL) { - if (fnmatch (nameguid_glob, fn, 0) == 0) { + if (fu_common_fnmatch (nameguid_glob, fn)) { g_autofree gchar *keyfn = g_build_filename (efivardir, fn, NULL); g_autoptr(GFile) file = g_file_new_for_path (keyfn); if (!fu_uefi_vars_set_immutable (keyfn, FALSE, NULL, error)) { diff --git a/src/fu-common.c b/src/fu-common.c index fb4b93a4c..2556bd03c 100644 --- a/src/fu-common.c +++ b/src/fu-common.c @@ -11,6 +11,10 @@ #include #include +#ifdef HAVE_FNMATCH_H +#include +#endif + #include #include #include @@ -1623,6 +1627,29 @@ fu_common_realpath (const gchar *filename, GError **error) return g_strdup (full_tmp); } +/** + * fu_common_fnmatch: + * @pattern: a glob pattern, e.g. `*foo*` + * @str: a string to match against the pattern, e.g. `bazfoobar` + * + * Matches a string against a glob pattern. + * + * Return value: %TRUE if the string matched + * + * Since: 1.3.5 + **/ +gboolean +fu_common_fnmatch (const gchar *pattern, const gchar *str) +{ + g_return_val_if_fail (pattern != NULL, FALSE); + g_return_val_if_fail (str != NULL, FALSE); +#ifdef HAVE_FNMATCH_H + return fnmatch (pattern, str, FNM_NOESCAPE) == 0; +#else + return g_strcmp0 (pattern, str) == 0; +#endif +} + /** * fu_common_strnsplit: * @str: a string to split diff --git a/src/fu-common.h b/src/fu-common.h index 5bc1b3421..6d744774d 100644 --- a/src/fu-common.h +++ b/src/fu-common.h @@ -89,6 +89,8 @@ gboolean fu_common_spawn_sync (const gchar * const *argv, gchar *fu_common_get_path (FuPathKind path_kind); gchar *fu_common_realpath (const gchar *filename, GError **error); +gboolean fu_common_fnmatch (const gchar *pattern, + const gchar *str); gboolean fu_common_rmtree (const gchar *directory, GError **error); GPtrArray *fu_common_get_files_recursive (const gchar *path, diff --git a/src/fu-engine.c b/src/fu-engine.c index 0fa154974..d583abe16 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -14,7 +14,6 @@ #ifdef HAVE_GUDEV #include #endif -#include #include #ifdef HAVE_UTSNAME_H #include @@ -1018,7 +1017,7 @@ fu_engine_require_vercmp (XbNode *req, const gchar *version, GError **error) rc = fu_common_vercmp (version, version_req); ret = rc >= 0; } else if (g_strcmp0 (tmp, "glob") == 0) { - ret = fnmatch (version_req, version, 0) == 0; + ret = fu_common_fnmatch (version_req, version); } else if (g_strcmp0 (tmp, "regex") == 0) { ret = g_regex_match_simple (version_req, version, 0, 0); } else { @@ -4331,7 +4330,7 @@ fu_engine_is_plugin_name_whitelisted (FuEngine *self, const gchar *name) return TRUE; for (guint i = 0; i < self->plugin_filter->len; i++) { const gchar *name_tmp = g_ptr_array_index (self->plugin_filter, i); - if (fnmatch (name_tmp, name, 0) == 0) + if (fu_common_fnmatch (name_tmp, name)) return TRUE; } return FALSE; diff --git a/src/fu-test.c b/src/fu-test.c index 8968c744e..5a16510c4 100644 --- a/src/fu-test.c +++ b/src/fu-test.c @@ -10,7 +10,6 @@ #include #include -#include #include "fu-test.h" #include "fu-common.h" @@ -113,7 +112,7 @@ fu_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error) return TRUE; /* matches a pattern */ - if (fnmatch (txt2, txt1, FNM_NOESCAPE) == 0) + if (fu_common_fnmatch (txt2, txt1)) return TRUE; /* save temp files and diff them */ From 019a1bc2b02f81181e463d69229485173d15d74d Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 26 Nov 2019 10:19:33 +0000 Subject: [PATCH 42/74] trivial: Untangle FuHistory from FuPlugin This will allow us to export FuPlugin in the future without dragging in the private fu-history.h too. --- docs/fwupd-docs.xml | 1 - src/fu-engine.c | 176 +++++++++++++++++++++++++++++++++++++++- src/fu-engine.h | 6 ++ src/fu-plugin-private.h | 6 -- src/fu-plugin.c | 175 +-------------------------------------- src/fu-self-test.c | 15 +++- 6 files changed, 192 insertions(+), 187 deletions(-) diff --git a/docs/fwupd-docs.xml b/docs/fwupd-docs.xml index 1852fb312..095aa5161 100644 --- a/docs/fwupd-docs.xml +++ b/docs/fwupd-docs.xml @@ -54,7 +54,6 @@ - diff --git a/src/fu-engine.c b/src/fu-engine.c index d583abe16..184f0bc00 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -18,6 +18,7 @@ #ifdef HAVE_UTSNAME_H #include #endif +#include #include "fwupd-common-private.h" #include "fwupd-enums-private.h" @@ -1612,6 +1613,143 @@ fu_engine_is_running_offline (FuEngine *self) #endif } +static gboolean +fu_engine_offline_setup (GError **error) +{ + gint rc; + g_autofree gchar *filename = NULL; + g_autofree gchar *symlink_target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG); + g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER); + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + /* does already exist */ + filename = fu_common_realpath (trigger, NULL); + if (g_strcmp0 (filename, symlink_target) == 0) { + g_debug ("%s already points to %s, skipping creation", + trigger, symlink_target); + return TRUE; + } + + /* create symlink for the systemd-system-update-generator */ + rc = symlink (symlink_target, trigger); + if (rc < 0) { + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_INTERNAL, + "Failed to create symlink %s to %s: %s", + trigger, symlink_target, strerror (errno)); + return FALSE; + } + return TRUE; +} + +static gboolean +fu_engine_offline_invalidate (GError **error) +{ + g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER); + g_autoptr(GError) error_local = NULL; + g_autoptr(GFile) file1 = NULL; + + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + + file1 = g_file_new_for_path (trigger); + if (!g_file_query_exists (file1, NULL)) + return TRUE; + if (!g_file_delete (file1, NULL, &error_local)) { + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_INTERNAL, + "Cannot delete %s: %s", + trigger, + error_local->message); + return FALSE; + } + return TRUE; +} + +/** + * fu_engine_schedule_update: + * @self: a #FuEngine + * @device: a #FuDevice + * @release: A #FwupdRelease + * @blob_cab: A #GBytes + * @flags: #FwupdInstallFlags + * @error: A #GError or NULL + * + * Schedule an offline update for the device + * + * Returns: #TRUE for success, #FALSE for failure + * + * Since: 1.3.5 + **/ +gboolean +fu_engine_schedule_update (FuEngine *self, + FuDevice *device, + FwupdRelease *release, + GBytes *blob_cab, + FwupdInstallFlags flags, + GError **error) +{ + gchar tmpname[] = {"XXXXXX.cab"}; + g_autofree gchar *dirname = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(FuHistory) history = NULL; + g_autoptr(GFile) file = NULL; + + /* id already exists */ + history = fu_history_new (); + if ((flags & FWUPD_INSTALL_FLAG_FORCE) == 0) { + g_autoptr(FuDevice) res_tmp = NULL; + res_tmp = fu_history_get_device_by_id (history, fu_device_get_id (device), NULL); + if (res_tmp != NULL && + fu_device_get_update_state (res_tmp) == FWUPD_UPDATE_STATE_PENDING) { + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_ALREADY_PENDING, + "%s is already scheduled to be updated", + fu_device_get_id (device)); + return FALSE; + } + } + + /* create directory */ + dirname = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG); + file = g_file_new_for_path (dirname); + if (!g_file_query_exists (file, NULL)) { + if (!g_file_make_directory_with_parents (file, NULL, error)) + return FALSE; + } + + /* get a random filename */ + for (guint i = 0; i < 6; i++) + tmpname[i] = (gchar) g_random_int_range ('A', 'Z'); + filename = g_build_filename (dirname, tmpname, NULL); + + /* just copy to the temp file */ + fu_device_set_status (device, FWUPD_STATUS_SCHEDULING); + if (!g_file_set_contents (filename, + g_bytes_get_data (blob_cab, NULL), + (gssize) g_bytes_get_size (blob_cab), + error)) + return FALSE; + + /* schedule for next boot */ + g_debug ("schedule %s to be installed to %s on next boot", + filename, fu_device_get_id (device)); + fwupd_release_set_filename (release, filename); + + /* add to database */ + fu_device_add_flag (device, FWUPD_DEVICE_FLAG_NEEDS_REBOOT); + fu_device_set_update_state (device, FWUPD_UPDATE_STATE_PENDING); + if (!fu_history_add_device (history, device, release, error)) + return FALSE; + + /* next boot we run offline */ + fu_device_set_progress (device, 100); + return fu_engine_offline_setup (error); +} + /** * fu_engine_install: * @self: A #FuEngine @@ -1745,8 +1883,8 @@ fu_engine_install (FuEngine *self, if (release_tmp == NULL) return FALSE; fwupd_release_set_version (release_tmp, version_rel); - return fu_plugin_runner_schedule_update (plugin, device, release_tmp, - blob_cab, flags, error); + return fu_engine_schedule_update (self, device, release_tmp, + blob_cab, flags, error); } /* add device to database */ @@ -2129,6 +2267,11 @@ fu_engine_update (FuEngine *self, FuPlugin *plugin; g_autofree gchar *str = NULL; g_autoptr(FuDevice) device = NULL; + g_autoptr(FuDevice) device_pending = NULL; + + /* cancel the pending action */ + if (!fu_engine_offline_invalidate (error)) + return FALSE; /* the device and plugin both may have changed */ device = fu_engine_get_device_by_id (self, device_id, error); @@ -2136,6 +2279,7 @@ fu_engine_update (FuEngine *self, g_prefix_error (error, "failed to get device after detach: "); return FALSE; } + device_pending = fu_history_get_device_by_id (self->history, device_id, NULL); str = fu_device_to_string (device); g_debug ("performing update on %s", str); plugin = fu_plugin_list_find_by_name (self->plugin_list, @@ -2160,6 +2304,34 @@ fu_engine_update (FuEngine *self, } return FALSE; } + + /* cleanup */ + if (device_pending != NULL) { + const gchar *tmp; + FwupdRelease *release; + + /* update history database */ + fu_device_set_update_state (device, FWUPD_UPDATE_STATE_SUCCESS); + if (!fu_history_modify_device (self->history, device, error)) + return FALSE; + + /* delete cab file */ + release = fu_device_get_release_default (device_pending); + tmp = fwupd_release_get_filename (release); + if (tmp != NULL && g_str_has_prefix (tmp, FWUPD_LIBEXECDIR)) { + g_autoptr(GError) error_delete = NULL; + g_autoptr(GFile) file = NULL; + file = g_file_new_for_path (tmp); + if (!g_file_delete (file, NULL, &error_delete)) { + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_INVALID_FILE, + "Failed to delete %s: %s", + tmp, error_delete->message); + return FALSE; + } + } + } return TRUE; } diff --git a/src/fu-engine.h b/src/fu-engine.h index fb14fd743..2ae60b542 100644 --- a/src/fu-engine.h +++ b/src/fu-engine.h @@ -168,3 +168,9 @@ void fu_engine_set_silo (FuEngine *self, XbSilo *silo); XbNode *fu_engine_get_component_by_guids (FuEngine *self, FuDevice *device); +gboolean fu_engine_schedule_update (FuEngine *self, + FuDevice *device, + FwupdRelease *release, + GBytes *blob_cab, + FwupdInstallFlags flags, + GError **error); diff --git a/src/fu-plugin-private.h b/src/fu-plugin-private.h index 7a0c85af7..54da55bbd 100644 --- a/src/fu-plugin-private.h +++ b/src/fu-plugin-private.h @@ -111,12 +111,6 @@ gboolean fu_plugin_runner_clear_results (FuPlugin *self, gboolean fu_plugin_runner_get_results (FuPlugin *self, FuDevice *device, GError **error); -gboolean fu_plugin_runner_schedule_update (FuPlugin *self, - FuDevice *device, - FwupdRelease *release, - GBytes *blob_cab, - FwupdInstallFlags flags, - GError **error); gint fu_plugin_name_compare (FuPlugin *plugin1, FuPlugin *plugin2); gint fu_plugin_order_compare (FuPlugin *plugin1, diff --git a/src/fu-plugin.c b/src/fu-plugin.c index 80e57cc26..919693fd1 100644 --- a/src/fu-plugin.c +++ b/src/fu-plugin.c @@ -19,7 +19,6 @@ #include "fu-device-private.h" #include "fu-plugin-private.h" -#include "fu-history.h" #include "fu-mutex.h" /** @@ -1123,62 +1122,6 @@ fu_plugin_runner_startup (FuPlugin *self, GError **error) return TRUE; } -static gboolean -fu_plugin_runner_offline_invalidate (GError **error) -{ - g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER); - g_autoptr(GError) error_local = NULL; - g_autoptr(GFile) file1 = NULL; - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - file1 = g_file_new_for_path (trigger); - if (!g_file_query_exists (file1, NULL)) - return TRUE; - if (!g_file_delete (file1, NULL, &error_local)) { - g_set_error (error, - FWUPD_ERROR, - FWUPD_ERROR_INTERNAL, - "Cannot delete %s: %s", - trigger, - error_local->message); - return FALSE; - } - return TRUE; -} - -static gboolean -fu_plugin_runner_offline_setup (GError **error) -{ - gint rc; - g_autofree gchar *filename = NULL; - g_autofree gchar *symlink_target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG); - g_autofree gchar *trigger = fu_common_get_path (FU_PATH_KIND_OFFLINE_TRIGGER); - - g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - - /* does already exist */ - filename = fu_common_realpath (trigger, NULL); - if (g_strcmp0 (filename, symlink_target) == 0) { - g_debug ("%s already points to %s, skipping creation", - trigger, symlink_target); - return TRUE; - } - - /* create symlink for the systemd-system-update-generator */ - rc = symlink (symlink_target, trigger); - if (rc < 0) { - g_set_error (error, - FWUPD_ERROR, - FWUPD_ERROR_INTERNAL, - "Failed to create symlink %s to %s: %s", - trigger, - "/var/lib", strerror (errno)); - return FALSE; - } - return TRUE; -} - static gboolean fu_plugin_runner_device_generic (FuPlugin *self, FuDevice *device, const gchar *symbol_name, @@ -2007,88 +1950,6 @@ fu_plugin_runner_device_register (FuPlugin *self, FuDevice *device) } } -/** - * fu_plugin_runner_schedule_update: - * @self: a #FuPlugin - * @device: a #FuDevice - * @release: A #FwupdRelease - * @blob_cab: A #GBytes - * @flags: #FwupdInstallFlags - * @error: A #GError or NULL - * - * Schedule an offline update with the plugin - * - * Returns: #TRUE for success, #FALSE for failure - * - * Since: 0.8.0 - **/ -gboolean -fu_plugin_runner_schedule_update (FuPlugin *self, - FuDevice *device, - FwupdRelease *release, - GBytes *blob_cab, - FwupdInstallFlags flags, - GError **error) -{ - gchar tmpname[] = {"XXXXXX.cab"}; - g_autofree gchar *dirname = NULL; - g_autofree gchar *filename = NULL; - g_autoptr(FuHistory) history = NULL; - g_autoptr(GFile) file = NULL; - - /* id already exists */ - history = fu_history_new (); - if ((flags & FWUPD_INSTALL_FLAG_FORCE) == 0) { - g_autoptr(FuDevice) res_tmp = NULL; - res_tmp = fu_history_get_device_by_id (history, fu_device_get_id (device), NULL); - if (res_tmp != NULL && - fu_device_get_update_state (res_tmp) == FWUPD_UPDATE_STATE_PENDING) { - g_set_error (error, - FWUPD_ERROR, - FWUPD_ERROR_ALREADY_PENDING, - "%s is already scheduled to be updated", - fu_device_get_id (device)); - return FALSE; - } - } - - /* create directory */ - dirname = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG); - file = g_file_new_for_path (dirname); - if (!g_file_query_exists (file, NULL)) { - if (!g_file_make_directory_with_parents (file, NULL, error)) - return FALSE; - } - - /* get a random filename */ - for (guint i = 0; i < 6; i++) - tmpname[i] = (gchar) g_random_int_range ('A', 'Z'); - filename = g_build_filename (dirname, tmpname, NULL); - - /* just copy to the temp file */ - fu_device_set_status (device, FWUPD_STATUS_SCHEDULING); - if (!g_file_set_contents (filename, - g_bytes_get_data (blob_cab, NULL), - (gssize) g_bytes_get_size (blob_cab), - error)) - return FALSE; - - /* schedule for next boot */ - g_debug ("schedule %s to be installed to %s on next boot", - filename, fu_device_get_id (device)); - fwupd_release_set_filename (release, filename); - - /* add to database */ - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_NEEDS_REBOOT); - fu_device_set_update_state (device, FWUPD_UPDATE_STATE_PENDING); - if (!fu_history_add_device (history, device, release, error)) - return FALSE; - - /* next boot we run offline */ - fu_device_set_progress (device, 100); - return fu_plugin_runner_offline_setup (error); -} - /** * fu_plugin_runner_verify: * @self: a #FuPlugin @@ -2281,8 +2142,6 @@ fu_plugin_runner_update (FuPlugin *self, { FuPluginPrivate *priv = GET_PRIVATE (self); FuPluginUpdateFunc update_func; - g_autoptr(FuHistory) history = NULL; - g_autoptr(FuDevice) device_pending = NULL; g_autoptr(GError) error_local = NULL; /* not enabled */ @@ -2304,13 +2163,7 @@ fu_plugin_runner_update (FuPlugin *self, return fu_plugin_device_write_firmware (self, device, blob_fw, flags, error); } - /* cancel the pending action */ - if (!fu_plugin_runner_offline_invalidate (error)) - return FALSE; - /* online */ - history = fu_history_new (); - device_pending = fu_history_get_device_by_id (history, fu_device_get_id (device), NULL); if (!update_func (self, device, blob_fw, flags, &error_local)) { if (error_local == NULL) { g_critical ("unset error in plugin %s for update()", @@ -2333,33 +2186,7 @@ fu_plugin_runner_update (FuPlugin *self, g_ptr_array_set_size (checksums, 0); } - /* cleanup */ - if (device_pending != NULL) { - const gchar *tmp; - FwupdRelease *release; - - /* update history database */ - fu_device_set_update_state (device, FWUPD_UPDATE_STATE_SUCCESS); - if (!fu_history_modify_device (history, device, error)) - return FALSE; - - /* delete cab file */ - release = fu_device_get_release_default (device_pending); - tmp = fwupd_release_get_filename (release); - if (tmp != NULL && g_str_has_prefix (tmp, FWUPD_LIBEXECDIR)) { - g_autoptr(GError) error_delete = NULL; - g_autoptr(GFile) file = NULL; - file = g_file_new_for_path (tmp); - if (!g_file_delete (file, NULL, &error_delete)) { - g_set_error (error, - FWUPD_ERROR, - FWUPD_ERROR_INVALID_FILE, - "Failed to delete %s: %s", - tmp, error_delete->message); - return FALSE; - } - } - } + /* success */ return TRUE; } diff --git a/src/fu-self-test.c b/src/fu-self-test.c index 488555564..f34c29dbc 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -2296,10 +2296,15 @@ fu_plugin_module_func (void) g_autoptr(FuDevice) device = NULL; g_autoptr(FuDevice) device2 = NULL; g_autoptr(FuDevice) device3 = NULL; + g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE); g_autoptr(FuHistory) history = NULL; g_autoptr(FuPlugin) plugin = NULL; g_autoptr(GBytes) blob_cab = NULL; g_autoptr(GMappedFile) mapped_file = NULL; + g_autoptr(XbSilo) silo_empty = xb_silo_new (); + + /* no metadata in daemon */ + fu_engine_set_silo (engine, silo_empty); /* create a fake device */ plugin = fu_plugin_new (); @@ -2342,8 +2347,8 @@ fu_plugin_module_func (void) blob_cab = g_mapped_file_get_bytes (mapped_file); release = fu_device_get_release_default (device); fwupd_release_set_version (release, "1.2.3"); - ret = fu_plugin_runner_schedule_update (plugin, device, release, blob_cab, - FWUPD_INSTALL_FLAG_NONE, &error); + ret = fu_engine_schedule_update (engine, device, release, blob_cab, + FWUPD_INSTALL_FLAG_NONE, &error); g_assert_no_error (error); g_assert (ret); g_assert_cmpint (cnt, ==, 1); @@ -2368,8 +2373,10 @@ fu_plugin_module_func (void) pending_cap = g_strdup (fwupd_release_get_filename (release)); /* lets do this online */ - ret = fu_plugin_runner_update (plugin, device, blob_cab, - FWUPD_INSTALL_FLAG_NONE, &error); + fu_engine_add_device (engine, device); + fu_engine_add_plugin (engine, plugin); + ret = fu_engine_install_blob (engine, device, blob_cab, + FWUPD_INSTALL_FLAG_NONE, &error); g_assert_no_error (error); g_assert (ret); g_assert_cmpint (cnt, ==, 4); From 11d10a00e7dbf490ac4d1fb0fea1c4dcf79ab86a Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 23 Nov 2019 10:47:19 +0000 Subject: [PATCH 43/74] Always use the more portable 3-arg form for open() --- .../fu-plugin-thunderbolt-power.c | 2 +- src/fu-udev-device.c | 31 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c b/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c index 75f6757c7..63b038cc0 100644 --- a/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c +++ b/plugins/thunderbolt-power/fu-plugin-thunderbolt-power.c @@ -187,7 +187,7 @@ fu_plugin_thunderbolt_power_kernel_force_power (FuPlugin *plugin, gboolean enabl return FALSE; } g_debug ("Setting force power to %d using kernel", enable); - fd = g_open (data->force_path, O_WRONLY); + fd = g_open (data->force_path, O_WRONLY, 0); if (fd == -1) { g_set_error (error, FWUPD_ERROR, diff --git a/src/fu-udev-device.c b/src/fu-udev-device.c index b04445237..618f1b607 100644 --- a/src/fu-udev-device.c +++ b/src/fu-udev-device.c @@ -714,15 +714,28 @@ fu_udev_device_open (FuDevice *device, GError **error) /* open device */ if (priv->device_file != NULL) { - priv->fd = g_open (priv->device_file, priv->readonly ? O_RDONLY : O_RDWR); - if (priv->fd < 0) { - g_set_error (error, - G_IO_ERROR, - G_IO_ERROR_FAILED, - "failed to open %s: %s", - priv->device_file, - strerror (errno)); - return FALSE; + if (priv->readonly) { + priv->fd = g_open (priv->device_file, O_RDONLY, 0); + if (priv->fd < 0) { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + "failed to open %s for reading: %s", + priv->device_file, + strerror (errno)); + return FALSE; + } + } else { + priv->fd = g_open (priv->device_file, O_RDWR, 0); + if (priv->fd < 0) { + g_set_error (error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + "failed to open %s: %s", + priv->device_file, + strerror (errno)); + return FALSE; + } } } From ed7a549b3a8936eebb1247234f9ff3add1aac2b2 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 26 Nov 2019 13:15:40 +0000 Subject: [PATCH 44/74] trivial: Include the correct header for S_IRWXU --- src/fu-io-channel.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fu-io-channel.c b/src/fu-io-channel.c index 3a68f67fd..f69fd1955 100644 --- a/src/fu-io-channel.c +++ b/src/fu-io-channel.c @@ -16,6 +16,7 @@ #include #endif #include +#include #include "fwupd-error.h" #include "fu-common.h" From f3880bce26149c54878b013766d04b62770aa157 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 26 Nov 2019 12:02:30 +0000 Subject: [PATCH 45/74] trivial: Add some optional debugging when hotplugging devices --- src/fu-engine.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/fu-engine.c b/src/fu-engine.c index 184f0bc00..a6b10ecb9 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -4265,6 +4265,12 @@ fu_engine_udev_device_add (FuEngine *self, GUdevDevice *udev_device) g_autoptr(GError) error_local = NULL; g_autoptr(GPtrArray) possible_plugins = NULL; + /* debug */ + if (g_getenv ("FWUPD_PROBE_VERBOSE") != NULL) { + g_debug ("UDEV %s added", + g_udev_device_get_sysfs_path (udev_device)); + } + /* add any extra quirks */ fu_device_set_quirks (FU_DEVICE (device), self->quirks); if (!fu_device_probe (FU_DEVICE (device), &error_local)) { @@ -4310,6 +4316,12 @@ fu_engine_udev_device_remove (FuEngine *self, GUdevDevice *udev_device) { g_autoptr(GPtrArray) devices = NULL; + /* debug */ + if (g_getenv ("FWUPD_PROBE_VERBOSE") != NULL) { + g_debug ("UDEV %s removed", + g_udev_device_get_sysfs_path (udev_device)); + } + /* go through each device and remove any that match */ devices = fu_device_list_get_all (self->device_list); for (guint i = 0; i < devices->len; i++) { @@ -4680,6 +4692,13 @@ fu_engine_usb_device_removed_cb (GUsbContext *ctx, { g_autoptr(GPtrArray) devices = NULL; + /* debug */ + if (g_getenv ("FWUPD_PROBE_VERBOSE") != NULL) { + g_debug ("USB %04x:%04x removed", + g_usb_device_get_vid (usb_device), + g_usb_device_get_pid (usb_device)); + } + /* go through each device and remove any that match */ devices = fu_device_list_get_all (self->device_list); for (guint i = 0; i < devices->len; i++) { @@ -4703,6 +4722,13 @@ fu_engine_usb_device_added_cb (GUsbContext *ctx, g_autoptr(GError) error_local = NULL; g_autoptr(GPtrArray) possible_plugins = NULL; + /* debug */ + if (g_getenv ("FWUPD_PROBE_VERBOSE") != NULL) { + g_debug ("USB %04x:%04x added", + g_usb_device_get_vid (usb_device), + g_usb_device_get_pid (usb_device)); + } + /* add any extra quirks */ fu_device_set_quirks (FU_DEVICE (device), self->quirks); if (!fu_device_probe (FU_DEVICE (device), &error_local)) { From aba4a5a2bd137a8c0aa4fe8b9bd88d49238c936d Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 26 Nov 2019 13:01:39 +0000 Subject: [PATCH 46/74] trivial: Split out a new helper funtion Other devices need to use this functionality too. --- .../synaptics-prometheus/fu-synaprom-config.c | 8 +------ src/fu-device.c | 22 +++++++++++++++++++ src/fu-device.h | 3 +++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/plugins/synaptics-prometheus/fu-synaprom-config.c b/plugins/synaptics-prometheus/fu-synaprom-config.c index 3a4c7c278..480c1a517 100644 --- a/plugins/synaptics-prometheus/fu-synaprom-config.c +++ b/plugins/synaptics-prometheus/fu-synaprom-config.c @@ -251,13 +251,7 @@ fu_synaprom_config_detach (FuDevice *device, GError **error) static void fu_synaprom_config_flags_notify_cb (FuDevice *parent, GParamSpec *pspec, FuDevice *device) { - if (fu_device_has_flag (parent, FWUPD_DEVICE_FLAG_IS_BOOTLOADER)) { - g_debug ("parent set IS_BOOTLOADER, mirroring to child"); - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER); - } else { - g_debug ("parent unset IS_BOOTLOADER, mirroring to child"); - fu_device_remove_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER); - } + fu_device_incorporate_flag (device, parent, FWUPD_DEVICE_FLAG_IS_BOOTLOADER); } static void diff --git a/src/fu-device.c b/src/fu-device.c index e08f38c6e..6f507a2f6 100644 --- a/src/fu-device.c +++ b/src/fu-device.c @@ -2607,6 +2607,28 @@ fu_device_incorporate (FuDevice *self, FuDevice *donor) } } +/** + * fu_device_incorporate_flag: + * @self: A #FuDevice + * @donor: Another #FuDevice + * @flag: A #FwupdDeviceFlags value + * + * Copy the value of a specific flag from the donor object. + * + * Since: 1.3.5 + **/ +void +fu_device_incorporate_flag (FuDevice *self, FuDevice *donor, FwupdDeviceFlags flag) +{ + if (fu_device_has_flag (donor, flag) && !fu_device_has_flag (self, flag)) { + g_debug ("donor set %s", fwupd_device_flag_to_string (flag)); + fu_device_add_flag (self, flag); + } else if (!fu_device_has_flag (donor, flag) && fu_device_has_flag (self, flag)) { + g_debug ("donor unset %s", fwupd_device_flag_to_string (flag)); + fu_device_remove_flag (self, flag); + } +} + /** * fu_device_incorporate_from_component: * @device: A #FuDevice diff --git a/src/fu-device.h b/src/fu-device.h index 7cd710090..1fffc23fc 100644 --- a/src/fu-device.h +++ b/src/fu-device.h @@ -246,6 +246,9 @@ gboolean fu_device_cleanup (FuDevice *self, GError **error); void fu_device_incorporate (FuDevice *self, FuDevice *donor); +void fu_device_incorporate_flag (FuDevice *self, + FuDevice *donor, + FwupdDeviceFlags flag); gboolean fu_device_open (FuDevice *self, GError **error); gboolean fu_device_close (FuDevice *self, From ed3f6cfd4fcb0cd8ba360c35e515c1587edd97c2 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 26 Nov 2019 11:53:00 +0000 Subject: [PATCH 47/74] synaptics-prometheus: Manually set the bootloader mode when attaching The fingerprint reader device doesn't actually disconnect and reconnect and so the FuDevice->setup() vfunc never gets called. --- plugins/synaptics-prometheus/fu-synaprom-device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/synaptics-prometheus/fu-synaprom-device.c b/plugins/synaptics-prometheus/fu-synaprom-device.c index ad1816dd8..45d1a4f51 100644 --- a/plugins/synaptics-prometheus/fu-synaprom-device.c +++ b/plugins/synaptics-prometheus/fu-synaprom-device.c @@ -394,6 +394,7 @@ fu_synaprom_device_attach (FuDevice *device, GError **error) g_prefix_error (error, "failed to force-reset device: "); return FALSE; } + fu_device_remove_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER); return TRUE; } @@ -428,6 +429,7 @@ fu_synaprom_device_detach (FuDevice *device, GError **error) g_prefix_error (error, "failed to force-reset device: "); return FALSE; } + fu_device_add_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER); return TRUE; } From f0f504c740144daadb8860a1d0512ed319d2ed62 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 26 Nov 2019 16:36:32 +0000 Subject: [PATCH 48/74] trivial: Do not use FuProgressbar in dfu-tool This is a debug-only command line program, and we don't want plugins to have access to the animated progressbar header in the future. --- docs/fwupd-docs.xml | 1 - plugins/dfu/dfu-tool.c | 14 +++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/docs/fwupd-docs.xml b/docs/fwupd-docs.xml index 095aa5161..050e93c5f 100644 --- a/docs/fwupd-docs.xml +++ b/docs/fwupd-docs.xml @@ -61,7 +61,6 @@ - diff --git a/plugins/dfu/dfu-tool.c b/plugins/dfu/dfu-tool.c index 12aa9742b..8534aed9a 100644 --- a/plugins/dfu/dfu-tool.c +++ b/plugins/dfu/dfu-tool.c @@ -16,7 +16,6 @@ #include "dfu-sector.h" #include "fu-device-locker.h" -#include "fu-progressbar.h" #include "fwupd-error.h" @@ -26,7 +25,6 @@ typedef struct { gboolean force; gchar *device_vid_pid; guint16 transfer_size; - FuProgressbar *progressbar; FuQuirks *quirks; } DfuToolPrivate; @@ -47,7 +45,6 @@ dfu_tool_private_free (DfuToolPrivate *priv) if (priv == NULL) return; g_free (priv->device_vid_pid); - g_object_unref (priv->progressbar); g_object_unref (priv->cancellable); g_object_unref (priv->quirks); if (priv->cmd_array != NULL) @@ -654,9 +651,9 @@ dfu_tool_convert (DfuToolPrivate *priv, gchar **values, GError **error) static void fu_tool_action_changed_cb (FuDevice *device, GParamSpec *pspec, DfuToolPrivate *priv) { - fu_progressbar_update (priv->progressbar, - fu_device_get_status (device), - fu_device_get_progress (device)); + g_print ("%s:\t%u%%\n", + fwupd_status_to_string (fu_device_get_status (device)), + fu_device_get_progress (device)); } static gboolean @@ -1313,11 +1310,6 @@ main (int argc, char *argv[]) _("Replace data in an existing firmware file"), dfu_tool_replace_data); - /* use animated progress bar */ - priv->progressbar = fu_progressbar_new (); - fu_progressbar_set_length_percentage (priv->progressbar, 50); - fu_progressbar_set_length_status (priv->progressbar, 20); - /* use quirks */ priv->quirks = fu_quirks_new (); if (!fu_quirks_load (priv->quirks, FU_QUIRKS_LOAD_FLAG_NONE, &error)) { From 9e5675e1b4649d7fea9eaaaabf862b6a072de595 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:35:03 +0000 Subject: [PATCH 49/74] trivial: Allow compiling without --- libfwupd/fwupd-client.c | 28 ++++++++++++++++++++++++++++ meson.build | 5 ++++- plugins/dfu/dfu-tool.c | 6 ++++++ src/fu-agent.c | 6 ++++++ src/fu-common.c | 10 ++++++++++ src/fu-engine.c | 23 +++++++++++++++++++++++ src/fu-tool.c | 6 ++++++ src/fu-util.c | 6 ++++++ 8 files changed, 89 insertions(+), 1 deletion(-) diff --git a/libfwupd/fwupd-client.c b/libfwupd/fwupd-client.c index 60a8667b4..0b8d5ae08 100644 --- a/libfwupd/fwupd-client.c +++ b/libfwupd/fwupd-client.c @@ -8,7 +8,9 @@ #include #include +#ifdef HAVE_GIO_UNIX #include +#endif #include #include @@ -953,6 +955,7 @@ fwupd_client_get_results (FwupdClient *client, const gchar *device_id, return fwupd_device_from_variant (helper->val); } +#ifdef HAVE_GIO_UNIX static void fwupd_client_send_message_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { @@ -971,6 +974,7 @@ fwupd_client_send_message_cb (GObject *source_object, GAsyncResult *res, gpointe fwupd_client_fixup_dbus_error (helper->error); g_main_loop_quit (helper->loop); } +#endif /** * fwupd_client_install: @@ -995,6 +999,7 @@ fwupd_client_install (FwupdClient *client, GCancellable *cancellable, GError **error) { +#ifdef HAVE_GIO_UNIX FwupdClientPrivate *priv = GET_PRIVATE (client); GVariant *body; GVariantBuilder builder; @@ -1084,6 +1089,13 @@ fwupd_client_install (FwupdClient *client, return FALSE; } return TRUE; +#else + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as is unavailable"); + return FALSE; +#endif } /** @@ -1103,6 +1115,7 @@ GPtrArray * fwupd_client_get_details (FwupdClient *client, const gchar *filename, GCancellable *cancellable, GError **error) { +#ifdef HAVE_GIO_UNIX FwupdClientPrivate *priv = GET_PRIVATE (client); GVariant *body; gint fd; @@ -1166,6 +1179,13 @@ fwupd_client_get_details (FwupdClient *client, const gchar *filename, /* return results */ return fwupd_device_array_from_variant (helper->val); +#else + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as is unavailable"); + return NULL; +#endif } /** @@ -1323,6 +1343,7 @@ fwupd_client_update_metadata (FwupdClient *client, GCancellable *cancellable, GError **error) { +#ifdef HAVE_GIO_UNIX FwupdClientPrivate *priv = GET_PRIVATE (client); GVariant *body; gint fd; @@ -1396,6 +1417,13 @@ fwupd_client_update_metadata (FwupdClient *client, return FALSE; } return TRUE; +#else + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as is unavailable"); + return FALSE; +#endif } /** diff --git a/meson.build b/meson.build index 00566d376..4988419d3 100644 --- a/meson.build +++ b/meson.build @@ -159,7 +159,10 @@ mandir = join_paths(prefix, get_option('mandir')) localedir = join_paths(prefix, get_option('localedir')) gio = dependency('gio-2.0', version : '>= 2.45.8') -giounix = dependency('gio-unix-2.0', version : '>= 2.45.8') +giounix = dependency('gio-unix-2.0', version : '>= 2.45.8', required: false) +if giounix.found() + conf.set('HAVE_GIO_UNIX', '1') +endif if gio.version().version_compare ('>= 2.55.0') conf.set('HAVE_GIO_2_55_0', '1') endif diff --git a/plugins/dfu/dfu-tool.c b/plugins/dfu/dfu-tool.c index 8534aed9a..103899bf0 100644 --- a/plugins/dfu/dfu-tool.c +++ b/plugins/dfu/dfu-tool.c @@ -10,7 +10,9 @@ #include #include #include +#ifdef HAVE_GIO_UNIX #include +#endif #include "dfu-device.h" #include "dfu-sector.h" @@ -1202,6 +1204,7 @@ dfu_tool_write (DfuToolPrivate *priv, gchar **values, GError **error) return TRUE; } +#ifdef HAVE_GIO_UNIX static gboolean dfu_tool_sigint_cb (gpointer user_data) { @@ -1210,6 +1213,7 @@ dfu_tool_sigint_cb (gpointer user_data) g_cancellable_cancel (priv->cancellable); return FALSE; } +#endif int main (int argc, char *argv[]) @@ -1320,11 +1324,13 @@ main (int argc, char *argv[]) /* do stuff on ctrl+c */ priv->cancellable = g_cancellable_new (); +#ifdef HAVE_GIO_UNIX g_unix_signal_add_full (G_PRIORITY_DEFAULT, SIGINT, dfu_tool_sigint_cb, priv, NULL); +#endif /* sort by command name */ g_ptr_array_sort (priv->cmd_array, diff --git a/src/fu-agent.c b/src/fu-agent.c index b2cc5b82b..89e1f221f 100644 --- a/src/fu-agent.c +++ b/src/fu-agent.c @@ -10,7 +10,9 @@ #include #include +#ifdef HAVE_GIO_UNIX #include +#endif #include #include #include @@ -117,6 +119,7 @@ fu_util_ignore_cb (const gchar *log_domain, GLogLevelFlags log_level, { } +#ifdef HAVE_GIO_UNIX static gboolean fu_util_sigint_cb (gpointer user_data) { @@ -125,6 +128,7 @@ fu_util_sigint_cb (gpointer user_data) g_cancellable_cancel (priv->cancellable); return FALSE; } +#endif static void fu_util_private_free (FuUtilPrivate *priv) @@ -183,9 +187,11 @@ main (int argc, char *argv[]) /* do stuff on ctrl+c */ priv->cancellable = g_cancellable_new (); +#ifdef HAVE_GIO_UNIX g_unix_signal_add_full (G_PRIORITY_DEFAULT, SIGINT, fu_util_sigint_cb, priv, NULL); +#endif /* get a list of the commands */ priv->context = g_option_context_new (NULL); diff --git a/src/fu-common.c b/src/fu-common.c index 2556bd03c..d80834423 100644 --- a/src/fu-common.c +++ b/src/fu-common.c @@ -8,7 +8,9 @@ #include +#ifdef HAVE_GIO_UNIX #include +#endif #include #ifdef HAVE_FNMATCH_H @@ -231,6 +233,7 @@ fu_common_get_contents_bytes (const gchar *filename, GError **error) GBytes * fu_common_get_contents_fd (gint fd, gsize count, GError **error) { +#ifdef HAVE_GIO_UNIX g_autoptr(GBytes) blob = NULL; g_autoptr(GError) error_local = NULL; g_autoptr(GInputStream) stream = NULL; @@ -258,6 +261,13 @@ fu_common_get_contents_fd (gint fd, gsize count, GError **error) return NULL; } return g_steal_pointer (&blob); +#else + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as is unavailable"); + return NULL; +#endif } static gboolean diff --git a/src/fu-engine.c b/src/fu-engine.c index a6b10ecb9..edaa934f0 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -9,7 +9,9 @@ #include "config.h" #include +#ifdef HAVE_GIO_UNIX #include +#endif #include #ifdef HAVE_GUDEV #include @@ -45,7 +47,9 @@ #include "fu-plugin-private.h" #include "fu-quirks.h" #include "fu-smbios.h" +#ifdef HAVE_GUDEV #include "fu-udev-device-private.h" +#endif #include "fu-usb-device-private.h" #include "fu-dfu-firmware.h" @@ -1616,6 +1620,7 @@ fu_engine_is_running_offline (FuEngine *self) static gboolean fu_engine_offline_setup (GError **error) { +#ifdef HAVE_GIO_UNIX gint rc; g_autofree gchar *filename = NULL; g_autofree gchar *symlink_target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG); @@ -1642,6 +1647,14 @@ fu_engine_offline_setup (GError **error) return FALSE; } return TRUE; +#else + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as not available"); + return FALSE; +#endif + } static gboolean @@ -2763,6 +2776,7 @@ fu_engine_config_changed_cb (FuConfig *config, FuEngine *self) error_local->message); } +#ifdef HAVE_GIO_UNIX static FuKeyringResult * fu_engine_get_existing_keyring_result (FuEngine *self, FuKeyring *kr, @@ -2780,6 +2794,7 @@ fu_engine_get_existing_keyring_result (FuEngine *self, return fu_keyring_verify_data (kr, blob, blob_sig, FU_KEYRING_VERIFY_FLAG_NONE, error); } +#endif /** * fu_engine_update_metadata: @@ -2799,6 +2814,7 @@ gboolean fu_engine_update_metadata (FuEngine *self, const gchar *remote_id, gint fd, gint fd_sig, GError **error) { +#ifdef HAVE_GIO_UNIX FwupdKeyringKind keyring_kind; FwupdRemote *remote; g_autoptr(GBytes) bytes_raw = NULL; @@ -2913,6 +2929,13 @@ fu_engine_update_metadata (FuEngine *self, const gchar *remote_id, return FALSE; } return fu_engine_load_metadata_store (self, FU_ENGINE_LOAD_FLAG_NONE, error); +#else + g_set_error (error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "Not supported as is unavailable"); + return FALSE; +#endif } /** diff --git a/src/fu-tool.c b/src/fu-tool.c index d3f6d8cfc..41412df3b 100644 --- a/src/fu-tool.c +++ b/src/fu-tool.c @@ -11,7 +11,9 @@ #include #include #include +#ifdef HAVE_GIO_UNIX #include +#endif #include #include #include @@ -171,6 +173,7 @@ fu_util_smbios_dump (FuUtilPrivate *priv, gchar **values, GError **error) return TRUE; } +#ifdef HAVE_GIO_UNIX static gboolean fu_util_sigint_cb (gpointer user_data) { @@ -179,6 +182,7 @@ fu_util_sigint_cb (gpointer user_data) g_cancellable_cancel (priv->cancellable); return FALSE; } +#endif static void fu_util_private_free (FuUtilPrivate *priv) @@ -1797,9 +1801,11 @@ main (int argc, char *argv[]) /* do stuff on ctrl+c */ priv->cancellable = g_cancellable_new (); +#ifdef HAVE_GIO_UNIX g_unix_signal_add_full (G_PRIORITY_DEFAULT, SIGINT, fu_util_sigint_cb, priv, NULL); +#endif g_signal_connect (priv->cancellable, "cancelled", G_CALLBACK (fu_util_cancelled_cb), priv); diff --git a/src/fu-util.c b/src/fu-util.c index c241a0a20..1b6eaa7fc 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -15,7 +15,9 @@ #include #include #include +#ifdef HAVE_GIO_UNIX #include +#endif #include #include #include @@ -2270,6 +2272,7 @@ fu_util_ignore_cb (const gchar *log_domain, GLogLevelFlags log_level, { } +#ifdef HAVE_GIO_UNIX static gboolean fu_util_sigint_cb (gpointer user_data) { @@ -2278,6 +2281,7 @@ fu_util_sigint_cb (gpointer user_data) g_cancellable_cancel (priv->cancellable); return FALSE; } +#endif static void fu_util_private_free (FuUtilPrivate *priv) @@ -2620,9 +2624,11 @@ main (int argc, char *argv[]) /* do stuff on ctrl+c */ priv->cancellable = g_cancellable_new (); +#ifdef HAVE_GIO_UNIX g_unix_signal_add_full (G_PRIORITY_DEFAULT, SIGINT, fu_util_sigint_cb, priv, NULL); +#endif /* sort by command name */ fu_util_cmd_array_sort (cmd_array); From 7d82a0980860ad1bd785a40a416ae8d2f879d1ad Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:42:31 +0000 Subject: [PATCH 50/74] trivial: Fix under-include to define O_RDONLY --- src/fu-tool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fu-tool.c b/src/fu-tool.c index 41412df3b..0d5a4d788 100644 --- a/src/fu-tool.c +++ b/src/fu-tool.c @@ -14,6 +14,7 @@ #ifdef HAVE_GIO_UNIX #include #endif +#include #include #include #include From ec73f86a79f7fed82b013e6ea84c65b743b3382d Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 22 Nov 2019 09:37:13 +0000 Subject: [PATCH 51/74] trivial: Allow building GCab from a subpackage --- meson.build | 2 +- subprojects/.gitignore | 1 + subprojects/gcab.wrap | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 subprojects/gcab.wrap diff --git a/meson.build b/meson.build index 4988419d3..ef1485262 100644 --- a/meson.build +++ b/meson.build @@ -207,7 +207,7 @@ if get_option('gpg') conf.set('ENABLE_GPG', '1') endif libm = cc.find_library('m', required: false) -libgcab = dependency('libgcab-1.0') +libgcab = dependency('libgcab-1.0', fallback : ['gcab', 'gcab_dep']) if libgcab.version().version_compare('>= 0.8') conf.set('HAVE_GCAB_0_8', '1') endif diff --git a/subprojects/.gitignore b/subprojects/.gitignore index 94e3341fd..4d276a280 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -1,3 +1,4 @@ gusb +gcab flashrom libxmlb diff --git a/subprojects/gcab.wrap b/subprojects/gcab.wrap new file mode 100644 index 000000000..35e59d0a7 --- /dev/null +++ b/subprojects/gcab.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory = gcab +url = https://gitlab.gnome.org/GNOME/gcab.git +revision = b55268ac1020cd6c033acb52f2e6ae984bf5c9fd From 6b0e66354b1b7007cb525a3d3c8280bf9001e880 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Fri, 22 Nov 2019 13:04:32 -0600 Subject: [PATCH 52/74] Convert libfwupdprivate to a shared library libfwupdplugin --- contrib/debian/control.in | 15 + contrib/debian/libfwupd2.install | 2 +- contrib/debian/libfwupdplugin1.install | 1 + contrib/debian/rules | 1 + .../generate-version-script.py | 0 docs/meson.build | 4 +- libfwupd/meson.build | 21 +- {src => libfwupdplugin}/fu-archive.c | 0 {src => libfwupdplugin}/fu-archive.h | 0 {src => libfwupdplugin}/fu-chunk.c | 0 {src => libfwupdplugin}/fu-chunk.h | 0 {src => libfwupdplugin}/fu-common-cab.c | 0 {src => libfwupdplugin}/fu-common-cab.h | 0 {src => libfwupdplugin}/fu-common-guid.c | 0 {src => libfwupdplugin}/fu-common-guid.h | 0 {src => libfwupdplugin}/fu-common-version.c | 0 {src => libfwupdplugin}/fu-common-version.h | 0 {src => libfwupdplugin}/fu-common.c | 0 {src => libfwupdplugin}/fu-common.h | 0 {src => libfwupdplugin}/fu-device-locker.c | 0 {src => libfwupdplugin}/fu-device-locker.h | 0 {src => libfwupdplugin}/fu-device-metadata.h | 0 {src => libfwupdplugin}/fu-device-private.h | 0 {src => libfwupdplugin}/fu-device.c | 0 {src => libfwupdplugin}/fu-device.h | 0 {src => libfwupdplugin}/fu-dfu-firmware.c | 0 {src => libfwupdplugin}/fu-dfu-firmware.h | 0 {src => libfwupdplugin}/fu-firmware-common.c | 0 {src => libfwupdplugin}/fu-firmware-common.h | 0 .../fu-firmware-image-private.h | 0 {src => libfwupdplugin}/fu-firmware-image.c | 0 {src => libfwupdplugin}/fu-firmware-image.h | 0 {src => libfwupdplugin}/fu-firmware.c | 0 {src => libfwupdplugin}/fu-firmware.h | 0 {src => libfwupdplugin}/fu-hash.py | 0 {src => libfwupdplugin}/fu-hwids.c | 0 {src => libfwupdplugin}/fu-hwids.h | 0 {src => libfwupdplugin}/fu-ihex-firmware.c | 0 {src => libfwupdplugin}/fu-ihex-firmware.h | 0 {src => libfwupdplugin}/fu-io-channel.c | 0 {src => libfwupdplugin}/fu-io-channel.h | 0 {src => libfwupdplugin}/fu-mutex.h | 0 {src => libfwupdplugin}/fu-plugin-private.h | 0 {src => libfwupdplugin}/fu-plugin-vfuncs.h | 0 {src => libfwupdplugin}/fu-plugin.c | 0 {src => libfwupdplugin}/fu-plugin.h | 0 {src => libfwupdplugin}/fu-progressbar.c | 0 {src => libfwupdplugin}/fu-progressbar.h | 0 {src => libfwupdplugin}/fu-quirks.c | 0 {src => libfwupdplugin}/fu-quirks.h | 0 libfwupdplugin/fu-self-test.c | 1596 +++++++++++++++ libfwupdplugin/fu-smbios-private.h | 20 + {src => libfwupdplugin}/fu-smbios.c | 2 +- {src => libfwupdplugin}/fu-smbios.h | 8 - {src => libfwupdplugin}/fu-srec-firmware.c | 0 {src => libfwupdplugin}/fu-srec-firmware.h | 0 {src => libfwupdplugin}/fu-test.c | 0 {src => libfwupdplugin}/fu-test.h | 0 .../fu-udev-device-private.h | 0 {src => libfwupdplugin}/fu-udev-device.c | 0 {src => libfwupdplugin}/fu-udev-device.h | 0 .../fu-usb-device-private.h | 0 {src => libfwupdplugin}/fu-usb-device.c | 0 {src => libfwupdplugin}/fu-usb-device.h | 0 libfwupdplugin/fwupdplugin.h | 46 + libfwupdplugin/fwupdplugin.map | 532 +++++ libfwupdplugin/meson.build | 223 +++ meson.build | 16 +- plugins/altos/meson.build | 9 +- plugins/amt/meson.build | 9 +- plugins/ata/meson.build | 19 +- plugins/colorhug/meson.build | 9 +- plugins/coreboot/meson.build | 9 +- plugins/csr/meson.build | 10 +- plugins/dell-dock/meson.build | 9 +- plugins/dell-esrt/meson.build | 9 +- plugins/dell/meson.build | 18 +- plugins/dfu/meson.build | 40 +- plugins/ebitdo/meson.build | 9 +- plugins/emmc/meson.build | 9 +- plugins/fastboot/meson.build | 9 +- plugins/flashrom/meson.build | 9 +- plugins/jabra/meson.build | 9 +- plugins/logitech-hidpp/meson.build | 17 +- plugins/modem-manager/meson.build | 9 +- plugins/nitrokey/meson.build | 16 +- plugins/nvme/meson.build | 19 +- plugins/optionrom/meson.build | 27 +- plugins/redfish/meson.build | 18 +- plugins/rts54hid/meson.build | 9 +- plugins/rts54hub/meson.build | 9 +- plugins/solokey/meson.build | 9 +- plugins/steelseries/meson.build | 8 +- plugins/superio/meson.build | 9 +- plugins/synaptics-cxaudio/meson.build | 9 +- plugins/synaptics-prometheus/meson.build | 27 +- plugins/synaptics-rmi/meson.build | 18 +- plugins/synapticsmst/meson.build | 18 +- plugins/test/meson.build | 9 +- plugins/thelio-io/meson.build | 9 +- plugins/thunderbolt-power/meson.build | 9 +- plugins/thunderbolt/meson.build | 27 +- plugins/uefi-recovery/meson.build | 9 +- plugins/uefi/meson.build | 27 +- plugins/upower/meson.build | 9 +- plugins/vli-usbhub/meson.build | 9 +- plugins/wacom-raw/meson.build | 9 +- plugins/wacom-usb/meson.build | 19 +- po/POTFILES.in | 2 +- src/fu-engine.c | 4 +- src/fu-self-test.c | 1718 ++--------------- src/fu-tool.c | 2 +- src/meson.build | 210 +- 113 files changed, 2920 insertions(+), 2047 deletions(-) create mode 100644 contrib/debian/libfwupdplugin1.install rename {libfwupd => contrib}/generate-version-script.py (100%) rename {src => libfwupdplugin}/fu-archive.c (100%) rename {src => libfwupdplugin}/fu-archive.h (100%) rename {src => libfwupdplugin}/fu-chunk.c (100%) rename {src => libfwupdplugin}/fu-chunk.h (100%) rename {src => libfwupdplugin}/fu-common-cab.c (100%) rename {src => libfwupdplugin}/fu-common-cab.h (100%) rename {src => libfwupdplugin}/fu-common-guid.c (100%) rename {src => libfwupdplugin}/fu-common-guid.h (100%) rename {src => libfwupdplugin}/fu-common-version.c (100%) rename {src => libfwupdplugin}/fu-common-version.h (100%) rename {src => libfwupdplugin}/fu-common.c (100%) rename {src => libfwupdplugin}/fu-common.h (100%) rename {src => libfwupdplugin}/fu-device-locker.c (100%) rename {src => libfwupdplugin}/fu-device-locker.h (100%) rename {src => libfwupdplugin}/fu-device-metadata.h (100%) rename {src => libfwupdplugin}/fu-device-private.h (100%) rename {src => libfwupdplugin}/fu-device.c (100%) rename {src => libfwupdplugin}/fu-device.h (100%) rename {src => libfwupdplugin}/fu-dfu-firmware.c (100%) rename {src => libfwupdplugin}/fu-dfu-firmware.h (100%) rename {src => libfwupdplugin}/fu-firmware-common.c (100%) rename {src => libfwupdplugin}/fu-firmware-common.h (100%) rename {src => libfwupdplugin}/fu-firmware-image-private.h (100%) rename {src => libfwupdplugin}/fu-firmware-image.c (100%) rename {src => libfwupdplugin}/fu-firmware-image.h (100%) rename {src => libfwupdplugin}/fu-firmware.c (100%) rename {src => libfwupdplugin}/fu-firmware.h (100%) rename {src => libfwupdplugin}/fu-hash.py (100%) rename {src => libfwupdplugin}/fu-hwids.c (100%) rename {src => libfwupdplugin}/fu-hwids.h (100%) rename {src => libfwupdplugin}/fu-ihex-firmware.c (100%) rename {src => libfwupdplugin}/fu-ihex-firmware.h (100%) rename {src => libfwupdplugin}/fu-io-channel.c (100%) rename {src => libfwupdplugin}/fu-io-channel.h (100%) rename {src => libfwupdplugin}/fu-mutex.h (100%) rename {src => libfwupdplugin}/fu-plugin-private.h (100%) rename {src => libfwupdplugin}/fu-plugin-vfuncs.h (100%) rename {src => libfwupdplugin}/fu-plugin.c (100%) rename {src => libfwupdplugin}/fu-plugin.h (100%) rename {src => libfwupdplugin}/fu-progressbar.c (100%) rename {src => libfwupdplugin}/fu-progressbar.h (100%) rename {src => libfwupdplugin}/fu-quirks.c (100%) rename {src => libfwupdplugin}/fu-quirks.h (100%) create mode 100644 libfwupdplugin/fu-self-test.c create mode 100644 libfwupdplugin/fu-smbios-private.h rename {src => libfwupdplugin}/fu-smbios.c (99%) rename {src => libfwupdplugin}/fu-smbios.h (72%) rename {src => libfwupdplugin}/fu-srec-firmware.c (100%) rename {src => libfwupdplugin}/fu-srec-firmware.h (100%) rename {src => libfwupdplugin}/fu-test.c (100%) rename {src => libfwupdplugin}/fu-test.h (100%) rename {src => libfwupdplugin}/fu-udev-device-private.h (100%) rename {src => libfwupdplugin}/fu-udev-device.c (100%) rename {src => libfwupdplugin}/fu-udev-device.h (100%) rename {src => libfwupdplugin}/fu-usb-device-private.h (100%) rename {src => libfwupdplugin}/fu-usb-device.c (100%) rename {src => libfwupdplugin}/fu-usb-device.h (100%) create mode 100644 libfwupdplugin/fwupdplugin.h create mode 100644 libfwupdplugin/fwupdplugin.map create mode 100644 libfwupdplugin/meson.build diff --git a/contrib/debian/control.in b/contrib/debian/control.in index 5d0572b83..75de509a1 100644 --- a/contrib/debian/control.in +++ b/contrib/debian/control.in @@ -12,6 +12,21 @@ Homepage: https://github.com/fwupd/fwupd Vcs-Git: https://salsa.debian.org/efi-team/fwupd.git Vcs-Browser: https://salsa.debian.org/efi-team/fwupd +Package: libfwupdplugin1 +Section: libs +Architecture: linux-any +Depends: ${misc:Depends}, + ${shlibs:Depends} +Multi-Arch: same +Description: Firmware update daemon plugin library + fwupd is a daemon to allow session software to update device firmware. + You can either use a GUI software manager like GNOME Software to view and + apply updates, the command-line tool or the system D-Bus interface directly. + Firmware updates are supported for a variety of technologies. + See for details + . + This package provides the library for the interface between daemon and plugins. + Package: libfwupd2 Section: libs Architecture: linux-any diff --git a/contrib/debian/libfwupd2.install b/contrib/debian/libfwupd2.install index 3de3b10a4..927e37b50 100644 --- a/contrib/debian/libfwupd2.install +++ b/contrib/debian/libfwupd2.install @@ -1 +1 @@ -usr/lib/*/*.so.* +usr/lib/*/libfwupd.so.* diff --git a/contrib/debian/libfwupdplugin1.install b/contrib/debian/libfwupdplugin1.install new file mode 100644 index 000000000..6c3648c06 --- /dev/null +++ b/contrib/debian/libfwupdplugin1.install @@ -0,0 +1 @@ +usr/lib/*/libfwupdplugin.so.* diff --git a/contrib/debian/rules b/contrib/debian/rules index 25428e401..3b070babd 100755 --- a/contrib/debian/rules +++ b/contrib/debian/rules @@ -65,6 +65,7 @@ override_dh_install: fi if [ ! -z "$$CI" ] && [ -f debian/tmp/usr/sbin/flashrom ]; then \ dh_install -pfwupd usr/sbin/flashrom ;\ + dh_install -plibfwupd2 usr/lib/*/libflashrom.so.*; \ fi dh_missing -a --fail-missing diff --git a/libfwupd/generate-version-script.py b/contrib/generate-version-script.py similarity index 100% rename from libfwupd/generate-version-script.py rename to contrib/generate-version-script.py diff --git a/docs/meson.build b/docs/meson.build index ffad58d47..7169a5480 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -2,9 +2,9 @@ gnome.gtkdoc( 'fwupd', src_dir : [ join_paths(meson.source_root(), 'libfwupd'), - join_paths(meson.source_root(), 'src'), + join_paths(meson.source_root(), 'libfwupdplugin'), join_paths(meson.build_root(), 'libfwupd'), - join_paths(meson.build_root(), 'src'), + join_paths(meson.build_root(), 'libfwupdplugin'), ], main_xml : 'fwupd-docs.xml', install : true diff --git a/libfwupd/meson.build b/libfwupd/meson.build index 8ff658411..0fca3a19d 100644 --- a/libfwupd/meson.build +++ b/libfwupd/meson.build @@ -27,8 +27,8 @@ install_headers([ subdir : 'fwupd-1/libfwupd', ) -mapfile = 'fwupd.map' -vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) +fwupd_mapfile = 'fwupd.map' +vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), fwupd_mapfile) fwupd = shared_library( 'fwupd', sources : [ @@ -40,8 +40,8 @@ fwupd = shared_library( 'fwupd-release.c', 'fwupd-remote.c', ], - soversion : lt_current, - version : lt_version, + soversion : libfwupd_lt_current, + version : libfwupd_lt_version, dependencies : [ giounix, soup, @@ -51,9 +51,9 @@ fwupd = shared_library( cargs, '-DLOCALSTATEDIR="' + localstatedir + '"', ], - include_directories : include_directories('..'), + include_directories : root_incdir, link_args : vflag, - link_depends : mapfile, + link_depends : fwupd_mapfile, install : true ) @@ -123,17 +123,16 @@ if get_option('introspection') # # To avoid the circular dep, and to ensure we don't change exported API # accidentally actually check in a version of the version script to git. - mapfile_target = custom_target('mapfile', + mapfile_target = custom_target('fwupd_mapfile', input: gir[0], output: 'fwupd.map', command: [ - join_paths(meson.current_source_dir(), 'generate-version-script.py'), + join_paths(meson.source_root(), 'contrib', 'generate-version-script.py'), 'LIBFWUPD', '@INPUT@', '@OUTPUT@', ], ) - diffcmd = find_program('diff') test('fwupd-exported-api', diffcmd, args : [ '-urNp', @@ -152,7 +151,7 @@ if get_option('tests') 'fwupd-self-test.c' ], include_directories : [ - include_directories('..'), + root_incdir, ], dependencies : [ gio, @@ -170,3 +169,5 @@ if get_option('tests') ) test('fwupd-self-test', e) endif + +fwupd_incdir = include_directories('.') diff --git a/src/fu-archive.c b/libfwupdplugin/fu-archive.c similarity index 100% rename from src/fu-archive.c rename to libfwupdplugin/fu-archive.c diff --git a/src/fu-archive.h b/libfwupdplugin/fu-archive.h similarity index 100% rename from src/fu-archive.h rename to libfwupdplugin/fu-archive.h diff --git a/src/fu-chunk.c b/libfwupdplugin/fu-chunk.c similarity index 100% rename from src/fu-chunk.c rename to libfwupdplugin/fu-chunk.c diff --git a/src/fu-chunk.h b/libfwupdplugin/fu-chunk.h similarity index 100% rename from src/fu-chunk.h rename to libfwupdplugin/fu-chunk.h diff --git a/src/fu-common-cab.c b/libfwupdplugin/fu-common-cab.c similarity index 100% rename from src/fu-common-cab.c rename to libfwupdplugin/fu-common-cab.c diff --git a/src/fu-common-cab.h b/libfwupdplugin/fu-common-cab.h similarity index 100% rename from src/fu-common-cab.h rename to libfwupdplugin/fu-common-cab.h diff --git a/src/fu-common-guid.c b/libfwupdplugin/fu-common-guid.c similarity index 100% rename from src/fu-common-guid.c rename to libfwupdplugin/fu-common-guid.c diff --git a/src/fu-common-guid.h b/libfwupdplugin/fu-common-guid.h similarity index 100% rename from src/fu-common-guid.h rename to libfwupdplugin/fu-common-guid.h diff --git a/src/fu-common-version.c b/libfwupdplugin/fu-common-version.c similarity index 100% rename from src/fu-common-version.c rename to libfwupdplugin/fu-common-version.c diff --git a/src/fu-common-version.h b/libfwupdplugin/fu-common-version.h similarity index 100% rename from src/fu-common-version.h rename to libfwupdplugin/fu-common-version.h diff --git a/src/fu-common.c b/libfwupdplugin/fu-common.c similarity index 100% rename from src/fu-common.c rename to libfwupdplugin/fu-common.c diff --git a/src/fu-common.h b/libfwupdplugin/fu-common.h similarity index 100% rename from src/fu-common.h rename to libfwupdplugin/fu-common.h diff --git a/src/fu-device-locker.c b/libfwupdplugin/fu-device-locker.c similarity index 100% rename from src/fu-device-locker.c rename to libfwupdplugin/fu-device-locker.c diff --git a/src/fu-device-locker.h b/libfwupdplugin/fu-device-locker.h similarity index 100% rename from src/fu-device-locker.h rename to libfwupdplugin/fu-device-locker.h diff --git a/src/fu-device-metadata.h b/libfwupdplugin/fu-device-metadata.h similarity index 100% rename from src/fu-device-metadata.h rename to libfwupdplugin/fu-device-metadata.h diff --git a/src/fu-device-private.h b/libfwupdplugin/fu-device-private.h similarity index 100% rename from src/fu-device-private.h rename to libfwupdplugin/fu-device-private.h diff --git a/src/fu-device.c b/libfwupdplugin/fu-device.c similarity index 100% rename from src/fu-device.c rename to libfwupdplugin/fu-device.c diff --git a/src/fu-device.h b/libfwupdplugin/fu-device.h similarity index 100% rename from src/fu-device.h rename to libfwupdplugin/fu-device.h diff --git a/src/fu-dfu-firmware.c b/libfwupdplugin/fu-dfu-firmware.c similarity index 100% rename from src/fu-dfu-firmware.c rename to libfwupdplugin/fu-dfu-firmware.c diff --git a/src/fu-dfu-firmware.h b/libfwupdplugin/fu-dfu-firmware.h similarity index 100% rename from src/fu-dfu-firmware.h rename to libfwupdplugin/fu-dfu-firmware.h diff --git a/src/fu-firmware-common.c b/libfwupdplugin/fu-firmware-common.c similarity index 100% rename from src/fu-firmware-common.c rename to libfwupdplugin/fu-firmware-common.c diff --git a/src/fu-firmware-common.h b/libfwupdplugin/fu-firmware-common.h similarity index 100% rename from src/fu-firmware-common.h rename to libfwupdplugin/fu-firmware-common.h diff --git a/src/fu-firmware-image-private.h b/libfwupdplugin/fu-firmware-image-private.h similarity index 100% rename from src/fu-firmware-image-private.h rename to libfwupdplugin/fu-firmware-image-private.h diff --git a/src/fu-firmware-image.c b/libfwupdplugin/fu-firmware-image.c similarity index 100% rename from src/fu-firmware-image.c rename to libfwupdplugin/fu-firmware-image.c diff --git a/src/fu-firmware-image.h b/libfwupdplugin/fu-firmware-image.h similarity index 100% rename from src/fu-firmware-image.h rename to libfwupdplugin/fu-firmware-image.h diff --git a/src/fu-firmware.c b/libfwupdplugin/fu-firmware.c similarity index 100% rename from src/fu-firmware.c rename to libfwupdplugin/fu-firmware.c diff --git a/src/fu-firmware.h b/libfwupdplugin/fu-firmware.h similarity index 100% rename from src/fu-firmware.h rename to libfwupdplugin/fu-firmware.h diff --git a/src/fu-hash.py b/libfwupdplugin/fu-hash.py similarity index 100% rename from src/fu-hash.py rename to libfwupdplugin/fu-hash.py diff --git a/src/fu-hwids.c b/libfwupdplugin/fu-hwids.c similarity index 100% rename from src/fu-hwids.c rename to libfwupdplugin/fu-hwids.c diff --git a/src/fu-hwids.h b/libfwupdplugin/fu-hwids.h similarity index 100% rename from src/fu-hwids.h rename to libfwupdplugin/fu-hwids.h diff --git a/src/fu-ihex-firmware.c b/libfwupdplugin/fu-ihex-firmware.c similarity index 100% rename from src/fu-ihex-firmware.c rename to libfwupdplugin/fu-ihex-firmware.c diff --git a/src/fu-ihex-firmware.h b/libfwupdplugin/fu-ihex-firmware.h similarity index 100% rename from src/fu-ihex-firmware.h rename to libfwupdplugin/fu-ihex-firmware.h diff --git a/src/fu-io-channel.c b/libfwupdplugin/fu-io-channel.c similarity index 100% rename from src/fu-io-channel.c rename to libfwupdplugin/fu-io-channel.c diff --git a/src/fu-io-channel.h b/libfwupdplugin/fu-io-channel.h similarity index 100% rename from src/fu-io-channel.h rename to libfwupdplugin/fu-io-channel.h diff --git a/src/fu-mutex.h b/libfwupdplugin/fu-mutex.h similarity index 100% rename from src/fu-mutex.h rename to libfwupdplugin/fu-mutex.h diff --git a/src/fu-plugin-private.h b/libfwupdplugin/fu-plugin-private.h similarity index 100% rename from src/fu-plugin-private.h rename to libfwupdplugin/fu-plugin-private.h diff --git a/src/fu-plugin-vfuncs.h b/libfwupdplugin/fu-plugin-vfuncs.h similarity index 100% rename from src/fu-plugin-vfuncs.h rename to libfwupdplugin/fu-plugin-vfuncs.h diff --git a/src/fu-plugin.c b/libfwupdplugin/fu-plugin.c similarity index 100% rename from src/fu-plugin.c rename to libfwupdplugin/fu-plugin.c diff --git a/src/fu-plugin.h b/libfwupdplugin/fu-plugin.h similarity index 100% rename from src/fu-plugin.h rename to libfwupdplugin/fu-plugin.h diff --git a/src/fu-progressbar.c b/libfwupdplugin/fu-progressbar.c similarity index 100% rename from src/fu-progressbar.c rename to libfwupdplugin/fu-progressbar.c diff --git a/src/fu-progressbar.h b/libfwupdplugin/fu-progressbar.h similarity index 100% rename from src/fu-progressbar.h rename to libfwupdplugin/fu-progressbar.h diff --git a/src/fu-quirks.c b/libfwupdplugin/fu-quirks.c similarity index 100% rename from src/fu-quirks.c rename to libfwupdplugin/fu-quirks.c diff --git a/src/fu-quirks.h b/libfwupdplugin/fu-quirks.h similarity index 100% rename from src/fu-quirks.h rename to libfwupdplugin/fu-quirks.h diff --git a/libfwupdplugin/fu-self-test.c b/libfwupdplugin/fu-self-test.c new file mode 100644 index 000000000..bb231a316 --- /dev/null +++ b/libfwupdplugin/fu-self-test.c @@ -0,0 +1,1596 @@ +/* + * Copyright (C) 2015-2018 Richard Hughes + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "fu-device-private.h" +#include "fu-plugin-private.h" +#include "fu-smbios-private.h" + +static void +fu_archive_invalid_func (void) +{ + g_autofree gchar *filename = NULL; + g_autoptr(FuArchive) archive = NULL; + g_autoptr(GBytes) data = NULL; + g_autoptr(GError) error = NULL; + + filename = fu_test_get_filename (TESTDATADIR, "metadata.xml"); + g_assert_nonnull (filename); + data = fu_common_get_contents_bytes (filename, &error); + g_assert_no_error (error); + g_assert_nonnull (data); + + archive = fu_archive_new (data, FU_ARCHIVE_FLAG_NONE, &error); + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED); + g_assert_null (archive); +} + +static void +fu_archive_cab_func (void) +{ + g_autofree gchar *checksum1 = NULL; + g_autofree gchar *checksum2 = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(FuArchive) archive = NULL; + g_autoptr(GBytes) data = NULL; + g_autoptr(GError) error = NULL; + GBytes *data_tmp; + + filename = fu_test_get_filename (TESTDATADIR, "colorhug/colorhug-als-3.0.2.cab"); + g_assert_nonnull (filename); + data = fu_common_get_contents_bytes (filename, &error); + g_assert_no_error (error); + g_assert_nonnull (data); + + archive = fu_archive_new (data, FU_ARCHIVE_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert_nonnull (archive); + + data_tmp = fu_archive_lookup_by_fn (archive, "firmware.metainfo.xml", &error); + g_assert_no_error (error); + g_assert_nonnull (data_tmp); + checksum1 = g_compute_checksum_for_bytes (G_CHECKSUM_SHA1, data_tmp); + g_assert_cmpstr (checksum1, ==, "8611114f51f7151f190de86a5c9259d79ff34216"); + + data_tmp = fu_archive_lookup_by_fn (archive, "firmware.bin", &error); + g_assert_no_error (error); + g_assert_nonnull (data_tmp); + checksum2 = g_compute_checksum_for_bytes (G_CHECKSUM_SHA1, data_tmp); + g_assert_cmpstr (checksum2, ==, "7c0ae84b191822bcadbdcbe2f74a011695d783c7"); + + data_tmp = fu_archive_lookup_by_fn (archive, "NOTGOINGTOEXIST.xml", &error); + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND); + g_assert_null (data_tmp); +} + +static void +fu_common_string_append_kv_func (void) +{ + g_autoptr(GString) str = g_string_new (NULL); + fu_common_string_append_kv (str, 0, "hdr", NULL); + fu_common_string_append_kv (str, 0, "key", "value"); + fu_common_string_append_kv (str, 0, "key1", "value1"); + fu_common_string_append_kv (str, 1, "key2", "value2"); + fu_common_string_append_kv (str, 1, "", "value2"); + fu_common_string_append_kv (str, 2, "key3", "value3"); + g_assert_cmpstr (str->str, ==, + "hdr:\n" + "key: value\n" + "key1: value1\n" + " key2: value2\n" + " value2\n" + " key3: value3\n"); +} + +static void +fu_common_version_guess_format_func (void) +{ + g_assert_cmpint (fu_common_version_guess_format (NULL), ==, FWUPD_VERSION_FORMAT_UNKNOWN); + g_assert_cmpint (fu_common_version_guess_format (""), ==, FWUPD_VERSION_FORMAT_UNKNOWN); + g_assert_cmpint (fu_common_version_guess_format ("1234ac"), ==, FWUPD_VERSION_FORMAT_PLAIN); + g_assert_cmpint (fu_common_version_guess_format ("1.2"), ==, FWUPD_VERSION_FORMAT_PAIR); + g_assert_cmpint (fu_common_version_guess_format ("1.2.3"), ==, FWUPD_VERSION_FORMAT_TRIPLET); + g_assert_cmpint (fu_common_version_guess_format ("1.2.3.4"), ==, FWUPD_VERSION_FORMAT_QUAD); + g_assert_cmpint (fu_common_version_guess_format ("1.2.3.4.5"), ==, FWUPD_VERSION_FORMAT_UNKNOWN); + g_assert_cmpint (fu_common_version_guess_format ("1a.2b.3"), ==, FWUPD_VERSION_FORMAT_PLAIN); + g_assert_cmpint (fu_common_version_guess_format ("1"), ==, FWUPD_VERSION_FORMAT_NUMBER); + g_assert_cmpint (fu_common_version_guess_format ("0x10201"), ==, FWUPD_VERSION_FORMAT_NUMBER); +} + +static void +fu_device_version_format_func (void) +{ + g_autoptr(FuDevice) device = fu_device_new (); + fu_device_add_flag (device, FWUPD_DEVICE_FLAG_ENSURE_SEMVER); + fu_device_set_version (device, "Ver1.2.3 RELEASE", FWUPD_VERSION_FORMAT_TRIPLET); + g_assert_cmpstr (fu_device_get_version (device), ==, "1.2.3"); +} + +static void +fu_device_open_refcount_func (void) +{ + gboolean ret; + g_autoptr(FuDevice) device = fu_device_new (); + g_autoptr(GError) error = NULL; + fu_device_set_id (device, "test_device"); + ret = fu_device_open (device, &error); + g_assert_no_error (error); + g_assert_true (ret); + ret = fu_device_open (device, &error); + g_assert_no_error (error); + g_assert_true (ret); + ret = fu_device_close (device, &error); + g_assert_no_error (error); + g_assert_true (ret); + ret = fu_device_close (device, &error); + g_assert_no_error (error); + g_assert_true (ret); + ret = fu_device_close (device, &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INTERNAL); + g_assert_false (ret); +} + +static void +fu_device_metadata_func (void) +{ + g_autoptr(FuDevice) device = fu_device_new (); + + /* string */ + fu_device_set_metadata (device, "foo", "bar"); + g_assert_cmpstr (fu_device_get_metadata (device, "foo"), ==, "bar"); + fu_device_set_metadata (device, "foo", "baz"); + g_assert_cmpstr (fu_device_get_metadata (device, "foo"), ==, "baz"); + g_assert_null (fu_device_get_metadata (device, "unknown")); + + /* boolean */ + fu_device_set_metadata_boolean (device, "baz", TRUE); + g_assert_cmpstr (fu_device_get_metadata (device, "baz"), ==, "true"); + g_assert_true (fu_device_get_metadata_boolean (device, "baz")); + g_assert_false (fu_device_get_metadata_boolean (device, "unknown")); + + /* integer */ + fu_device_set_metadata_integer (device, "dum", 12345); + g_assert_cmpstr (fu_device_get_metadata (device, "dum"), ==, "12345"); + g_assert_cmpint (fu_device_get_metadata_integer (device, "dum"), ==, 12345); + g_assert_cmpint (fu_device_get_metadata_integer (device, "unknown"), ==, G_MAXUINT); + + /* broken integer */ + fu_device_set_metadata (device, "dum", "123junk"); + g_assert_cmpint (fu_device_get_metadata_integer (device, "dum"), ==, G_MAXUINT); + fu_device_set_metadata (device, "huge", "4294967296"); /* not 32 bit */ + g_assert_cmpint (fu_device_get_metadata_integer (device, "huge"), ==, G_MAXUINT); +} + +static void +fu_smbios_func (void) +{ + const gchar *str; + gboolean ret; + g_autofree gchar *dump = NULL; + g_autoptr(FuSmbios) smbios = NULL; + g_autoptr(GError) error = NULL; + + smbios = fu_smbios_new (); + ret = fu_smbios_setup (smbios, &error); + g_assert_no_error (error); + g_assert (ret); + dump = fu_smbios_to_string (smbios); + if (g_getenv ("VERBOSE") != NULL) + g_debug ("%s", dump); + + /* test for missing table */ + str = fu_smbios_get_string (smbios, 0xff, 0, &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); + g_assert_null (str); + g_clear_error (&error); + + /* check for invalid offset */ + str = fu_smbios_get_string (smbios, FU_SMBIOS_STRUCTURE_TYPE_BIOS, 0xff, &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); + g_assert_null (str); + g_clear_error (&error); + + /* get vendor */ + str = fu_smbios_get_string (smbios, FU_SMBIOS_STRUCTURE_TYPE_BIOS, 0x04, &error); + g_assert_no_error (error); + g_assert_cmpstr (str, ==, "LENOVO"); +} + +static void +fu_smbios3_func (void) +{ + const gchar *str; + gboolean ret; + g_autofree gchar *path = NULL; + g_autoptr(FuSmbios) smbios = NULL; + g_autoptr(GError) error = NULL; + + path = fu_test_get_filename (TESTDATADIR, "dmi/tables64"); + g_assert_nonnull (path); + + smbios = fu_smbios_new (); + ret = fu_smbios_setup_from_path (smbios, path, &error); + g_assert_no_error (error); + g_assert (ret); + if (g_getenv ("VERBOSE") != NULL) { + g_autofree gchar *dump = fu_smbios_to_string (smbios); + g_debug ("%s", dump); + } + + /* get vendor */ + str = fu_smbios_get_string (smbios, FU_SMBIOS_STRUCTURE_TYPE_BIOS, 0x04, &error); + g_assert_no_error (error); + g_assert_cmpstr (str, ==, "Dell Inc."); +} + +static void +fu_hwids_func (void) +{ + g_autoptr(FuHwids) hwids = NULL; + g_autoptr(FuSmbios) smbios = NULL; + g_autoptr(GError) error = NULL; + gboolean ret; + + struct { + const gchar *key; + const gchar *value; + } guids[] = { + { "Manufacturer", "6de5d951-d755-576b-bd09-c5cf66b27234" }, + { "HardwareID-14", "6de5d951-d755-576b-bd09-c5cf66b27234" }, + { "HardwareID-13", "f8e1de5f-b68c-5f52-9d1a-f1ba52f1f773" }, + { "HardwareID-12", "e093d715-70f7-51f4-b6c8-b4a7e31def85" }, + { "HardwareID-11", "db73af4c-4612-50f7-b8a7-787cf4871847" }, + { "HardwareID-10", "f4275c1f-6130-5191-845c-3426247eb6a1" }, + { "HardwareID-9", "0cf8618d-9eff-537c-9f35-46861406eb9c" }, + { "HardwareID-8", "059eb22d-6dc7-59af-abd3-94bbe017f67c" }, + { "HardwareID-7", "da1da9b6-62f5-5f22-8aaa-14db7eeda2a4" }, + { "HardwareID-6", "178cd22d-ad9f-562d-ae0a-34009822cdbe" }, + { "HardwareID-5", "8dc9b7c5-f5d5-5850-9ab3-bd6f0549d814" }, + { "HardwareID-4", "660ccba8-1b78-5a33-80e6-9fb8354ee873" }, + { "HardwareID-3", "3faec92a-3ae3-5744-be88-495e90a7d541" }, + { "HardwareID-2", "f5ff077f-3eeb-5bae-be1c-e98ffe8ce5f8" }, + { "HardwareID-1", "b7cceb67-774c-537e-bf8b-22c6107e9a74" }, + { "HardwareID-0", "147efce9-f201-5fc8-ab0c-c859751c3440" }, + { NULL, NULL } + }; + + smbios = fu_smbios_new (); + ret = fu_smbios_setup (smbios, &error); + g_assert_no_error (error); + g_assert (ret); + + hwids = fu_hwids_new (); + ret = fu_hwids_setup (hwids, smbios, &error); + g_assert_no_error (error); + g_assert (ret); + + g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_MANUFACTURER), ==, + "LENOVO"); + g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_ENCLOSURE_KIND), ==, + "a"); + g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_FAMILY), ==, + "ThinkPad T440s"); + g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_PRODUCT_NAME), ==, + "20ARS19C0C"); + g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_BIOS_VENDOR), ==, + "LENOVO"); + g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_BIOS_VERSION), ==, + "GJET75WW (2.25 )"); + g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_BIOS_MAJOR_RELEASE), ==, "02"); + g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_BIOS_MINOR_RELEASE), ==, "19"); + g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_PRODUCT_SKU), ==, + "LENOVO_MT_20AR_BU_Think_FM_ThinkPad T440s"); + for (guint i = 0; guids[i].key != NULL; i++) { + g_autofree gchar *guid = fu_hwids_get_guid (hwids, guids[i].key, &error); + g_assert_no_error (error); + g_assert_cmpstr (guid, ==, guids[i].value); + } + for (guint i = 0; guids[i].key != NULL; i++) + g_assert (fu_hwids_has_guid (hwids, guids[i].value)); +} + +static void +_plugin_device_added_cb (FuPlugin *plugin, FuDevice *device, gpointer user_data) +{ + FuDevice **dev = (FuDevice **) user_data; + *dev = g_object_ref (device); + fu_test_loop_quit (); +} + +static void +fu_plugin_delay_func (void) +{ + FuDevice *device_tmp; + g_autoptr(FuPlugin) plugin = NULL; + g_autoptr(FuDevice) device = NULL; + + plugin = fu_plugin_new (); + g_signal_connect (plugin, "device-added", + G_CALLBACK (_plugin_device_added_cb), + &device_tmp); + g_signal_connect (plugin, "device-removed", + G_CALLBACK (_plugin_device_added_cb), + &device_tmp); + + /* add device straight away */ + device = fu_device_new (); + fu_device_set_id (device, "testdev"); + fu_plugin_device_add (plugin, device); + g_assert (device_tmp != NULL); + g_assert_cmpstr (fu_device_get_id (device_tmp), ==, "b7eccd0059d6d7dc2ef76c35d6de0048cc8c029d"); + g_clear_object (&device_tmp); + + /* remove device */ + fu_plugin_device_remove (plugin, device); + g_assert (device_tmp != NULL); + g_assert_cmpstr (fu_device_get_id (device_tmp), ==, "b7eccd0059d6d7dc2ef76c35d6de0048cc8c029d"); + g_clear_object (&device_tmp); +} + +static void +fu_plugin_quirks_func (void) +{ + const gchar *tmp; + gboolean ret; + g_autoptr(FuQuirks) quirks = fu_quirks_new (); + g_autoptr(FuPlugin) plugin = fu_plugin_new (); + g_autoptr(GError) error = NULL; + + ret = fu_quirks_load (quirks, FU_QUIRKS_LOAD_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert (ret); + fu_plugin_set_quirks (plugin, quirks); + + /* exact */ + tmp = fu_plugin_lookup_quirk_by_id (plugin, "USB\\VID_0A5C&PID_6412", "Flags"); + g_assert_cmpstr (tmp, ==, "ignore-runtime"); + tmp = fu_plugin_lookup_quirk_by_id (plugin, "ACME Inc.=True", "Test"); + g_assert_cmpstr (tmp, ==, "awesome"); + tmp = fu_plugin_lookup_quirk_by_id (plugin, "CORP*", "Test"); + g_assert_cmpstr (tmp, ==, "town"); + tmp = fu_plugin_lookup_quirk_by_id (plugin, "baz", "Unfound"); + g_assert_cmpstr (tmp, ==, NULL); + tmp = fu_plugin_lookup_quirk_by_id (plugin, "unfound", "tests"); + g_assert_cmpstr (tmp, ==, NULL); + tmp = fu_plugin_lookup_quirk_by_id (plugin, "unfound", "unfound"); + g_assert_cmpstr (tmp, ==, NULL); + tmp = fu_plugin_lookup_quirk_by_id (plugin, "bb9ec3e2-77b3-53bc-a1f1-b05916715627", "Flags"); + g_assert_cmpstr (tmp, ==, "clever"); +} + +static void +fu_plugin_quirks_performance_func (void) +{ + gboolean ret; + g_autoptr(FuQuirks) quirks = fu_quirks_new (); + g_autoptr(GTimer) timer = g_timer_new (); + g_autoptr(GError) error = NULL; + const gchar *keys[] = { "Name", "Children", "Flags", NULL }; + + ret = fu_quirks_load (quirks, FU_QUIRKS_LOAD_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert (ret); + + /* lookup */ + g_timer_reset (timer); + for (guint j = 0; j < 1000; j++) { + const gchar *group = "DeviceInstanceId=USB\\VID_0BDA&PID_1100"; + for (guint i = 0; keys[i] != NULL; i++) { + const gchar *tmp = fu_quirks_lookup_by_id (quirks, group, keys[i]); + g_assert_cmpstr (tmp, !=, NULL); + } + } + g_print ("lookup=%.3fms ", g_timer_elapsed (timer, NULL) * 1000.f); +} + +static void +fu_plugin_quirks_device_func (void) +{ + FuDevice *device_tmp; + GPtrArray *children; + gboolean ret; + g_autoptr(FuDevice) device = fu_device_new (); + g_autoptr(FuQuirks) quirks = fu_quirks_new (); + g_autoptr(GError) error = NULL; + + ret = fu_quirks_load (quirks, FU_QUIRKS_LOAD_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert (ret); + + /* use quirk file to set device attributes */ + fu_device_set_physical_id (device, "usb:00:05"); + fu_device_set_quirks (device, quirks); + fu_device_add_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE); + fu_device_add_instance_id (device, "USB\\VID_0BDA&PID_1100"); + fu_device_convert_instance_ids (device); + g_assert_cmpstr (fu_device_get_name (device), ==, "Hub"); + + /* ensure children are created */ + children = fu_device_get_children (device); + g_assert_cmpint (children->len, ==, 1); + device_tmp = g_ptr_array_index (children, 0); + g_assert_cmpstr (fu_device_get_name (device_tmp), ==, "HDMI"); + g_assert (fu_device_has_flag (device_tmp, FWUPD_DEVICE_FLAG_UPDATABLE)); +} + + +static void +fu_common_firmware_builder_func (void) +{ + const gchar *data; + g_autofree gchar *archive_fn = NULL; + g_autoptr(GBytes) archive_blob = NULL; + g_autoptr(GBytes) firmware_blob = NULL; + g_autoptr(GError) error = NULL; + + /* get test file */ + archive_fn = fu_test_get_filename (TESTDATADIR, "builder/firmware.tar"); + g_assert (archive_fn != NULL); + archive_blob = fu_common_get_contents_bytes (archive_fn, &error); + g_assert_no_error (error); + g_assert (archive_blob != NULL); + + /* generate the firmware */ + firmware_blob = fu_common_firmware_builder (archive_blob, + "startup.sh", + "firmware.bin", + &error); + if (firmware_blob == NULL) { + if (g_error_matches (error, FWUPD_ERROR, FWUPD_ERROR_PERMISSION_DENIED)) { + g_test_skip ("Missing permissions to create namespace in container"); + return; + } + if (g_error_matches (error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED)) { + g_test_skip ("User namespaces not supported in container"); + return; + } + g_assert_no_error (error); + } + + /* check it */ + data = g_bytes_get_data (firmware_blob, NULL); + g_assert_cmpstr (data, ==, "xobdnas eht ni gninnur"); +} + +static void +fu_test_stdout_cb (const gchar *line, gpointer user_data) +{ + guint *lines = (guint *) user_data; + g_debug ("got '%s'", line); + (*lines)++; +} + +static gboolean +_open_cb (GObject *device, GError **error) +{ + g_assert_cmpstr (g_object_get_data (device, "state"), ==, "closed"); + g_object_set_data (device, "state", (gpointer) "opened"); + return TRUE; +} + +static gboolean +_close_cb (GObject *device, GError **error) +{ + g_assert_cmpstr (g_object_get_data (device, "state"), ==, "opened"); + g_object_set_data (device, "state", (gpointer) "closed-on-unref"); + return TRUE; +} + +static void +fu_device_locker_func (void) +{ + g_autoptr(FuDeviceLocker) locker = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GObject) device = g_object_new (G_TYPE_OBJECT, NULL); + + g_object_set_data (device, "state", (gpointer) "closed"); + locker = fu_device_locker_new_full (device, _open_cb, _close_cb, &error); + g_assert_no_error (error); + g_assert_nonnull (locker); + g_clear_object (&locker); + g_assert_cmpstr (g_object_get_data (device, "state"), ==, "closed-on-unref"); +} + +static gboolean +_fail_open_cb (GObject *device, GError **error) +{ + g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "fail"); + return FALSE; +} + +static gboolean +_fail_close_cb (GObject *device, GError **error) +{ + g_assert_not_reached (); + return TRUE; +} + +static void +fu_device_locker_fail_func (void) +{ + g_autoptr(FuDeviceLocker) locker = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GObject) device = g_object_new (G_TYPE_OBJECT, NULL); + locker = fu_device_locker_new_full (device, _fail_open_cb, _fail_close_cb, &error); + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED); + g_assert_null (locker); +} + +static void +fu_common_spawn_func (void) +{ + gboolean ret; + guint lines = 0; + g_autoptr(GError) error = NULL; + g_autofree gchar *fn = NULL; + const gchar *argv[3] = { "replace", "test", NULL }; + + fn = fu_test_get_filename (TESTDATADIR, "spawn.sh"); + g_assert (fn != NULL); + argv[0] = fn; + ret = fu_common_spawn_sync (argv, + fu_test_stdout_cb, &lines, 0, NULL, &error); + g_assert_no_error (error); + g_assert (ret); + g_assert_cmpint (lines, ==, 6); +} + +static void +fu_common_spawn_timeout_func (void) +{ + gboolean ret; + guint lines = 0; + g_autoptr(GError) error = NULL; + g_autofree gchar *fn = NULL; + const gchar *argv[3] = { "replace", "test", NULL }; + + fn = fu_test_get_filename (TESTDATADIR, "spawn.sh"); + g_assert (fn != NULL); + argv[0] = fn; + ret = fu_common_spawn_sync (argv, fu_test_stdout_cb, &lines, 50, NULL, &error); + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED); + g_assert (!ret); + g_assert_cmpint (lines, ==, 1); +} + +static void +fu_progressbar_func (void) +{ + g_autoptr(FuProgressbar) progressbar = fu_progressbar_new (); + + fu_progressbar_set_length_status (progressbar, 20); + fu_progressbar_set_length_percentage (progressbar, 50); + + g_print ("\n"); + for (guint i = 0; i < 100; i++) { + fu_progressbar_update (progressbar, FWUPD_STATUS_DECOMPRESSING, i); + g_usleep (10000); + } + fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); + for (guint i = 0; i < 100; i++) { + guint pc = (i > 25 && i < 75) ? 0 : i; + fu_progressbar_update (progressbar, FWUPD_STATUS_LOADING, pc); + g_usleep (10000); + } + fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); + + for (guint i = 0; i < 5000; i++) { + fu_progressbar_update (progressbar, FWUPD_STATUS_LOADING, 0); + g_usleep (1000); + } + fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); +} + +static void +fu_common_endian_func (void) +{ + guint8 buf[2]; + + fu_common_write_uint16 (buf, 0x1234, G_LITTLE_ENDIAN); + g_assert_cmpint (buf[0], ==, 0x34); + g_assert_cmpint (buf[1], ==, 0x12); + g_assert_cmpint (fu_common_read_uint16 (buf, G_LITTLE_ENDIAN), ==, 0x1234); + + fu_common_write_uint16 (buf, 0x1234, G_BIG_ENDIAN); + g_assert_cmpint (buf[0], ==, 0x12); + g_assert_cmpint (buf[1], ==, 0x34); + g_assert_cmpint (fu_common_read_uint16 (buf, G_BIG_ENDIAN), ==, 0x1234); +} + +static GBytes * +_build_cab (GCabCompression compression, ...) +{ +#ifdef HAVE_GCAB_1_0 + gboolean ret; + va_list args; + g_autoptr(GCabCabinet) cabinet = NULL; + g_autoptr(GCabFolder) cabfolder = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GOutputStream) op = NULL; + + /* create a new archive */ + cabinet = gcab_cabinet_new (); + cabfolder = gcab_folder_new (compression); + ret = gcab_cabinet_add_folder (cabinet, cabfolder, &error); + g_assert_no_error (error); + g_assert (ret); + + /* add each file */ + va_start (args, compression); + do { + const gchar *fn; + const gchar *text; + g_autoptr(GCabFile) cabfile = NULL; + g_autoptr(GBytes) blob = NULL; + + /* get filename */ + fn = va_arg (args, const gchar *); + if (fn == NULL) + break; + + /* get contents */ + text = va_arg (args, const gchar *); + if (text == NULL) + break; + g_debug ("creating %s with %s", fn, text); + + /* add a GCabFile to the cabinet */ + blob = g_bytes_new_static (text, strlen (text)); + cabfile = gcab_file_new_with_bytes (fn, blob); + ret = gcab_folder_add_file (cabfolder, cabfile, FALSE, NULL, &error); + g_assert_no_error (error); + g_assert (ret); + } while (TRUE); + va_end (args); + + /* write the archive to a blob */ + op = g_memory_output_stream_new_resizable (); + ret = gcab_cabinet_write_simple (cabinet, op, NULL, NULL, NULL, &error); + g_assert_no_error (error); + g_assert (ret); + ret = g_output_stream_close (op, NULL, &error); + g_assert_no_error (error); + g_assert (ret); + return g_memory_output_stream_steal_as_bytes (G_MEMORY_OUTPUT_STREAM (op)); +#else + return NULL; +#endif +} + +static void +fu_common_store_cab_func (void) +{ + GBytes *blob_tmp; + g_autoptr(GBytes) blob = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(XbNode) component = NULL; + g_autoptr(XbNode) csum = NULL; + g_autoptr(XbNode) rel = NULL; + g_autoptr(XbNode) req = NULL; + g_autoptr(XbSilo) silo = NULL; + + /* create silo */ + blob = _build_cab (GCAB_COMPRESSION_NONE, + "acme.metainfo.xml", + "\n" + " com.acme.example.firmware\n" + " ACME Firmware\n" + " \n" + " ae56e3fb-6528-5bc4-8b03-012f124075d7\n" + " \n" + " \n" + " \n" + " 5\n" + " 7c211433f02071597741e6ff5a8ea34789abbf43\n" + "

We fixed things

\n" + "
\n" + "
\n" + " \n" + " org.freedesktop.fwupd\n" + " \n" + "
", + "firmware.dfu", "world", + "firmware.dfu.asc", "signature", + NULL); + if (blob == NULL) { + g_test_skip ("libgcab too old"); + return; + } + silo = fu_common_cab_build_silo (blob, 10240, &error); + g_assert_no_error (error); + g_assert_nonnull (silo); + + /* verify */ + component = xb_silo_query_first (silo, "components/component/id[text()='com.acme.example.firmware']/..", &error); + g_assert_no_error (error); + g_assert_nonnull (component); + rel = xb_node_query_first (component, "releases/release", &error); + g_assert_no_error (error); + g_assert_nonnull (rel); + g_assert_cmpstr (xb_node_get_attr (rel, "version"), ==, "1.2.3"); + csum = xb_node_query_first (rel, "checksum[@target='content']", &error); + g_assert_nonnull (csum); + g_assert_cmpstr (xb_node_get_text (csum), ==, "7c211433f02071597741e6ff5a8ea34789abbf43"); + blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.dfu)"); + g_assert_nonnull (blob_tmp); + blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.dfu.asc)"); + g_assert_nonnull (blob_tmp); + req = xb_node_query_first (component, "requires/id", &error); + g_assert_no_error (error); + g_assert_nonnull (req); +} + +static void +fu_common_store_cab_unsigned_func (void) +{ + GBytes *blob_tmp; + g_autoptr(GBytes) blob = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(XbNode) component = NULL; + g_autoptr(XbNode) csum = NULL; + g_autoptr(XbNode) rel = NULL; + g_autoptr(XbSilo) silo = NULL; + + /* create silo */ + blob = _build_cab (GCAB_COMPRESSION_NONE, + "acme.metainfo.xml", + "\n" + " com.acme.example.firmware\n" + " \n" + " \n" + " \n" + "", + "firmware.bin", "world", + NULL); + if (blob == NULL) { + g_test_skip ("libgcab too old"); + return; + } + silo = fu_common_cab_build_silo (blob, 10240, &error); + g_assert_no_error (error); + g_assert_nonnull (silo); + + /* verify */ + component = xb_silo_query_first (silo, "components/component/id[text()='com.acme.example.firmware']/..", &error); + g_assert_no_error (error); + g_assert_nonnull (component); + rel = xb_node_query_first (component, "releases/release", &error); + g_assert_no_error (error); + g_assert_nonnull (rel); + g_assert_cmpstr (xb_node_get_attr (rel, "version"), ==, "1.2.3"); + csum = xb_node_query_first (rel, "checksum[@target='content']", &error); + g_assert_null (csum); + blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.bin)"); + g_assert_nonnull (blob_tmp); + blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.bin.asc)"); + g_assert_null (blob_tmp); +} + +static void +fu_common_store_cab_folder_func (void) +{ + GBytes *blob_tmp; + g_autoptr(GBytes) blob = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(XbNode) component = NULL; + g_autoptr(XbNode) rel = NULL; + g_autoptr(XbSilo) silo = NULL; + + /* create silo */ + blob = _build_cab (GCAB_COMPRESSION_NONE, + "lvfs\\acme.metainfo.xml", + "\n" + " com.acme.example.firmware\n" + " \n" + " \n" + " \n" + "", + "lvfs\\firmware.bin", "world", + NULL); + if (blob == NULL) { + g_test_skip ("libgcab too old"); + return; + } + silo = fu_common_cab_build_silo (blob, 10240, &error); + g_assert_no_error (error); + g_assert_nonnull (silo); + + /* verify */ + component = xb_silo_query_first (silo, "components/component/id[text()='com.acme.example.firmware']/..", &error); + g_assert_no_error (error); + g_assert_nonnull (component); + rel = xb_node_query_first (component, "releases/release", &error); + g_assert_no_error (error); + g_assert_nonnull (rel); + g_assert_cmpstr (xb_node_get_attr (rel, "version"), ==, "1.2.3"); + blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.bin)"); + g_assert_nonnull (blob_tmp); +} + +static void +fu_common_store_cab_error_no_metadata_func (void) +{ + g_autoptr(XbSilo) silo = NULL; + g_autoptr(GBytes) blob = NULL; + g_autoptr(GError) error = NULL; + + blob = _build_cab (GCAB_COMPRESSION_NONE, + "foo.txt", "hello", + "bar.txt", "world", + NULL); + if (blob == NULL) { + g_test_skip ("libgcab too old"); + return; + } + silo = fu_common_cab_build_silo (blob, 10240, &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); + g_assert_null (silo); +} + +static void +fu_common_store_cab_error_wrong_size_func (void) +{ + g_autoptr(XbSilo) silo = NULL; + g_autoptr(GBytes) blob = NULL; + g_autoptr(GError) error = NULL; + + blob = _build_cab (GCAB_COMPRESSION_NONE, + "acme.metainfo.xml", + "\n" + " com.acme.example.firmware\n" + " \n" + " \n" + " 7004701\n" + " deadbeef\n" + " \n" + " \n" + "", + "firmware.bin", "world", + NULL); + if (blob == NULL) { + g_test_skip ("libgcab too old"); + return; + } + silo = fu_common_cab_build_silo (blob, 10240, &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); + g_assert_null (silo); +} + +static void +fu_common_store_cab_error_missing_file_func (void) +{ + g_autoptr(XbSilo) silo = NULL; + g_autoptr(GBytes) blob = NULL; + g_autoptr(GError) error = NULL; + + blob = _build_cab (GCAB_COMPRESSION_NONE, + "acme.metainfo.xml", + "\n" + " com.acme.example.firmware\n" + " \n" + " \n" + " \n" + " \n" + " \n" + "", + "firmware.bin", "world", + NULL); + if (blob == NULL) { + g_test_skip ("libgcab too old"); + return; + } + silo = fu_common_cab_build_silo (blob, 10240, &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); + g_assert_null (silo); +} + +static void +fu_common_store_cab_error_size_func (void) +{ + g_autoptr(XbSilo) silo = NULL; + g_autoptr(GBytes) blob = NULL; + g_autoptr(GError) error = NULL; + + blob = _build_cab (GCAB_COMPRESSION_NONE, + "acme.metainfo.xml", + "\n" + " com.acme.example.firmware\n" + " \n" + " \n" + " \n" + "", + "firmware.bin", "world", + NULL); + if (blob == NULL) { + g_test_skip ("libgcab too old"); + return; + } + silo = fu_common_cab_build_silo (blob, 123, &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); + g_assert_null (silo); +} + +static void +fu_common_store_cab_error_wrong_checksum_func (void) +{ + g_autoptr(XbSilo) silo = NULL; + g_autoptr(GBytes) blob = NULL; + g_autoptr(GError) error = NULL; + + blob = _build_cab (GCAB_COMPRESSION_NONE, + "acme.metainfo.xml", + "\n" + " com.acme.example.firmware\n" + " \n" + " \n" + " deadbeef\n" + " \n" + " \n" + "", + "firmware.bin", "world", + NULL); + if (blob == NULL) { + g_test_skip ("libgcab too old"); + return; + } + silo = fu_common_cab_build_silo (blob, 10240, &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); + g_assert_null (silo); +} + +static gboolean +fu_device_poll_cb (FuDevice *device, GError **error) +{ + guint64 cnt = fu_device_get_metadata_integer (device, "cnt"); + g_debug ("poll cnt=%" G_GUINT64_FORMAT, cnt); + fu_device_set_metadata_integer (device, "cnt", cnt + 1); + return TRUE; +} + +static void +fu_device_poll_func (void) +{ + g_autoptr(FuDevice) device = fu_device_new (); + FuDeviceClass *klass = FU_DEVICE_GET_CLASS (device); + guint cnt; + + /* set up a 10ms poll */ + klass->poll = fu_device_poll_cb; + fu_device_set_metadata_integer (device, "cnt", 0); + fu_device_set_poll_interval (device, 10); + fu_test_loop_run_with_timeout (100); + fu_test_loop_quit (); + cnt = fu_device_get_metadata_integer (device, "cnt"); + g_assert_cmpint (cnt, >=, 8); + + /* disable the poll */ + fu_device_set_poll_interval (device, 0); + fu_test_loop_run_with_timeout (100); + fu_test_loop_quit (); + g_assert_cmpint (fu_device_get_metadata_integer (device, "cnt"), ==, cnt); +} + +static void +fu_device_incorporate_func (void) +{ + g_autoptr(FuDevice) device = fu_device_new (); + g_autoptr(FuDevice) donor = fu_device_new (); + + /* set up donor device */ + fu_device_set_alternate_id (donor, "alt-id"); + fu_device_set_equivalent_id (donor, "equiv-id"); + fu_device_set_metadata (donor, "test", "me"); + fu_device_set_metadata (donor, "test2", "me"); + + /* base properties */ + fu_device_add_flag (donor, FWUPD_DEVICE_FLAG_REQUIRE_AC); + fu_device_set_created (donor, 123); + fu_device_set_modified (donor, 456); + fu_device_add_icon (donor, "computer"); + + /* existing properties */ + fu_device_set_equivalent_id (device, "DO_NOT_OVERWRITE"); + fu_device_set_metadata (device, "test2", "DO_NOT_OVERWRITE"); + fu_device_set_modified (device, 789); + + /* incorporate properties from donor to device */ + fu_device_incorporate (device, donor); + g_assert_cmpstr (fu_device_get_alternate_id (device), ==, "alt-id"); + g_assert_cmpstr (fu_device_get_equivalent_id (device), ==, "DO_NOT_OVERWRITE"); + g_assert_cmpstr (fu_device_get_metadata (device, "test"), ==, "me"); + g_assert_cmpstr (fu_device_get_metadata (device, "test2"), ==, "DO_NOT_OVERWRITE"); + g_assert_true (fu_device_has_flag (device, FWUPD_DEVICE_FLAG_REQUIRE_AC)); + g_assert_cmpint (fu_device_get_created (device), ==, 123); + g_assert_cmpint (fu_device_get_modified (device), ==, 789); + g_assert_cmpint (fu_device_get_icons(device)->len, ==, 1); +} + +static void +fu_chunk_func (void) +{ + g_autofree gchar *chunked1_str = NULL; + g_autofree gchar *chunked2_str = NULL; + g_autofree gchar *chunked3_str = NULL; + g_autofree gchar *chunked4_str = NULL; + g_autoptr(GPtrArray) chunked1 = NULL; + g_autoptr(GPtrArray) chunked2 = NULL; + g_autoptr(GPtrArray) chunked3 = NULL; + g_autoptr(GPtrArray) chunked4 = NULL; + + chunked3 = fu_chunk_array_new ((const guint8 *) "123456", 6, 0x0, 3, 3); + chunked3_str = fu_chunk_array_to_string (chunked3); + g_print ("\n%s", chunked3_str); + g_assert_cmpstr (chunked3_str, ==, "#00: page:00 addr:0000 len:03 123\n" + "#01: page:01 addr:0000 len:03 456\n"); + + chunked4 = fu_chunk_array_new ((const guint8 *) "123456", 6, 0x4, 4, 4); + chunked4_str = fu_chunk_array_to_string (chunked4); + g_print ("\n%s", chunked4_str); + g_assert_cmpstr (chunked4_str, ==, "#00: page:01 addr:0000 len:04 1234\n" + "#01: page:02 addr:0000 len:02 56\n"); + + chunked1 = fu_chunk_array_new ((const guint8 *) "0123456789abcdef", 16, 0x0, 10, 4); + chunked1_str = fu_chunk_array_to_string (chunked1); + g_print ("\n%s", chunked1_str); + g_assert_cmpstr (chunked1_str, ==, "#00: page:00 addr:0000 len:04 0123\n" + "#01: page:00 addr:0004 len:04 4567\n" + "#02: page:00 addr:0008 len:02 89\n" + "#03: page:01 addr:0000 len:04 abcd\n" + "#04: page:01 addr:0004 len:02 ef\n"); + + chunked2 = fu_chunk_array_new ((const guint8 *) "XXXXXXYYYYYYZZZZZZ", 18, 0x0, 6, 4); + chunked2_str = fu_chunk_array_to_string (chunked2); + g_print ("\n%s", chunked2_str); + g_assert_cmpstr (chunked2_str, ==, "#00: page:00 addr:0000 len:04 XXXX\n" + "#01: page:00 addr:0004 len:02 XX\n" + "#02: page:01 addr:0000 len:04 YYYY\n" + "#03: page:01 addr:0004 len:02 YY\n" + "#04: page:02 addr:0000 len:04 ZZZZ\n" + "#05: page:02 addr:0004 len:02 ZZ\n"); +} + +static void +fu_common_strstrip_func (void) +{ + + struct { + const gchar *old; + const gchar *new; + } map[] = { + { "same", "same" }, + { " leading", "leading" }, + { "tailing ", "tailing" }, + { " b ", "b" }, + { " ", "" }, + { NULL, NULL } + }; + for (guint i = 0; map[i].old != NULL; i++) { + g_autofree gchar *tmp = fu_common_strstrip (map[i].old); + g_assert_cmpstr (tmp, ==, map[i].new); + } +} + +static void +fu_common_version_func (void) +{ + guint i; + struct { + guint32 val; + const gchar *ver; + FwupdVersionFormat flags; + } version_from_uint32[] = { + { 0x0, "0.0.0.0", FWUPD_VERSION_FORMAT_QUAD }, + { 0xff, "0.0.0.255", FWUPD_VERSION_FORMAT_QUAD }, + { 0xff01, "0.0.255.1", FWUPD_VERSION_FORMAT_QUAD }, + { 0xff0001, "0.255.0.1", FWUPD_VERSION_FORMAT_QUAD }, + { 0xff000100, "255.0.1.0", FWUPD_VERSION_FORMAT_QUAD }, + { 0x0, "0.0.0", FWUPD_VERSION_FORMAT_TRIPLET }, + { 0xff, "0.0.255", FWUPD_VERSION_FORMAT_TRIPLET }, + { 0xff01, "0.0.65281", FWUPD_VERSION_FORMAT_TRIPLET }, + { 0xff0001, "0.255.1", FWUPD_VERSION_FORMAT_TRIPLET }, + { 0xff000100, "255.0.256", FWUPD_VERSION_FORMAT_TRIPLET }, + { 0x0, "0", FWUPD_VERSION_FORMAT_NUMBER }, + { 0xff000100, "4278190336", FWUPD_VERSION_FORMAT_NUMBER }, + { 0x0, "11.0.0.0", FWUPD_VERSION_FORMAT_INTEL_ME }, + { 0xffffffff, "18.31.255.65535", FWUPD_VERSION_FORMAT_INTEL_ME }, + { 0x0b32057a, "11.11.50.1402", FWUPD_VERSION_FORMAT_INTEL_ME }, + { 0xb8320d84, "11.8.50.3460", FWUPD_VERSION_FORMAT_INTEL_ME2 }, + { 0x226a4b00, "137.2706.768", FWUPD_VERSION_FORMAT_SURFACE_LEGACY }, + { 0x6001988, "6.25.136", FWUPD_VERSION_FORMAT_SURFACE }, + { 0, NULL } + }; + struct { + guint16 val; + const gchar *ver; + FwupdVersionFormat flags; + } version_from_uint16[] = { + { 0x0, "0.0", FWUPD_VERSION_FORMAT_PAIR }, + { 0xff, "0.255", FWUPD_VERSION_FORMAT_PAIR }, + { 0xff01, "255.1", FWUPD_VERSION_FORMAT_PAIR }, + { 0x0, "0.0", FWUPD_VERSION_FORMAT_BCD }, + { 0x0110, "1.10", FWUPD_VERSION_FORMAT_BCD }, + { 0x9999, "99.99", FWUPD_VERSION_FORMAT_BCD }, + { 0x0, "0", FWUPD_VERSION_FORMAT_NUMBER }, + { 0x1234, "4660", FWUPD_VERSION_FORMAT_NUMBER }, + { 0, NULL } + }; + struct { + const gchar *old; + const gchar *new; + } version_parse[] = { + { "0", "0" }, + { "0x1a", "0.0.26" }, + { "257", "0.0.257" }, + { "1.2.3", "1.2.3" }, + { "0xff0001", "0.255.1" }, + { "16711681", "0.255.1" }, + { "20150915", "20150915" }, + { "dave", "dave" }, + { "0x1x", "0x1x" }, + { NULL, NULL } + }; + + /* check version conversion */ + for (i = 0; version_from_uint32[i].ver != NULL; i++) { + g_autofree gchar *ver = NULL; + ver = fu_common_version_from_uint32 (version_from_uint32[i].val, + version_from_uint32[i].flags); + g_assert_cmpstr (ver, ==, version_from_uint32[i].ver); + } + for (i = 0; version_from_uint16[i].ver != NULL; i++) { + g_autofree gchar *ver = NULL; + ver = fu_common_version_from_uint16 (version_from_uint16[i].val, + version_from_uint16[i].flags); + g_assert_cmpstr (ver, ==, version_from_uint16[i].ver); + } + + /* check version parsing */ + for (i = 0; version_parse[i].old != NULL; i++) { + g_autofree gchar *ver = NULL; + ver = fu_common_version_parse (version_parse[i].old); + g_assert_cmpstr (ver, ==, version_parse[i].new); + } +} + +static void +fu_common_vercmp_func (void) +{ + /* same */ + g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.3"), ==, 0); + g_assert_cmpint (fu_common_vercmp ("001.002.003", "001.002.003"), ==, 0); + + /* same, not dotted decimal */ + g_assert_cmpint (fu_common_vercmp ("1.2.3", "0x1020003"), ==, 0); + g_assert_cmpint (fu_common_vercmp ("0x10203", "0x10203"), ==, 0); + + /* upgrade and downgrade */ + g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.4"), <, 0); + g_assert_cmpint (fu_common_vercmp ("001.002.000", "001.002.009"), <, 0); + g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.2"), >, 0); + g_assert_cmpint (fu_common_vercmp ("001.002.009", "001.002.000"), >, 0); + + /* unequal depth */ + g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.3.1"), <, 0); + g_assert_cmpint (fu_common_vercmp ("1.2.3.1", "1.2.4"), <, 0); + + /* mixed-alpha-numeric */ + g_assert_cmpint (fu_common_vercmp ("1.2.3a", "1.2.3a"), ==, 0); + g_assert_cmpint (fu_common_vercmp ("1.2.3a", "1.2.3b"), <, 0); + g_assert_cmpint (fu_common_vercmp ("1.2.3b", "1.2.3a"), >, 0); + + /* alpha version append */ + g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.3a"), <, 0); + g_assert_cmpint (fu_common_vercmp ("1.2.3a", "1.2.3"), >, 0); + + /* alpha only */ + g_assert_cmpint (fu_common_vercmp ("alpha", "alpha"), ==, 0); + g_assert_cmpint (fu_common_vercmp ("alpha", "beta"), <, 0); + g_assert_cmpint (fu_common_vercmp ("beta", "alpha"), >, 0); + + /* alpha-compare */ + g_assert_cmpint (fu_common_vercmp ("1.2a.3", "1.2a.3"), ==, 0); + g_assert_cmpint (fu_common_vercmp ("1.2a.3", "1.2b.3"), <, 0); + g_assert_cmpint (fu_common_vercmp ("1.2b.3", "1.2a.3"), >, 0); + + /* tilde is all-powerful */ + g_assert_cmpint (fu_common_vercmp ("1.2.3~rc1", "1.2.3~rc1"), ==, 0); + g_assert_cmpint (fu_common_vercmp ("1.2.3~rc1", "1.2.3"), <, 0); + g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.3~rc1"), >, 0); + g_assert_cmpint (fu_common_vercmp ("1.2.3~rc2", "1.2.3~rc1"), >, 0); + + /* invalid */ + g_assert_cmpint (fu_common_vercmp ("1", NULL), ==, G_MAXINT); + g_assert_cmpint (fu_common_vercmp (NULL, "1"), ==, G_MAXINT); + g_assert_cmpint (fu_common_vercmp (NULL, NULL), ==, G_MAXINT); +} + +static void +fu_firmware_ihex_func (void) +{ + const guint8 *data; + gboolean ret; + gsize len; + g_autofree gchar *filename_hex = NULL; + g_autofree gchar *filename_ref = NULL; + g_autofree gchar *str = NULL; + g_autoptr(FuFirmware) firmware = fu_ihex_firmware_new (); + g_autoptr(GBytes) data_file = NULL; + g_autoptr(GBytes) data_fw = NULL; + g_autoptr(GBytes) data_hex = NULL; + g_autoptr(GBytes) data_ref = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GFile) file_ref = NULL; + g_autoptr(GFile) file_hex = NULL; + + /* load a Intel hex32 file */ + filename_hex = fu_test_get_filename (TESTDATADIR, "firmware.hex"); + g_assert (filename_hex != NULL); + file_hex = g_file_new_for_path (filename_hex); + data_file = g_file_load_bytes (file_hex, NULL, NULL, &error); + g_assert_no_error (error); + g_assert (data_file != NULL); + ret = fu_firmware_parse (firmware, data_file, FWUPD_INSTALL_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert (ret); + data_fw = fu_firmware_get_image_default_bytes (firmware, &error); + g_assert_no_error (error); + g_assert_nonnull (data_fw); + g_assert_cmpint (g_bytes_get_size (data_fw), ==, 136); + + /* did we match the reference file? */ + filename_ref = fu_test_get_filename (TESTDATADIR, "firmware.bin"); + g_assert (filename_ref != NULL); + file_ref = g_file_new_for_path (filename_ref); + data_ref = g_file_load_bytes (file_ref, NULL, NULL, &error); + g_assert_no_error (error); + g_assert (data_ref != NULL); + ret = fu_common_bytes_compare (data_fw, data_ref, &error); + g_assert_no_error (error); + g_assert_true (ret); + + /* export a ihex file (which will be slightly different due to + * non-continous regions being expanded */ + data_hex = fu_firmware_write (firmware, &error); + g_assert_no_error (error); + g_assert (data_hex != NULL); + data = g_bytes_get_data (data_hex, &len); + str = g_strndup ((const gchar *) data, len); + g_assert_cmpstr (str, ==, + ":104000003DEF20F000000000FACF01F0FBCF02F0FE\n" + ":10401000E9CF03F0EACF04F0E1CF05F0E2CF06F0FC\n" + ":10402000D9CF07F0DACF08F0F3CF09F0F4CF0AF0D8\n" + ":10403000F6CF0BF0F7CF0CF0F8CF0DF0F5CF0EF078\n" + ":104040000EC0F5FF0DC0F8FF0CC0F7FF0BC0F6FF68\n" + ":104050000AC0F4FF09C0F3FF08C0DAFF07C0D9FFA8\n" + ":1040600006C0E2FF05C0E1FF04C0EAFF03C0E9FFAC\n" + ":1040700002C0FBFF01C0FAFF11003FEF20F000017A\n" + ":0840800042EF20F03DEF20F0BB\n" + ":00000001FF\n"); +} + +static void +fu_firmware_ihex_signed_func (void) +{ + const guint8 *data; + gboolean ret; + gsize len; + g_autofree gchar *filename_shex = NULL; + g_autoptr(FuFirmware) firmware = fu_ihex_firmware_new (); + g_autoptr(GBytes) data_file = NULL; + g_autoptr(GBytes) data_fw = NULL; + g_autoptr(GBytes) data_sig = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GFile) file_hex = NULL; + + /* load a signed Intel hex32 file */ + filename_shex = fu_test_get_filename (TESTDATADIR, "firmware.shex"); + g_assert (filename_shex != NULL); + file_hex = g_file_new_for_path (filename_shex); + data_file = g_file_load_bytes (file_hex, NULL, NULL, &error); + g_assert_no_error (error); + g_assert (data_file != NULL); + ret = fu_firmware_parse (firmware, data_file, FWUPD_INSTALL_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert (ret); + data_fw = fu_firmware_get_image_by_id_bytes (firmware, NULL, &error); + g_assert_no_error (error); + g_assert_nonnull (data_fw); + g_assert_cmpint (g_bytes_get_size (data_fw), ==, 136); + + /* get the signed image */ + data_sig = fu_firmware_get_image_by_id_bytes (firmware, + FU_FIRMWARE_IMAGE_ID_SIGNATURE, + &error); + g_assert_no_error (error); + g_assert_nonnull (data_sig); + data = g_bytes_get_data (data_sig, &len); + g_assert_cmpint (len, ==, 8); + g_assert (data != NULL); + g_assert_cmpint (memcmp (data, "deadbeef", 8), ==, 0); +} + +static void +fu_firmware_ihex_offset_func (void) +{ + const guint8 *data; + gboolean ret; + gsize len; + g_autofree gchar *str = NULL; + g_autoptr(FuFirmware) firmware = fu_ihex_firmware_new (); + g_autoptr(FuFirmware) firmware_verify = fu_ihex_firmware_new (); + g_autoptr(FuFirmwareImage) img_verify = NULL; + g_autoptr(FuFirmwareImage) img = NULL; + g_autoptr(GBytes) data_bin = NULL; + g_autoptr(GBytes) data_dummy = NULL; + g_autoptr(GBytes) data_verify = NULL; + g_autoptr(GError) error = NULL; + + /* add a 4 byte image in high memory */ + data_dummy = g_bytes_new_static ("foo", 4); + img = fu_firmware_image_new (data_dummy); + fu_firmware_image_set_addr (img, 0x80000000); + fu_firmware_add_image (firmware, img); + data_bin = fu_firmware_write (firmware, &error); + g_assert_no_error (error); + g_assert (data_bin != NULL); + data = g_bytes_get_data (data_bin, &len); + str = g_strndup ((const gchar *) data, len); + g_assert_cmpstr (str, ==, + ":0200000480007A\n" + ":04000000666F6F00B8\n" + ":00000001FF\n"); + + /* check we can load it too */ + ret = fu_firmware_parse (firmware_verify, data_bin, FWUPD_INSTALL_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert (ret); + img_verify = fu_firmware_get_image_default (firmware_verify, &error); + g_assert_no_error (error); + g_assert (img_verify != NULL); + g_assert_cmpint (fu_firmware_image_get_addr (img_verify), ==, 0x80000000); + data_verify = fu_firmware_image_write (img_verify, &error); + g_assert_no_error (error); + g_assert (data_verify != NULL); + g_assert_cmpint (g_bytes_get_size (data_verify), ==, 0x4); +} + +static void +fu_firmware_srec_func (void) +{ + gboolean ret; + g_autofree gchar *filename_srec = NULL; + g_autofree gchar *filename_ref = NULL; + g_autoptr(FuFirmware) firmware = fu_srec_firmware_new (); + g_autoptr(GBytes) data_ref = NULL; + g_autoptr(GBytes) data_srec = NULL; + g_autoptr(GBytes) data_bin = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GFile) file_bin = NULL; + g_autoptr(GFile) file_srec = NULL; + + filename_srec = fu_test_get_filename (TESTDATADIR, "firmware.srec"); + g_assert (filename_srec != NULL); + file_srec = g_file_new_for_path (filename_srec); + data_srec = g_file_load_bytes (file_srec, NULL, NULL, &error); + g_assert_no_error (error); + g_assert (data_srec != NULL); + ret = fu_firmware_parse (firmware, data_srec, FWUPD_INSTALL_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert (ret); + data_bin = fu_firmware_get_image_default_bytes (firmware, &error); + g_assert_no_error (error); + g_assert_nonnull (data_bin); + g_assert_cmpint (g_bytes_get_size (data_bin), ==, 136); + + /* did we match the reference file? */ + filename_ref = fu_test_get_filename (TESTDATADIR, "firmware.bin"); + g_assert (filename_ref != NULL); + file_bin = g_file_new_for_path (filename_ref); + data_ref = g_file_load_bytes (file_bin, NULL, NULL, &error); + g_assert_no_error (error); + g_assert (data_ref != NULL); + ret = fu_common_bytes_compare (data_bin, data_ref, &error); + g_assert_no_error (error); + g_assert_true (ret); +} + +static void +fu_firmware_srec_tokenization_func (void) +{ + FuSrecFirmwareRecord *rcd; + GPtrArray *records; + gboolean ret; + g_autoptr(FuFirmware) firmware = fu_srec_firmware_new (); + g_autoptr(GBytes) data_srec = NULL; + g_autoptr(GError) error = NULL; + const gchar *buf = "S3060000001400E5\r\n" + "S31000000002281102000000007F0304002C\r\n" + "S306000000145095\r\n" + "S70500000000FA\r\n"; + data_srec = g_bytes_new_static (buf, strlen (buf)); + g_assert_no_error (error); + g_assert (data_srec != NULL); + ret = fu_firmware_tokenize (firmware, data_srec, FWUPD_INSTALL_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert (ret); + + records = fu_srec_firmware_get_records (FU_SREC_FIRMWARE (firmware)); + g_assert_nonnull (records); + g_assert_cmpint (records->len, ==, 4); + rcd = g_ptr_array_index (records, 2); + g_assert_nonnull (rcd); + g_assert_cmpint (rcd->ln, ==, 0x3); + g_assert_cmpint (rcd->kind, ==, 3); + g_assert_cmpint (rcd->addr, ==, 0x14); + g_assert_cmpint (rcd->buf->len, ==, 0x1); + g_assert_cmpint (rcd->buf->data[0], ==, 0x50); +} + +static void +fu_firmware_dfu_func (void) +{ + gboolean ret; + g_autofree gchar *filename_dfu = NULL; + g_autofree gchar *filename_ref = NULL; + g_autoptr(FuFirmware) firmware = fu_dfu_firmware_new (); + g_autoptr(GBytes) data_ref = NULL; + g_autoptr(GBytes) data_dfu = NULL; + g_autoptr(GBytes) data_bin = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GFile) file_bin = NULL; + g_autoptr(GFile) file_dfu = NULL; + + filename_dfu = fu_test_get_filename (TESTDATADIR, "firmware.dfu"); + g_assert (filename_dfu != NULL); + file_dfu = g_file_new_for_path (filename_dfu); + data_dfu = g_file_load_bytes (file_dfu, NULL, NULL, &error); + g_assert_no_error (error); + g_assert (data_dfu != NULL); + ret = fu_firmware_parse (firmware, data_dfu, FWUPD_INSTALL_FLAG_NONE, &error); + g_assert_no_error (error); + g_assert (ret); + g_assert_cmpint (fu_dfu_firmware_get_vid (FU_DFU_FIRMWARE (firmware)), ==, 0x1234); + g_assert_cmpint (fu_dfu_firmware_get_pid (FU_DFU_FIRMWARE (firmware)), ==, 0x4321); + g_assert_cmpint (fu_dfu_firmware_get_release (FU_DFU_FIRMWARE (firmware)), ==, 0xdead); + data_bin = fu_firmware_get_image_default_bytes (firmware, &error); + g_assert_no_error (error); + g_assert_nonnull (data_bin); + g_assert_cmpint (g_bytes_get_size (data_bin), ==, 136); + + /* did we match the reference file? */ + filename_ref = fu_test_get_filename (TESTDATADIR, "firmware.bin"); + g_assert (filename_ref != NULL); + file_bin = g_file_new_for_path (filename_ref); + data_ref = g_file_load_bytes (file_bin, NULL, NULL, &error); + g_assert_no_error (error); + g_assert (data_ref != NULL); + ret = fu_common_bytes_compare (data_bin, data_ref, &error); + g_assert_no_error (error); + g_assert_true (ret); +} + +static void +fu_firmware_func (void) +{ + g_autoptr(FuFirmware) firmware = fu_firmware_new (); + g_autoptr(FuFirmwareImage) img1 = fu_firmware_image_new (NULL); + g_autoptr(FuFirmwareImage) img2 = fu_firmware_image_new (NULL); + g_autoptr(FuFirmwareImage) img_id = NULL; + g_autoptr(FuFirmwareImage) img_idx = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *str = NULL; + + fu_firmware_image_set_addr (img1, 0x200); + fu_firmware_image_set_idx (img1, 13); + fu_firmware_image_set_id (img1, "primary"); + fu_firmware_add_image (firmware, img1); + fu_firmware_image_set_addr (img2, 0x400); + fu_firmware_image_set_idx (img2, 23); + fu_firmware_image_set_id (img2, "secondary"); + fu_firmware_add_image (firmware, img2); + + img_id = fu_firmware_get_image_by_id (firmware, "NotGoingToExist", &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND); + g_assert_null (img_id); + g_clear_error (&error); + img_id = fu_firmware_get_image_by_id (firmware, "primary", &error); + g_assert_no_error (error); + g_assert_nonnull (img_id); + g_assert_cmpint (fu_firmware_image_get_addr (img_id), ==, 0x200); + g_assert_cmpint (fu_firmware_image_get_idx (img_id), ==, 13); + g_assert_cmpstr (fu_firmware_image_get_id (img_id), ==, "primary"); + + img_idx = fu_firmware_get_image_by_idx (firmware, 123456, &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND); + g_assert_null (img_idx); + g_clear_error (&error); + img_idx = fu_firmware_get_image_by_idx (firmware, 23, &error); + g_assert_no_error (error); + g_assert_nonnull (img_idx); + g_assert_cmpint (fu_firmware_image_get_addr (img_idx), ==, 0x400); + g_assert_cmpint (fu_firmware_image_get_idx (img_idx), ==, 23); + g_assert_cmpstr (fu_firmware_image_get_id (img_idx), ==, "secondary"); + + str = fu_firmware_to_string (firmware); + g_assert_cmpstr (str, ==, "FuFirmware:\n" + " FuFirmwareImage:\n" + " ID: primary\n" + " Index: 0xd\n" + " Address: 0x200\n" + " FuFirmwareImage:\n" + " ID: secondary\n" + " Index: 0x17\n" + " Address: 0x400\n"); +} + +int +main (int argc, char **argv) +{ + g_test_init (&argc, &argv, NULL); + + /* only critical and error are fatal */ + g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL); + g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); + g_setenv ("FWUPD_DATADIR", TESTDATADIR_SRC, TRUE); + g_setenv ("FWUPD_PLUGINDIR", TESTDATADIR_SRC, TRUE); + g_setenv ("FWUPD_SYSCONFDIR", TESTDATADIR_SRC, TRUE); + g_setenv ("FWUPD_SYSFSFWDIR", TESTDATADIR_SRC, TRUE); + g_setenv ("FWUPD_OFFLINE_TRIGGER", "/tmp/fwupd-self-test/system-update", TRUE); + g_setenv ("FWUPD_LOCALSTATEDIR", "/tmp/fwupd-self-test/var", TRUE); + + if (g_test_slow ()) + g_test_add_func ("/fwupd/progressbar", fu_progressbar_func); + g_test_add_func ("/fwupd/plugin{delay}", fu_plugin_delay_func); + g_test_add_func ("/fwupd/plugin{quirks}", fu_plugin_quirks_func); + g_test_add_func ("/fwupd/plugin{quirks-performance}", fu_plugin_quirks_performance_func); + g_test_add_func ("/fwupd/plugin{quirks-device}", fu_plugin_quirks_device_func); + g_test_add_func ("/fwupd/chunk", fu_chunk_func); + g_test_add_func ("/fwupd/common{string-append-kv}", fu_common_string_append_kv_func); + g_test_add_func ("/fwupd/common{version-guess-format}", fu_common_version_guess_format_func); + g_test_add_func ("/fwupd/common{version}", fu_common_version_func); + g_test_add_func ("/fwupd/common{vercmp}", fu_common_vercmp_func); + g_test_add_func ("/fwupd/common{strstrip}", fu_common_strstrip_func); + g_test_add_func ("/fwupd/common{endian}", fu_common_endian_func); + g_test_add_func ("/fwupd/common{cab-success}", fu_common_store_cab_func); + g_test_add_func ("/fwupd/common{cab-success-unsigned}", fu_common_store_cab_unsigned_func); + g_test_add_func ("/fwupd/common{cab-success-folder}", fu_common_store_cab_folder_func); + g_test_add_func ("/fwupd/common{cab-error-no-metadata}", fu_common_store_cab_error_no_metadata_func); + g_test_add_func ("/fwupd/common{cab-error-wrong-size}", fu_common_store_cab_error_wrong_size_func); + g_test_add_func ("/fwupd/common{cab-error-wrong-checksum}", fu_common_store_cab_error_wrong_checksum_func); + g_test_add_func ("/fwupd/common{cab-error-missing-file}", fu_common_store_cab_error_missing_file_func); + g_test_add_func ("/fwupd/common{cab-error-size}", fu_common_store_cab_error_size_func); + g_test_add_func ("/fwupd/common{spawn)", fu_common_spawn_func); + g_test_add_func ("/fwupd/common{spawn-timeout)", fu_common_spawn_timeout_func); + g_test_add_func ("/fwupd/common{firmware-builder}", fu_common_firmware_builder_func); + g_test_add_func ("/fwupd/hwids", fu_hwids_func); + g_test_add_func ("/fwupd/smbios", fu_smbios_func); + g_test_add_func ("/fwupd/smbios3", fu_smbios3_func); + g_test_add_func ("/fwupd/firmware", fu_firmware_func); + g_test_add_func ("/fwupd/firmware{ihex}", fu_firmware_ihex_func); + g_test_add_func ("/fwupd/firmware{ihex-offset}", fu_firmware_ihex_offset_func); + g_test_add_func ("/fwupd/firmware{ihex-signed}", fu_firmware_ihex_signed_func); + g_test_add_func ("/fwupd/firmware{srec-tokenization}", fu_firmware_srec_tokenization_func); + g_test_add_func ("/fwupd/firmware{srec}", fu_firmware_srec_func); + g_test_add_func ("/fwupd/firmware{dfu}", fu_firmware_dfu_func); + g_test_add_func ("/fwupd/archive{invalid}", fu_archive_invalid_func); + g_test_add_func ("/fwupd/archive{cab}", fu_archive_cab_func); + g_test_add_func ("/fwupd/device{incorporate}", fu_device_incorporate_func); + if (g_test_slow ()) + g_test_add_func ("/fwupd/device{poll}", fu_device_poll_func); + g_test_add_func ("/fwupd/device-locker{success}", fu_device_locker_func); + g_test_add_func ("/fwupd/device-locker{fail}", fu_device_locker_fail_func); + g_test_add_func ("/fwupd/device{metadata}", fu_device_metadata_func); + g_test_add_func ("/fwupd/device{open-refcount}", fu_device_open_refcount_func); + g_test_add_func ("/fwupd/device{version-format}", fu_device_version_format_func); + return g_test_run (); +} diff --git a/libfwupdplugin/fu-smbios-private.h b/libfwupdplugin/fu-smbios-private.h new file mode 100644 index 000000000..97c46baae --- /dev/null +++ b/libfwupdplugin/fu-smbios-private.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2017 Richard Hughes + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#pragma once + +#include + +#include "fu-smbios.h" + +gboolean fu_smbios_setup (FuSmbios *self, + GError **error); +gboolean fu_smbios_setup_from_path (FuSmbios *self, + const gchar *path, + GError **error); +gboolean fu_smbios_setup_from_file (FuSmbios *self, + const gchar *filename, + GError **error); diff --git a/src/fu-smbios.c b/libfwupdplugin/fu-smbios.c similarity index 99% rename from src/fu-smbios.c rename to libfwupdplugin/fu-smbios.c index 559020213..c1e9cdee4 100644 --- a/src/fu-smbios.c +++ b/libfwupdplugin/fu-smbios.c @@ -12,7 +12,7 @@ #include #include "fu-common.h" -#include "fu-smbios.h" +#include "fu-smbios-private.h" #include "fwupd-error.h" struct _FuSmbios { diff --git a/src/fu-smbios.h b/libfwupdplugin/fu-smbios.h similarity index 72% rename from src/fu-smbios.h rename to libfwupdplugin/fu-smbios.h index d3b734f66..e9ef02c74 100644 --- a/src/fu-smbios.h +++ b/libfwupdplugin/fu-smbios.h @@ -19,14 +19,6 @@ FuSmbios *fu_smbios_new (void); #define FU_SMBIOS_STRUCTURE_TYPE_BASEBOARD 0x02 #define FU_SMBIOS_STRUCTURE_TYPE_CHASSIS 0x03 -gboolean fu_smbios_setup (FuSmbios *self, - GError **error); -gboolean fu_smbios_setup_from_path (FuSmbios *self, - const gchar *path, - GError **error); -gboolean fu_smbios_setup_from_file (FuSmbios *self, - const gchar *filename, - GError **error); gchar *fu_smbios_to_string (FuSmbios *self); const gchar *fu_smbios_get_string (FuSmbios *self, diff --git a/src/fu-srec-firmware.c b/libfwupdplugin/fu-srec-firmware.c similarity index 100% rename from src/fu-srec-firmware.c rename to libfwupdplugin/fu-srec-firmware.c diff --git a/src/fu-srec-firmware.h b/libfwupdplugin/fu-srec-firmware.h similarity index 100% rename from src/fu-srec-firmware.h rename to libfwupdplugin/fu-srec-firmware.h diff --git a/src/fu-test.c b/libfwupdplugin/fu-test.c similarity index 100% rename from src/fu-test.c rename to libfwupdplugin/fu-test.c diff --git a/src/fu-test.h b/libfwupdplugin/fu-test.h similarity index 100% rename from src/fu-test.h rename to libfwupdplugin/fu-test.h diff --git a/src/fu-udev-device-private.h b/libfwupdplugin/fu-udev-device-private.h similarity index 100% rename from src/fu-udev-device-private.h rename to libfwupdplugin/fu-udev-device-private.h diff --git a/src/fu-udev-device.c b/libfwupdplugin/fu-udev-device.c similarity index 100% rename from src/fu-udev-device.c rename to libfwupdplugin/fu-udev-device.c diff --git a/src/fu-udev-device.h b/libfwupdplugin/fu-udev-device.h similarity index 100% rename from src/fu-udev-device.h rename to libfwupdplugin/fu-udev-device.h diff --git a/src/fu-usb-device-private.h b/libfwupdplugin/fu-usb-device-private.h similarity index 100% rename from src/fu-usb-device-private.h rename to libfwupdplugin/fu-usb-device-private.h diff --git a/src/fu-usb-device.c b/libfwupdplugin/fu-usb-device.c similarity index 100% rename from src/fu-usb-device.c rename to libfwupdplugin/fu-usb-device.c diff --git a/src/fu-usb-device.h b/libfwupdplugin/fu-usb-device.h similarity index 100% rename from src/fu-usb-device.h rename to libfwupdplugin/fu-usb-device.h diff --git a/libfwupdplugin/fwupdplugin.h b/libfwupdplugin/fwupdplugin.h new file mode 100644 index 000000000..09c70c328 --- /dev/null +++ b/libfwupdplugin/fwupdplugin.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2015 Richard Hughes + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#pragma once + +/** + * SECTION:fwupdplugin + * @short_description: Helper objects for plugins interacting with fwupd daemon + */ + +#define __FWUPDPLUGIN_H_INSIDE__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef FWUPD_DISABLE_DEPRECATED +#include +#endif + +#undef __FWUPDPLUGIN_H_INSIDE__ diff --git a/libfwupdplugin/fwupdplugin.map b/libfwupdplugin/fwupdplugin.map new file mode 100644 index 000000000..aa54114c1 --- /dev/null +++ b/libfwupdplugin/fwupdplugin.map @@ -0,0 +1,532 @@ +# generated automatically, do not edit! + +LIBFWUPDPLUGIN_0.1.0 { + global: + fu_device_add_flag; + fu_device_get_metadata; + fu_device_get_type; + fu_device_new; + fu_device_set_metadata; + local: *; +}; + +LIBFWUPDPLUGIN_0.3.5 { + global: + fu_common_vercmp; + local: *; +} LIBFWUPDPLUGIN_0.1.0; + +LIBFWUPDPLUGIN_0.6.1 { + global: + fu_device_get_equivalent_id; + fu_device_set_equivalent_id; + local: *; +} LIBFWUPDPLUGIN_0.3.5; + +LIBFWUPDPLUGIN_0.7.1 { + global: + fu_device_set_id; + fu_device_set_name; + local: *; +} LIBFWUPDPLUGIN_0.6.1; + +LIBFWUPDPLUGIN_0.7.2 { + global: + fu_device_add_guid; + fu_device_get_alternate; + fu_device_set_alternate; + local: *; +} LIBFWUPDPLUGIN_0.7.1; + +LIBFWUPDPLUGIN_0.8.0 { + global: + fu_plugin_alloc_data; + fu_plugin_cache_add; + fu_plugin_cache_lookup; + fu_plugin_cache_remove; + fu_plugin_device_add; + fu_plugin_device_remove; + fu_plugin_get_data; + fu_plugin_get_enabled; + fu_plugin_get_name; + fu_plugin_get_type; + fu_plugin_get_usb_context; + fu_plugin_new; + fu_plugin_open; + fu_plugin_request_recoldplug; + fu_plugin_runner_clear_results; + fu_plugin_runner_coldplug; + fu_plugin_runner_coldplug_cleanup; + fu_plugin_runner_coldplug_prepare; + fu_plugin_runner_get_results; + fu_plugin_runner_startup; + fu_plugin_runner_unlock; + fu_plugin_runner_update; + fu_plugin_runner_verify; + fu_plugin_set_coldplug_delay; + fu_plugin_set_enabled; + fu_plugin_set_name; + fu_plugin_set_usb_context; + local: *; +} LIBFWUPDPLUGIN_0.7.2; + +LIBFWUPDPLUGIN_0.9.1 { + global: + fu_plugin_check_hwid; + fu_test_get_filename; + fu_test_loop_quit; + fu_test_loop_run_with_timeout; + local: *; +} LIBFWUPDPLUGIN_0.8.0; + +LIBFWUPDPLUGIN_0.9.3 { + global: + fu_hwids_get_guid; + fu_hwids_get_guids; + fu_hwids_get_replace_keys; + fu_hwids_get_replace_values; + fu_hwids_get_type; + fu_hwids_get_value; + fu_hwids_has_guid; + fu_hwids_new; + fu_hwids_setup; + local: *; +} LIBFWUPDPLUGIN_0.9.1; + +LIBFWUPDPLUGIN_0.9.5 { + global: + fu_common_get_contents_fd; + fu_common_set_contents_bytes; + local: *; +} LIBFWUPDPLUGIN_0.9.3; + +LIBFWUPDPLUGIN_0.9.7 { + global: + fu_common_extract_archive; + fu_common_firmware_builder; + fu_common_get_contents_bytes; + fu_common_mkdir_parent; + fu_common_rmtree; + fu_common_spawn_sync; + fu_device_get_metadata_boolean; + fu_device_get_metadata_integer; + fu_device_set_metadata_boolean; + fu_device_set_metadata_integer; + fu_plugin_device_register; + fu_plugin_get_dmi_value; + fu_plugin_runner_device_register; + fu_plugin_set_hwids; + fu_progressbar_get_type; + fu_progressbar_new; + fu_progressbar_set_interactive; + fu_progressbar_set_length_percentage; + fu_progressbar_set_length_status; + fu_progressbar_set_title; + fu_progressbar_update; + local: *; +} LIBFWUPDPLUGIN_0.9.5; + +LIBFWUPDPLUGIN_0.9.8 { + global: + fu_device_to_string; + fu_plugin_get_smbios_data; + fu_plugin_get_smbios_string; + local: *; +} LIBFWUPDPLUGIN_0.9.7; + +LIBFWUPDPLUGIN_1.0.0 { + global: + fu_device_locker_get_type; + fu_device_locker_new; + fu_device_locker_new_full; + fu_plugin_add_rule; + fu_plugin_get_order; + fu_plugin_get_rules; + fu_plugin_has_rule; + fu_plugin_set_order; + fu_plugin_set_priority; + fu_plugin_set_smbios; + fu_smbios_get_data; + fu_smbios_get_string; + fu_smbios_get_type; + fu_smbios_new; + fu_smbios_setup; + fu_smbios_setup_from_file; + fu_smbios_setup_from_path; + fu_smbios_to_string; + local: *; +} LIBFWUPDPLUGIN_0.9.8; + +LIBFWUPDPLUGIN_1.0.1 { + global: + fu_chunk_array_to_string; + fu_chunk_array_to_string; + fu_plugin_get_quirks; + fu_plugin_lookup_quirk_by_id; + fu_plugin_set_quirks; + fu_quirks_get_type; + fu_quirks_load; + fu_quirks_lookup_by_id; + fu_quirks_new; + local: *; +} LIBFWUPDPLUGIN_1.0.0; + +LIBFWUPDPLUGIN_1.0.2 { + global: + fu_device_get_remove_delay; + fu_device_set_remove_delay; + fu_plugin_runner_udev_device_added; + fu_plugin_runner_udev_device_changed; + fu_plugin_runner_usb_device_added; + fu_usb_device_get_dev; + fu_usb_device_get_type; + fu_usb_device_new; + fu_usb_device_set_dev; + local: *; +} LIBFWUPDPLUGIN_1.0.1; + +LIBFWUPDPLUGIN_1.0.3 { + global: + fu_common_read_uint16; + fu_common_read_uint32; + fu_common_write_uint16; + fu_common_write_uint32; + fu_device_get_progress; + fu_device_get_quirks; + fu_device_get_status; + fu_device_set_progress; + fu_device_set_progress_full; + fu_device_set_quirks; + fu_device_set_status; + fu_usb_device_is_open; + local: *; +} LIBFWUPDPLUGIN_1.0.2; + +LIBFWUPDPLUGIN_1.0.4 { + global: + fu_plugin_add_report_metadata; + fu_plugin_get_report_metadata; + fu_plugin_runner_recoldplug; + fu_test_compare_lines; + local: *; +} LIBFWUPDPLUGIN_1.0.3; + +LIBFWUPDPLUGIN_1.0.5 { + global: + fu_device_get_release_default; + local: *; +} LIBFWUPDPLUGIN_1.0.4; + +LIBFWUPDPLUGIN_1.0.6 { + global: + fu_common_get_files_recursive; + fu_plugin_get_config_value; + local: *; +} LIBFWUPDPLUGIN_1.0.5; + +LIBFWUPDPLUGIN_1.0.7 { + global: + fu_plugin_add_compile_version; + fu_plugin_add_runtime_version; + fu_plugin_set_compile_versions; + fu_plugin_set_runtime_versions; + local: *; +} LIBFWUPDPLUGIN_1.0.6; + +LIBFWUPDPLUGIN_1.0.8 { + global: + fu_common_error_array_get_best; + fu_common_get_path; + fu_device_add_child; + fu_device_add_parent_guid; + fu_device_attach; + fu_device_detach; + fu_device_get_children; + fu_device_get_guids_as_str; + fu_device_get_order; + fu_device_get_parent; + fu_device_get_parent_guids; + fu_device_has_parent_guid; + fu_device_read_firmware; + fu_device_set_order; + fu_device_set_parent; + fu_device_write_firmware; + fu_plugin_guess_name_from_fn; + fu_plugin_name_compare; + fu_plugin_order_compare; + local: *; +} LIBFWUPDPLUGIN_1.0.7; + +LIBFWUPDPLUGIN_1.0.9 { + global: + fu_plugin_runner_composite_cleanup; + fu_plugin_runner_composite_prepare; + local: *; +} LIBFWUPDPLUGIN_1.0.8; + +LIBFWUPDPLUGIN_1.1.0 { + global: + fu_device_get_alternate_id; + fu_device_get_custom_flags; + fu_device_has_custom_flag; + fu_device_incorporate; + fu_device_set_alternate_id; + fu_device_set_custom_flags; + local: *; +} LIBFWUPDPLUGIN_1.0.9; + +LIBFWUPDPLUGIN_1.1.1 { + global: + fu_device_get_priority; + fu_device_set_priority; + fu_plugin_get_hwids; + fu_plugin_get_priority; + local: *; +} LIBFWUPDPLUGIN_1.1.0; + +LIBFWUPDPLUGIN_1.1.2 { + global: + fu_chunk_array_new; + fu_chunk_array_new_from_bytes; + fu_chunk_new; + fu_common_find_program_in_path; + fu_common_strstrip; + fu_common_strtoull; + fu_device_add_counterpart_guid; + fu_device_close; + fu_device_ensure_id; + fu_device_get_logical_id; + fu_device_get_physical_id; + fu_device_open; + fu_device_poll; + fu_device_prepare_firmware; + fu_device_probe; + fu_device_probe_invalidate; + fu_device_set_firmware_size_max; + fu_device_set_firmware_size_min; + fu_device_set_logical_id; + fu_device_set_physical_id; + fu_device_set_poll_interval; + fu_device_setup; + fu_plugin_add_udev_subsystem; + fu_plugin_lookup_quirk_by_id_as_uint64; + fu_plugin_runner_device_removed; + fu_plugin_runner_update_attach; + fu_plugin_runner_update_cleanup; + fu_plugin_runner_update_detach; + fu_plugin_runner_update_prepare; + fu_plugin_runner_update_reload; + fu_plugin_set_udev_subsystems; + fu_udev_device_emit_changed; + fu_udev_device_get_dev; + fu_udev_device_get_model; + fu_udev_device_get_revision; + fu_udev_device_get_subsystem; + fu_udev_device_get_sysfs_path; + fu_udev_device_get_type; + fu_udev_device_get_vendor; + fu_udev_device_new; + fu_udev_device_set_physical_id; + fu_usb_device_get_pid; + fu_usb_device_get_platform_id; + fu_usb_device_get_vid; + local: *; +} LIBFWUPDPLUGIN_1.1.1; + +LIBFWUPDPLUGIN_1.2.0 { + global: + fu_common_cab_build_silo; + fu_common_string_replace; + fu_common_version_from_uint16; + fu_common_version_from_uint32; + fu_common_version_guess_format; + fu_common_version_parse; + local: *; +} LIBFWUPDPLUGIN_1.1.2; + +LIBFWUPDPLUGIN_1.2.2 { + global: + fu_archive_get_type; + fu_archive_lookup_by_fn; + fu_archive_new; + fu_common_dump_bytes; + fu_common_dump_raw; + fu_device_has_guid; + fu_io_channel_get_type; + fu_io_channel_new_file; + fu_io_channel_read_bytes; + fu_io_channel_read_raw; + fu_io_channel_shutdown; + fu_io_channel_unix_get_fd; + fu_io_channel_unix_new; + fu_io_channel_write_bytes; + fu_io_channel_write_raw; + local: *; +} LIBFWUPDPLUGIN_1.2.0; + +LIBFWUPDPLUGIN_1.2.4 { + global: + fu_common_bytes_align; + fu_common_dump_full; + fu_common_string_append_kb; + fu_common_string_append_ku; + fu_common_string_append_kv; + fu_common_string_append_kx; + fu_device_incorporate_from_component; + fu_plugin_get_build_hash; + fu_plugin_set_build_hash; + fu_udev_device_get_slot_depth; + local: *; +} LIBFWUPDPLUGIN_1.2.2; + +LIBFWUPDPLUGIN_1.2.5 { + global: + fu_common_guid_is_plausible; + fu_device_add_instance_id; + fu_device_convert_instance_ids; + local: *; +} LIBFWUPDPLUGIN_1.2.4; + +LIBFWUPDPLUGIN_1.2.6 { + global: + fu_common_bytes_compare; + fu_common_bytes_is_empty; + fu_common_realpath; + fu_device_activate; + fu_device_get_firmware_size_max; + fu_device_get_firmware_size_min; + fu_device_set_firmware_size; + fu_plugin_runner_activate; + local: *; +} LIBFWUPDPLUGIN_1.2.5; + +LIBFWUPDPLUGIN_1.2.9 { + global: + fu_common_version_ensure_semver; + fu_common_version_verify_format; + fu_device_add_instance_id_full; + fu_device_set_version; + local: *; +} LIBFWUPDPLUGIN_1.2.6; + +LIBFWUPDPLUGIN_1.3.1 { + global: + fu_byte_array_append_uint16; + fu_byte_array_append_uint32; + fu_byte_array_append_uint8; + fu_common_bytes_pad; + fu_common_strnsplit; + fu_device_rescan; + fu_firmware_add_image; + fu_firmware_get_image_by_id; + fu_firmware_get_image_by_id_bytes; + fu_firmware_get_image_by_idx; + fu_firmware_get_image_by_idx_bytes; + fu_firmware_get_image_default; + fu_firmware_get_image_default_bytes; + fu_firmware_get_images; + fu_firmware_get_type; + fu_firmware_image_get_addr; + fu_firmware_image_get_id; + fu_firmware_image_get_idx; + fu_firmware_image_get_type; + fu_firmware_image_new; + fu_firmware_image_set_addr; + fu_firmware_image_set_bytes; + fu_firmware_image_set_id; + fu_firmware_image_set_idx; + fu_firmware_image_to_string; + fu_firmware_image_write_chunk; + fu_firmware_new; + fu_firmware_new_from_bytes; + fu_firmware_parse; + fu_firmware_parse_full; + fu_firmware_strparse_uint16; + fu_firmware_strparse_uint24; + fu_firmware_strparse_uint32; + fu_firmware_strparse_uint4; + fu_firmware_strparse_uint8; + fu_firmware_to_string; + fu_firmware_write; + fu_ihex_firmware_get_type; + fu_ihex_firmware_new; + fu_memcpy_safe; + fu_plugin_has_custom_flag; + fu_udev_device_get_device_file; + local: *; +} LIBFWUPDPLUGIN_1.2.9; + +LIBFWUPDPLUGIN_1.3.2 { + global: + fu_common_bytes_compare_raw; + fu_common_strwidth; + fu_firmware_tokenize; + fu_io_channel_read_byte_array; + fu_io_channel_write_byte_array; + fu_srec_firmware_get_records; + fu_srec_firmware_get_type; + fu_srec_firmware_new; + fu_srec_firmware_record_new; + fu_usb_device_find_udev_device; + local: *; +} LIBFWUPDPLUGIN_1.3.1; + +LIBFWUPDPLUGIN_1.3.3 { + global: + fu_common_read_uint16_safe; + fu_common_read_uint32_safe; + fu_common_read_uint8_safe; + fu_common_version_parse_from_format; + fu_device_cleanup; + fu_device_get_possible_plugins; + fu_device_get_specialized_gtype; + fu_device_prepare; + fu_device_reload; + fu_device_remove_metadata; + fu_dfu_firmware_get_pid; + fu_dfu_firmware_get_release; + fu_dfu_firmware_get_type; + fu_dfu_firmware_get_version; + fu_dfu_firmware_get_vid; + fu_dfu_firmware_new; + fu_dfu_firmware_set_pid; + fu_dfu_firmware_set_release; + fu_dfu_firmware_set_version; + fu_dfu_firmware_set_vid; + fu_firmware_get_version; + fu_firmware_image_write; + fu_firmware_parse_file; + fu_firmware_set_version; + fu_firmware_write_file; + fu_plugin_add_firmware_gtype; + fu_plugin_get_hwid_replace_value; + fu_plugin_set_device_gtype; + fu_quirks_lookup_by_id_iter; + fu_udev_device_get_fd; + fu_udev_device_ioctl; + fu_udev_device_pread; + fu_udev_device_pwrite; + fu_udev_device_set_fd; + fu_udev_device_set_readonly; + local: *; +} LIBFWUPDPLUGIN_1.3.2; + +LIBFWUPDPLUGIN_1.3.4 { + global: + fu_archive_iterate; + fu_firmware_image_get_version; + fu_firmware_image_set_version; + fu_ihex_firmware_get_records; + fu_usb_device_get_spec; + local: *; +} LIBFWUPDPLUGIN_1.3.3; + +LIBFWUPDPLUGIN_1.3.5 { + global: + fu_common_fnmatch; + fu_device_get_protocol; + fu_device_incorporate_flag; + fu_device_set_protocol; + fu_plugin_is_open; + local: *; +} LIBFWUPDPLUGIN_1.3.4; diff --git a/libfwupdplugin/meson.build b/libfwupdplugin/meson.build new file mode 100644 index 000000000..c697a469e --- /dev/null +++ b/libfwupdplugin/meson.build @@ -0,0 +1,223 @@ +fwupdplugin_src = [ + 'fu-archive.c', + 'fu-chunk.c', + 'fu-common.c', + 'fu-common-cab.c', + 'fu-common-guid.c', + 'fu-common-version.c', + 'fu-device-locker.c', + 'fu-device.c', + 'fu-dfu-firmware.c', + 'fu-firmware.c', + 'fu-firmware-common.c', + 'fu-firmware-image.c', + 'fu-hwids.c', + 'fu-ihex-firmware.c', + 'fu-io-channel.c', + 'fu-plugin.c', + 'fu-progressbar.c', + 'fu-quirks.c', + 'fu-smbios.c', + 'fu-srec-firmware.c', + 'fu-test.c', + 'fu-udev-device.c', + 'fu-usb-device.c', +] + +fwupdplugin_headers = [ + 'fu-archive.h', + 'fu-chunk.h', + 'fu-common.h', + 'fu-common-cab.h', + 'fu-common-guid.h', + 'fu-common-version.h', + 'fu-device.h', + 'fu-device-metadata.h', + 'fu-device-locker.h', + 'fu-dfu-firmware.h', + 'fu-firmware.h', + 'fu-firmware-common.h', + 'fu-firmware-image.h', + 'fu-hwids.h', + 'fu-ihex-firmware.h', + 'fu-io-channel.h', + 'fu-plugin.h', + 'fu-progressbar.h', + 'fu-quirks.h', + 'fu-smbios.h', + 'fu-srec-firmware.h', + 'fu-test.h', + 'fu-udev-device.h', + 'fu-usb-device.h', +] + +fu_hash = custom_target( + 'fu-hash.h', + input : fwupdplugin_src, + output : 'fu-hash.h', + command : [python3.path(), + join_paths(meson.current_source_dir(), 'fu-hash.py'), + '@OUTPUT@', '@INPUT@'] +) + +fwupdplugin_headers_private = [ + fu_hash, + 'fu-device-private.h', + 'fu-plugin-private.h', + 'fu-smbios-private.h', + 'fu-usb-device-private.h', +] + +introspection_deps = [ + libxmlb, + giounix, + gusb, +] + +if get_option('gudev') + fwupdplugin_headers_private += 'fu-udev-device-private.h' + introspection_deps += gudev +endif + +library_deps = [ + introspection_deps, + gmodule, + libarchive, + libjsonglib, + libgcab, + sqlite, + valgrind, +] + +fwupdplugin_mapfile = 'fwupdplugin.map' +vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), fwupdplugin_mapfile) +fwupdplugin = shared_library( + 'fwupdplugin', + sources : [ + fwupdplugin_src, + fwupdplugin_headers + ], + soversion : libfwupdplugin_lt_current, + version : libfwupdplugin_lt_version, + include_directories : [ + root_incdir, + fwupd_incdir, + ], + dependencies : [ + library_deps + ], + link_with : [ + fwupd, + ], + link_args : vflag, + link_depends : fwupdplugin_mapfile, + install : true +) + +if get_option('introspection') + gir_dep = declare_dependency(sources: gir) + gir = gnome.generate_gir(fwupd, + sources : [ + fwupdplugin_src, + fwupdplugin_headers, + fwupdplugin_headers_private, + ], + nsversion : '1.0', + namespace : 'FwupdPlugin', + symbol_prefix : 'fu', + identifier_prefix : 'Fu', + export_packages : 'fu', + include_directories : [ + fwupd_incdir, + ], + dependencies : [ + gir_dep, + introspection_deps + ], + link_with : [ + fwupdplugin, + ], + includes : [ + 'Gio-2.0', + 'GObject-2.0', + 'GUsb-1.0', + ], + install : false + ) + gnome.generate_vapi('fwupdplugin', + sources : gir[0], + packages : ['gio-2.0'], + install : false, + ) + + # Verify the map file is correct -- note we can't actually use the generated + # file for two reasons: + # + # 1. We don't hard depend on GObject Introspection + # 2. The map file is required to build the lib that the GIR is built from + # + # To avoid the circular dep, and to ensure we don't change exported API + # accidentally actually check in a version of the version script to git. + fwupdplugin_mapfile_target = custom_target('fwupdplugin_mapfile', + input: gir[0], + output: 'fwupdplugin.map', + command: [ + join_paths(meson.source_root(), 'contrib', 'generate-version-script.py'), + 'LIBFWUPDPLUGIN', + '@INPUT@', + '@OUTPUT@', + ], + ) + + test('fwupdplugin-exported-api', diffcmd, + args : [ + '-urNp', + join_paths(meson.current_source_dir(), 'fwupdplugin.map'), + fwupdplugin_mapfile_target, + ], + ) +endif + +if get_option('tests') + test_deps = [ + colorhug_test_firmware, + builder_test_firmware, + hwid_test_firmware, + noreqs_test_firmware, + fu_hash, + ] + if get_option('pkcs7') + test_deps += colorhug_pkcs7_signature + endif + testdatadir_src = join_paths(meson.source_root(), 'data', 'tests') + testdatadir_dst = join_paths(meson.build_root(), 'data', 'tests') + pluginbuilddir = join_paths(meson.build_root(), 'plugins', 'test') + e = executable( + 'fwupdplugin-self-test', + test_deps, + sources : [ + fwupdplugin_src, + 'fu-self-test.c' + ], + include_directories : [ + root_incdir, + fwupd_incdir, + ], + dependencies : [ + library_deps + ], + link_with : [ + fwupd, + fwupdplugin + ], + c_args : [ + '-DTESTDATADIR_SRC="' + testdatadir_src + '"', + '-DTESTDATADIR_DST="' + testdatadir_dst + '"', + '-DTESTDATADIR="' + testdatadir_src + ':' + testdatadir_dst + '"', + '-DPLUGINBUILDDIR="' + pluginbuilddir + '"', + ], + ) + test('fu-self-test', e, is_parallel:false, timeout:180) +endif + +fwupdplugin_incdir = include_directories('.') diff --git a/meson.build b/meson.build index ef1485262..959fc0d41 100644 --- a/meson.build +++ b/meson.build @@ -40,10 +40,14 @@ conf.set_quoted('PACKAGE_VERSION', fwupd_version) # - If the interface is the same as the previous version, but bugs are # fixed, change: # REVISION += 1 -lt_current = '2' -lt_revision = '0' -lt_age = '0' -lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision) +libfwupd_lt_current = '2' +libfwupd_lt_revision = '0' +libfwupd_lt_age = '0' +libfwupd_lt_version = '@0@.@1@.@2@'.format(libfwupd_lt_current, libfwupd_lt_age, libfwupd_lt_revision) +libfwupdplugin_lt_current = '1' +libfwupdplugin_lt_revision = '0' +libfwupdplugin_lt_age = '0' +libfwupdplugin_lt_version = '@0@.@1@.@2@'.format(libfwupdplugin_lt_current, libfwupdplugin_lt_age, libfwupdplugin_lt_revision) # get supported warning flags warning_flags = [ @@ -158,6 +162,7 @@ localstatedir = join_paths(prefix, get_option('localstatedir')) mandir = join_paths(prefix, get_option('mandir')) localedir = join_paths(prefix, get_option('localedir')) +diffcmd = find_program('diff') gio = dependency('gio-2.0', version : '>= 2.45.8') giounix = dependency('gio-unix-2.0', version : '>= 2.45.8', required: false) if giounix.found() @@ -387,6 +392,8 @@ if build_standalone plugin_deps += gudev endif +root_incdir = include_directories('.') + if get_option('gtkdoc') gtkdocscan = find_program('gtkdoc-scan', required : true) subdir('docs') @@ -398,6 +405,7 @@ endif if build_standalone subdir('data') subdir('po') + subdir('libfwupdplugin') subdir('src') subdir('plugins') subdir('contrib') diff --git a/plugins/altos/meson.build b/plugins/altos/meson.build index 55cb3d841..0474ad429 100644 --- a/plugins/altos/meson.build +++ b/plugins/altos/meson.build @@ -12,14 +12,15 @@ shared_module('fu_plugin_altos', 'fu-plugin-altos.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/amt/meson.build b/plugins/amt/meson.build index addd2d788..d03f68e04 100644 --- a/plugins/amt/meson.build +++ b/plugins/amt/meson.build @@ -6,14 +6,15 @@ shared_module('fu_plugin_amt', 'fu-plugin-amt.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/ata/meson.build b/plugins/ata/meson.build index 7171e6b49..e9aea71f6 100644 --- a/plugins/ata/meson.build +++ b/plugins/ata/meson.build @@ -13,9 +13,9 @@ shared_module('fu_plugin_ata', 'fu-ata-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, @@ -24,7 +24,8 @@ shared_module('fu_plugin_ata', '-DLOCALSTATEDIR="' + localstatedir + '"', ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], dependencies : [ plugin_deps, @@ -42,16 +43,16 @@ if get_option('tests') 'fu-ata-device.c', ], include_directories : [ - include_directories('..'), - include_directories('../..'), - include_directories('../../libfwupd'), - include_directories('../../src'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) diff --git a/plugins/colorhug/meson.build b/plugins/colorhug/meson.build index 4894f2954..f525de758 100644 --- a/plugins/colorhug/meson.build +++ b/plugins/colorhug/meson.build @@ -14,14 +14,15 @@ shared_module('fu_plugin_colorhug', 'fu-plugin-colorhug.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/coreboot/meson.build b/plugins/coreboot/meson.build index e449877e9..da0026971 100644 --- a/plugins/coreboot/meson.build +++ b/plugins/coreboot/meson.build @@ -6,14 +6,15 @@ shared_module('fu_plugin_coreboot', 'fu-coreboot-common.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : [ cargs, diff --git a/plugins/csr/meson.build b/plugins/csr/meson.build index 09595c860..0871bed03 100644 --- a/plugins/csr/meson.build +++ b/plugins/csr/meson.build @@ -11,10 +11,10 @@ shared_module('fu_plugin_csr', 'fu-plugin-csr.c', ], include_directories : [ - include_directories('../..'), - include_directories('../dfu'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, + plugindfu_incdir, ], install : true, install_dir: plugin_dir, @@ -23,7 +23,7 @@ shared_module('fu_plugin_csr', plugin_deps, ], link_with : [ - libfwupdprivate, + fwupdplugin, dfu, ], ) diff --git a/plugins/dell-dock/meson.build b/plugins/dell-dock/meson.build index 0f00003d3..9a66c68de 100644 --- a/plugins/dell-dock/meson.build +++ b/plugins/dell-dock/meson.build @@ -17,14 +17,15 @@ shared_module('fu_plugin_dell_dock', 'fu-dell-dock-i2c-mst.c' ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/dell-esrt/meson.build b/plugins/dell-esrt/meson.build index cb9f45551..ed4eee70b 100644 --- a/plugins/dell-esrt/meson.build +++ b/plugins/dell-esrt/meson.build @@ -10,9 +10,9 @@ shared_module('fu_plugin_dell_esrt', 'fu-plugin-dell-esrt.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, @@ -20,7 +20,8 @@ shared_module('fu_plugin_dell_esrt', cargs, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], dependencies : [ plugin_deps, diff --git a/plugins/dell/meson.build b/plugins/dell/meson.build index 5ab20e309..bf4f3eab0 100644 --- a/plugins/dell/meson.build +++ b/plugins/dell/meson.build @@ -11,14 +11,15 @@ shared_module('fu_plugin_dell', 'fu-dell-smi.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : [ cargs, @@ -44,9 +45,9 @@ if get_option('tests') 'fu-plugin-dell.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, @@ -57,7 +58,8 @@ if get_option('tests') tpm2tss, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : [ cargs, diff --git a/plugins/dfu/meson.build b/plugins/dfu/meson.build index c82028f34..9705f0d63 100644 --- a/plugins/dfu/meson.build +++ b/plugins/dfu/meson.build @@ -28,13 +28,14 @@ dfu = static_library( gudev, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, include_directories : [ - include_directories('../..'), - include_directories('../../libfwupd'), - include_directories('../../src'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], ) @@ -44,9 +45,9 @@ shared_module('fu_plugin_dfu', 'fu-plugin-dfu.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, @@ -55,7 +56,8 @@ shared_module('fu_plugin_dfu', plugin_deps, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, dfu, ], ) @@ -67,10 +69,9 @@ dfu_tool = executable( 'dfu-tool.c', ], include_directories : [ - include_directories('..'), - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ libxmlb, @@ -81,7 +82,8 @@ dfu_tool = executable( ], link_with : [ dfu, - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, install : true, @@ -118,10 +120,9 @@ if get_option('tests') 'dfu-self-test.c' ], include_directories : [ - include_directories('..'), - include_directories('../..'), - include_directories('../../libfwupd'), - include_directories('../../src'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ libxmlb, @@ -132,9 +133,12 @@ if get_option('tests') ], link_with : [ dfu, - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) test('dfu-self-test', e) endif + +plugindfu_incdir = include_directories('.') diff --git a/plugins/ebitdo/meson.build b/plugins/ebitdo/meson.build index 6ad545375..8277e84c6 100644 --- a/plugins/ebitdo/meson.build +++ b/plugins/ebitdo/meson.build @@ -13,14 +13,15 @@ shared_module('fu_plugin_ebitdo', 'fu-ebitdo-firmware.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/emmc/meson.build b/plugins/emmc/meson.build index ab32c5a1c..bbabe23e0 100644 --- a/plugins/emmc/meson.build +++ b/plugins/emmc/meson.build @@ -10,14 +10,15 @@ shared_module('fu_plugin_emmc', 'fu-emmc-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/fastboot/meson.build b/plugins/fastboot/meson.build index 09d9b2323..c0071ffda 100644 --- a/plugins/fastboot/meson.build +++ b/plugins/fastboot/meson.build @@ -11,14 +11,15 @@ shared_module('fu_plugin_fastboot', 'fu-fastboot-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/flashrom/meson.build b/plugins/flashrom/meson.build index 1e5a60647..18060d9dc 100644 --- a/plugins/flashrom/meson.build +++ b/plugins/flashrom/meson.build @@ -10,14 +10,15 @@ shared_module('fu_plugin_flashrom', 'fu-plugin-flashrom.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : [ cargs, diff --git a/plugins/jabra/meson.build b/plugins/jabra/meson.build index 0b9c5bdf9..7d5d6138d 100644 --- a/plugins/jabra/meson.build +++ b/plugins/jabra/meson.build @@ -11,14 +11,15 @@ shared_module('fu_plugin_jabra', 'fu-jabra-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/logitech-hidpp/meson.build b/plugins/logitech-hidpp/meson.build index 82b0fc69f..858503cfd 100644 --- a/plugins/logitech-hidpp/meson.build +++ b/plugins/logitech-hidpp/meson.build @@ -21,14 +21,15 @@ shared_module('fu_plugin_logitech_hidpp', 'fu-logitech-hidpp-runtime.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ @@ -45,14 +46,16 @@ if get_option('tests') 'fu-logitech-hidpp-common.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, ) diff --git a/plugins/modem-manager/meson.build b/plugins/modem-manager/meson.build index ce1d3c661..822e4277f 100644 --- a/plugins/modem-manager/meson.build +++ b/plugins/modem-manager/meson.build @@ -13,9 +13,9 @@ shared_module('fu_plugin_modem_manager', 'fu-mm-utils.c' ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, @@ -23,7 +23,8 @@ shared_module('fu_plugin_modem_manager', cargs, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], dependencies : [ plugin_deps, diff --git a/plugins/nitrokey/meson.build b/plugins/nitrokey/meson.build index 225b49b73..6b9991fa8 100644 --- a/plugins/nitrokey/meson.build +++ b/plugins/nitrokey/meson.build @@ -12,14 +12,14 @@ shared_module('fu_plugin_nitrokey', 'fu-plugin-nitrokey.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupdplugin, ], c_args : cargs, dependencies : [ @@ -36,16 +36,16 @@ if get_option('tests') 'fu-self-test.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, valgrind, ], link_with : [ - libfwupdprivate, + fwupdplugin, ], ) test('nitrokey-self-test', e) diff --git a/plugins/nvme/meson.build b/plugins/nvme/meson.build index 40e8210a2..d0db9f434 100644 --- a/plugins/nvme/meson.build +++ b/plugins/nvme/meson.build @@ -14,9 +14,9 @@ shared_module('fu_plugin_nvme', 'fu-nvme-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, @@ -25,7 +25,8 @@ shared_module('fu_plugin_nvme', '-DLOCALSTATEDIR="' + localstatedir + '"', ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], dependencies : [ plugin_deps, @@ -44,16 +45,16 @@ if get_option('tests') 'fu-nvme-device.c', ], include_directories : [ - include_directories('..'), - include_directories('../..'), - include_directories('../../libfwupd'), - include_directories('../../src'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) diff --git a/plugins/optionrom/meson.build b/plugins/optionrom/meson.build index 96dcc5f97..10901ff5e 100644 --- a/plugins/optionrom/meson.build +++ b/plugins/optionrom/meson.build @@ -12,14 +12,15 @@ shared_module('fu_plugin_optionrom', 'fu-rom.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ @@ -35,16 +36,17 @@ executable( 'fu-rom.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, libjsonglib, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, ) @@ -61,15 +63,16 @@ if get_option('tests') 'fu-rom.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) diff --git a/plugins/redfish/meson.build b/plugins/redfish/meson.build index 5c88504e3..25fc5c7d3 100644 --- a/plugins/redfish/meson.build +++ b/plugins/redfish/meson.build @@ -8,14 +8,15 @@ shared_module('fu_plugin_redfish', 'fu-redfish-common.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ @@ -39,9 +40,9 @@ if get_option('tests') 'fu-redfish-common.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, @@ -49,7 +50,8 @@ if get_option('tests') libjsonglib, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) diff --git a/plugins/rts54hid/meson.build b/plugins/rts54hid/meson.build index 809a11349..99f1ecfe2 100644 --- a/plugins/rts54hid/meson.build +++ b/plugins/rts54hid/meson.build @@ -14,14 +14,15 @@ shared_module('fu_plugin_rts54hid', 'fu-plugin-rts54hid.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/rts54hub/meson.build b/plugins/rts54hub/meson.build index 46b220382..ff91f92f8 100644 --- a/plugins/rts54hub/meson.build +++ b/plugins/rts54hub/meson.build @@ -13,14 +13,15 @@ shared_module('fu_plugin_rts54hub', 'fu-plugin-rts54hub.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/solokey/meson.build b/plugins/solokey/meson.build index b4e3b115a..d5a18a5b9 100644 --- a/plugins/solokey/meson.build +++ b/plugins/solokey/meson.build @@ -14,14 +14,15 @@ shared_module('fu_plugin_solokey', 'fu-plugin-solokey.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/steelseries/meson.build b/plugins/steelseries/meson.build index 68fe15abc..6320e66b3 100644 --- a/plugins/steelseries/meson.build +++ b/plugins/steelseries/meson.build @@ -11,14 +11,14 @@ shared_module('fu_plugin_steelseries', 'fu-steelseries-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/superio/meson.build b/plugins/superio/meson.build index 7c81e7cb8..5c4bcdd6a 100644 --- a/plugins/superio/meson.build +++ b/plugins/superio/meson.build @@ -14,14 +14,15 @@ shared_module('fu_plugin_superio', 'fu-superio-common.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/synaptics-cxaudio/meson.build b/plugins/synaptics-cxaudio/meson.build index 850caad94..f7be3040d 100644 --- a/plugins/synaptics-cxaudio/meson.build +++ b/plugins/synaptics-cxaudio/meson.build @@ -12,14 +12,15 @@ shared_module('fu_plugin_synaptics_cxaudio', 'fu-synaptics-cxaudio-firmware.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/synaptics-prometheus/meson.build b/plugins/synaptics-prometheus/meson.build index 8fc887def..7e2f72fad 100644 --- a/plugins/synaptics-prometheus/meson.build +++ b/plugins/synaptics-prometheus/meson.build @@ -14,14 +14,15 @@ shared_module('fu_plugin_synaptics_prometheus', 'fu-synaprom-firmware.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ @@ -43,15 +44,16 @@ if get_option('tests') 'fu-synaprom-firmware.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) @@ -65,15 +67,16 @@ if get_option('tests') 'fu-synaprom-firmware.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ gio, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) diff --git a/plugins/synaptics-rmi/meson.build b/plugins/synaptics-rmi/meson.build index 9e33a3449..3e71f911c 100644 --- a/plugins/synaptics-rmi/meson.build +++ b/plugins/synaptics-rmi/meson.build @@ -16,9 +16,9 @@ shared_module('fu_plugin_synaptics_rmi', 'fu-synaptics-rmi-firmware.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, @@ -27,7 +27,8 @@ shared_module('fu_plugin_synaptics_rmi', plugin_deps, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], ) @@ -41,15 +42,16 @@ if get_option('tests') 'fu-synaptics-rmi-firmware.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ gio, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) diff --git a/plugins/synapticsmst/meson.build b/plugins/synapticsmst/meson.build index 05844d779..24281d4bd 100644 --- a/plugins/synapticsmst/meson.build +++ b/plugins/synapticsmst/meson.build @@ -13,9 +13,9 @@ shared_module('fu_plugin_synapticsmst', 'fu-synapticsmst-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, @@ -23,7 +23,8 @@ shared_module('fu_plugin_synapticsmst', cargs, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], dependencies : [ plugin_deps, @@ -43,9 +44,9 @@ if get_option('tests') 'fu-synapticsmst-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, @@ -53,7 +54,8 @@ if get_option('tests') valgrind, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : [ cargs, diff --git a/plugins/test/meson.build b/plugins/test/meson.build index c473ab4b0..2e1d91f9f 100644 --- a/plugins/test/meson.build +++ b/plugins/test/meson.build @@ -11,14 +11,15 @@ shared_module('fu_plugin_test', 'fu-plugin-test.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : install_dummy, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/thelio-io/meson.build b/plugins/thelio-io/meson.build index 9f4f85cd0..523a9263e 100644 --- a/plugins/thelio-io/meson.build +++ b/plugins/thelio-io/meson.build @@ -11,14 +11,15 @@ shared_module('fu_plugin_thelio_io', 'fu-thelio-io-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/thunderbolt-power/meson.build b/plugins/thunderbolt-power/meson.build index 747c782f6..bc0516f6e 100644 --- a/plugins/thunderbolt-power/meson.build +++ b/plugins/thunderbolt-power/meson.build @@ -6,14 +6,15 @@ fu_plugin_thunderbolt_power = shared_module('fu_plugin_thunderbolt_power', 'fu-plugin-thunderbolt-power.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/thunderbolt/meson.build b/plugins/thunderbolt/meson.build index 87c6c8d11..8abb201c4 100644 --- a/plugins/thunderbolt/meson.build +++ b/plugins/thunderbolt/meson.build @@ -7,14 +7,15 @@ fu_plugin_thunderbolt = shared_module('fu_plugin_thunderbolt', 'fu-thunderbolt-image.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ @@ -31,14 +32,15 @@ executable('tbtfwucli', 'fu-thunderbolt-tool.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], c_args : cargs, link_with : [ fu_plugin_thunderbolt, - libfwupdprivate, + fwupd, + fwupdplugin, ], dependencies : [ plugin_deps, @@ -60,16 +62,17 @@ if get_option('tests') and umockdev.found() and gio.version().version_compare('> 'fu-thunderbolt-image.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, umockdev, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) diff --git a/plugins/uefi-recovery/meson.build b/plugins/uefi-recovery/meson.build index a674b2a57..3039fb8ed 100644 --- a/plugins/uefi-recovery/meson.build +++ b/plugins/uefi-recovery/meson.build @@ -10,14 +10,15 @@ shared_module('fu_plugin_uefi_recovery', 'fu-plugin-uefi-recovery.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : [ cargs, diff --git a/plugins/uefi/meson.build b/plugins/uefi/meson.build index 45b18d7d3..39b5f566f 100644 --- a/plugins/uefi/meson.build +++ b/plugins/uefi/meson.build @@ -27,14 +27,15 @@ shared_module('fu_plugin_uefi', 'fu-uefi-vars.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ @@ -63,9 +64,9 @@ executable( 'fu-uefi-vars.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ libxmlb, @@ -77,7 +78,8 @@ executable( tpm2tss, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], install : true, install_dir : join_paths(libexecdir, 'fwupd'), @@ -108,9 +110,9 @@ if get_option('tests') 'fu-ucs2.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ plugin_deps, @@ -119,7 +121,8 @@ if get_option('tests') tpm2tss, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) diff --git a/plugins/upower/meson.build b/plugins/upower/meson.build index 0f9e0dc3a..8a8915ee7 100644 --- a/plugins/upower/meson.build +++ b/plugins/upower/meson.build @@ -6,14 +6,15 @@ shared_module('fu_plugin_upower', 'fu-plugin-upower.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/vli-usbhub/meson.build b/plugins/vli-usbhub/meson.build index f12f6c93f..d0f1105bd 100644 --- a/plugins/vli-usbhub/meson.build +++ b/plugins/vli-usbhub/meson.build @@ -21,14 +21,15 @@ shared_module('fu_plugin_vli_usbhub', 'fu-vli-usbhub-pd-firmware.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs, dependencies : [ diff --git a/plugins/wacom-raw/meson.build b/plugins/wacom-raw/meson.build index 1a27f7c4d..aaf5bce67 100644 --- a/plugins/wacom-raw/meson.build +++ b/plugins/wacom-raw/meson.build @@ -14,9 +14,9 @@ shared_module('fu_plugin_wacom_raw', 'fu-wacom-emr-device.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, @@ -25,6 +25,7 @@ shared_module('fu_plugin_wacom_raw', plugin_deps, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], ) diff --git a/plugins/wacom-usb/meson.build b/plugins/wacom-usb/meson.build index 3090aa0ae..6a861254e 100644 --- a/plugins/wacom-usb/meson.build +++ b/plugins/wacom-usb/meson.build @@ -16,9 +16,9 @@ shared_module('fu_plugin_wacom_usb', 'fu-plugin-wacom-usb.c', ], include_directories : [ - include_directories('../..'), - include_directories('../../src'), - include_directories('../../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], install : true, install_dir: plugin_dir, @@ -27,7 +27,8 @@ shared_module('fu_plugin_wacom_usb', plugin_deps, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], ) @@ -43,10 +44,9 @@ if get_option('tests') 'fu-wac-firmware.c', ], include_directories : [ - include_directories('..'), - include_directories('../..'), - include_directories('../../libfwupd'), - include_directories('../../src'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ libxmlb, @@ -56,7 +56,8 @@ if get_option('tests') libm, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) diff --git a/po/POTFILES.in b/po/POTFILES.in index d8025f3f5..c47b5e05d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,6 @@ data/remotes.d/lvfs.metainfo.xml data/remotes.d/lvfs-testing.metainfo.xml +libfwupdplugin/fu-progressbar.c policy/org.freedesktop.fwupd.policy.in plugins/dfu/dfu-tool.c plugins/uefi/fu-plugin-uefi.c @@ -10,6 +11,5 @@ src/fu-debug.c src/fu-main.c src/fu-offline.c src/fu-tool.c -src/fu-progressbar.c src/fu-util.c src/fu-util-common.c diff --git a/src/fu-engine.c b/src/fu-engine.c index edaa934f0..5d010a114 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -46,10 +46,8 @@ #include "fu-plugin-list.h" #include "fu-plugin-private.h" #include "fu-quirks.h" -#include "fu-smbios.h" -#ifdef HAVE_GUDEV +#include "fu-smbios-private.h" #include "fu-udev-device-private.h" -#endif #include "fu-usb-device-private.h" #include "fu-dfu-firmware.h" diff --git a/src/fu-self-test.c b/src/fu-self-test.c index f34c29dbc..339bb8f87 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -8,34 +8,24 @@ #include #include +#include #include #include #include #include #include -#include "fu-archive.h" -#include "fu-common-cab.h" -#include "fu-common-version.h" -#include "fu-chunk.h" #include "fu-config.h" #include "fu-device-list.h" #include "fu-device-private.h" -#include "fu-dfu-firmware.h" #include "fu-engine.h" -#include "fu-ihex-firmware.h" -#include "fu-quirks.h" #include "fu-keyring.h" #include "fu-history.h" #include "fu-install-task.h" #include "fu-plugin-private.h" #include "fu-plugin-list.h" -#include "fu-progressbar.h" #include "fu-hash.h" -#include "fu-hwids.h" -#include "fu-smbios.h" -#include "fu-srec-firmware.h" -#include "fu-test.h" +#include "fu-smbios-private.h" #ifdef ENABLE_GPG #include "fu-keyring-gpg.h" @@ -55,25 +45,6 @@ fu_self_test_mkroot (void) g_assert_cmpint (g_mkdir_with_parents ("/tmp/fwupd-self-test/var/lib/fwupd", 0755), ==, 0); } -static void -fu_archive_invalid_func (void) -{ - g_autofree gchar *filename = NULL; - g_autoptr(FuArchive) archive = NULL; - g_autoptr(GBytes) data = NULL; - g_autoptr(GError) error = NULL; - - filename = fu_test_get_filename (TESTDATADIR, "metadata.xml"); - g_assert_nonnull (filename); - data = fu_common_get_contents_bytes (filename, &error); - g_assert_no_error (error); - g_assert_nonnull (data); - - archive = fu_archive_new (data, FU_ARCHIVE_FLAG_NONE, &error); - g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED); - g_assert_null (archive); -} - static void fu_engine_generate_md_func (void) { @@ -118,75 +89,32 @@ fu_engine_generate_md_func (void) } static void -fu_archive_cab_func (void) +fu_plugin_hash_func (void) { - g_autofree gchar *checksum1 = NULL; - g_autofree gchar *checksum2 = NULL; - g_autofree gchar *filename = NULL; - g_autoptr(FuArchive) archive = NULL; - g_autoptr(GBytes) data = NULL; - g_autoptr(GError) error = NULL; - GBytes *data_tmp; + GError *error = NULL; + g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE); + g_autoptr(FuPlugin) plugin = fu_plugin_new (); + gboolean ret = FALSE; - filename = fu_test_get_filename (TESTDATADIR, "colorhug/colorhug-als-3.0.2.cab"); - g_assert_nonnull (filename); - data = fu_common_get_contents_bytes (filename, &error); + ret = fu_engine_load (engine, FU_ENGINE_LOAD_FLAG_NO_ENUMERATE, &error); g_assert_no_error (error); - g_assert_nonnull (data); + g_assert (ret); - archive = fu_archive_new (data, FU_ARCHIVE_FLAG_NONE, &error); + /* make sure not tainted */ + ret = fu_engine_get_tainted (engine); + g_assert_false (ret); + + /* create a tainted plugin */ + g_setenv ("FWUPD_PLUGIN_TEST", "build-hash", TRUE); + ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test." G_MODULE_SUFFIX, &error); g_assert_no_error (error); - g_assert_nonnull (archive); - data_tmp = fu_archive_lookup_by_fn (archive, "firmware.metainfo.xml", &error); - g_assert_no_error (error); - g_assert_nonnull (data_tmp); - checksum1 = g_compute_checksum_for_bytes (G_CHECKSUM_SHA1, data_tmp); - g_assert_cmpstr (checksum1, ==, "8611114f51f7151f190de86a5c9259d79ff34216"); - - data_tmp = fu_archive_lookup_by_fn (archive, "firmware.bin", &error); - g_assert_no_error (error); - g_assert_nonnull (data_tmp); - checksum2 = g_compute_checksum_for_bytes (G_CHECKSUM_SHA1, data_tmp); - g_assert_cmpstr (checksum2, ==, "7c0ae84b191822bcadbdcbe2f74a011695d783c7"); - - data_tmp = fu_archive_lookup_by_fn (archive, "NOTGOINGTOEXIST.xml", &error); - g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND); - g_assert_null (data_tmp); -} - -static void -fu_common_string_append_kv_func (void) -{ - g_autoptr(GString) str = g_string_new (NULL); - fu_common_string_append_kv (str, 0, "hdr", NULL); - fu_common_string_append_kv (str, 0, "key", "value"); - fu_common_string_append_kv (str, 0, "key1", "value1"); - fu_common_string_append_kv (str, 1, "key2", "value2"); - fu_common_string_append_kv (str, 1, "", "value2"); - fu_common_string_append_kv (str, 2, "key3", "value3"); - g_assert_cmpstr (str->str, ==, - "hdr:\n" - "key: value\n" - "key1: value1\n" - " key2: value2\n" - " value2\n" - " key3: value3\n"); -} - -static void -fu_common_version_guess_format_func (void) -{ - g_assert_cmpint (fu_common_version_guess_format (NULL), ==, FWUPD_VERSION_FORMAT_UNKNOWN); - g_assert_cmpint (fu_common_version_guess_format (""), ==, FWUPD_VERSION_FORMAT_UNKNOWN); - g_assert_cmpint (fu_common_version_guess_format ("1234ac"), ==, FWUPD_VERSION_FORMAT_PLAIN); - g_assert_cmpint (fu_common_version_guess_format ("1.2"), ==, FWUPD_VERSION_FORMAT_PAIR); - g_assert_cmpint (fu_common_version_guess_format ("1.2.3"), ==, FWUPD_VERSION_FORMAT_TRIPLET); - g_assert_cmpint (fu_common_version_guess_format ("1.2.3.4"), ==, FWUPD_VERSION_FORMAT_QUAD); - g_assert_cmpint (fu_common_version_guess_format ("1.2.3.4.5"), ==, FWUPD_VERSION_FORMAT_UNKNOWN); - g_assert_cmpint (fu_common_version_guess_format ("1a.2b.3"), ==, FWUPD_VERSION_FORMAT_PLAIN); - g_assert_cmpint (fu_common_version_guess_format ("1"), ==, FWUPD_VERSION_FORMAT_NUMBER); - g_assert_cmpint (fu_common_version_guess_format ("0x10201"), ==, FWUPD_VERSION_FORMAT_NUMBER); + /* make sure it tainted now */ + g_test_expect_message ("FuEngine", G_LOG_LEVEL_WARNING, "* has incorrect built version*"); + fu_engine_add_plugin (engine, plugin); + ret = fu_engine_get_tainted (engine); + g_assert_true (ret); + g_unsetenv ("FWUPD_PLUGIN_TEST"); } static void @@ -1920,195 +1848,108 @@ fu_device_list_func (void) } static void -fu_device_version_format_func (void) +fu_plugin_list_func (void) { - g_autoptr(FuDevice) device = fu_device_new (); - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_ENSURE_SEMVER); - fu_device_set_version (device, "Ver1.2.3 RELEASE", FWUPD_VERSION_FORMAT_TRIPLET); - g_assert_cmpstr (fu_device_get_version (device), ==, "1.2.3"); -} - -static void -fu_device_open_refcount_func (void) -{ - gboolean ret; - g_autoptr(FuDevice) device = fu_device_new (); - g_autoptr(GError) error = NULL; - fu_device_set_id (device, "test_device"); - ret = fu_device_open (device, &error); - g_assert_no_error (error); - g_assert_true (ret); - ret = fu_device_open (device, &error); - g_assert_no_error (error); - g_assert_true (ret); - ret = fu_device_close (device, &error); - g_assert_no_error (error); - g_assert_true (ret); - ret = fu_device_close (device, &error); - g_assert_no_error (error); - g_assert_true (ret); - ret = fu_device_close (device, &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INTERNAL); - g_assert_false (ret); -} - -static void -fu_device_metadata_func (void) -{ - g_autoptr(FuDevice) device = fu_device_new (); - - /* string */ - fu_device_set_metadata (device, "foo", "bar"); - g_assert_cmpstr (fu_device_get_metadata (device, "foo"), ==, "bar"); - fu_device_set_metadata (device, "foo", "baz"); - g_assert_cmpstr (fu_device_get_metadata (device, "foo"), ==, "baz"); - g_assert_null (fu_device_get_metadata (device, "unknown")); - - /* boolean */ - fu_device_set_metadata_boolean (device, "baz", TRUE); - g_assert_cmpstr (fu_device_get_metadata (device, "baz"), ==, "true"); - g_assert_true (fu_device_get_metadata_boolean (device, "baz")); - g_assert_false (fu_device_get_metadata_boolean (device, "unknown")); - - /* integer */ - fu_device_set_metadata_integer (device, "dum", 12345); - g_assert_cmpstr (fu_device_get_metadata (device, "dum"), ==, "12345"); - g_assert_cmpint (fu_device_get_metadata_integer (device, "dum"), ==, 12345); - g_assert_cmpint (fu_device_get_metadata_integer (device, "unknown"), ==, G_MAXUINT); - - /* broken integer */ - fu_device_set_metadata (device, "dum", "123junk"); - g_assert_cmpint (fu_device_get_metadata_integer (device, "dum"), ==, G_MAXUINT); - fu_device_set_metadata (device, "huge", "4294967296"); /* not 32 bit */ - g_assert_cmpint (fu_device_get_metadata_integer (device, "huge"), ==, G_MAXUINT); -} - -static void -fu_smbios_func (void) -{ - const gchar *str; - gboolean ret; - g_autofree gchar *dump = NULL; - g_autoptr(FuSmbios) smbios = NULL; + GPtrArray *plugins; + FuPlugin *plugin; + g_autoptr(FuPluginList) plugin_list = fu_plugin_list_new (); + g_autoptr(FuPlugin) plugin1 = fu_plugin_new (); + g_autoptr(FuPlugin) plugin2 = fu_plugin_new (); g_autoptr(GError) error = NULL; - smbios = fu_smbios_new (); - ret = fu_smbios_setup (smbios, &error); + fu_plugin_set_name (plugin1, "plugin1"); + fu_plugin_set_name (plugin2, "plugin2"); + + /* get all the plugins */ + fu_plugin_list_add (plugin_list, plugin1); + fu_plugin_list_add (plugin_list, plugin2); + plugins = fu_plugin_list_get_all (plugin_list); + g_assert_cmpint (plugins->len, ==, 2); + + /* get a single plugin */ + plugin = fu_plugin_list_find_by_name (plugin_list, "plugin1", &error); + g_assert_no_error (error); + g_assert (plugin != NULL); + g_assert_cmpstr (fu_plugin_get_name (plugin), ==, "plugin1"); + + /* does not exist */ + plugin = fu_plugin_list_find_by_name (plugin_list, "nope", &error); + g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND); + g_assert (plugin == NULL); +} + +static void +fu_plugin_list_depsolve_func (void) +{ + GPtrArray *plugins; + FuPlugin *plugin; + gboolean ret; + g_autoptr(FuPluginList) plugin_list = fu_plugin_list_new (); + g_autoptr(FuPlugin) plugin1 = fu_plugin_new (); + g_autoptr(FuPlugin) plugin2 = fu_plugin_new (); + g_autoptr(GError) error = NULL; + + fu_plugin_set_name (plugin1, "plugin1"); + fu_plugin_set_name (plugin2, "plugin2"); + + /* add rule then depsolve */ + fu_plugin_list_add (plugin_list, plugin1); + fu_plugin_list_add (plugin_list, plugin2); + fu_plugin_add_rule (plugin1, FU_PLUGIN_RULE_RUN_AFTER, "plugin2"); + ret = fu_plugin_list_depsolve (plugin_list, &error); g_assert_no_error (error); g_assert (ret); - dump = fu_smbios_to_string (smbios); - if (g_getenv ("VERBOSE") != NULL) - g_debug ("%s", dump); + plugins = fu_plugin_list_get_all (plugin_list); + g_assert_cmpint (plugins->len, ==, 2); + plugin = g_ptr_array_index (plugins, 0); + g_assert_cmpstr (fu_plugin_get_name (plugin), ==, "plugin2"); + g_assert_cmpint (fu_plugin_get_order (plugin), ==, 0); + g_assert (fu_plugin_get_enabled (plugin)); - /* test for missing table */ - str = fu_smbios_get_string (smbios, 0xff, 0, &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); - g_assert_null (str); - g_clear_error (&error); - - /* check for invalid offset */ - str = fu_smbios_get_string (smbios, FU_SMBIOS_STRUCTURE_TYPE_BIOS, 0xff, &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); - g_assert_null (str); - g_clear_error (&error); - - /* get vendor */ - str = fu_smbios_get_string (smbios, FU_SMBIOS_STRUCTURE_TYPE_BIOS, 0x04, &error); - g_assert_no_error (error); - g_assert_cmpstr (str, ==, "LENOVO"); -} - -static void -fu_smbios3_func (void) -{ - const gchar *str; - gboolean ret; - g_autofree gchar *path = NULL; - g_autoptr(FuSmbios) smbios = NULL; - g_autoptr(GError) error = NULL; - - path = fu_test_get_filename (TESTDATADIR, "dmi/tables64"); - g_assert_nonnull (path); - - smbios = fu_smbios_new (); - ret = fu_smbios_setup_from_path (smbios, path, &error); + /* add another rule, then re-depsolve */ + fu_plugin_add_rule (plugin1, FU_PLUGIN_RULE_CONFLICTS, "plugin2"); + ret = fu_plugin_list_depsolve (plugin_list, &error); g_assert_no_error (error); g_assert (ret); - if (g_getenv ("VERBOSE") != NULL) { - g_autofree gchar *dump = fu_smbios_to_string (smbios); - g_debug ("%s", dump); - } - - /* get vendor */ - str = fu_smbios_get_string (smbios, FU_SMBIOS_STRUCTURE_TYPE_BIOS, 0x04, &error); + plugin = fu_plugin_list_find_by_name (plugin_list, "plugin1", &error); g_assert_no_error (error); - g_assert_cmpstr (str, ==, "Dell Inc."); + g_assert (plugin != NULL); + g_assert (fu_plugin_get_enabled (plugin)); + plugin = fu_plugin_list_find_by_name (plugin_list, "plugin2", &error); + g_assert_no_error (error); + g_assert (plugin != NULL); + g_assert (!fu_plugin_get_enabled (plugin)); } static void -fu_hwids_func (void) +fu_history_migrate_func (void) { - g_autoptr(FuHwids) hwids = NULL; - g_autoptr(FuSmbios) smbios = NULL; - g_autoptr(GError) error = NULL; gboolean ret; + g_autoptr(GError) error = NULL; + g_autoptr(GFile) file_dst = NULL; + g_autoptr(GFile) file_src = NULL; + g_autoptr(FuDevice) device = NULL; + g_autoptr(FuHistory) history = NULL; + g_autofree gchar *filename = NULL; - struct { - const gchar *key; - const gchar *value; - } guids[] = { - { "Manufacturer", "6de5d951-d755-576b-bd09-c5cf66b27234" }, - { "HardwareID-14", "6de5d951-d755-576b-bd09-c5cf66b27234" }, - { "HardwareID-13", "f8e1de5f-b68c-5f52-9d1a-f1ba52f1f773" }, - { "HardwareID-12", "e093d715-70f7-51f4-b6c8-b4a7e31def85" }, - { "HardwareID-11", "db73af4c-4612-50f7-b8a7-787cf4871847" }, - { "HardwareID-10", "f4275c1f-6130-5191-845c-3426247eb6a1" }, - { "HardwareID-9", "0cf8618d-9eff-537c-9f35-46861406eb9c" }, - { "HardwareID-8", "059eb22d-6dc7-59af-abd3-94bbe017f67c" }, - { "HardwareID-7", "da1da9b6-62f5-5f22-8aaa-14db7eeda2a4" }, - { "HardwareID-6", "178cd22d-ad9f-562d-ae0a-34009822cdbe" }, - { "HardwareID-5", "8dc9b7c5-f5d5-5850-9ab3-bd6f0549d814" }, - { "HardwareID-4", "660ccba8-1b78-5a33-80e6-9fb8354ee873" }, - { "HardwareID-3", "3faec92a-3ae3-5744-be88-495e90a7d541" }, - { "HardwareID-2", "f5ff077f-3eeb-5bae-be1c-e98ffe8ce5f8" }, - { "HardwareID-1", "b7cceb67-774c-537e-bf8b-22c6107e9a74" }, - { "HardwareID-0", "147efce9-f201-5fc8-ab0c-c859751c3440" }, - { NULL, NULL } - }; - - smbios = fu_smbios_new (); - ret = fu_smbios_setup (smbios, &error); + /* load old version */ + filename = fu_test_get_filename (TESTDATADIR, "history_v1.db"); + file_src = g_file_new_for_path (filename); + file_dst = g_file_new_for_path ("/tmp/fwupd-self-test/var/lib/fwupd/pending.db"); + ret = g_file_copy (file_src, file_dst, G_FILE_COPY_OVERWRITE, NULL, + NULL, NULL, &error); g_assert_no_error (error); g_assert (ret); - hwids = fu_hwids_new (); - ret = fu_hwids_setup (hwids, smbios, &error); - g_assert_no_error (error); - g_assert (ret); + /* create, migrating as required */ + history = fu_history_new (); + g_assert (history != NULL); - g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_MANUFACTURER), ==, - "LENOVO"); - g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_ENCLOSURE_KIND), ==, - "a"); - g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_FAMILY), ==, - "ThinkPad T440s"); - g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_PRODUCT_NAME), ==, - "20ARS19C0C"); - g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_BIOS_VENDOR), ==, - "LENOVO"); - g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_BIOS_VERSION), ==, - "GJET75WW (2.25 )"); - g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_BIOS_MAJOR_RELEASE), ==, "02"); - g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_BIOS_MINOR_RELEASE), ==, "19"); - g_assert_cmpstr (fu_hwids_get_value (hwids, FU_HWIDS_KEY_PRODUCT_SKU), ==, - "LENOVO_MT_20AR_BU_Think_FM_ThinkPad T440s"); - for (guint i = 0; guids[i].key != NULL; i++) { - g_autofree gchar *guid = fu_hwids_get_guid (hwids, guids[i].key, &error); - g_assert_no_error (error); - g_assert_cmpstr (guid, ==, guids[i].value); - } - for (guint i = 0; guids[i].key != NULL; i++) - g_assert (fu_hwids_has_guid (hwids, guids[i].value)); + /* get device */ + device = fu_history_get_device_by_id (history, "2ba16d10df45823dd4494ff10a0bfccfef512c9d", &error); + g_assert_no_error (error); + g_assert (device != NULL); + g_assert_cmpstr (fu_device_get_id (device), ==, "2ba16d10df45823dd4494ff10a0bfccfef512c9d"); } static void @@ -2130,36 +1971,6 @@ _plugin_device_added_cb (FuPlugin *plugin, FuDevice *device, gpointer user_data) fu_test_loop_quit (); } -static void -fu_plugin_delay_func (void) -{ - FuDevice *device_tmp; - g_autoptr(FuPlugin) plugin = NULL; - g_autoptr(FuDevice) device = NULL; - - plugin = fu_plugin_new (); - g_signal_connect (plugin, "device-added", - G_CALLBACK (_plugin_device_added_cb), - &device_tmp); - g_signal_connect (plugin, "device-removed", - G_CALLBACK (_plugin_device_added_cb), - &device_tmp); - - /* add device straight away */ - device = fu_device_new (); - fu_device_set_id (device, "testdev"); - fu_plugin_device_add (plugin, device); - g_assert (device_tmp != NULL); - g_assert_cmpstr (fu_device_get_id (device_tmp), ==, "b7eccd0059d6d7dc2ef76c35d6de0048cc8c029d"); - g_clear_object (&device_tmp); - - /* remove device */ - fu_plugin_device_remove (plugin, device); - g_assert (device_tmp != NULL); - g_assert_cmpstr (fu_device_get_id (device_tmp), ==, "b7eccd0059d6d7dc2ef76c35d6de0048cc8c029d"); - g_clear_object (&device_tmp); -} - static void _plugin_device_register_cb (FuPlugin *plugin, FuDevice *device, gpointer user_data) { @@ -2167,120 +1978,6 @@ _plugin_device_register_cb (FuPlugin *plugin, FuDevice *device, gpointer user_da fu_plugin_runner_device_register (plugin, device); } -static void -fu_plugin_quirks_func (void) -{ - const gchar *tmp; - gboolean ret; - g_autoptr(FuQuirks) quirks = fu_quirks_new (); - g_autoptr(FuPlugin) plugin = fu_plugin_new (); - g_autoptr(GError) error = NULL; - - ret = fu_quirks_load (quirks, FU_QUIRKS_LOAD_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - fu_plugin_set_quirks (plugin, quirks); - - /* exact */ - tmp = fu_plugin_lookup_quirk_by_id (plugin, "USB\\VID_0A5C&PID_6412", "Flags"); - g_assert_cmpstr (tmp, ==, "ignore-runtime"); - tmp = fu_plugin_lookup_quirk_by_id (plugin, "ACME Inc.=True", "Test"); - g_assert_cmpstr (tmp, ==, "awesome"); - tmp = fu_plugin_lookup_quirk_by_id (plugin, "CORP*", "Test"); - g_assert_cmpstr (tmp, ==, "town"); - tmp = fu_plugin_lookup_quirk_by_id (plugin, "baz", "Unfound"); - g_assert_cmpstr (tmp, ==, NULL); - tmp = fu_plugin_lookup_quirk_by_id (plugin, "unfound", "tests"); - g_assert_cmpstr (tmp, ==, NULL); - tmp = fu_plugin_lookup_quirk_by_id (plugin, "unfound", "unfound"); - g_assert_cmpstr (tmp, ==, NULL); - tmp = fu_plugin_lookup_quirk_by_id (plugin, "bb9ec3e2-77b3-53bc-a1f1-b05916715627", "Flags"); - g_assert_cmpstr (tmp, ==, "clever"); -} - -static void -fu_plugin_quirks_performance_func (void) -{ - gboolean ret; - g_autoptr(FuQuirks) quirks = fu_quirks_new (); - g_autoptr(GTimer) timer = g_timer_new (); - g_autoptr(GError) error = NULL; - const gchar *keys[] = { "Name", "Children", "Flags", NULL }; - - ret = fu_quirks_load (quirks, FU_QUIRKS_LOAD_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - - /* lookup */ - g_timer_reset (timer); - for (guint j = 0; j < 1000; j++) { - const gchar *group = "DeviceInstanceId=USB\\VID_0BDA&PID_1100"; - for (guint i = 0; keys[i] != NULL; i++) { - const gchar *tmp = fu_quirks_lookup_by_id (quirks, group, keys[i]); - g_assert_cmpstr (tmp, !=, NULL); - } - } - g_print ("lookup=%.3fms ", g_timer_elapsed (timer, NULL) * 1000.f); -} - -static void -fu_plugin_quirks_device_func (void) -{ - FuDevice *device_tmp; - GPtrArray *children; - gboolean ret; - g_autoptr(FuDevice) device = fu_device_new (); - g_autoptr(FuQuirks) quirks = fu_quirks_new (); - g_autoptr(GError) error = NULL; - - ret = fu_quirks_load (quirks, FU_QUIRKS_LOAD_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - - /* use quirk file to set device attributes */ - fu_device_set_physical_id (device, "usb:00:05"); - fu_device_set_quirks (device, quirks); - fu_device_add_flag (device, FWUPD_DEVICE_FLAG_UPDATABLE); - fu_device_add_instance_id (device, "USB\\VID_0BDA&PID_1100"); - fu_device_convert_instance_ids (device); - g_assert_cmpstr (fu_device_get_name (device), ==, "Hub"); - - /* ensure children are created */ - children = fu_device_get_children (device); - g_assert_cmpint (children->len, ==, 1); - device_tmp = g_ptr_array_index (children, 0); - g_assert_cmpstr (fu_device_get_name (device_tmp), ==, "HDMI"); - g_assert (fu_device_has_flag (device_tmp, FWUPD_DEVICE_FLAG_UPDATABLE)); -} - -static void -fu_plugin_hash_func (void) -{ - GError *error = NULL; - g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE); - g_autoptr(FuPlugin) plugin = fu_plugin_new (); - gboolean ret = FALSE; - - ret = fu_engine_load (engine, FU_ENGINE_LOAD_FLAG_NO_ENUMERATE, &error); - g_assert_no_error (error); - g_assert (ret); - - /* make sure not tainted */ - ret = fu_engine_get_tainted (engine); - g_assert_false (ret); - - /* create a tainted plugin */ - g_setenv ("FWUPD_PLUGIN_TEST", "build-hash", TRUE); - ret = fu_plugin_open (plugin, PLUGINBUILDDIR "/libfu_plugin_test." G_MODULE_SUFFIX, &error); - g_assert_no_error (error); - - /* make sure it tainted now */ - g_test_expect_message ("FuEngine", G_LOG_LEVEL_WARNING, "* has incorrect built version*"); - fu_engine_add_plugin (engine, plugin); - ret = fu_engine_get_tainted (engine); - g_assert_true (ret); -} - static void fu_plugin_module_func (void) { @@ -2416,111 +2113,6 @@ fu_plugin_module_func (void) g_unlink (pending_cap); } -static void -fu_plugin_list_func (void) -{ - GPtrArray *plugins; - FuPlugin *plugin; - g_autoptr(FuPluginList) plugin_list = fu_plugin_list_new (); - g_autoptr(FuPlugin) plugin1 = fu_plugin_new (); - g_autoptr(FuPlugin) plugin2 = fu_plugin_new (); - g_autoptr(GError) error = NULL; - - fu_plugin_set_name (plugin1, "plugin1"); - fu_plugin_set_name (plugin2, "plugin2"); - - /* get all the plugins */ - fu_plugin_list_add (plugin_list, plugin1); - fu_plugin_list_add (plugin_list, plugin2); - plugins = fu_plugin_list_get_all (plugin_list); - g_assert_cmpint (plugins->len, ==, 2); - - /* get a single plugin */ - plugin = fu_plugin_list_find_by_name (plugin_list, "plugin1", &error); - g_assert_no_error (error); - g_assert (plugin != NULL); - g_assert_cmpstr (fu_plugin_get_name (plugin), ==, "plugin1"); - - /* does not exist */ - plugin = fu_plugin_list_find_by_name (plugin_list, "nope", &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND); - g_assert (plugin == NULL); -} - -static void -fu_plugin_list_depsolve_func (void) -{ - GPtrArray *plugins; - FuPlugin *plugin; - gboolean ret; - g_autoptr(FuPluginList) plugin_list = fu_plugin_list_new (); - g_autoptr(FuPlugin) plugin1 = fu_plugin_new (); - g_autoptr(FuPlugin) plugin2 = fu_plugin_new (); - g_autoptr(GError) error = NULL; - - fu_plugin_set_name (plugin1, "plugin1"); - fu_plugin_set_name (plugin2, "plugin2"); - - /* add rule then depsolve */ - fu_plugin_list_add (plugin_list, plugin1); - fu_plugin_list_add (plugin_list, plugin2); - fu_plugin_add_rule (plugin1, FU_PLUGIN_RULE_RUN_AFTER, "plugin2"); - ret = fu_plugin_list_depsolve (plugin_list, &error); - g_assert_no_error (error); - g_assert (ret); - plugins = fu_plugin_list_get_all (plugin_list); - g_assert_cmpint (plugins->len, ==, 2); - plugin = g_ptr_array_index (plugins, 0); - g_assert_cmpstr (fu_plugin_get_name (plugin), ==, "plugin2"); - g_assert_cmpint (fu_plugin_get_order (plugin), ==, 0); - g_assert (fu_plugin_get_enabled (plugin)); - - /* add another rule, then re-depsolve */ - fu_plugin_add_rule (plugin1, FU_PLUGIN_RULE_CONFLICTS, "plugin2"); - ret = fu_plugin_list_depsolve (plugin_list, &error); - g_assert_no_error (error); - g_assert (ret); - plugin = fu_plugin_list_find_by_name (plugin_list, "plugin1", &error); - g_assert_no_error (error); - g_assert (plugin != NULL); - g_assert (fu_plugin_get_enabled (plugin)); - plugin = fu_plugin_list_find_by_name (plugin_list, "plugin2", &error); - g_assert_no_error (error); - g_assert (plugin != NULL); - g_assert (!fu_plugin_get_enabled (plugin)); -} - -static void -fu_history_migrate_func (void) -{ - gboolean ret; - g_autoptr(GError) error = NULL; - g_autoptr(GFile) file_dst = NULL; - g_autoptr(GFile) file_src = NULL; - g_autoptr(FuDevice) device = NULL; - g_autoptr(FuHistory) history = NULL; - g_autofree gchar *filename = NULL; - - /* load old version */ - filename = fu_test_get_filename (TESTDATADIR, "history_v1.db"); - file_src = g_file_new_for_path (filename); - file_dst = g_file_new_for_path ("/tmp/fwupd-self-test/var/lib/fwupd/pending.db"); - ret = g_file_copy (file_src, file_dst, G_FILE_COPY_OVERWRITE, NULL, - NULL, NULL, &error); - g_assert_no_error (error); - g_assert (ret); - - /* create, migrating as required */ - history = fu_history_new (); - g_assert (history != NULL); - - /* get device */ - device = fu_history_get_device_by_id (history, "2ba16d10df45823dd4494ff10a0bfccfef512c9d", &error); - g_assert_no_error (error); - g_assert (device != NULL); - g_assert_cmpstr (fu_device_get_id (device), ==, "2ba16d10df45823dd4494ff10a0bfccfef512c9d"); -} - static void fu_history_func (void) { @@ -2827,189 +2419,6 @@ fu_keyring_pkcs7_self_signed_func (void) #endif } -static void -fu_common_firmware_builder_func (void) -{ - const gchar *data; - g_autofree gchar *archive_fn = NULL; - g_autoptr(GBytes) archive_blob = NULL; - g_autoptr(GBytes) firmware_blob = NULL; - g_autoptr(GError) error = NULL; - - /* get test file */ - archive_fn = fu_test_get_filename (TESTDATADIR, "builder/firmware.tar"); - g_assert (archive_fn != NULL); - archive_blob = fu_common_get_contents_bytes (archive_fn, &error); - g_assert_no_error (error); - g_assert (archive_blob != NULL); - - /* generate the firmware */ - firmware_blob = fu_common_firmware_builder (archive_blob, - "startup.sh", - "firmware.bin", - &error); - if (firmware_blob == NULL) { - if (g_error_matches (error, FWUPD_ERROR, FWUPD_ERROR_PERMISSION_DENIED)) { - g_test_skip ("Missing permissions to create namespace in container"); - return; - } - if (g_error_matches (error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED)) { - g_test_skip ("User namespaces not supported in container"); - return; - } - g_assert_no_error (error); - } - - /* check it */ - data = g_bytes_get_data (firmware_blob, NULL); - g_assert_cmpstr (data, ==, "xobdnas eht ni gninnur"); -} - -static void -fu_test_stdout_cb (const gchar *line, gpointer user_data) -{ - guint *lines = (guint *) user_data; - g_debug ("got '%s'", line); - (*lines)++; -} - -static gboolean -_open_cb (GObject *device, GError **error) -{ - g_assert_cmpstr (g_object_get_data (device, "state"), ==, "closed"); - g_object_set_data (device, "state", (gpointer) "opened"); - return TRUE; -} - -static gboolean -_close_cb (GObject *device, GError **error) -{ - g_assert_cmpstr (g_object_get_data (device, "state"), ==, "opened"); - g_object_set_data (device, "state", (gpointer) "closed-on-unref"); - return TRUE; -} - -static void -fu_device_locker_func (void) -{ - g_autoptr(FuDeviceLocker) locker = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(GObject) device = g_object_new (G_TYPE_OBJECT, NULL); - - g_object_set_data (device, "state", (gpointer) "closed"); - locker = fu_device_locker_new_full (device, _open_cb, _close_cb, &error); - g_assert_no_error (error); - g_assert_nonnull (locker); - g_clear_object (&locker); - g_assert_cmpstr (g_object_get_data (device, "state"), ==, "closed-on-unref"); -} - -static gboolean -_fail_open_cb (GObject *device, GError **error) -{ - g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "fail"); - return FALSE; -} - -static gboolean -_fail_close_cb (GObject *device, GError **error) -{ - g_assert_not_reached (); - return TRUE; -} - -static void -fu_device_locker_fail_func (void) -{ - g_autoptr(FuDeviceLocker) locker = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(GObject) device = g_object_new (G_TYPE_OBJECT, NULL); - locker = fu_device_locker_new_full (device, _fail_open_cb, _fail_close_cb, &error); - g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED); - g_assert_null (locker); -} - -static void -fu_common_spawn_func (void) -{ - gboolean ret; - guint lines = 0; - g_autoptr(GError) error = NULL; - g_autofree gchar *fn = NULL; - const gchar *argv[3] = { "replace", "test", NULL }; - - fn = fu_test_get_filename (TESTDATADIR, "spawn.sh"); - g_assert (fn != NULL); - argv[0] = fn; - ret = fu_common_spawn_sync (argv, - fu_test_stdout_cb, &lines, 0, NULL, &error); - g_assert_no_error (error); - g_assert (ret); - g_assert_cmpint (lines, ==, 6); -} - -static void -fu_common_spawn_timeout_func (void) -{ - gboolean ret; - guint lines = 0; - g_autoptr(GError) error = NULL; - g_autofree gchar *fn = NULL; - const gchar *argv[3] = { "replace", "test", NULL }; - - fn = fu_test_get_filename (TESTDATADIR, "spawn.sh"); - g_assert (fn != NULL); - argv[0] = fn; - ret = fu_common_spawn_sync (argv, fu_test_stdout_cb, &lines, 50, NULL, &error); - g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED); - g_assert (!ret); - g_assert_cmpint (lines, ==, 1); -} - -static void -fu_progressbar_func (void) -{ - g_autoptr(FuProgressbar) progressbar = fu_progressbar_new (); - - fu_progressbar_set_length_status (progressbar, 20); - fu_progressbar_set_length_percentage (progressbar, 50); - - g_print ("\n"); - for (guint i = 0; i < 100; i++) { - fu_progressbar_update (progressbar, FWUPD_STATUS_DECOMPRESSING, i); - g_usleep (10000); - } - fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); - for (guint i = 0; i < 100; i++) { - guint pc = (i > 25 && i < 75) ? 0 : i; - fu_progressbar_update (progressbar, FWUPD_STATUS_LOADING, pc); - g_usleep (10000); - } - fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); - - for (guint i = 0; i < 5000; i++) { - fu_progressbar_update (progressbar, FWUPD_STATUS_LOADING, 0); - g_usleep (1000); - } - fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); -} - -static void -fu_common_endian_func (void) -{ - guint8 buf[2]; - - fu_common_write_uint16 (buf, 0x1234, G_LITTLE_ENDIAN); - g_assert_cmpint (buf[0], ==, 0x34); - g_assert_cmpint (buf[1], ==, 0x12); - g_assert_cmpint (fu_common_read_uint16 (buf, G_LITTLE_ENDIAN), ==, 0x1234); - - fu_common_write_uint16 (buf, 0x1234, G_BIG_ENDIAN); - g_assert_cmpint (buf[0], ==, 0x12); - g_assert_cmpint (buf[1], ==, 0x34); - g_assert_cmpint (fu_common_read_uint16 (buf, G_BIG_ENDIAN), ==, 0x1234); -} - static GBytes * _build_cab (GCabCompression compression, ...) { @@ -3244,817 +2653,6 @@ fu_plugin_composite_func (void) } } -static void -fu_common_store_cab_func (void) -{ - GBytes *blob_tmp; - g_autoptr(GBytes) blob = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(XbNode) component = NULL; - g_autoptr(XbNode) csum = NULL; - g_autoptr(XbNode) rel = NULL; - g_autoptr(XbNode) req = NULL; - g_autoptr(XbSilo) silo = NULL; - - /* create silo */ - blob = _build_cab (GCAB_COMPRESSION_NONE, - "acme.metainfo.xml", - "\n" - " com.acme.example.firmware\n" - " ACME Firmware\n" - " \n" - " ae56e3fb-6528-5bc4-8b03-012f124075d7\n" - " \n" - " \n" - " \n" - " 5\n" - " 7c211433f02071597741e6ff5a8ea34789abbf43\n" - "

We fixed things

\n" - "
\n" - "
\n" - " \n" - " org.freedesktop.fwupd\n" - " \n" - "
", - "firmware.dfu", "world", - "firmware.dfu.asc", "signature", - NULL); - if (blob == NULL) { - g_test_skip ("libgcab too old"); - return; - } - silo = fu_common_cab_build_silo (blob, 10240, &error); - g_assert_no_error (error); - g_assert_nonnull (silo); - - /* verify */ - component = xb_silo_query_first (silo, "components/component/id[text()='com.acme.example.firmware']/..", &error); - g_assert_no_error (error); - g_assert_nonnull (component); - rel = xb_node_query_first (component, "releases/release", &error); - g_assert_no_error (error); - g_assert_nonnull (rel); - g_assert_cmpstr (xb_node_get_attr (rel, "version"), ==, "1.2.3"); - csum = xb_node_query_first (rel, "checksum[@target='content']", &error); - g_assert_nonnull (csum); - g_assert_cmpstr (xb_node_get_text (csum), ==, "7c211433f02071597741e6ff5a8ea34789abbf43"); - blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.dfu)"); - g_assert_nonnull (blob_tmp); - blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.dfu.asc)"); - g_assert_nonnull (blob_tmp); - req = xb_node_query_first (component, "requires/id", &error); - g_assert_no_error (error); - g_assert_nonnull (req); -} - -static void -fu_common_store_cab_unsigned_func (void) -{ - GBytes *blob_tmp; - g_autoptr(GBytes) blob = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(XbNode) component = NULL; - g_autoptr(XbNode) csum = NULL; - g_autoptr(XbNode) rel = NULL; - g_autoptr(XbSilo) silo = NULL; - - /* create silo */ - blob = _build_cab (GCAB_COMPRESSION_NONE, - "acme.metainfo.xml", - "\n" - " com.acme.example.firmware\n" - " \n" - " \n" - " \n" - "", - "firmware.bin", "world", - NULL); - if (blob == NULL) { - g_test_skip ("libgcab too old"); - return; - } - silo = fu_common_cab_build_silo (blob, 10240, &error); - g_assert_no_error (error); - g_assert_nonnull (silo); - - /* verify */ - component = xb_silo_query_first (silo, "components/component/id[text()='com.acme.example.firmware']/..", &error); - g_assert_no_error (error); - g_assert_nonnull (component); - rel = xb_node_query_first (component, "releases/release", &error); - g_assert_no_error (error); - g_assert_nonnull (rel); - g_assert_cmpstr (xb_node_get_attr (rel, "version"), ==, "1.2.3"); - csum = xb_node_query_first (rel, "checksum[@target='content']", &error); - g_assert_null (csum); - blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.bin)"); - g_assert_nonnull (blob_tmp); - blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.bin.asc)"); - g_assert_null (blob_tmp); -} - -static void -fu_common_store_cab_folder_func (void) -{ - GBytes *blob_tmp; - g_autoptr(GBytes) blob = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(XbNode) component = NULL; - g_autoptr(XbNode) rel = NULL; - g_autoptr(XbSilo) silo = NULL; - - /* create silo */ - blob = _build_cab (GCAB_COMPRESSION_NONE, - "lvfs\\acme.metainfo.xml", - "\n" - " com.acme.example.firmware\n" - " \n" - " \n" - " \n" - "", - "lvfs\\firmware.bin", "world", - NULL); - if (blob == NULL) { - g_test_skip ("libgcab too old"); - return; - } - silo = fu_common_cab_build_silo (blob, 10240, &error); - g_assert_no_error (error); - g_assert_nonnull (silo); - - /* verify */ - component = xb_silo_query_first (silo, "components/component/id[text()='com.acme.example.firmware']/..", &error); - g_assert_no_error (error); - g_assert_nonnull (component); - rel = xb_node_query_first (component, "releases/release", &error); - g_assert_no_error (error); - g_assert_nonnull (rel); - g_assert_cmpstr (xb_node_get_attr (rel, "version"), ==, "1.2.3"); - blob_tmp = xb_node_get_data (rel, "fwupd::ReleaseBlob(firmware.bin)"); - g_assert_nonnull (blob_tmp); -} - -static void -fu_common_store_cab_error_no_metadata_func (void) -{ - g_autoptr(XbSilo) silo = NULL; - g_autoptr(GBytes) blob = NULL; - g_autoptr(GError) error = NULL; - - blob = _build_cab (GCAB_COMPRESSION_NONE, - "foo.txt", "hello", - "bar.txt", "world", - NULL); - if (blob == NULL) { - g_test_skip ("libgcab too old"); - return; - } - silo = fu_common_cab_build_silo (blob, 10240, &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); - g_assert_null (silo); -} - -static void -fu_common_store_cab_error_wrong_size_func (void) -{ - g_autoptr(XbSilo) silo = NULL; - g_autoptr(GBytes) blob = NULL; - g_autoptr(GError) error = NULL; - - blob = _build_cab (GCAB_COMPRESSION_NONE, - "acme.metainfo.xml", - "\n" - " com.acme.example.firmware\n" - " \n" - " \n" - " 7004701\n" - " deadbeef\n" - " \n" - " \n" - "", - "firmware.bin", "world", - NULL); - if (blob == NULL) { - g_test_skip ("libgcab too old"); - return; - } - silo = fu_common_cab_build_silo (blob, 10240, &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); - g_assert_null (silo); -} - -static void -fu_common_store_cab_error_missing_file_func (void) -{ - g_autoptr(XbSilo) silo = NULL; - g_autoptr(GBytes) blob = NULL; - g_autoptr(GError) error = NULL; - - blob = _build_cab (GCAB_COMPRESSION_NONE, - "acme.metainfo.xml", - "\n" - " com.acme.example.firmware\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "", - "firmware.bin", "world", - NULL); - if (blob == NULL) { - g_test_skip ("libgcab too old"); - return; - } - silo = fu_common_cab_build_silo (blob, 10240, &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); - g_assert_null (silo); -} - -static void -fu_common_store_cab_error_size_func (void) -{ - g_autoptr(XbSilo) silo = NULL; - g_autoptr(GBytes) blob = NULL; - g_autoptr(GError) error = NULL; - - blob = _build_cab (GCAB_COMPRESSION_NONE, - "acme.metainfo.xml", - "\n" - " com.acme.example.firmware\n" - " \n" - " \n" - " \n" - "", - "firmware.bin", "world", - NULL); - if (blob == NULL) { - g_test_skip ("libgcab too old"); - return; - } - silo = fu_common_cab_build_silo (blob, 123, &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); - g_assert_null (silo); -} - -static void -fu_common_store_cab_error_wrong_checksum_func (void) -{ - g_autoptr(XbSilo) silo = NULL; - g_autoptr(GBytes) blob = NULL; - g_autoptr(GError) error = NULL; - - blob = _build_cab (GCAB_COMPRESSION_NONE, - "acme.metainfo.xml", - "\n" - " com.acme.example.firmware\n" - " \n" - " \n" - " deadbeef\n" - " \n" - " \n" - "", - "firmware.bin", "world", - NULL); - if (blob == NULL) { - g_test_skip ("libgcab too old"); - return; - } - silo = fu_common_cab_build_silo (blob, 10240, &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE); - g_assert_null (silo); -} - -static gboolean -fu_device_poll_cb (FuDevice *device, GError **error) -{ - guint64 cnt = fu_device_get_metadata_integer (device, "cnt"); - g_debug ("poll cnt=%" G_GUINT64_FORMAT, cnt); - fu_device_set_metadata_integer (device, "cnt", cnt + 1); - return TRUE; -} - -static void -fu_device_poll_func (void) -{ - g_autoptr(FuDevice) device = fu_device_new (); - FuDeviceClass *klass = FU_DEVICE_GET_CLASS (device); - guint cnt; - - /* set up a 10ms poll */ - klass->poll = fu_device_poll_cb; - fu_device_set_metadata_integer (device, "cnt", 0); - fu_device_set_poll_interval (device, 10); - fu_test_loop_run_with_timeout (100); - fu_test_loop_quit (); - cnt = fu_device_get_metadata_integer (device, "cnt"); - g_assert_cmpint (cnt, >=, 8); - - /* disable the poll */ - fu_device_set_poll_interval (device, 0); - fu_test_loop_run_with_timeout (100); - fu_test_loop_quit (); - g_assert_cmpint (fu_device_get_metadata_integer (device, "cnt"), ==, cnt); -} - -static void -fu_device_incorporate_func (void) -{ - g_autoptr(FuDevice) device = fu_device_new (); - g_autoptr(FuDevice) donor = fu_device_new (); - - /* set up donor device */ - fu_device_set_alternate_id (donor, "alt-id"); - fu_device_set_equivalent_id (donor, "equiv-id"); - fu_device_set_metadata (donor, "test", "me"); - fu_device_set_metadata (donor, "test2", "me"); - - /* base properties */ - fu_device_add_flag (donor, FWUPD_DEVICE_FLAG_REQUIRE_AC); - fu_device_set_created (donor, 123); - fu_device_set_modified (donor, 456); - fu_device_add_icon (donor, "computer"); - - /* existing properties */ - fu_device_set_equivalent_id (device, "DO_NOT_OVERWRITE"); - fu_device_set_metadata (device, "test2", "DO_NOT_OVERWRITE"); - fu_device_set_modified (device, 789); - - /* incorporate properties from donor to device */ - fu_device_incorporate (device, donor); - g_assert_cmpstr (fu_device_get_alternate_id (device), ==, "alt-id"); - g_assert_cmpstr (fu_device_get_equivalent_id (device), ==, "DO_NOT_OVERWRITE"); - g_assert_cmpstr (fu_device_get_metadata (device, "test"), ==, "me"); - g_assert_cmpstr (fu_device_get_metadata (device, "test2"), ==, "DO_NOT_OVERWRITE"); - g_assert_true (fu_device_has_flag (device, FWUPD_DEVICE_FLAG_REQUIRE_AC)); - g_assert_cmpint (fu_device_get_created (device), ==, 123); - g_assert_cmpint (fu_device_get_modified (device), ==, 789); - g_assert_cmpint (fu_device_get_icons(device)->len, ==, 1); -} - -static void -fu_chunk_func (void) -{ - g_autofree gchar *chunked1_str = NULL; - g_autofree gchar *chunked2_str = NULL; - g_autofree gchar *chunked3_str = NULL; - g_autofree gchar *chunked4_str = NULL; - g_autoptr(GPtrArray) chunked1 = NULL; - g_autoptr(GPtrArray) chunked2 = NULL; - g_autoptr(GPtrArray) chunked3 = NULL; - g_autoptr(GPtrArray) chunked4 = NULL; - - chunked3 = fu_chunk_array_new ((const guint8 *) "123456", 6, 0x0, 3, 3); - chunked3_str = fu_chunk_array_to_string (chunked3); - g_print ("\n%s", chunked3_str); - g_assert_cmpstr (chunked3_str, ==, "#00: page:00 addr:0000 len:03 123\n" - "#01: page:01 addr:0000 len:03 456\n"); - - chunked4 = fu_chunk_array_new ((const guint8 *) "123456", 6, 0x4, 4, 4); - chunked4_str = fu_chunk_array_to_string (chunked4); - g_print ("\n%s", chunked4_str); - g_assert_cmpstr (chunked4_str, ==, "#00: page:01 addr:0000 len:04 1234\n" - "#01: page:02 addr:0000 len:02 56\n"); - - chunked1 = fu_chunk_array_new ((const guint8 *) "0123456789abcdef", 16, 0x0, 10, 4); - chunked1_str = fu_chunk_array_to_string (chunked1); - g_print ("\n%s", chunked1_str); - g_assert_cmpstr (chunked1_str, ==, "#00: page:00 addr:0000 len:04 0123\n" - "#01: page:00 addr:0004 len:04 4567\n" - "#02: page:00 addr:0008 len:02 89\n" - "#03: page:01 addr:0000 len:04 abcd\n" - "#04: page:01 addr:0004 len:02 ef\n"); - - chunked2 = fu_chunk_array_new ((const guint8 *) "XXXXXXYYYYYYZZZZZZ", 18, 0x0, 6, 4); - chunked2_str = fu_chunk_array_to_string (chunked2); - g_print ("\n%s", chunked2_str); - g_assert_cmpstr (chunked2_str, ==, "#00: page:00 addr:0000 len:04 XXXX\n" - "#01: page:00 addr:0004 len:02 XX\n" - "#02: page:01 addr:0000 len:04 YYYY\n" - "#03: page:01 addr:0004 len:02 YY\n" - "#04: page:02 addr:0000 len:04 ZZZZ\n" - "#05: page:02 addr:0004 len:02 ZZ\n"); -} - -static void -fu_common_strstrip_func (void) -{ - - struct { - const gchar *old; - const gchar *new; - } map[] = { - { "same", "same" }, - { " leading", "leading" }, - { "tailing ", "tailing" }, - { " b ", "b" }, - { " ", "" }, - { NULL, NULL } - }; - for (guint i = 0; map[i].old != NULL; i++) { - g_autofree gchar *tmp = fu_common_strstrip (map[i].old); - g_assert_cmpstr (tmp, ==, map[i].new); - } -} - -static void -fu_common_version_func (void) -{ - guint i; - struct { - guint32 val; - const gchar *ver; - FwupdVersionFormat flags; - } version_from_uint32[] = { - { 0x0, "0.0.0.0", FWUPD_VERSION_FORMAT_QUAD }, - { 0xff, "0.0.0.255", FWUPD_VERSION_FORMAT_QUAD }, - { 0xff01, "0.0.255.1", FWUPD_VERSION_FORMAT_QUAD }, - { 0xff0001, "0.255.0.1", FWUPD_VERSION_FORMAT_QUAD }, - { 0xff000100, "255.0.1.0", FWUPD_VERSION_FORMAT_QUAD }, - { 0x0, "0.0.0", FWUPD_VERSION_FORMAT_TRIPLET }, - { 0xff, "0.0.255", FWUPD_VERSION_FORMAT_TRIPLET }, - { 0xff01, "0.0.65281", FWUPD_VERSION_FORMAT_TRIPLET }, - { 0xff0001, "0.255.1", FWUPD_VERSION_FORMAT_TRIPLET }, - { 0xff000100, "255.0.256", FWUPD_VERSION_FORMAT_TRIPLET }, - { 0x0, "0", FWUPD_VERSION_FORMAT_NUMBER }, - { 0xff000100, "4278190336", FWUPD_VERSION_FORMAT_NUMBER }, - { 0x0, "11.0.0.0", FWUPD_VERSION_FORMAT_INTEL_ME }, - { 0xffffffff, "18.31.255.65535", FWUPD_VERSION_FORMAT_INTEL_ME }, - { 0x0b32057a, "11.11.50.1402", FWUPD_VERSION_FORMAT_INTEL_ME }, - { 0xb8320d84, "11.8.50.3460", FWUPD_VERSION_FORMAT_INTEL_ME2 }, - { 0x226a4b00, "137.2706.768", FWUPD_VERSION_FORMAT_SURFACE_LEGACY }, - { 0x6001988, "6.25.136", FWUPD_VERSION_FORMAT_SURFACE }, - { 0, NULL } - }; - struct { - guint16 val; - const gchar *ver; - FwupdVersionFormat flags; - } version_from_uint16[] = { - { 0x0, "0.0", FWUPD_VERSION_FORMAT_PAIR }, - { 0xff, "0.255", FWUPD_VERSION_FORMAT_PAIR }, - { 0xff01, "255.1", FWUPD_VERSION_FORMAT_PAIR }, - { 0x0, "0.0", FWUPD_VERSION_FORMAT_BCD }, - { 0x0110, "1.10", FWUPD_VERSION_FORMAT_BCD }, - { 0x9999, "99.99", FWUPD_VERSION_FORMAT_BCD }, - { 0x0, "0", FWUPD_VERSION_FORMAT_NUMBER }, - { 0x1234, "4660", FWUPD_VERSION_FORMAT_NUMBER }, - { 0, NULL } - }; - struct { - const gchar *old; - const gchar *new; - } version_parse[] = { - { "0", "0" }, - { "0x1a", "0.0.26" }, - { "257", "0.0.257" }, - { "1.2.3", "1.2.3" }, - { "0xff0001", "0.255.1" }, - { "16711681", "0.255.1" }, - { "20150915", "20150915" }, - { "dave", "dave" }, - { "0x1x", "0x1x" }, - { NULL, NULL } - }; - - /* check version conversion */ - for (i = 0; version_from_uint32[i].ver != NULL; i++) { - g_autofree gchar *ver = NULL; - ver = fu_common_version_from_uint32 (version_from_uint32[i].val, - version_from_uint32[i].flags); - g_assert_cmpstr (ver, ==, version_from_uint32[i].ver); - } - for (i = 0; version_from_uint16[i].ver != NULL; i++) { - g_autofree gchar *ver = NULL; - ver = fu_common_version_from_uint16 (version_from_uint16[i].val, - version_from_uint16[i].flags); - g_assert_cmpstr (ver, ==, version_from_uint16[i].ver); - } - - /* check version parsing */ - for (i = 0; version_parse[i].old != NULL; i++) { - g_autofree gchar *ver = NULL; - ver = fu_common_version_parse (version_parse[i].old); - g_assert_cmpstr (ver, ==, version_parse[i].new); - } -} - -static void -fu_common_vercmp_func (void) -{ - /* same */ - g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.3"), ==, 0); - g_assert_cmpint (fu_common_vercmp ("001.002.003", "001.002.003"), ==, 0); - - /* same, not dotted decimal */ - g_assert_cmpint (fu_common_vercmp ("1.2.3", "0x1020003"), ==, 0); - g_assert_cmpint (fu_common_vercmp ("0x10203", "0x10203"), ==, 0); - - /* upgrade and downgrade */ - g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.4"), <, 0); - g_assert_cmpint (fu_common_vercmp ("001.002.000", "001.002.009"), <, 0); - g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.2"), >, 0); - g_assert_cmpint (fu_common_vercmp ("001.002.009", "001.002.000"), >, 0); - - /* unequal depth */ - g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.3.1"), <, 0); - g_assert_cmpint (fu_common_vercmp ("1.2.3.1", "1.2.4"), <, 0); - - /* mixed-alpha-numeric */ - g_assert_cmpint (fu_common_vercmp ("1.2.3a", "1.2.3a"), ==, 0); - g_assert_cmpint (fu_common_vercmp ("1.2.3a", "1.2.3b"), <, 0); - g_assert_cmpint (fu_common_vercmp ("1.2.3b", "1.2.3a"), >, 0); - - /* alpha version append */ - g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.3a"), <, 0); - g_assert_cmpint (fu_common_vercmp ("1.2.3a", "1.2.3"), >, 0); - - /* alpha only */ - g_assert_cmpint (fu_common_vercmp ("alpha", "alpha"), ==, 0); - g_assert_cmpint (fu_common_vercmp ("alpha", "beta"), <, 0); - g_assert_cmpint (fu_common_vercmp ("beta", "alpha"), >, 0); - - /* alpha-compare */ - g_assert_cmpint (fu_common_vercmp ("1.2a.3", "1.2a.3"), ==, 0); - g_assert_cmpint (fu_common_vercmp ("1.2a.3", "1.2b.3"), <, 0); - g_assert_cmpint (fu_common_vercmp ("1.2b.3", "1.2a.3"), >, 0); - - /* tilde is all-powerful */ - g_assert_cmpint (fu_common_vercmp ("1.2.3~rc1", "1.2.3~rc1"), ==, 0); - g_assert_cmpint (fu_common_vercmp ("1.2.3~rc1", "1.2.3"), <, 0); - g_assert_cmpint (fu_common_vercmp ("1.2.3", "1.2.3~rc1"), >, 0); - g_assert_cmpint (fu_common_vercmp ("1.2.3~rc2", "1.2.3~rc1"), >, 0); - - /* invalid */ - g_assert_cmpint (fu_common_vercmp ("1", NULL), ==, G_MAXINT); - g_assert_cmpint (fu_common_vercmp (NULL, "1"), ==, G_MAXINT); - g_assert_cmpint (fu_common_vercmp (NULL, NULL), ==, G_MAXINT); -} - -static void -fu_firmware_ihex_func (void) -{ - const guint8 *data; - gboolean ret; - gsize len; - g_autofree gchar *filename_hex = NULL; - g_autofree gchar *filename_ref = NULL; - g_autofree gchar *str = NULL; - g_autoptr(FuFirmware) firmware = fu_ihex_firmware_new (); - g_autoptr(GBytes) data_file = NULL; - g_autoptr(GBytes) data_fw = NULL; - g_autoptr(GBytes) data_hex = NULL; - g_autoptr(GBytes) data_ref = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(GFile) file_ref = NULL; - g_autoptr(GFile) file_hex = NULL; - - /* load a Intel hex32 file */ - filename_hex = fu_test_get_filename (TESTDATADIR, "firmware.hex"); - g_assert (filename_hex != NULL); - file_hex = g_file_new_for_path (filename_hex); - data_file = g_file_load_bytes (file_hex, NULL, NULL, &error); - g_assert_no_error (error); - g_assert (data_file != NULL); - ret = fu_firmware_parse (firmware, data_file, FWUPD_INSTALL_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - data_fw = fu_firmware_get_image_default_bytes (firmware, &error); - g_assert_no_error (error); - g_assert_nonnull (data_fw); - g_assert_cmpint (g_bytes_get_size (data_fw), ==, 136); - - /* did we match the reference file? */ - filename_ref = fu_test_get_filename (TESTDATADIR, "firmware.bin"); - g_assert (filename_ref != NULL); - file_ref = g_file_new_for_path (filename_ref); - data_ref = g_file_load_bytes (file_ref, NULL, NULL, &error); - g_assert_no_error (error); - g_assert (data_ref != NULL); - ret = fu_common_bytes_compare (data_fw, data_ref, &error); - g_assert_no_error (error); - g_assert_true (ret); - - /* export a ihex file (which will be slightly different due to - * non-continous regions being expanded */ - data_hex = fu_firmware_write (firmware, &error); - g_assert_no_error (error); - g_assert (data_hex != NULL); - data = g_bytes_get_data (data_hex, &len); - str = g_strndup ((const gchar *) data, len); - g_assert_cmpstr (str, ==, - ":104000003DEF20F000000000FACF01F0FBCF02F0FE\n" - ":10401000E9CF03F0EACF04F0E1CF05F0E2CF06F0FC\n" - ":10402000D9CF07F0DACF08F0F3CF09F0F4CF0AF0D8\n" - ":10403000F6CF0BF0F7CF0CF0F8CF0DF0F5CF0EF078\n" - ":104040000EC0F5FF0DC0F8FF0CC0F7FF0BC0F6FF68\n" - ":104050000AC0F4FF09C0F3FF08C0DAFF07C0D9FFA8\n" - ":1040600006C0E2FF05C0E1FF04C0EAFF03C0E9FFAC\n" - ":1040700002C0FBFF01C0FAFF11003FEF20F000017A\n" - ":0840800042EF20F03DEF20F0BB\n" - ":00000001FF\n"); -} - -static void -fu_firmware_ihex_signed_func (void) -{ - const guint8 *data; - gboolean ret; - gsize len; - g_autofree gchar *filename_shex = NULL; - g_autoptr(FuFirmware) firmware = fu_ihex_firmware_new (); - g_autoptr(GBytes) data_file = NULL; - g_autoptr(GBytes) data_fw = NULL; - g_autoptr(GBytes) data_sig = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(GFile) file_hex = NULL; - - /* load a signed Intel hex32 file */ - filename_shex = fu_test_get_filename (TESTDATADIR, "firmware.shex"); - g_assert (filename_shex != NULL); - file_hex = g_file_new_for_path (filename_shex); - data_file = g_file_load_bytes (file_hex, NULL, NULL, &error); - g_assert_no_error (error); - g_assert (data_file != NULL); - ret = fu_firmware_parse (firmware, data_file, FWUPD_INSTALL_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - data_fw = fu_firmware_get_image_by_id_bytes (firmware, NULL, &error); - g_assert_no_error (error); - g_assert_nonnull (data_fw); - g_assert_cmpint (g_bytes_get_size (data_fw), ==, 136); - - /* get the signed image */ - data_sig = fu_firmware_get_image_by_id_bytes (firmware, - FU_FIRMWARE_IMAGE_ID_SIGNATURE, - &error); - g_assert_no_error (error); - g_assert_nonnull (data_sig); - data = g_bytes_get_data (data_sig, &len); - g_assert_cmpint (len, ==, 8); - g_assert (data != NULL); - g_assert_cmpint (memcmp (data, "deadbeef", 8), ==, 0); -} - -static void -fu_firmware_ihex_offset_func (void) -{ - const guint8 *data; - gboolean ret; - gsize len; - g_autofree gchar *str = NULL; - g_autoptr(FuFirmware) firmware = fu_ihex_firmware_new (); - g_autoptr(FuFirmware) firmware_verify = fu_ihex_firmware_new (); - g_autoptr(FuFirmwareImage) img_verify = NULL; - g_autoptr(FuFirmwareImage) img = NULL; - g_autoptr(GBytes) data_bin = NULL; - g_autoptr(GBytes) data_dummy = NULL; - g_autoptr(GBytes) data_verify = NULL; - g_autoptr(GError) error = NULL; - - /* add a 4 byte image in high memory */ - data_dummy = g_bytes_new_static ("foo", 4); - img = fu_firmware_image_new (data_dummy); - fu_firmware_image_set_addr (img, 0x80000000); - fu_firmware_add_image (firmware, img); - data_bin = fu_firmware_write (firmware, &error); - g_assert_no_error (error); - g_assert (data_bin != NULL); - data = g_bytes_get_data (data_bin, &len); - str = g_strndup ((const gchar *) data, len); - g_assert_cmpstr (str, ==, - ":0200000480007A\n" - ":04000000666F6F00B8\n" - ":00000001FF\n"); - - /* check we can load it too */ - ret = fu_firmware_parse (firmware_verify, data_bin, FWUPD_INSTALL_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - img_verify = fu_firmware_get_image_default (firmware_verify, &error); - g_assert_no_error (error); - g_assert (img_verify != NULL); - g_assert_cmpint (fu_firmware_image_get_addr (img_verify), ==, 0x80000000); - data_verify = fu_firmware_image_write (img_verify, &error); - g_assert_no_error (error); - g_assert (data_verify != NULL); - g_assert_cmpint (g_bytes_get_size (data_verify), ==, 0x4); -} - -static void -fu_firmware_srec_func (void) -{ - gboolean ret; - g_autofree gchar *filename_srec = NULL; - g_autofree gchar *filename_ref = NULL; - g_autoptr(FuFirmware) firmware = fu_srec_firmware_new (); - g_autoptr(GBytes) data_ref = NULL; - g_autoptr(GBytes) data_srec = NULL; - g_autoptr(GBytes) data_bin = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(GFile) file_bin = NULL; - g_autoptr(GFile) file_srec = NULL; - - filename_srec = fu_test_get_filename (TESTDATADIR, "firmware.srec"); - g_assert (filename_srec != NULL); - file_srec = g_file_new_for_path (filename_srec); - data_srec = g_file_load_bytes (file_srec, NULL, NULL, &error); - g_assert_no_error (error); - g_assert (data_srec != NULL); - ret = fu_firmware_parse (firmware, data_srec, FWUPD_INSTALL_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - data_bin = fu_firmware_get_image_default_bytes (firmware, &error); - g_assert_no_error (error); - g_assert_nonnull (data_bin); - g_assert_cmpint (g_bytes_get_size (data_bin), ==, 136); - - /* did we match the reference file? */ - filename_ref = fu_test_get_filename (TESTDATADIR, "firmware.bin"); - g_assert (filename_ref != NULL); - file_bin = g_file_new_for_path (filename_ref); - data_ref = g_file_load_bytes (file_bin, NULL, NULL, &error); - g_assert_no_error (error); - g_assert (data_ref != NULL); - ret = fu_common_bytes_compare (data_bin, data_ref, &error); - g_assert_no_error (error); - g_assert_true (ret); -} - -static void -fu_firmware_srec_tokenization_func (void) -{ - FuSrecFirmwareRecord *rcd; - GPtrArray *records; - gboolean ret; - g_autoptr(FuFirmware) firmware = fu_srec_firmware_new (); - g_autoptr(GBytes) data_srec = NULL; - g_autoptr(GError) error = NULL; - const gchar *buf = "S3060000001400E5\r\n" - "S31000000002281102000000007F0304002C\r\n" - "S306000000145095\r\n" - "S70500000000FA\r\n"; - data_srec = g_bytes_new_static (buf, strlen (buf)); - g_assert_no_error (error); - g_assert (data_srec != NULL); - ret = fu_firmware_tokenize (firmware, data_srec, FWUPD_INSTALL_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - - records = fu_srec_firmware_get_records (FU_SREC_FIRMWARE (firmware)); - g_assert_nonnull (records); - g_assert_cmpint (records->len, ==, 4); - rcd = g_ptr_array_index (records, 2); - g_assert_nonnull (rcd); - g_assert_cmpint (rcd->ln, ==, 0x3); - g_assert_cmpint (rcd->kind, ==, 3); - g_assert_cmpint (rcd->addr, ==, 0x14); - g_assert_cmpint (rcd->buf->len, ==, 0x1); - g_assert_cmpint (rcd->buf->data[0], ==, 0x50); -} - -static void -fu_firmware_dfu_func (void) -{ - gboolean ret; - g_autofree gchar *filename_dfu = NULL; - g_autofree gchar *filename_ref = NULL; - g_autoptr(FuFirmware) firmware = fu_dfu_firmware_new (); - g_autoptr(GBytes) data_ref = NULL; - g_autoptr(GBytes) data_dfu = NULL; - g_autoptr(GBytes) data_bin = NULL; - g_autoptr(GError) error = NULL; - g_autoptr(GFile) file_bin = NULL; - g_autoptr(GFile) file_dfu = NULL; - - filename_dfu = fu_test_get_filename (TESTDATADIR, "firmware.dfu"); - g_assert (filename_dfu != NULL); - file_dfu = g_file_new_for_path (filename_dfu); - data_dfu = g_file_load_bytes (file_dfu, NULL, NULL, &error); - g_assert_no_error (error); - g_assert (data_dfu != NULL); - ret = fu_firmware_parse (firmware, data_dfu, FWUPD_INSTALL_FLAG_NONE, &error); - g_assert_no_error (error); - g_assert (ret); - g_assert_cmpint (fu_dfu_firmware_get_vid (FU_DFU_FIRMWARE (firmware)), ==, 0x1234); - g_assert_cmpint (fu_dfu_firmware_get_pid (FU_DFU_FIRMWARE (firmware)), ==, 0x4321); - g_assert_cmpint (fu_dfu_firmware_get_release (FU_DFU_FIRMWARE (firmware)), ==, 0xdead); - data_bin = fu_firmware_get_image_default_bytes (firmware, &error); - g_assert_no_error (error); - g_assert_nonnull (data_bin); - g_assert_cmpint (g_bytes_get_size (data_bin), ==, 136); - - /* did we match the reference file? */ - filename_ref = fu_test_get_filename (TESTDATADIR, "firmware.bin"); - g_assert (filename_ref != NULL); - file_bin = g_file_new_for_path (filename_ref); - data_ref = g_file_load_bytes (file_bin, NULL, NULL, &error); - g_assert_no_error (error); - g_assert (data_ref != NULL); - ret = fu_common_bytes_compare (data_bin, data_ref, &error); - g_assert_no_error (error); - g_assert_true (ret); -} static void fu_memcpy_func (void) @@ -4128,60 +2726,6 @@ fu_memcpy_func (void) g_clear_error (&error); } -static void -fu_firmware_func (void) -{ - g_autoptr(FuFirmware) firmware = fu_firmware_new (); - g_autoptr(FuFirmwareImage) img1 = fu_firmware_image_new (NULL); - g_autoptr(FuFirmwareImage) img2 = fu_firmware_image_new (NULL); - g_autoptr(FuFirmwareImage) img_id = NULL; - g_autoptr(FuFirmwareImage) img_idx = NULL; - g_autoptr(GError) error = NULL; - g_autofree gchar *str = NULL; - - fu_firmware_image_set_addr (img1, 0x200); - fu_firmware_image_set_idx (img1, 13); - fu_firmware_image_set_id (img1, "primary"); - fu_firmware_add_image (firmware, img1); - fu_firmware_image_set_addr (img2, 0x400); - fu_firmware_image_set_idx (img2, 23); - fu_firmware_image_set_id (img2, "secondary"); - fu_firmware_add_image (firmware, img2); - - img_id = fu_firmware_get_image_by_id (firmware, "NotGoingToExist", &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND); - g_assert_null (img_id); - g_clear_error (&error); - img_id = fu_firmware_get_image_by_id (firmware, "primary", &error); - g_assert_no_error (error); - g_assert_nonnull (img_id); - g_assert_cmpint (fu_firmware_image_get_addr (img_id), ==, 0x200); - g_assert_cmpint (fu_firmware_image_get_idx (img_id), ==, 13); - g_assert_cmpstr (fu_firmware_image_get_id (img_id), ==, "primary"); - - img_idx = fu_firmware_get_image_by_idx (firmware, 123456, &error); - g_assert_error (error, FWUPD_ERROR, FWUPD_ERROR_NOT_FOUND); - g_assert_null (img_idx); - g_clear_error (&error); - img_idx = fu_firmware_get_image_by_idx (firmware, 23, &error); - g_assert_no_error (error); - g_assert_nonnull (img_idx); - g_assert_cmpint (fu_firmware_image_get_addr (img_idx), ==, 0x400); - g_assert_cmpint (fu_firmware_image_get_idx (img_idx), ==, 23); - g_assert_cmpstr (fu_firmware_image_get_id (img_idx), ==, "secondary"); - - str = fu_firmware_to_string (firmware); - g_assert_cmpstr (str, ==, "FuFirmware:\n" - " FuFirmwareImage:\n" - " ID: primary\n" - " Index: 0xd\n" - " Address: 0x200\n" - " FuFirmwareImage:\n" - " ID: secondary\n" - " Index: 0x17\n" - " Address: 0x400\n"); -} - int main (int argc, char **argv) { @@ -4201,27 +2745,9 @@ main (int argc, char **argv) fu_self_test_mkroot (); /* tests go here */ - if (g_test_slow ()) - g_test_add_func ("/fwupd/progressbar", fu_progressbar_func); + g_test_add_func ("/fwupd/plugin{build-hash}", fu_plugin_hash_func); + g_test_add_func ("/fwupd/plugin{module}", fu_plugin_module_func); g_test_add_func ("/fwupd/memcpy", fu_memcpy_func); - g_test_add_func ("/fwupd/firmware", fu_firmware_func); - g_test_add_func ("/fwupd/firmware{ihex}", fu_firmware_ihex_func); - g_test_add_func ("/fwupd/firmware{ihex-offset}", fu_firmware_ihex_offset_func); - g_test_add_func ("/fwupd/firmware{ihex-signed}", fu_firmware_ihex_signed_func); - g_test_add_func ("/fwupd/firmware{srec-tokenization}", fu_firmware_srec_tokenization_func); - g_test_add_func ("/fwupd/firmware{srec}", fu_firmware_srec_func); - g_test_add_func ("/fwupd/firmware{dfu}", fu_firmware_dfu_func); - g_test_add_func ("/fwupd/archive{invalid}", fu_archive_invalid_func); - g_test_add_func ("/fwupd/archive{cab}", fu_archive_cab_func); - g_test_add_func ("/fwupd/engine{requirements-other-device}", fu_engine_requirements_other_device_func); - g_test_add_func ("/fwupd/device{incorporate}", fu_device_incorporate_func); - if (g_test_slow ()) - g_test_add_func ("/fwupd/device{poll}", fu_device_poll_func); - g_test_add_func ("/fwupd/device-locker{success}", fu_device_locker_func); - g_test_add_func ("/fwupd/device-locker{fail}", fu_device_locker_fail_func); - g_test_add_func ("/fwupd/device{metadata}", fu_device_metadata_func); - g_test_add_func ("/fwupd/device{open-refcount}", fu_device_open_refcount_func); - g_test_add_func ("/fwupd/device{version-format}", fu_device_version_format_func); g_test_add_func ("/fwupd/device-list", fu_device_list_func); g_test_add_func ("/fwupd/device-list{delay}", fu_device_list_delay_func); g_test_add_func ("/fwupd/device-list{compatible}", fu_device_list_compatible_func); @@ -4248,40 +2774,14 @@ main (int argc, char **argv) g_test_add_func ("/fwupd/engine{device-priority}", fu_engine_device_priority_func); g_test_add_func ("/fwupd/engine{install-duration}", fu_engine_install_duration_func); g_test_add_func ("/fwupd/engine{generate-md}", fu_engine_generate_md_func); - g_test_add_func ("/fwupd/hwids", fu_hwids_func); - g_test_add_func ("/fwupd/smbios", fu_smbios_func); - g_test_add_func ("/fwupd/smbios3", fu_smbios3_func); + g_test_add_func ("/fwupd/engine{requirements-other-device}", fu_engine_requirements_other_device_func); + g_test_add_func ("/fwupd/plugin{composite}", fu_plugin_composite_func); g_test_add_func ("/fwupd/history", fu_history_func); g_test_add_func ("/fwupd/history{migrate}", fu_history_migrate_func); g_test_add_func ("/fwupd/plugin-list", fu_plugin_list_func); g_test_add_func ("/fwupd/plugin-list{depsolve}", fu_plugin_list_depsolve_func); - g_test_add_func ("/fwupd/plugin{delay}", fu_plugin_delay_func); - g_test_add_func ("/fwupd/plugin{module}", fu_plugin_module_func); - g_test_add_func ("/fwupd/plugin{quirks}", fu_plugin_quirks_func); - g_test_add_func ("/fwupd/plugin{quirks-performance}", fu_plugin_quirks_performance_func); - g_test_add_func ("/fwupd/plugin{quirks-device}", fu_plugin_quirks_device_func); - g_test_add_func ("/fwupd/plugin{composite}", fu_plugin_composite_func); g_test_add_func ("/fwupd/keyring{gpg}", fu_keyring_gpg_func); g_test_add_func ("/fwupd/keyring{pkcs7}", fu_keyring_pkcs7_func); g_test_add_func ("/fwupd/keyring{pkcs7-self-signed}", fu_keyring_pkcs7_self_signed_func); - g_test_add_func ("/fwupd/plugin{build-hash}", fu_plugin_hash_func); - g_test_add_func ("/fwupd/chunk", fu_chunk_func); - g_test_add_func ("/fwupd/common{string-append-kv}", fu_common_string_append_kv_func); - g_test_add_func ("/fwupd/common{version-guess-format}", fu_common_version_guess_format_func); - g_test_add_func ("/fwupd/common{version}", fu_common_version_func); - g_test_add_func ("/fwupd/common{vercmp}", fu_common_vercmp_func); - g_test_add_func ("/fwupd/common{strstrip}", fu_common_strstrip_func); - g_test_add_func ("/fwupd/common{endian}", fu_common_endian_func); - g_test_add_func ("/fwupd/common{cab-success}", fu_common_store_cab_func); - g_test_add_func ("/fwupd/common{cab-success-unsigned}", fu_common_store_cab_unsigned_func); - g_test_add_func ("/fwupd/common{cab-success-folder}", fu_common_store_cab_folder_func); - g_test_add_func ("/fwupd/common{cab-error-no-metadata}", fu_common_store_cab_error_no_metadata_func); - g_test_add_func ("/fwupd/common{cab-error-wrong-size}", fu_common_store_cab_error_wrong_size_func); - g_test_add_func ("/fwupd/common{cab-error-wrong-checksum}", fu_common_store_cab_error_wrong_checksum_func); - g_test_add_func ("/fwupd/common{cab-error-missing-file}", fu_common_store_cab_error_missing_file_func); - g_test_add_func ("/fwupd/common{cab-error-size}", fu_common_store_cab_error_size_func); - g_test_add_func ("/fwupd/common{spawn)", fu_common_spawn_func); - g_test_add_func ("/fwupd/common{spawn-timeout)", fu_common_spawn_timeout_func); - g_test_add_func ("/fwupd/common{firmware-builder}", fu_common_firmware_builder_func); return g_test_run (); } diff --git a/src/fu-tool.c b/src/fu-tool.c index 0d5a4d788..8028d13b3 100644 --- a/src/fu-tool.c +++ b/src/fu-tool.c @@ -25,7 +25,7 @@ #include "fu-history.h" #include "fu-plugin-private.h" #include "fu-progressbar.h" -#include "fu-smbios.h" +#include "fu-smbios-private.h" #include "fu-util-common.h" #include "fu-debug.h" #include "fwupd-common-private.h" diff --git a/src/meson.build b/src/meson.build index e59d29f82..f59722d3a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -6,36 +6,7 @@ endif keyring_deps = [] keyring_src = [] -test_deps = [] -libfwupdprivate_src = [ - 'fu-archive.c', - 'fu-chunk.c', - 'fu-common.c', - 'fu-common-cab.c', - 'fu-common-guid.c', - 'fu-common-version.c', - 'fu-device.c', - 'fu-device-locker.c', - 'fu-dfu-firmware.c', - 'fu-firmware.c', - 'fu-firmware-common.c', - 'fu-firmware-image.c', - 'fu-hwids.c', - 'fu-history.c', - 'fu-ihex-firmware.c', - 'fu-io-channel.c', - 'fu-plugin.c', - 'fu-progressbar.c', - 'fu-quirks.c', - 'fu-smbios.c', - 'fu-srec-firmware.c', - 'fu-test.c', - 'fu-usb-device.c', -] - -if get_option('gudev') - libfwupdprivate_src += 'fu-udev-device.c' -endif +systemd_src = [] if get_option('gpg') keyring_src += 'fu-keyring-gpg.c' @@ -46,54 +17,25 @@ endif if get_option('pkcs7') keyring_src += 'fu-keyring-pkcs7.c' keyring_deps += gnutls - if get_option('tests') - test_deps += colorhug_pkcs7_signature - endif endif if get_option('systemd') - libfwupdprivate_src += 'fu-systemd.c' + systemd_src += 'fu-systemd.c' endif -libfwupdprivate = static_library( - 'fwupdprivate', - sources : [ - libfwupdprivate_src, - ], - include_directories : [ - include_directories('..'), - include_directories('../libfwupd'), - ], - dependencies : [ - giounix, - gudev, - gusb, - libarchive, - libgcab, - libjsonglib, - libxmlb, - soup, - sqlite, - valgrind, - ], - link_with : [ - fwupd, - ], - c_args : [ - '-DFU_OFFLINE_DESTDIR=""', - ], -) - if build_daemon fwupdmgr = executable( 'fwupdmgr', sources : [ 'fu-util.c', + 'fu-history.c', 'fu-util-common.c', + systemd_src ], include_directories : [ - include_directories('..'), - include_directories('../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ libxmlb, @@ -107,7 +49,7 @@ fwupdmgr = executable( ], link_with : [ fwupd, - libfwupdprivate, + fwupdplugin, ], install : true, install_dir : bindir @@ -120,10 +62,12 @@ fwupdagent = executable( sources : [ 'fu-agent.c', 'fu-util-common.c', + systemd_src, ], include_directories : [ - include_directories('..'), - include_directories('../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ libxmlb, @@ -135,7 +79,7 @@ fwupdagent = executable( ], link_with : [ fwupd, - libfwupdprivate, + fwupdplugin, ], install : true, install_dir : join_paths(libexecdir, 'fwupd') @@ -143,15 +87,18 @@ fwupdagent = executable( endif if get_option('systemd') -fwupdagent = executable( +fwupdoffline = executable( 'fwupdoffline', sources : [ + 'fu-history.c', 'fu-offline.c', 'fu-util-common.c', + systemd_src ], include_directories : [ - include_directories('..'), - include_directories('../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ giounix, @@ -159,10 +106,11 @@ fwupdagent = executable( gusb, libxmlb, soup, + sqlite, ], link_with : [ fwupd, - libfwupdprivate, + fwupdplugin, ], install : true, install_dir : join_paths(libexecdir, 'fwupd') @@ -176,27 +124,19 @@ resources_src = gnome.compile_resources( c_name : 'fu' ) -fu_hash = custom_target( - 'fu-hash.h', - input : libfwupdprivate_src, - output : 'fu-hash.h', - command : [python3.path(), - join_paths(meson.current_source_dir(), 'fu-hash.py'), - '@OUTPUT@', '@INPUT@'] -) - fwupdtool = executable( 'fwupdtool', resources_src, fu_hash, + export_dynamic : true, sources : [ 'fu-tool.c', keyring_src, - libfwupdprivate_src, 'fu-config.c', 'fu-debug.c', 'fu-device-list.c', 'fu-engine.c', + 'fu-history.c', 'fu-idle.c', 'fu-install-task.c', 'fu-keyring.c', @@ -204,10 +144,12 @@ fwupdtool = executable( 'fu-keyring-utils.c', 'fu-plugin-list.c', 'fu-util-common.c', + systemd_src ], include_directories : [ - include_directories('..'), - include_directories('../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ keyring_deps, @@ -225,7 +167,7 @@ fwupdtool = executable( ], link_with : [ fwupd, - libfwupdprivate, + fwupdplugin ], install : true, install_dir : join_paths(libexecdir, 'fwupd') @@ -256,11 +198,11 @@ executable( fu_hash, sources : [ keyring_src, - libfwupdprivate_src, 'fu-config.c', 'fu-debug.c', 'fu-device-list.c', 'fu-engine.c', + 'fu-history.c', 'fu-idle.c', 'fu-install-task.c', 'fu-keyring.c', @@ -268,10 +210,12 @@ executable( 'fu-keyring-utils.c', 'fu-main.c', 'fu-plugin-list.c', + systemd_src ], include_directories : [ - include_directories('..'), - include_directories('../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ keyring_deps, @@ -288,7 +232,10 @@ executable( libarchive, libjsonglib, ], - link_with : fwupd, + link_with : [ + fwupd, + fwupdplugin + ], c_args : [ '-DFU_OFFLINE_DESTDIR=""', ], @@ -305,18 +252,14 @@ if get_option('tests') e = executable( 'fu-self-test', resources_src, - colorhug_test_firmware, - builder_test_firmware, - hwid_test_firmware, - noreqs_test_firmware, test_deps, fu_hash, sources : [ keyring_src, - libfwupdprivate_src, 'fu-config.c', 'fu-device-list.c', 'fu-engine.c', + 'fu-history.c', 'fu-idle.c', 'fu-install-task.c', 'fu-keyring.c', @@ -324,12 +267,12 @@ if get_option('tests') 'fu-keyring-utils.c', 'fu-plugin-list.c', 'fu-self-test.c', - 'fu-smbios.c', - 'fu-test.c', + systemd_src ], include_directories : [ - include_directories('..'), - include_directories('../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ keyring_deps, @@ -347,6 +290,7 @@ if get_option('tests') ], link_with : [ fwupd, + fwupdplugin ], c_args : [ '-DTESTDATADIR_SRC="' + testdatadir_src + '"', @@ -366,79 +310,21 @@ if get_option('tests') 'fu-firmware-dump.c', ], include_directories : [ - include_directories('..'), - include_directories('../libfwupd'), + root_incdir, + fwupd_incdir, + fwupdplugin_incdir, ], dependencies : [ gio, ], link_with : [ - libfwupdprivate, + fwupd, + fwupdplugin, ], c_args : cargs ) endif -if get_option('introspection') - gir_dep = declare_dependency(sources: gir) - gnome.generate_gir(fwupd, - sources : [ - 'fu-archive.c', - 'fu-archive.h', - 'fu-chunk.c', - 'fu-chunk.h', - 'fu-common.c', - 'fu-common-guid.c', - 'fu-common-guid.h', - 'fu-common-version.c', - 'fu-common-version.h', - 'fu-common.h', - 'fu-device.c', - 'fu-device.h', - 'fu-device-locker.c', - 'fu-device-locker.h', - 'fu-firmware.c', - 'fu-firmware.h', - 'fu-firmware-common.c', - 'fu-firmware-common.h', - 'fu-firmware-image.c', - 'fu-firmware-image.h', - 'fu-io-channel.c', - 'fu-plugin.c', - 'fu-plugin.h', - 'fu-quirks.c', - 'fu-quirks.h', - 'fu-udev-device.c', - 'fu-usb-device.c', - ], - nsversion : '1.0', - namespace : 'Fu', - symbol_prefix : 'fu', - identifier_prefix : 'Fu', - export_packages : 'fu', - include_directories : [ - include_directories('..'), - include_directories('../libfwupd'), - ], - dependencies : [ - libxmlb, - gir_dep, - giounix, - gusb, - soup, - sqlite, - ], - link_with : [ - libfwupdprivate, - ], - includes : [ - 'Gio-2.0', - 'GObject-2.0', - 'GUsb-1.0', - ], - ) -endif - if get_option('tests') subdir('fuzzing') endif From 11503c23ee7bb4735ca46a879a0607cb7809f6a5 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Sun, 24 Nov 2019 14:02:29 -0600 Subject: [PATCH 53/74] Install development files for libfwupdplugin This splits out all development files, including headers into their own packages where relevant. Notably absent is `fu-hash.h` which is used for determining taint. Out of tree developed plugins should still taint the daemon. --- contrib/debian/control.in | 28 ++++++++++++++++ contrib/debian/gir1.2-fwupd-2.0.install | 2 +- contrib/debian/gir1.2-fwupdplugin-1.0.install | 1 + contrib/debian/libfwupd-dev.install | 12 ++++--- contrib/debian/libfwupdplugin-dev.install | 7 ++++ contrib/debian/rules | 3 ++ contrib/fwupd.spec.in | 3 ++ libfwupdplugin/fu-deprecated.h | 13 ++++++++ libfwupdplugin/meson.build | 33 +++++++++++++++++-- 9 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 contrib/debian/gir1.2-fwupdplugin-1.0.install create mode 100644 contrib/debian/libfwupdplugin-dev.install create mode 100644 libfwupdplugin/fu-deprecated.h diff --git a/contrib/debian/control.in b/contrib/debian/control.in index 75de509a1..c45a3d9b0 100644 --- a/contrib/debian/control.in +++ b/contrib/debian/control.in @@ -140,6 +140,34 @@ Description: GObject introspection data for libfwupd It can be used by packages using the GIRepository format to generate dynamic bindings. +Package: libfwupdplugin-dev +Architecture: linux-any +Multi-Arch: same +Depends: libfwupd2 (= ${binary:Version}), + gir1.2-fwupdplugin-1.0 (= ${binary:Version}), + ${misc:Depends} +Section: libdevel +Description: development files for libfwupdplugin + fwupd is a daemon to allow session software to update device firmware. + You can either use a GUI software manager like GNOME Software to view and + apply updates, the command-line tool or the system D-Bus interface directly. + Firmware updates are supported for a variety of technologies. + See for details + . + This package provides the development files for libfwupdplugin + +Package: gir1.2-fwupdplugin-1.0 +Architecture: linux-any +Multi-Arch: same +Depends: ${misc:Depends}, + ${gir:Depends} +Section: introspection +Description: GObject introspection data for libfwupdplugin + This package provides the introspection data for libfwupdplugin. + . + It can be used by packages using the GIRepository format to generate + dynamic bindings. + Package: fwupd-amd64-signed-template Architecture: amd64 Depends: ${shlibs:Depends}, ${misc:Depends}, make | build-essential | dpkg-dev diff --git a/contrib/debian/gir1.2-fwupd-2.0.install b/contrib/debian/gir1.2-fwupd-2.0.install index eee37f27b..341e84900 100644 --- a/contrib/debian/gir1.2-fwupd-2.0.install +++ b/contrib/debian/gir1.2-fwupd-2.0.install @@ -1 +1 @@ -usr/lib/*/girepository-1.0/*.typelib +usr/lib/*/girepository-1.0/Fwupd-*.typelib diff --git a/contrib/debian/gir1.2-fwupdplugin-1.0.install b/contrib/debian/gir1.2-fwupdplugin-1.0.install new file mode 100644 index 000000000..009c462fd --- /dev/null +++ b/contrib/debian/gir1.2-fwupdplugin-1.0.install @@ -0,0 +1 @@ +usr/lib/*/girepository-1.0/FwupdPlugin-*.typelib diff --git a/contrib/debian/libfwupd-dev.install b/contrib/debian/libfwupd-dev.install index 8691785f0..97661f753 100644 --- a/contrib/debian/libfwupd-dev.install +++ b/contrib/debian/libfwupd-dev.install @@ -1,5 +1,7 @@ -usr/include/* -usr/lib/*/*.so -usr/lib/*/pkgconfig/*.pc -usr/share/gir-1.0/*.gir -usr/share/vala/vapi +usr/include/fwupd-1/fwupd.h +usr/include/fwupd-1/libfwupd +usr/lib/*/libfwupd.so +usr/lib/*/pkgconfig/fwupd.pc +usr/share/gir-1.0/Fwupd-*.gir +usr/share/vala/vapi/fwupd.deps +usr/share/vala/vapi/fwupd.vapi diff --git a/contrib/debian/libfwupdplugin-dev.install b/contrib/debian/libfwupdplugin-dev.install new file mode 100644 index 000000000..5732c5110 --- /dev/null +++ b/contrib/debian/libfwupdplugin-dev.install @@ -0,0 +1,7 @@ +usr/include/fwupd-1/fwupdplugin.h +usr/include/fwupd-1/libfwupdplugin +usr/lib/*/libfwupdplugin.so +usr/lib/*/pkgconfig/fwupdplugin.pc +usr/share/gir-1.0/FwupdPlugin-*.gir +usr/share/vala/vapi/fwupdplugin.deps +usr/share/vala/vapi/fwupdplugin.vapi diff --git a/contrib/debian/rules b/contrib/debian/rules index 3b070babd..2075804e9 100755 --- a/contrib/debian/rules +++ b/contrib/debian/rules @@ -66,6 +66,9 @@ override_dh_install: if [ ! -z "$$CI" ] && [ -f debian/tmp/usr/sbin/flashrom ]; then \ dh_install -pfwupd usr/sbin/flashrom ;\ dh_install -plibfwupd2 usr/lib/*/libflashrom.so.*; \ + dh_install -plibfwupd-dev usr/include/libflashrom.h; \ + dh_install -plibfwupd-dev usr/lib/*/libflashrom.so; \ + dh_install -plibfwupd-dev usr/lib/*/pkgconfig/flashrom.pc; \ fi dh_missing -a --fail-missing diff --git a/contrib/fwupd.spec.in b/contrib/fwupd.spec.in index 60f9c6770..e8d7b895e 100644 --- a/contrib/fwupd.spec.in +++ b/contrib/fwupd.spec.in @@ -299,6 +299,7 @@ rm ${RPM_BUILD_ROOT}%{_sbindir}/flashrom %{_localstatedir}/lib/fwupd/builder/README.md %{_libdir}/libfwupd*.so.* %{_libdir}/girepository-1.0/Fwupd-2.0.typelib +%{_libdir}/girepository-1.0/FwupdPlugin-1.0.typelib /usr/lib/udev/rules.d/*.rules /usr/lib/systemd/system-shutdown/fwupd.shutdown %dir %{_libdir}/fwupd-plugins-3 @@ -370,11 +371,13 @@ rm ${RPM_BUILD_ROOT}%{_sbindir}/flashrom %files devel %{_datadir}/gir-1.0/Fwupd-2.0.gir +%{_datadir}/gir-1.0/FwupdPlugin-1.0.gir %{_datadir}/gtk-doc/html/fwupd %{_datadir}/vala/vapi %{_includedir}/fwupd-1 %{_libdir}/libfwupd*.so %{_libdir}/pkgconfig/fwupd.pc +%{_libdir}/pkgconfig/fwupdplugin.pc %files tests %dir %{_datadir}/installed-tests/fwupd diff --git a/libfwupdplugin/fu-deprecated.h b/libfwupdplugin/fu-deprecated.h new file mode 100644 index 000000000..a3671517a --- /dev/null +++ b/libfwupdplugin/fu-deprecated.h @@ -0,0 +1,13 @@ +/* + * Copyright (C) 2017 Richard Hughes + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#pragma once + +G_BEGIN_DECLS + +/* indeed, nothing */ + +G_END_DECLS diff --git a/libfwupdplugin/meson.build b/libfwupdplugin/meson.build index c697a469e..db5ff2f86 100644 --- a/libfwupdplugin/meson.build +++ b/libfwupdplugin/meson.build @@ -50,6 +50,13 @@ fwupdplugin_headers = [ 'fu-udev-device.h', 'fu-usb-device.h', ] +install_headers( + 'fwupdplugin.h', + subdir : 'fwupd-1', +) +install_headers([fwupdplugin_headers, 'fu-plugin-vfuncs.h'], + subdir : 'fwupd-1/libfwupdplugin', +) fu_hash = custom_target( 'fu-hash.h', @@ -85,7 +92,6 @@ library_deps = [ libarchive, libjsonglib, libgcab, - sqlite, valgrind, ] @@ -114,6 +120,27 @@ fwupdplugin = shared_library( install : true ) +fwupdplugin_pkgg = import('pkgconfig') +fwupdplugin_pkgg.generate( + libraries : fwupdplugin, + requires : [ 'gio-2.0', + 'gmodule-2.0', + 'gobject-2.0', + 'gusb', + 'fwupd', + 'json-glib-1.0', + 'libarchive', + 'libgcab-1.0', + 'libsoup-2.4', + 'xmlb', + ], + subdirs : 'fwupd-1', + version : meson.project_version(), + name : 'fwupdplugin', + filebase : 'fwupdplugin', + description : 'library for plugins to use to interact with fwupd daemon', +) + if get_option('introspection') gir_dep = declare_dependency(sources: gir) gir = gnome.generate_gir(fwupd, @@ -142,12 +169,12 @@ if get_option('introspection') 'GObject-2.0', 'GUsb-1.0', ], - install : false + install : true ) gnome.generate_vapi('fwupdplugin', sources : gir[0], packages : ['gio-2.0'], - install : false, + install : true, ) # Verify the map file is correct -- note we can't actually use the generated From aed7826c8f77b0e7f24fa6006ac20f742740a67d Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 11:19:05 +0000 Subject: [PATCH 54/74] trivial: Properly namespace the defines in the exported header --- libfwupdplugin/fu-usb-device.h | 12 +++++------ plugins/csr/fu-csr-device.c | 20 +++++++++---------- plugins/dell-dock/fu-dell-dock-hid.c | 4 ++-- .../fu-logitech-hidpp-bootloader.c | 2 +- plugins/rts54hid/fu-rts54hid-common.h | 2 +- plugins/rts54hid/fu-rts54hid-device.c | 16 +++++++-------- plugins/rts54hid/fu-rts54hid-module.c | 4 ++-- .../fu-synaptics-cxaudio-device.c | 8 ++++---- plugins/wacom-usb/fu-wac-device.c | 8 ++++---- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/libfwupdplugin/fu-usb-device.h b/libfwupdplugin/fu-usb-device.h index a5a738afe..6f3dc09ef 100644 --- a/libfwupdplugin/fu-usb-device.h +++ b/libfwupdplugin/fu-usb-device.h @@ -16,14 +16,14 @@ G_DECLARE_DERIVABLE_TYPE (FuUsbDevice, fu_usb_device, FU, USB_DEVICE, FuDevice) /* HID */ -#define HID_REPORT_GET 0x01 -#define HID_REPORT_SET 0x09 +#define FU_HID_REPORT_GET 0x01 +#define FU_HID_REPORT_SET 0x09 -#define HID_REPORT_TYPE_INPUT 0x01 -#define HID_REPORT_TYPE_OUTPUT 0x02 -#define HID_REPORT_TYPE_FEATURE 0x03 +#define FU_HID_REPORT_TYPE_INPUT 0x01 +#define FU_HID_REPORT_TYPE_OUTPUT 0x02 +#define FU_HID_REPORT_TYPE_FEATURE 0x03 -#define HID_FEATURE 0x0300 +#define FU_HID_FEATURE 0x0300 struct _FuUsbDeviceClass { diff --git a/plugins/csr/fu-csr-device.c b/plugins/csr/fu-csr-device.c index 4d9ac5cbf..ea76a062f 100644 --- a/plugins/csr/fu-csr-device.c +++ b/plugins/csr/fu-csr-device.c @@ -80,8 +80,8 @@ fu_csr_device_attach (FuDevice *device, GError **error) G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_SET, /* bRequest */ - HID_FEATURE | FU_CSR_REPORT_ID_CONTROL, /* wValue */ + FU_HID_REPORT_SET, /* bRequest */ + FU_HID_FEATURE | FU_CSR_REPORT_ID_CONTROL, /* wValue */ 0x0000, /* wIndex */ buf, sizeof(buf), &sz, FU_CSR_DEVICE_TIMEOUT, /* timeout */ @@ -115,8 +115,8 @@ fu_csr_device_get_status (FuCsrDevice *self, GError **error) G_USB_DEVICE_DIRECTION_DEVICE_TO_HOST, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_GET, /* bRequest */ - HID_FEATURE | FU_CSR_REPORT_ID_STATUS, /* wValue */ + FU_HID_REPORT_GET, /* bRequest */ + FU_HID_FEATURE | FU_CSR_REPORT_ID_STATUS, /* wValue */ 0x0000, /* wIndex */ buf, sizeof(buf), &sz, FU_CSR_DEVICE_TIMEOUT, @@ -175,8 +175,8 @@ fu_csr_device_clear_status (FuCsrDevice *self, GError **error) G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_SET, /* bRequest */ - HID_FEATURE | FU_CSR_REPORT_ID_CONTROL, /* wValue */ + FU_HID_REPORT_SET, /* bRequest */ + FU_HID_FEATURE | FU_CSR_REPORT_ID_CONTROL, /* wValue */ 0x0000, /* wIndex */ buf, sizeof(buf), &sz, FU_CSR_DEVICE_TIMEOUT, @@ -212,8 +212,8 @@ fu_csr_device_upload_chunk (FuCsrDevice *self, GError **error) G_USB_DEVICE_DIRECTION_DEVICE_TO_HOST, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_GET, /* bRequest */ - HID_FEATURE | FU_CSR_REPORT_ID_COMMAND, /* wValue */ + FU_HID_REPORT_GET, /* bRequest */ + FU_HID_FEATURE | FU_CSR_REPORT_ID_COMMAND, /* wValue */ 0x0000, /* wIndex */ buf, sizeof(buf), &sz, FU_CSR_DEVICE_TIMEOUT, @@ -365,8 +365,8 @@ fu_csr_device_download_chunk (FuCsrDevice *self, guint16 idx, GBytes *chunk, GEr G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_SET, /* bRequest */ - HID_FEATURE | FU_CSR_REPORT_ID_COMMAND, /* wValue */ + FU_HID_REPORT_SET, /* bRequest */ + FU_HID_FEATURE | FU_CSR_REPORT_ID_COMMAND, /* wValue */ 0x0000, /* wIndex */ buf, sizeof(buf), diff --git a/plugins/dell-dock/fu-dell-dock-hid.c b/plugins/dell-dock/fu-dell-dock-hid.c index 214069b9f..267b3725d 100644 --- a/plugins/dell-dock/fu-dell-dock-hid.c +++ b/plugins/dell-dock/fu-dell-dock-hid.c @@ -89,7 +89,7 @@ fu_dell_dock_hid_set_report (FuDevice *self, ret = g_usb_device_control_transfer ( usb_device, G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE, G_USB_DEVICE_REQUEST_TYPE_CLASS, - G_USB_DEVICE_RECIPIENT_INTERFACE, HID_REPORT_SET, 0x0200, + G_USB_DEVICE_RECIPIENT_INTERFACE, FU_HID_REPORT_SET, 0x0200, 0x0000, outbuffer, 192, &actual_len, HIDI2C_TRANSACTION_TIMEOUT, NULL, &error_local); if (ret) @@ -129,7 +129,7 @@ fu_dell_dock_hid_get_report (FuDevice *self, ret = g_usb_device_control_transfer ( usb_device, G_USB_DEVICE_DIRECTION_DEVICE_TO_HOST, G_USB_DEVICE_REQUEST_TYPE_CLASS, - G_USB_DEVICE_RECIPIENT_INTERFACE, HID_REPORT_GET, 0x0100, + G_USB_DEVICE_RECIPIENT_INTERFACE, FU_HID_REPORT_GET, 0x0100, 0x0000, inbuffer, 192, &actual_len, HIDI2C_TRANSACTION_TIMEOUT, NULL, &error_local); if (ret) diff --git a/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.c b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.c index 11a33bcf7..1fed336fe 100644 --- a/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.c +++ b/plugins/logitech-hidpp/fu-logitech-hidpp-bootloader.c @@ -346,7 +346,7 @@ fu_logitech_hidpp_bootloader_request (FuLogitechHidPpBootloader *self, G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_SET, + FU_HID_REPORT_SET, 0x0200, 0x0000, buf_request, sizeof (buf_request), diff --git a/plugins/rts54hid/fu-rts54hid-common.h b/plugins/rts54hid/fu-rts54hid-common.h index 069b0c301..d62e7d26a 100644 --- a/plugins/rts54hid/fu-rts54hid-common.h +++ b/plugins/rts54hid/fu-rts54hid-common.h @@ -9,7 +9,7 @@ #pragma once #define FU_RTS54HID_TRANSFER_BLOCK_SIZE 0x80 -#define FU_RTS54HID_REPORT_LENGTH 0xc0 +#define FU_RTS54FU_HID_REPORT_LENGTH 0xc0 /* [vendor-cmd:64] [data-payload:128] */ #define FU_RTS54HID_CMD_BUFFER_OFFSET_DATA 0x40 diff --git a/plugins/rts54hid/fu-rts54hid-device.c b/plugins/rts54hid/fu-rts54hid-device.c index 118bc7535..42563514b 100644 --- a/plugins/rts54hid/fu-rts54hid-device.c +++ b/plugins/rts54hid/fu-rts54hid-device.c @@ -41,7 +41,7 @@ fu_rts54hid_device_set_report (FuRts54HidDevice *self, G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_SET, + FU_HID_REPORT_SET, 0x0200, 0x0000, buf, buf_sz, &actual_len, @@ -69,7 +69,7 @@ fu_rts54hid_device_get_report (FuRts54HidDevice *self, G_USB_DEVICE_DIRECTION_DEVICE_TO_HOST, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_GET, + FU_HID_REPORT_GET, 0x0100, 0x0000, buf, buf_sz, &actual_len, /* actual length */ @@ -99,7 +99,7 @@ fu_rts54hid_device_set_clock_mode (FuRts54HidDevice *self, gboolean enable, GErr .bufferlen = 0, .parameters = 0, }; - guint8 buf[FU_RTS54HID_REPORT_LENGTH] = { 0 }; + guint8 buf[FU_RTS54FU_HID_REPORT_LENGTH] = { 0 }; memcpy (buf, &cmd_buffer, sizeof(cmd_buffer)); if (!fu_rts54hid_device_set_report (self, buf, sizeof(buf), error)) { g_prefix_error (error, "failed to set clock-mode=%i: ", enable); @@ -118,7 +118,7 @@ fu_rts54hid_device_reset_to_flash (FuRts54HidDevice *self, GError **error) .bufferlen = 0, .parameters = 0, }; - guint8 buf[FU_RTS54HID_REPORT_LENGTH] = { 0 }; + guint8 buf[FU_RTS54FU_HID_REPORT_LENGTH] = { 0 }; memcpy (buf, &cmd_buffer, sizeof(cmd_buffer)); if (!fu_rts54hid_device_set_report (self, buf, sizeof(buf), error)) { g_prefix_error (error, "failed to soft reset: "); @@ -141,7 +141,7 @@ fu_rts54hid_device_write_flash (FuRts54HidDevice *self, .bufferlen = GUINT16_TO_LE (data_sz), .parameters = 0, }; - guint8 buf[FU_RTS54HID_REPORT_LENGTH] = { 0 }; + guint8 buf[FU_RTS54FU_HID_REPORT_LENGTH] = { 0 }; g_return_val_if_fail (data_sz <= 128, FALSE); g_return_val_if_fail (data != NULL, FALSE); @@ -172,7 +172,7 @@ fu_rts54hid_device_verify_update_fw (FuRts54HidDevice *self, GError **error) .bufferlen = GUINT16_TO_LE (1), .parameters = 0, }; - guint8 buf[FU_RTS54HID_REPORT_LENGTH] = { 0 }; + guint8 buf[FU_RTS54FU_HID_REPORT_LENGTH] = { 0 }; /* set then get */ memcpy (buf, &cmd_buffer, sizeof(cmd_buffer)); @@ -208,7 +208,7 @@ fu_rts54hid_device_erase_spare_bank (FuRts54HidDevice *self, GError **error) .bufferlen = 0, .parameters = 0, }; - guint8 buf[FU_RTS54HID_REPORT_LENGTH] = { 0 }; + guint8 buf[FU_RTS54FU_HID_REPORT_LENGTH] = { 0 }; memcpy (buf, &cmd_buffer, sizeof(cmd_buffer)); if (!fu_rts54hid_device_set_report (self, buf, sizeof(buf), error)) { g_prefix_error (error, "failed to erase spare bank: "); @@ -230,7 +230,7 @@ fu_rts54hid_device_ensure_status (FuRts54HidDevice *self, GError **error) .bufferlen = GUINT16_TO_LE (32), .parameters = 0, }; - guint8 buf[FU_RTS54HID_REPORT_LENGTH] = { 0 }; + guint8 buf[FU_RTS54FU_HID_REPORT_LENGTH] = { 0 }; g_autofree gchar *version = NULL; /* set then get */ diff --git a/plugins/rts54hid/fu-rts54hid-module.c b/plugins/rts54hid/fu-rts54hid-module.c index 6d8606ac5..c761e7b09 100644 --- a/plugins/rts54hid/fu-rts54hid-module.c +++ b/plugins/rts54hid/fu-rts54hid-module.c @@ -61,7 +61,7 @@ fu_rts54hid_module_i2c_write (FuRts54HidModule *self, .data_sz = self->register_addr_len, .speed = self->i2c_speed | 0x80}, }; - guint8 buf[FU_RTS54HID_REPORT_LENGTH] = { 0 }; + guint8 buf[FU_RTS54FU_HID_REPORT_LENGTH] = { 0 }; g_return_val_if_fail (data_sz <= 128, FALSE); g_return_val_if_fail (data != NULL, FALSE); @@ -101,7 +101,7 @@ fu_rts54hid_module_i2c_read (FuRts54HidModule *self, .data_sz = self->register_addr_len, .speed = self->i2c_speed | 0x80}, }; - guint8 buf[FU_RTS54HID_REPORT_LENGTH] = { 0 }; + guint8 buf[FU_RTS54FU_HID_REPORT_LENGTH] = { 0 }; g_return_val_if_fail (data_sz <= 192, FALSE); g_return_val_if_fail (data != NULL, FALSE); diff --git a/plugins/synaptics-cxaudio/fu-synaptics-cxaudio-device.c b/plugins/synaptics-cxaudio/fu-synaptics-cxaudio-device.c index 7b2839e5b..9823fc97c 100644 --- a/plugins/synaptics-cxaudio/fu-synaptics-cxaudio-device.c +++ b/plugins/synaptics-cxaudio/fu-synaptics-cxaudio-device.c @@ -94,8 +94,8 @@ fu_synaptics_cxaudio_device_output_report (FuSynapticsCxaudioDevice *self, G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_SET, - (HID_REPORT_TYPE_OUTPUT << 8) | report_number, + FU_HID_REPORT_SET, + (FU_HID_REPORT_TYPE_OUTPUT << 8) | report_number, FU_SYNAPTICS_CXAUDIO_HID_INTERFACE, buf, bufsz, &actual_length, FU_SYNAPTICS_CXAUDIO_USB_TIMEOUT, NULL, error)) { @@ -132,8 +132,8 @@ fu_synaptics_cxaudio_device_input_report (FuSynapticsCxaudioDevice *self, G_USB_DEVICE_DIRECTION_DEVICE_TO_HOST, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_GET, - (HID_REPORT_TYPE_INPUT << 8) | ReportID, + FU_HID_REPORT_GET, + (FU_HID_REPORT_TYPE_INPUT << 8) | ReportID, FU_SYNAPTICS_CXAUDIO_HID_INTERFACE, buf, bufsz, &actual_length, FU_SYNAPTICS_CXAUDIO_USB_TIMEOUT, NULL, error)) { diff --git a/plugins/wacom-usb/fu-wac-device.c b/plugins/wacom-usb/fu-wac-device.c index 29ad61bfd..50b6e6fc6 100644 --- a/plugins/wacom-usb/fu-wac-device.c +++ b/plugins/wacom-usb/fu-wac-device.c @@ -149,8 +149,8 @@ fu_wac_device_get_feature_report (FuWacDevice *self, G_USB_DEVICE_DIRECTION_DEVICE_TO_HOST, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_GET, /* bRequest */ - HID_FEATURE | cmd, /* wValue */ + FU_HID_REPORT_GET, /* bRequest */ + FU_HID_FEATURE | cmd, /* wValue */ 0x0000, /* wIndex */ buf, bufsz, &sz, FU_WAC_DEVICE_TIMEOUT, @@ -200,8 +200,8 @@ fu_wac_device_set_feature_report (FuWacDevice *self, G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE, G_USB_DEVICE_REQUEST_TYPE_CLASS, G_USB_DEVICE_RECIPIENT_INTERFACE, - HID_REPORT_SET, /* bRequest */ - HID_FEATURE | cmd, /* wValue */ + FU_HID_REPORT_SET, /* bRequest */ + FU_HID_FEATURE | cmd, /* wValue */ 0x0000, /* wIndex */ buf, bufsz, &sz, FU_WAC_DEVICE_TIMEOUT, From 6a710c3c239ffa85308839d72a30b68b562d0f53 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 11:39:52 +0000 Subject: [PATCH 55/74] trivial: Never add duplicate symbols to the map file --- contrib/generate-version-script.py | 3 ++- libfwupdplugin/fwupdplugin.map | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/generate-version-script.py b/contrib/generate-version-script.py index bd3bf3b0a..408199f3f 100755 --- a/contrib/generate-version-script.py +++ b/contrib/generate-version-script.py @@ -38,7 +38,8 @@ class LdVersionScript: if version not in self.releases: self.releases[version] = [] release = self.releases[version] - release.append(identifier) + if identifier not in release: + release.append(identifier) return version def _add_cls(self, cls): diff --git a/libfwupdplugin/fwupdplugin.map b/libfwupdplugin/fwupdplugin.map index aa54114c1..f5c74209f 100644 --- a/libfwupdplugin/fwupdplugin.map +++ b/libfwupdplugin/fwupdplugin.map @@ -159,7 +159,6 @@ LIBFWUPDPLUGIN_1.0.0 { LIBFWUPDPLUGIN_1.0.1 { global: - fu_chunk_array_to_string; fu_chunk_array_to_string; fu_plugin_get_quirks; fu_plugin_lookup_quirk_by_id; From 3ee52ca4dd8c57090bac0707d907953e77bc2f1f Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 11:40:49 +0000 Subject: [PATCH 56/74] trivial: Include the Fwupd GIR in the FwupdPLugin GIR --- libfwupd/meson.build | 6 +++--- libfwupdplugin/meson.build | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libfwupd/meson.build b/libfwupd/meson.build index 0fca3a19d..bc871b2a1 100644 --- a/libfwupd/meson.build +++ b/libfwupd/meson.build @@ -69,7 +69,7 @@ pkgg.generate( ) if get_option('introspection') - gir = gnome.generate_gir(fwupd, + fwupd_gir = gnome.generate_gir(fwupd, sources : [ 'fwupd-client.c', 'fwupd-client.h', @@ -110,7 +110,7 @@ if get_option('introspection') ) gnome.generate_vapi('fwupd', - sources : gir[0], + sources : fwupd_gir[0], packages : ['gio-2.0', 'libsoup-2.4'], install : true, ) @@ -124,7 +124,7 @@ if get_option('introspection') # To avoid the circular dep, and to ensure we don't change exported API # accidentally actually check in a version of the version script to git. mapfile_target = custom_target('fwupd_mapfile', - input: gir[0], + input: fwupd_gir[0], output: 'fwupd.map', command: [ join_paths(meson.source_root(), 'contrib', 'generate-version-script.py'), diff --git a/libfwupdplugin/meson.build b/libfwupdplugin/meson.build index db5ff2f86..837b5a2d0 100644 --- a/libfwupdplugin/meson.build +++ b/libfwupdplugin/meson.build @@ -142,8 +142,8 @@ fwupdplugin_pkgg.generate( ) if get_option('introspection') - gir_dep = declare_dependency(sources: gir) - gir = gnome.generate_gir(fwupd, + gir_dep = declare_dependency(sources: fwupd_gir) + fwupdplugin_gir = gnome.generate_gir(fwupd, sources : [ fwupdplugin_src, fwupdplugin_headers, @@ -168,11 +168,12 @@ if get_option('introspection') 'Gio-2.0', 'GObject-2.0', 'GUsb-1.0', + fwupd_gir[0], ], install : true ) gnome.generate_vapi('fwupdplugin', - sources : gir[0], + sources : fwupd_gir[0], packages : ['gio-2.0'], install : true, ) @@ -186,7 +187,7 @@ if get_option('introspection') # To avoid the circular dep, and to ensure we don't change exported API # accidentally actually check in a version of the version script to git. fwupdplugin_mapfile_target = custom_target('fwupdplugin_mapfile', - input: gir[0], + input: fwupdplugin_gir[0], output: 'fwupdplugin.map', command: [ join_paths(meson.source_root(), 'contrib', 'generate-version-script.py'), From a0d81c726f3b88fcc33a3e53453fa498576345e9 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 11:41:54 +0000 Subject: [PATCH 57/74] trivial: Fix up a few introspection problems in FwupdPlugin --- libfwupdplugin/fu-chunk.c | 4 ++-- libfwupdplugin/fu-common.c | 4 ++-- libfwupdplugin/fu-device.c | 2 +- libfwupdplugin/fu-hwids.c | 2 +- libfwupdplugin/fu-io-channel.c | 2 +- libfwupdplugin/fu-plugin.c | 6 +++--- libfwupdplugin/fu-quirks.h | 2 +- libfwupdplugin/fu-usb-device.c | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libfwupdplugin/fu-chunk.c b/libfwupdplugin/fu-chunk.c index ebc453ba0..a4b39a6d9 100644 --- a/libfwupdplugin/fu-chunk.c +++ b/libfwupdplugin/fu-chunk.c @@ -114,7 +114,7 @@ fu_chunk_array_to_string (GPtrArray *chunks) * Chunks a linear blob of memory into packets, ensuring each packet does not * cross a package boundary and is less that a specific transfer size. * - * Return value: (element-type FuChunk): array of packets + * Return value: (transfer container) (element-type FuChunk): array of packets * * Since: 1.1.2 **/ @@ -197,7 +197,7 @@ fu_chunk_array_new (const guint8 *data, * Chunks a linear blob of memory into packets, ensuring each packet does not * cross a package boundary and is less that a specific transfer size. * - * Return value: (element-type FuChunk): array of packets + * Return value: (transfer container) (element-type FuChunk): array of packets * * Since: 1.1.2 **/ diff --git a/libfwupdplugin/fu-common.c b/libfwupdplugin/fu-common.c index d80834423..7ad33f8be 100644 --- a/libfwupdplugin/fu-common.c +++ b/libfwupdplugin/fu-common.c @@ -121,7 +121,7 @@ fu_common_get_file_list_internal (GPtrArray *files, const gchar *directory, GErr * If any path under @directory cannot be accessed due to permissions an error * will be returned. * - * Returns: (transfer container): array of files, or %NULL for error + * Returns: (transfer container) (element-type utf8): array of files, or %NULL for error * * Since: 1.0.6 **/ @@ -1671,7 +1671,7 @@ fu_common_fnmatch (const gchar *pattern, const gchar *str) * delimiter. If @max_tokens is reached, the remainder of string is appended * to the last token. * - * Return value: a newly-allocated NULL-terminated array of strings + * Return value: (transfer full): a newly-allocated NULL-terminated array of strings * * Since: 1.3.1 **/ diff --git a/libfwupdplugin/fu-device.c b/libfwupdplugin/fu-device.c index 6f507a2f6..8dd90733a 100644 --- a/libfwupdplugin/fu-device.c +++ b/libfwupdplugin/fu-device.c @@ -150,7 +150,7 @@ fu_device_set_property (GObject *object, guint prop_id, * * Gets the list of possible plugin names, typically added from quirk files. * - * Returns: (element-type utf-8) (transfer container): plugin names + * Returns: (element-type utf8) (transfer container): plugin names * * Since: 1.3.3 **/ diff --git a/libfwupdplugin/fu-hwids.c b/libfwupdplugin/fu-hwids.c index f587620d1..11fb1c088 100644 --- a/libfwupdplugin/fu-hwids.c +++ b/libfwupdplugin/fu-hwids.c @@ -68,7 +68,7 @@ fu_hwids_has_guid (FuHwids *self, const gchar *guid) * * Returns all the defined HWIDs * - * Returns: (transfer none) (element-type utf-8): An array of GUIDs + * Returns: (transfer none) (element-type utf8): An array of GUIDs * * Since: 0.9.3 **/ diff --git a/libfwupdplugin/fu-io-channel.c b/libfwupdplugin/fu-io-channel.c index f69fd1955..cdaa08be8 100644 --- a/libfwupdplugin/fu-io-channel.c +++ b/libfwupdplugin/fu-io-channel.c @@ -271,7 +271,7 @@ fu_io_channel_read_bytes (FuIOChannel *self, * * Reads bytes from the TTY, that will fail if exceeding @timeout_ms. * - * Returns: a #GByteArray, or %NULL for error + * Returns: (transfer full): a #GByteArray, or %NULL for error * * Since: 1.3.2 **/ diff --git a/libfwupdplugin/fu-plugin.c b/libfwupdplugin/fu-plugin.c index 919693fd1..ab84bae73 100644 --- a/libfwupdplugin/fu-plugin.c +++ b/libfwupdplugin/fu-plugin.c @@ -763,7 +763,7 @@ fu_plugin_set_hwids (FuPlugin *self, FuHwids *hwids) /** * fu_plugin_set_udev_subsystems: * @self: A #FuPlugin - * @udev_subsystems: A #GPtrArray + * @udev_subsystems: (element-type utf8): A #GPtrArray * * Sets the udev subsystems used by a plugin * @@ -1440,7 +1440,7 @@ fu_plugin_runner_coldplug_cleanup (FuPlugin *self, GError **error) /** * fu_plugin_runner_composite_prepare: * @self: a #FuPlugin - * @devices: a #GPtrArray of devices + * @devices: (element-type FuDevice): a #GPtrArray of devices * @error: a #GError or NULL * * Runs the composite_prepare routine for the plugin @@ -1460,7 +1460,7 @@ fu_plugin_runner_composite_prepare (FuPlugin *self, GPtrArray *devices, GError * /** * fu_plugin_runner_composite_cleanup: * @self: a #FuPlugin - * @devices: a #GPtrArray of devices + * @devices: (element-type FuDevice): a #GPtrArray of devices * @error: a #GError or NULL * * Runs the composite_cleanup routine for the plugin diff --git a/libfwupdplugin/fu-quirks.h b/libfwupdplugin/fu-quirks.h index 40c01d297..db985ffbc 100644 --- a/libfwupdplugin/fu-quirks.h +++ b/libfwupdplugin/fu-quirks.h @@ -40,7 +40,7 @@ const gchar *fu_quirks_lookup_by_id (FuQuirks *self, const gchar *key); gboolean fu_quirks_lookup_by_id_iter (FuQuirks *self, const gchar *group, - FuQuirksIter iter, + FuQuirksIter iter_cb, gpointer user_data); #define FU_QUIRKS_PLUGIN "Plugin" diff --git a/libfwupdplugin/fu-usb-device.c b/libfwupdplugin/fu-usb-device.c index 3bce0015d..56eb15f8d 100644 --- a/libfwupdplugin/fu-usb-device.c +++ b/libfwupdplugin/fu-usb-device.c @@ -430,11 +430,11 @@ fu_usb_device_set_dev (FuUsbDevice *device, GUsbDevice *usb_device) /** * fu_usb_device_find_udev_device: * @device: A #FuUsbDevice - * @usb_device: A #GUsbDevice, or %NULL + * @error: A #GError, or %NULL * * Gets the matching #GUdevDevice for the #GUsbDevice. * - * Returns: a #GUdevDevice, or NULL if unset or invalid + * Returns: (transfer full): a #GUdevDevice, or NULL if unset or invalid * * Since: 1.3.2 **/ From 00f66f659d4bd6aa480e95b078181451b7746156 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 11:42:53 +0000 Subject: [PATCH 58/74] trivial: Do not include non-introspectable functions in the GIR If we do need these for managed languages, we can of course create boxed types when requried. --- libfwupdplugin/fu-chunk.c | 6 +++--- libfwupdplugin/fu-common-cab.c | 2 +- libfwupdplugin/fu-device.c | 2 +- libfwupdplugin/fu-plugin.c | 2 +- libfwupdplugin/fu-srec-firmware.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libfwupdplugin/fu-chunk.c b/libfwupdplugin/fu-chunk.c index a4b39a6d9..d92a66403 100644 --- a/libfwupdplugin/fu-chunk.c +++ b/libfwupdplugin/fu-chunk.c @@ -21,7 +21,7 @@ */ /** - * fu_chunk_new: + * fu_chunk_new: (skip): * @idx: the packet number * @page: the hardware memory page * @address: the address *within* the page @@ -104,7 +104,7 @@ fu_chunk_array_to_string (GPtrArray *chunks) } /** - * fu_chunk_array_new: + * fu_chunk_array_new: (skip): * @data: a linear blob of memory, or %NULL * @data_sz: size of @data_sz * @addr_start: the hardware address offset, or 0 @@ -188,7 +188,7 @@ fu_chunk_array_new (const guint8 *data, } /** - * fu_chunk_array_new_from_bytes: + * fu_chunk_array_new_from_bytes: (skip): * @blob: a #GBytes * @addr_start: the hardware address offset, or 0 * @page_sz: the hardware page size, or 0 diff --git a/libfwupdplugin/fu-common-cab.c b/libfwupdplugin/fu-common-cab.c index 8fda335f0..3250a2428 100644 --- a/libfwupdplugin/fu-common-cab.c +++ b/libfwupdplugin/fu-common-cab.c @@ -375,7 +375,7 @@ fu_common_cab_set_container_checksum_cb (XbBuilderFixup *self, } /** - * fu_common_cab_build_silo: + * fu_common_cab_build_silo: (skip): * @blob: A readable blob * @size_max: The maximum size of the archive * @error: A #FuEndianType, e.g. %G_LITTLE_ENDIAN diff --git a/libfwupdplugin/fu-device.c b/libfwupdplugin/fu-device.c index 8dd90733a..36469cc4e 100644 --- a/libfwupdplugin/fu-device.c +++ b/libfwupdplugin/fu-device.c @@ -2630,7 +2630,7 @@ fu_device_incorporate_flag (FuDevice *self, FuDevice *donor, FwupdDeviceFlags fl } /** - * fu_device_incorporate_from_component: + * fu_device_incorporate_from_component: (skip): * @device: A #FuDevice * @component: A #XbNode * diff --git a/libfwupdplugin/fu-plugin.c b/libfwupdplugin/fu-plugin.c index ab84bae73..0ace66f42 100644 --- a/libfwupdplugin/fu-plugin.c +++ b/libfwupdplugin/fu-plugin.c @@ -280,7 +280,7 @@ fu_plugin_get_data (FuPlugin *self) } /** - * fu_plugin_alloc_data: + * fu_plugin_alloc_data: (skip): * @self: A #FuPlugin * @data_sz: the size to allocate * diff --git a/libfwupdplugin/fu-srec-firmware.c b/libfwupdplugin/fu-srec-firmware.c index 1cd5b8398..8a12810c9 100644 --- a/libfwupdplugin/fu-srec-firmware.c +++ b/libfwupdplugin/fu-srec-firmware.c @@ -58,7 +58,7 @@ fu_srec_firmware_record_free (FuSrecFirmwareRecord *rcd) } /** - * fu_srec_firmware_record_new: + * fu_srec_firmware_record_new: (skip): * @ln: unsigned integer * @kind: #FuFirmwareSrecRecordKind * @addr: unsigned integer From f3d5207351eeb004d97a57056e383411aec106af Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 10:55:16 +0000 Subject: [PATCH 59/74] trivial: Unexport fu_test_loop_run_with_timeout() --- libfwupdplugin/fu-self-test.c | 35 ++++++++++++++++++++++++ libfwupdplugin/fu-test.c | 49 ---------------------------------- libfwupdplugin/fu-test.h | 2 -- libfwupdplugin/fwupdplugin.map | 2 -- src/fu-self-test.c | 35 ++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 53 deletions(-) diff --git a/libfwupdplugin/fu-self-test.c b/libfwupdplugin/fu-self-test.c index bb231a316..56b8565a7 100644 --- a/libfwupdplugin/fu-self-test.c +++ b/libfwupdplugin/fu-self-test.c @@ -16,6 +16,41 @@ #include "fu-plugin-private.h" #include "fu-smbios-private.h" +static GMainLoop *_test_loop = NULL; +static guint _test_loop_timeout_id = 0; + +static gboolean +fu_test_hang_check_cb (gpointer user_data) +{ + g_main_loop_quit (_test_loop); + _test_loop_timeout_id = 0; + return G_SOURCE_REMOVE; +} + +static void +fu_test_loop_run_with_timeout (guint timeout_ms) +{ + g_assert (_test_loop_timeout_id == 0); + g_assert (_test_loop == NULL); + _test_loop = g_main_loop_new (NULL, FALSE); + _test_loop_timeout_id = g_timeout_add (timeout_ms, fu_test_hang_check_cb, NULL); + g_main_loop_run (_test_loop); +} + +static void +fu_test_loop_quit (void) +{ + if (_test_loop_timeout_id > 0) { + g_source_remove (_test_loop_timeout_id); + _test_loop_timeout_id = 0; + } + if (_test_loop != NULL) { + g_main_loop_quit (_test_loop); + g_main_loop_unref (_test_loop); + _test_loop = NULL; + } +} + static void fu_archive_invalid_func (void) { diff --git a/libfwupdplugin/fu-test.c b/libfwupdplugin/fu-test.c index 5a16510c4..8a1b0c125 100644 --- a/libfwupdplugin/fu-test.c +++ b/libfwupdplugin/fu-test.c @@ -14,55 +14,6 @@ #include "fu-test.h" #include "fu-common.h" -static GMainLoop *_test_loop = NULL; -static guint _test_loop_timeout_id = 0; - -static gboolean -fu_test_hang_check_cb (gpointer user_data) -{ - g_main_loop_quit (_test_loop); - _test_loop_timeout_id = 0; - return G_SOURCE_REMOVE; -} - -/** - * fu_test_loop_run_with_timeout: - * @timeout_ms: The timeout in milliseconds - * - * Quits the test loop after a timeout - * - * Since: 0.9.1 - **/ -void -fu_test_loop_run_with_timeout (guint timeout_ms) -{ - g_assert (_test_loop_timeout_id == 0); - g_assert (_test_loop == NULL); - _test_loop = g_main_loop_new (NULL, FALSE); - _test_loop_timeout_id = g_timeout_add (timeout_ms, fu_test_hang_check_cb, NULL); - g_main_loop_run (_test_loop); -} - -/** - * fu_test_loop_quit: - * - * Quits the test loop - * - * Since: 0.9.1 - **/ -void -fu_test_loop_quit (void) -{ - if (_test_loop_timeout_id > 0) { - g_source_remove (_test_loop_timeout_id); - _test_loop_timeout_id = 0; - } - if (_test_loop != NULL) { - g_main_loop_quit (_test_loop); - g_main_loop_unref (_test_loop); - _test_loop = NULL; - } -} /** * fu_test_get_filename: diff --git a/libfwupdplugin/fu-test.h b/libfwupdplugin/fu-test.h index d12fce7fa..2cc3d0ae0 100644 --- a/libfwupdplugin/fu-test.h +++ b/libfwupdplugin/fu-test.h @@ -10,8 +10,6 @@ gchar *fu_test_get_filename (const gchar *testdatadirs, const gchar *filename); -void fu_test_loop_run_with_timeout (guint timeout_ms); -void fu_test_loop_quit (void); gboolean fu_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error); diff --git a/libfwupdplugin/fwupdplugin.map b/libfwupdplugin/fwupdplugin.map index f5c74209f..91e3d6942 100644 --- a/libfwupdplugin/fwupdplugin.map +++ b/libfwupdplugin/fwupdplugin.map @@ -74,8 +74,6 @@ LIBFWUPDPLUGIN_0.9.1 { global: fu_plugin_check_hwid; fu_test_get_filename; - fu_test_loop_quit; - fu_test_loop_run_with_timeout; local: *; } LIBFWUPDPLUGIN_0.8.0; diff --git a/src/fu-self-test.c b/src/fu-self-test.c index 339bb8f87..f686dd54c 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -34,6 +34,41 @@ #include "fu-keyring-pkcs7.h" #endif +static GMainLoop *_test_loop = NULL; +static guint _test_loop_timeout_id = 0; + +static gboolean +fu_test_hang_check_cb (gpointer user_data) +{ + g_main_loop_quit (_test_loop); + _test_loop_timeout_id = 0; + return G_SOURCE_REMOVE; +} + +static void +fu_test_loop_run_with_timeout (guint timeout_ms) +{ + g_assert (_test_loop_timeout_id == 0); + g_assert (_test_loop == NULL); + _test_loop = g_main_loop_new (NULL, FALSE); + _test_loop_timeout_id = g_timeout_add (timeout_ms, fu_test_hang_check_cb, NULL); + g_main_loop_run (_test_loop); +} + +static void +fu_test_loop_quit (void) +{ + if (_test_loop_timeout_id > 0) { + g_source_remove (_test_loop_timeout_id); + _test_loop_timeout_id = 0; + } + if (_test_loop != NULL) { + g_main_loop_quit (_test_loop); + g_main_loop_unref (_test_loop); + _test_loop = NULL; + } +} + static void fu_self_test_mkroot (void) { From 606fa91daecd84e78dab1a550268efa97db8ff80 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 10:57:24 +0000 Subject: [PATCH 60/74] trivial: Unexport fu_test_compare_lines() It's only used two places in the self tests. --- libfwupdplugin/fu-test.c | 39 ---------------------------------- libfwupdplugin/fu-test.h | 3 --- libfwupdplugin/fwupdplugin.map | 1 - plugins/dfu/dfu-self-test.c | 19 +++++++++++++++++ src/fu-self-test.c | 19 +++++++++++++++++ 5 files changed, 38 insertions(+), 43 deletions(-) diff --git a/libfwupdplugin/fu-test.c b/libfwupdplugin/fu-test.c index 8a1b0c125..506eb4cc6 100644 --- a/libfwupdplugin/fu-test.c +++ b/libfwupdplugin/fu-test.c @@ -40,42 +40,3 @@ fu_test_get_filename (const gchar *testdatadirs, const gchar *filename) } return NULL; } - -/** - * fu_test_compare_lines: - * @txt1: First line to compare - * @txt2: second line to compare - * @error: A #GError or #NULL - * - * Compare two lines. - * - * Returns: #TRUE if identical, #FALSE if not (diff is set in error) - * - * Since: 1.0.4 - **/ -gboolean -fu_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error) -{ - g_autofree gchar *output = NULL; - - /* exactly the same */ - if (g_strcmp0 (txt1, txt2) == 0) - return TRUE; - - /* matches a pattern */ - if (fu_common_fnmatch (txt2, txt1)) - return TRUE; - - /* save temp files and diff them */ - if (!g_file_set_contents ("/tmp/a", txt1, -1, error)) - return FALSE; - if (!g_file_set_contents ("/tmp/b", txt2, -1, error)) - return FALSE; - if (!g_spawn_command_line_sync ("diff -urNp /tmp/b /tmp/a", - &output, NULL, NULL, error)) - return FALSE; - - /* just output the diff */ - g_set_error_literal (error, 1, 0, output); - return FALSE; -} diff --git a/libfwupdplugin/fu-test.h b/libfwupdplugin/fu-test.h index 2cc3d0ae0..203112490 100644 --- a/libfwupdplugin/fu-test.h +++ b/libfwupdplugin/fu-test.h @@ -10,6 +10,3 @@ gchar *fu_test_get_filename (const gchar *testdatadirs, const gchar *filename); -gboolean fu_test_compare_lines (const gchar *txt1, - const gchar *txt2, - GError **error); diff --git a/libfwupdplugin/fwupdplugin.map b/libfwupdplugin/fwupdplugin.map index 91e3d6942..8236e1dc8 100644 --- a/libfwupdplugin/fwupdplugin.map +++ b/libfwupdplugin/fwupdplugin.map @@ -204,7 +204,6 @@ LIBFWUPDPLUGIN_1.0.4 { fu_plugin_add_report_metadata; fu_plugin_get_report_metadata; fu_plugin_runner_recoldplug; - fu_test_compare_lines; local: *; } LIBFWUPDPLUGIN_1.0.3; diff --git a/plugins/dfu/dfu-self-test.c b/plugins/dfu/dfu-self-test.c index 60fa60646..20e4a610f 100644 --- a/plugins/dfu/dfu-self-test.c +++ b/plugins/dfu/dfu-self-test.c @@ -48,6 +48,25 @@ dfu_self_test_get_bytes_for_file (GFile *file, GError **error) return g_bytes_new_take (contents, length); } +static gboolean +fu_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error) +{ + g_autofree gchar *output = NULL; + if (g_strcmp0 (txt1, txt2) == 0) + return TRUE; + if (fu_common_fnmatch (txt2, txt1)) + return TRUE; + if (!g_file_set_contents ("/tmp/a", txt1, -1, error)) + return FALSE; + if (!g_file_set_contents ("/tmp/b", txt2, -1, error)) + return FALSE; + if (!g_spawn_command_line_sync ("diff -urNp /tmp/b /tmp/a", + &output, NULL, NULL, error)) + return FALSE; + g_set_error_literal (error, 1, 0, output); + return FALSE; +} + static void dfu_firmware_raw_func (void) { diff --git a/src/fu-self-test.c b/src/fu-self-test.c index f686dd54c..eb313fb47 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -80,6 +80,25 @@ fu_self_test_mkroot (void) g_assert_cmpint (g_mkdir_with_parents ("/tmp/fwupd-self-test/var/lib/fwupd", 0755), ==, 0); } +static gboolean +fu_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error) +{ + g_autofree gchar *output = NULL; + if (g_strcmp0 (txt1, txt2) == 0) + return TRUE; + if (fu_common_fnmatch (txt2, txt1)) + return TRUE; + if (!g_file_set_contents ("/tmp/a", txt1, -1, error)) + return FALSE; + if (!g_file_set_contents ("/tmp/b", txt2, -1, error)) + return FALSE; + if (!g_spawn_command_line_sync ("diff -urNp /tmp/b /tmp/a", + &output, NULL, NULL, error)) + return FALSE; + g_set_error_literal (error, 1, 0, output); + return FALSE; +} + static void fu_engine_generate_md_func (void) { From 3ed2ac831589a474e6724c77878bcdcfcc7603a1 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 12:11:50 +0000 Subject: [PATCH 61/74] trivial: Unexport fu_test_get_filename() We don't actually need either of the things it provides (looking up in source and built, and converting to an absolute path) so just replace it with g_build_filename() instead. This also has the advantage that it does the right thing on Windows. --- docs/fwupd-docs.xml | 1 - libfwupdplugin/fu-self-test.c | 40 ++++-------- libfwupdplugin/fu-test.c | 42 ------------ libfwupdplugin/fu-test.h | 12 ---- libfwupdplugin/fwupdplugin.h | 1 - libfwupdplugin/fwupdplugin.map | 1 - libfwupdplugin/meson.build | 3 - plugins/ata/fu-self-test.c | 4 +- plugins/dfu/dfu-self-test.c | 1 - plugins/nvme/fu-self-test.c | 8 +-- plugins/optionrom/fu-self-test.c | 9 ++- plugins/redfish/fu-self-test.c | 1 - plugins/synaptics-prometheus/fu-self-test.c | 4 +- plugins/thunderbolt/fu-self-test.c | 22 ++----- plugins/thunderbolt/fu-thunderbolt-tool.c | 1 - plugins/thunderbolt/meson.build | 4 +- plugins/uefi/fu-self-test.c | 10 +-- plugins/wacom-usb/fu-self-test.c | 5 +- src/fu-self-test.c | 71 ++++++--------------- src/meson.build | 1 - 20 files changed, 55 insertions(+), 186 deletions(-) delete mode 100644 libfwupdplugin/fu-test.c delete mode 100644 libfwupdplugin/fu-test.h diff --git a/docs/fwupd-docs.xml b/docs/fwupd-docs.xml index 050e93c5f..541a189a0 100644 --- a/docs/fwupd-docs.xml +++ b/docs/fwupd-docs.xml @@ -63,7 +63,6 @@ - diff --git a/libfwupdplugin/fu-self-test.c b/libfwupdplugin/fu-self-test.c index 56b8565a7..6eb2f95dd 100644 --- a/libfwupdplugin/fu-self-test.c +++ b/libfwupdplugin/fu-self-test.c @@ -59,8 +59,7 @@ fu_archive_invalid_func (void) g_autoptr(GBytes) data = NULL; g_autoptr(GError) error = NULL; - filename = fu_test_get_filename (TESTDATADIR, "metadata.xml"); - g_assert_nonnull (filename); + filename = g_build_filename (TESTDATADIR_SRC, "metadata.xml", NULL); data = fu_common_get_contents_bytes (filename, &error); g_assert_no_error (error); g_assert_nonnull (data); @@ -81,8 +80,7 @@ fu_archive_cab_func (void) g_autoptr(GError) error = NULL; GBytes *data_tmp; - filename = fu_test_get_filename (TESTDATADIR, "colorhug/colorhug-als-3.0.2.cab"); - g_assert_nonnull (filename); + filename = g_build_filename (TESTDATADIR_DST, "colorhug", "colorhug-als-3.0.2.cab", NULL); data = fu_common_get_contents_bytes (filename, &error); g_assert_no_error (error); g_assert_nonnull (data); @@ -250,9 +248,7 @@ fu_smbios3_func (void) g_autoptr(FuSmbios) smbios = NULL; g_autoptr(GError) error = NULL; - path = fu_test_get_filename (TESTDATADIR, "dmi/tables64"); - g_assert_nonnull (path); - + path = g_build_filename (TESTDATADIR_SRC, "dmi", "tables64", NULL); smbios = fu_smbios_new (); ret = fu_smbios_setup_from_path (smbios, path, &error); g_assert_no_error (error); @@ -469,8 +465,7 @@ fu_common_firmware_builder_func (void) g_autoptr(GError) error = NULL; /* get test file */ - archive_fn = fu_test_get_filename (TESTDATADIR, "builder/firmware.tar"); - g_assert (archive_fn != NULL); + archive_fn = g_build_filename (TESTDATADIR_DST, "builder", "firmware.tar", NULL); archive_blob = fu_common_get_contents_bytes (archive_fn, &error); g_assert_no_error (error); g_assert (archive_blob != NULL); @@ -570,8 +565,7 @@ fu_common_spawn_func (void) g_autofree gchar *fn = NULL; const gchar *argv[3] = { "replace", "test", NULL }; - fn = fu_test_get_filename (TESTDATADIR, "spawn.sh"); - g_assert (fn != NULL); + fn = g_build_filename (TESTDATADIR_SRC, "spawn.sh", NULL); argv[0] = fn; ret = fu_common_spawn_sync (argv, fu_test_stdout_cb, &lines, 0, NULL, &error); @@ -589,8 +583,7 @@ fu_common_spawn_timeout_func (void) g_autofree gchar *fn = NULL; const gchar *argv[3] = { "replace", "test", NULL }; - fn = fu_test_get_filename (TESTDATADIR, "spawn.sh"); - g_assert (fn != NULL); + fn = g_build_filename (TESTDATADIR_SRC, "spawn.sh", NULL); argv[0] = fn; ret = fu_common_spawn_sync (argv, fu_test_stdout_cb, &lines, 50, NULL, &error); g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED); @@ -1268,8 +1261,7 @@ fu_firmware_ihex_func (void) g_autoptr(GFile) file_hex = NULL; /* load a Intel hex32 file */ - filename_hex = fu_test_get_filename (TESTDATADIR, "firmware.hex"); - g_assert (filename_hex != NULL); + filename_hex = g_build_filename (TESTDATADIR_SRC, "firmware.hex", NULL); file_hex = g_file_new_for_path (filename_hex); data_file = g_file_load_bytes (file_hex, NULL, NULL, &error); g_assert_no_error (error); @@ -1283,8 +1275,7 @@ fu_firmware_ihex_func (void) g_assert_cmpint (g_bytes_get_size (data_fw), ==, 136); /* did we match the reference file? */ - filename_ref = fu_test_get_filename (TESTDATADIR, "firmware.bin"); - g_assert (filename_ref != NULL); + filename_ref = g_build_filename (TESTDATADIR_SRC, "firmware.bin", NULL); file_ref = g_file_new_for_path (filename_ref); data_ref = g_file_load_bytes (file_ref, NULL, NULL, &error); g_assert_no_error (error); @@ -1328,8 +1319,7 @@ fu_firmware_ihex_signed_func (void) g_autoptr(GFile) file_hex = NULL; /* load a signed Intel hex32 file */ - filename_shex = fu_test_get_filename (TESTDATADIR, "firmware.shex"); - g_assert (filename_shex != NULL); + filename_shex = g_build_filename (TESTDATADIR_SRC, "firmware.shex", NULL); file_hex = g_file_new_for_path (filename_shex); data_file = g_file_load_bytes (file_hex, NULL, NULL, &error); g_assert_no_error (error); @@ -1413,8 +1403,7 @@ fu_firmware_srec_func (void) g_autoptr(GFile) file_bin = NULL; g_autoptr(GFile) file_srec = NULL; - filename_srec = fu_test_get_filename (TESTDATADIR, "firmware.srec"); - g_assert (filename_srec != NULL); + filename_srec = g_build_filename (TESTDATADIR_SRC, "firmware.srec", NULL); file_srec = g_file_new_for_path (filename_srec); data_srec = g_file_load_bytes (file_srec, NULL, NULL, &error); g_assert_no_error (error); @@ -1428,8 +1417,7 @@ fu_firmware_srec_func (void) g_assert_cmpint (g_bytes_get_size (data_bin), ==, 136); /* did we match the reference file? */ - filename_ref = fu_test_get_filename (TESTDATADIR, "firmware.bin"); - g_assert (filename_ref != NULL); + filename_ref = g_build_filename (TESTDATADIR_SRC, "firmware.bin", NULL); file_bin = g_file_new_for_path (filename_ref); data_ref = g_file_load_bytes (file_bin, NULL, NULL, &error); g_assert_no_error (error); @@ -1485,8 +1473,7 @@ fu_firmware_dfu_func (void) g_autoptr(GFile) file_bin = NULL; g_autoptr(GFile) file_dfu = NULL; - filename_dfu = fu_test_get_filename (TESTDATADIR, "firmware.dfu"); - g_assert (filename_dfu != NULL); + filename_dfu = g_build_filename (TESTDATADIR_SRC, "firmware.dfu", NULL); file_dfu = g_file_new_for_path (filename_dfu); data_dfu = g_file_load_bytes (file_dfu, NULL, NULL, &error); g_assert_no_error (error); @@ -1503,8 +1490,7 @@ fu_firmware_dfu_func (void) g_assert_cmpint (g_bytes_get_size (data_bin), ==, 136); /* did we match the reference file? */ - filename_ref = fu_test_get_filename (TESTDATADIR, "firmware.bin"); - g_assert (filename_ref != NULL); + filename_ref = g_build_filename (TESTDATADIR_SRC, "firmware.bin", NULL); file_bin = g_file_new_for_path (filename_ref); data_ref = g_file_load_bytes (file_bin, NULL, NULL, &error); g_assert_no_error (error); diff --git a/libfwupdplugin/fu-test.c b/libfwupdplugin/fu-test.c deleted file mode 100644 index 506eb4cc6..000000000 --- a/libfwupdplugin/fu-test.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2010-2017 Richard Hughes - * - * SPDX-License-Identifier: LGPL-2.1+ - */ - -#include "config.h" - -#include - -#include -#include - -#include "fu-test.h" -#include "fu-common.h" - - -/** - * fu_test_get_filename: - * @testdatadirs: semicolon delimitted list of directories - * @filename: the filename to look for - * - * Returns the first path that matches filename in testdatadirs - * - * Returns: (transfer full): full path to file or NULL - * - * Since: 0.9.1 - **/ -gchar * -fu_test_get_filename (const gchar *testdatadirs, const gchar *filename) -{ - g_auto(GStrv) split = g_strsplit (testdatadirs, ":", -1); - for (guint i = 0; split[i] != NULL; i++) { - g_autofree gchar *tmp = NULL; - g_autofree gchar *path = NULL; - path = g_build_filename (split[i], filename, NULL); - tmp = fu_common_realpath (path, NULL); - if (tmp != NULL) - return g_steal_pointer (&tmp); - } - return NULL; -} diff --git a/libfwupdplugin/fu-test.h b/libfwupdplugin/fu-test.h deleted file mode 100644 index 203112490..000000000 --- a/libfwupdplugin/fu-test.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (C) 2010-2011 Richard Hughes - * - * SPDX-License-Identifier: LGPL-2.1+ - */ - -#pragma once - -#include - -gchar *fu_test_get_filename (const gchar *testdatadirs, - const gchar *filename); diff --git a/libfwupdplugin/fwupdplugin.h b/libfwupdplugin/fwupdplugin.h index 09c70c328..5c647cd55 100644 --- a/libfwupdplugin/fwupdplugin.h +++ b/libfwupdplugin/fwupdplugin.h @@ -35,7 +35,6 @@ #include #include #include -#include #include #include diff --git a/libfwupdplugin/fwupdplugin.map b/libfwupdplugin/fwupdplugin.map index 8236e1dc8..e762f969b 100644 --- a/libfwupdplugin/fwupdplugin.map +++ b/libfwupdplugin/fwupdplugin.map @@ -73,7 +73,6 @@ LIBFWUPDPLUGIN_0.8.0 { LIBFWUPDPLUGIN_0.9.1 { global: fu_plugin_check_hwid; - fu_test_get_filename; local: *; } LIBFWUPDPLUGIN_0.8.0; diff --git a/libfwupdplugin/meson.build b/libfwupdplugin/meson.build index 837b5a2d0..1d781eea1 100644 --- a/libfwupdplugin/meson.build +++ b/libfwupdplugin/meson.build @@ -19,7 +19,6 @@ fwupdplugin_src = [ 'fu-quirks.c', 'fu-smbios.c', 'fu-srec-firmware.c', - 'fu-test.c', 'fu-udev-device.c', 'fu-usb-device.c', ] @@ -46,7 +45,6 @@ fwupdplugin_headers = [ 'fu-quirks.h', 'fu-smbios.h', 'fu-srec-firmware.h', - 'fu-test.h', 'fu-udev-device.h', 'fu-usb-device.h', ] @@ -241,7 +239,6 @@ if get_option('tests') c_args : [ '-DTESTDATADIR_SRC="' + testdatadir_src + '"', '-DTESTDATADIR_DST="' + testdatadir_dst + '"', - '-DTESTDATADIR="' + testdatadir_src + ':' + testdatadir_dst + '"', '-DPLUGINBUILDDIR="' + pluginbuilddir + '"', ], ) diff --git a/plugins/ata/fu-self-test.c b/plugins/ata/fu-self-test.c index 02aae8c2e..7614dae41 100644 --- a/plugins/ata/fu-self-test.c +++ b/plugins/ata/fu-self-test.c @@ -9,7 +9,6 @@ #include #include "fu-ata-device.h" -#include "fu-test.h" static void fu_ata_id_func (void) @@ -21,8 +20,7 @@ fu_ata_id_func (void) g_autoptr(FuAtaDevice) dev = NULL; g_autoptr(GError) error = NULL; - path = fu_test_get_filename (TESTDATADIR, "StarDrive-SBFM61.2.bin"); - g_assert_nonnull (path); + path = g_build_filename (TESTDATADIR, "StarDrive-SBFM61.2.bin", NULL); ret = g_file_get_contents (path, &data, &sz, &error); g_assert_no_error (error); g_assert (ret); diff --git a/plugins/dfu/dfu-self-test.c b/plugins/dfu/dfu-self-test.c index 20e4a610f..2a1e9ffe1 100644 --- a/plugins/dfu/dfu-self-test.c +++ b/plugins/dfu/dfu-self-test.c @@ -16,7 +16,6 @@ #include "dfu-sector.h" #include "dfu-target-private.h" -#include "fu-test.h" #include "fu-common.h" #include "fwupd-error.h" diff --git a/plugins/nvme/fu-self-test.c b/plugins/nvme/fu-self-test.c index e337f2262..9b872bb0b 100644 --- a/plugins/nvme/fu-self-test.c +++ b/plugins/nvme/fu-self-test.c @@ -10,7 +10,6 @@ #include "fu-device-private.h" #include "fu-nvme-device.h" -#include "fu-test.h" static void fu_nvme_cns_func (void) @@ -22,8 +21,7 @@ fu_nvme_cns_func (void) g_autoptr(FuNvmeDevice) dev = NULL; g_autoptr(GError) error = NULL; - path = fu_test_get_filename (TESTDATADIR, "TOSHIBA_THNSN5512GPU7.bin"); - g_assert_nonnull (path); + path = g_build_filename (TESTDATADIR, "TOSHIBA_THNSN5512GPU7.bin", NULL); ret = g_file_get_contents (path, &data, &sz, &error); g_assert_no_error (error); g_assert (ret); @@ -45,8 +43,8 @@ fu_nvme_cns_all_func (void) g_autoptr(GDir) dir = NULL; /* may or may not exist */ - path = fu_test_get_filename (TESTDATADIR, "blobs"); - if (path == NULL) + path = g_build_filename (TESTDATADIR, "blobs", NULL); + if (!g_file_test (path, G_FILE_TEST_EXISTS)) return; dir = g_dir_open (path, 0, NULL); while ((fn = g_dir_read_name (dir)) != NULL) { diff --git a/plugins/optionrom/fu-self-test.c b/plugins/optionrom/fu-self-test.c index 468c1b5bd..d3aa79326 100644 --- a/plugins/optionrom/fu-self-test.c +++ b/plugins/optionrom/fu-self-test.c @@ -13,7 +13,6 @@ #include "fu-plugin-private.h" #include "fu-rom.h" -#include "fu-test.h" static void fu_rom_func (void) @@ -62,8 +61,8 @@ fu_rom_func (void) g_assert (rom != NULL); /* load file */ - filename = fu_test_get_filename (TESTDATADIR, data[i].fn); - if (filename == NULL) + filename = g_build_filename (TESTDATADIR, data[i].fn, NULL); + if (!g_file_test (filename, G_FILE_TEST_EXISTS)) continue; g_print ("\nparsing %s...", filename); file = g_file_new_for_path (filename); @@ -84,8 +83,8 @@ fu_rom_all_func (void) g_autofree gchar *path = NULL; /* may or may not exist */ - path = fu_test_get_filename (TESTDATADIR, "roms"); - if (path == NULL) + path = g_build_filename (TESTDATADIR, "roms", NULL); + if (!g_file_test (path, G_FILE_TEST_EXISTS)) return; g_print ("\n"); dir = g_dir_open (path, 0, NULL); diff --git a/plugins/redfish/fu-self-test.c b/plugins/redfish/fu-self-test.c index d1ba40d4d..ccebba416 100644 --- a/plugins/redfish/fu-self-test.c +++ b/plugins/redfish/fu-self-test.c @@ -9,7 +9,6 @@ #include #include "fu-plugin-private.h" -#include "fu-test.h" #include "fu-redfish-common.h" diff --git a/plugins/synaptics-prometheus/fu-self-test.c b/plugins/synaptics-prometheus/fu-self-test.c index 651a68d00..a9b4df72d 100644 --- a/plugins/synaptics-prometheus/fu-self-test.c +++ b/plugins/synaptics-prometheus/fu-self-test.c @@ -9,7 +9,6 @@ #include #include "fu-plugin-private.h" -#include "fu-test.h" #include "fu-synaprom-device.h" #include "fu-synaprom-firmware.h" @@ -29,8 +28,7 @@ fu_test_synaprom_firmware_func (void) g_autoptr(FuFirmware) firmware2 = NULL; g_autoptr(FuFirmware) firmware = fu_synaprom_firmware_new (); - filename = fu_test_get_filename (TESTDATADIR, "test.pkg"); - g_assert_nonnull (filename); + filename = g_build_filename (TESTDATADIR, "test.pkg", NULL); fw = fu_common_get_contents_bytes (filename, &error); g_assert_no_error (error); g_assert_nonnull (fw); diff --git a/plugins/thunderbolt/fu-self-test.c b/plugins/thunderbolt/fu-self-test.c index cae122769..888ce8d16 100644 --- a/plugins/thunderbolt/fu-self-test.c +++ b/plugins/thunderbolt/fu-self-test.c @@ -24,7 +24,6 @@ #include "fu-plugin-private.h" #include "fu-thunderbolt-image.h" -#include "fu-test.h" static gchar * udev_mock_add_domain (UMockdevTestbed *bed, int id) @@ -343,9 +342,7 @@ write_controller_fw (const gchar *nvm) g_autoptr(GError) error = NULL; gssize n; - fw_path = fu_test_get_filename (TESTDATADIR, "thunderbolt/minimal-fw-controller.bin"); - g_assert_nonnull (fw_path); - + fw_path = g_build_filename (TESTDATADIR, "thunderbolt/minimal-fw-controller.bin", NULL); fw_file = g_file_new_for_path (fw_path); g_assert_nonnull (fw_file); @@ -916,8 +913,7 @@ test_set_up (ThunderboltTest *tt, gconstpointer params) if (flags & TEST_PREPARE_FIRMWARE) { g_autofree gchar *fw_path = NULL; - fw_path = fu_test_get_filename (TESTDATADIR, "thunderbolt/minimal-fw.bin"); - g_assert_nonnull (fw_path); + fw_path = g_build_filename (TESTDATADIR, "thunderbolt/minimal-fw.bin", NULL); tt->fw_file = g_mapped_file_new (fw_path, FALSE, &error); g_assert_no_error (error); g_assert_nonnull (tt->fw_file); @@ -1010,10 +1006,8 @@ test_image_validation (ThunderboltTest *tt, gconstpointer user_data) g_autoptr(GError) error = NULL; /* image as if read from the controller (i.e. no headers) */ - ctl_path = fu_test_get_filename (TESTDATADIR, - "thunderbolt/minimal-fw-controller.bin"); - g_assert_nonnull (ctl_path); - + ctl_path = g_build_filename (TESTDATADIR, + "thunderbolt/minimal-fw-controller.bin", NULL); ctl_file = g_mapped_file_new (ctl_path, FALSE, &error); g_assert_no_error (error); g_assert_nonnull (ctl_file); @@ -1022,9 +1016,7 @@ test_image_validation (ThunderboltTest *tt, gconstpointer user_data) g_assert_nonnull (ctl_data); /* valid firmware update image */ - fwi_path = fu_test_get_filename (TESTDATADIR, "thunderbolt/minimal-fw.bin"); - g_assert_nonnull (fwi_path); - + fwi_path = g_build_filename (TESTDATADIR, "thunderbolt/minimal-fw.bin", NULL); fwi_file = g_mapped_file_new (fwi_path, FALSE, &error); g_assert_no_error (error); g_assert_nonnull (fwi_file); @@ -1033,9 +1025,7 @@ test_image_validation (ThunderboltTest *tt, gconstpointer user_data) g_assert_nonnull (fwi_data); /* a wrong/bad firmware update image */ - bad_path = fu_test_get_filename (TESTDATADIR, "colorhug/firmware.bin"); - g_assert_nonnull (bad_path); - + bad_path = g_build_filename (TESTDATADIR, "colorhug/firmware.bin", NULL); bad_file = g_mapped_file_new (bad_path, FALSE, &error); g_assert_no_error (error); g_assert_nonnull (bad_file); diff --git a/plugins/thunderbolt/fu-thunderbolt-tool.c b/plugins/thunderbolt/fu-thunderbolt-tool.c index 8581201b7..419ba5f7c 100644 --- a/plugins/thunderbolt/fu-thunderbolt-tool.c +++ b/plugins/thunderbolt/fu-thunderbolt-tool.c @@ -12,7 +12,6 @@ #include "fu-thunderbolt-image.h" #include "fu-plugin-vfuncs.h" #include "fu-hash.h" -#include "fu-test.h" static gsize read_farb_pointer (gchar *image) diff --git a/plugins/thunderbolt/meson.build b/plugins/thunderbolt/meson.build index 8abb201c4..06ab34eec 100644 --- a/plugins/thunderbolt/meson.build +++ b/plugins/thunderbolt/meson.build @@ -23,9 +23,7 @@ fu_plugin_thunderbolt = shared_module('fu_plugin_thunderbolt', ], ) -testdatadir_src = join_paths(meson.source_root(), 'data', 'tests') -testdatadir_dst = join_paths(meson.build_root(), 'data', 'tests') -cargs += '-DTESTDATADIR="' + testdatadir_src + ':' + testdatadir_dst + '"' +cargs += '-DTESTDATADIR="' + join_paths(meson.source_root(), 'data', 'tests') + '"' executable('tbtfwucli', fu_hash, sources : [ diff --git a/plugins/uefi/fu-self-test.c b/plugins/uefi/fu-self-test.c index 860bda291..08ceed389 100644 --- a/plugins/uefi/fu-self-test.c +++ b/plugins/uefi/fu-self-test.c @@ -8,7 +8,6 @@ #include -#include "fu-test.h" #include "fu-ucs2.h" #include "fu-uefi-bgrt.h" #include "fu-uefi-common.h" @@ -129,8 +128,7 @@ fu_uefi_bitmap_func (void) g_autofree gchar *buf = NULL; g_autoptr(GError) error = NULL; - fn = fu_test_get_filename (TESTDATADIR, "test.bmp"); - g_assert (fn != NULL); + fn = g_build_filename (TESTDATADIR, "test.bmp", NULL); ret = g_file_get_contents (fn, &buf, &sz, &error); g_assert_no_error (error); g_assert_true (ret); @@ -149,8 +147,7 @@ fu_uefi_device_func (void) g_autoptr(FuUefiDevice) dev = NULL; g_autoptr(GError) error = NULL; - fn = fu_test_get_filename (TESTDATADIR, "efi/esrt/entries/entry0"); - g_assert (fn != NULL); + fn = g_build_filename (TESTDATADIR, "efi/esrt/entries/entry0", NULL); dev = fu_uefi_device_new_from_entry (fn, &error); g_assert_nonnull (dev); g_assert_no_error (error); @@ -287,8 +284,7 @@ fu_uefi_update_info_func (void) g_autoptr(FuUefiUpdateInfo) info = NULL; g_autoptr(GError) error = NULL; - fn = fu_test_get_filename (TESTDATADIR, "efi/esrt/entries/entry0"); - g_assert (fn != NULL); + fn = g_build_filename (TESTDATADIR, "efi/esrt/entries/entry0", NULL); dev = fu_uefi_device_new_from_entry (fn, &error); g_assert_no_error (error); g_assert_nonnull (dev); diff --git a/plugins/wacom-usb/fu-self-test.c b/plugins/wacom-usb/fu-self-test.c index 786568de2..eb5d27ed3 100644 --- a/plugins/wacom-usb/fu-self-test.c +++ b/plugins/wacom-usb/fu-self-test.c @@ -10,7 +10,6 @@ #include #include "fu-common.h" -#include "fu-test.h" #include "fu-wac-common.h" #include "fu-wac-firmware.h" @@ -28,8 +27,8 @@ fu_wac_firmware_parse_func (void) g_autoptr(GError) error = NULL; /* parse the test file */ - fn = fu_test_get_filename (TESTDATADIR, "test.wac"); - if (fn == NULL) { + fn = g_build_filename (TESTDATADIR, "test.wac", NULL); + if (!g_file_test (fn, G_FILE_TEST_EXISTS)) { g_test_skip ("no data file found"); return; } diff --git a/src/fu-self-test.c b/src/fu-self-test.c index eb313fb47..cdec24c4b 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -112,8 +112,7 @@ fu_engine_generate_md_func (void) g_autoptr(XbNode) component = NULL; /* put cab file somewhere we can parse it */ - filename = fu_test_get_filename (TESTDATADIR, "colorhug/colorhug-als-3.0.2.cab"); - g_assert_nonnull (filename); + filename = g_build_filename (TESTDATADIR_DST, "colorhug", "colorhug-als-3.0.2.cab", NULL); data = fu_common_get_contents_bytes (filename, &error); g_assert_no_error (error); g_assert_nonnull (data); @@ -827,8 +826,7 @@ fu_engine_device_unlock_func (void) g_assert (ret); /* add the hardcoded 'fwupd' metadata */ - filename = fu_test_get_filename (TESTDATADIR, "metadata.xml"); - g_assert (filename != NULL); + filename = g_build_filename (TESTDATADIR_SRC, "metadata.xml", NULL); file = g_file_new_for_path (filename); ret = xb_builder_source_load_file (source, file, XB_BUILDER_SOURCE_FLAG_NONE, @@ -881,8 +879,7 @@ fu_engine_require_hwid_func (void) g_assert (ret); /* get generated file as a blob */ - filename = fu_test_get_filename (TESTDATADIR, "missing-hwid/hwid-1.2.3.cab"); - g_assert (filename != NULL); + filename = g_build_filename (TESTDATADIR_DST, "missing-hwid", "hwid-1.2.3.cab", NULL); blob_cab = fu_common_get_contents_bytes (filename, &error); g_assert_no_error (error); g_assert (blob_cab != NULL); @@ -919,7 +916,6 @@ fu_engine_downgrade_func (void) { FwupdRelease *rel; gboolean ret; - g_autofree gchar *testdatadir = NULL; g_autoptr(FuDevice) device = fu_device_new (); g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE); g_autoptr(GError) error = NULL; @@ -1003,9 +999,7 @@ fu_engine_downgrade_func (void) g_assert_no_error (error); g_assert (ret); - testdatadir = fu_test_get_filename (TESTDATADIR, "."); - g_assert (testdatadir != NULL); - g_setenv ("FU_SELF_TEST_REMOTES_DIR", testdatadir, TRUE); + g_setenv ("FU_SELF_TEST_REMOTES_DIR", TESTDATADIR_SRC, TRUE); ret = fu_engine_load (engine, FU_ENGINE_LOAD_FLAG_NO_ENUMERATE, &error); g_assert_no_error (error); g_assert (ret); @@ -1080,7 +1074,6 @@ fu_engine_install_duration_func (void) { FwupdRelease *rel; gboolean ret; - g_autofree gchar *testdatadir = NULL; g_autoptr(FuDevice) device = fu_device_new (); g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE); g_autoptr(GError) error = NULL; @@ -1114,9 +1107,7 @@ fu_engine_install_duration_func (void) g_assert_no_error (error); g_assert (ret); - testdatadir = fu_test_get_filename (TESTDATADIR, "."); - g_assert (testdatadir != NULL); - g_setenv ("FU_SELF_TEST_REMOTES_DIR", testdatadir, TRUE); + g_setenv ("FU_SELF_TEST_REMOTES_DIR", TESTDATADIR_SRC, TRUE); ret = fu_engine_load (engine, FU_ENGINE_LOAD_FLAG_NO_ENUMERATE, &error); g_assert_no_error (error); g_assert (ret); @@ -1151,7 +1142,6 @@ fu_engine_history_func (void) g_autofree gchar *device_str_expected = NULL; g_autofree gchar *device_str = NULL; g_autofree gchar *filename = NULL; - g_autofree gchar *testdatadir = NULL; g_autoptr(FuDevice) device2 = NULL; g_autoptr(FuDevice) device = fu_device_new (); g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE); @@ -1179,9 +1169,7 @@ fu_engine_history_func (void) g_assert (ret); fu_engine_add_plugin (engine, plugin); - testdatadir = fu_test_get_filename (TESTDATADIR, "."); - g_assert (testdatadir != NULL); - g_setenv ("FU_SELF_TEST_REMOTES_DIR", testdatadir, TRUE); + g_setenv ("FU_SELF_TEST_REMOTES_DIR", TESTDATADIR_SRC, TRUE); ret = fu_engine_load (engine, FU_ENGINE_LOAD_FLAG_NO_ENUMERATE, &error); g_assert_no_error (error); g_assert (ret); @@ -1203,8 +1191,7 @@ fu_engine_history_func (void) g_assert_cmpint (devices->len, ==, 1); g_assert (fu_device_has_flag (device, FWUPD_DEVICE_FLAG_REGISTERED)); - filename = fu_test_get_filename (TESTDATADIR, "missing-hwid/noreqs-1.2.3.cab"); - g_assert (filename != NULL); + filename = g_build_filename (TESTDATADIR_DST, "missing-hwid", "noreqs-1.2.3.cab", NULL); blob_cab = fu_common_get_contents_bytes (filename, &error); g_assert_no_error (error); g_assert (blob_cab != NULL); @@ -1287,7 +1274,6 @@ fu_engine_history_inherit (void) { gboolean ret; g_autofree gchar *filename = NULL; - g_autofree gchar *testdatadir = NULL; g_autoptr(FuDevice) device = fu_device_new (); g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE); g_autoptr(FuInstallTask) task = NULL; @@ -1308,9 +1294,7 @@ fu_engine_history_inherit (void) g_assert_no_error (error); g_assert (ret); fu_engine_add_plugin (engine, plugin); - testdatadir = fu_test_get_filename (TESTDATADIR, "."); - g_assert (testdatadir != NULL); - g_setenv ("FU_SELF_TEST_REMOTES_DIR", testdatadir, TRUE); + g_setenv ("FU_SELF_TEST_REMOTES_DIR", TESTDATADIR_SRC, TRUE); ret = fu_engine_load (engine, FU_ENGINE_LOAD_FLAG_NO_ENUMERATE, &error); g_assert_no_error (error); g_assert (ret); @@ -1331,8 +1315,7 @@ fu_engine_history_inherit (void) g_assert_cmpint (devices->len, ==, 1); g_assert (fu_device_has_flag (device, FWUPD_DEVICE_FLAG_REGISTERED)); - filename = fu_test_get_filename (TESTDATADIR, "missing-hwid/noreqs-1.2.3.cab"); - g_assert (filename != NULL); + filename = g_build_filename (TESTDATADIR_DST, "missing-hwid", "noreqs-1.2.3.cab", NULL); blob_cab = fu_common_get_contents_bytes (filename, &error); g_assert_no_error (error); g_assert (blob_cab != NULL); @@ -1394,7 +1377,6 @@ fu_engine_history_error_func (void) g_autofree gchar *device_str_expected = NULL; g_autofree gchar *device_str = NULL; g_autofree gchar *filename = NULL; - g_autofree gchar *testdatadir = NULL; g_autoptr(FuDevice) device2 = NULL; g_autoptr(FuDevice) device = fu_device_new (); g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE); @@ -1419,9 +1401,7 @@ fu_engine_history_error_func (void) g_assert (ret); fu_engine_add_plugin (engine, plugin); - testdatadir = fu_test_get_filename (TESTDATADIR, "."); - g_assert (testdatadir != NULL); - g_setenv ("FU_SELF_TEST_REMOTES_DIR", testdatadir, TRUE); + g_setenv ("FU_SELF_TEST_REMOTES_DIR", TESTDATADIR_SRC, TRUE); ret = fu_engine_load (engine, FU_ENGINE_LOAD_FLAG_NO_ENUMERATE, &error); g_assert_no_error (error); g_assert (ret); @@ -1443,8 +1423,7 @@ fu_engine_history_error_func (void) g_assert (fu_device_has_flag (device, FWUPD_DEVICE_FLAG_REGISTERED)); /* install the wrong thing */ - filename = fu_test_get_filename (TESTDATADIR, "missing-hwid/noreqs-1.2.3.cab"); - g_assert (filename != NULL); + filename = g_build_filename (TESTDATADIR_DST, "missing-hwid", "noreqs-1.2.3.cab", NULL); blob_cab = fu_common_get_contents_bytes (filename, &error); g_assert_no_error (error); g_assert (blob_cab != NULL); @@ -1987,7 +1966,7 @@ fu_history_migrate_func (void) g_autofree gchar *filename = NULL; /* load old version */ - filename = fu_test_get_filename (TESTDATADIR, "history_v1.db"); + filename = g_build_filename (TESTDATADIR_SRC, "history_v1.db", NULL); file_src = g_file_new_for_path (filename); file_dst = g_file_new_for_path ("/tmp/fwupd-self-test/var/lib/fwupd/pending.db"); ret = g_file_copy (file_src, file_dst, G_FILE_COPY_OVERWRITE, NULL, @@ -2091,7 +2070,7 @@ fu_plugin_module_func (void) g_signal_connect (device, "notify::status", G_CALLBACK (_plugin_status_changed_cb), &cnt); - mapped_file_fn = fu_test_get_filename (TESTDATADIR, "colorhug/firmware.bin"); + mapped_file_fn = g_build_filename (TESTDATADIR_SRC, "colorhug", "firmware.bin", NULL); mapped_file = g_mapped_file_new (mapped_file_fn, FALSE, &error); g_assert_no_error (error); g_assert (mapped_file != NULL); @@ -2318,15 +2297,13 @@ fu_keyring_gpg_func (void) ret = fu_keyring_setup (keyring, &error); g_assert_no_error (error); g_assert_true (ret); - pki_dir = fu_test_get_filename (TESTDATADIR, "pki"); - g_assert_nonnull (pki_dir); + pki_dir = g_build_filename (TESTDATADIR_SRC, "pki", NULL); ret = fu_keyring_add_public_keys (keyring, pki_dir, &error); g_assert_no_error (error); g_assert_true (ret); /* verify with GnuPG */ - fw_pass = fu_test_get_filename (TESTDATADIR, "colorhug/firmware.bin"); - g_assert_nonnull (fw_pass); + fw_pass = g_build_filename (TESTDATADIR_SRC, "colorhug", "firmware.bin", NULL); blob_pass = fu_common_get_contents_bytes (fw_pass, &error); g_assert_no_error (error); g_assert_nonnull (blob_pass); @@ -2341,8 +2318,7 @@ fu_keyring_gpg_func (void) "3FC6B804410ED0840D8F2F9748A6D80E4538BAC2"); /* verify will fail with GnuPG */ - fw_fail = fu_test_get_filename (TESTDATADIR, "colorhug/colorhug-als-3.0.2.cab"); - g_assert_nonnull (fw_fail); + fw_fail = g_build_filename (TESTDATADIR_DST, "colorhug", "colorhug-als-3.0.2.cab", NULL); blob_fail = fu_common_get_contents_bytes (fw_fail, &error); g_assert_no_error (error); g_assert_nonnull (blob_fail); @@ -2380,20 +2356,17 @@ fu_keyring_pkcs7_func (void) ret = fu_keyring_setup (keyring, &error); g_assert_no_error (error); g_assert_true (ret); - pki_dir = fu_test_get_filename (TESTDATADIR_SRC, "pki"); - g_assert_nonnull (pki_dir); + pki_dir = g_build_filename (TESTDATADIR_SRC, "pki", NULL); ret = fu_keyring_add_public_keys (keyring, pki_dir, &error); g_assert_no_error (error); g_assert_true (ret); /* verify with a signature from the old LVFS */ - fw_pass = fu_test_get_filename (TESTDATADIR_SRC, "colorhug/firmware.bin"); - g_assert_nonnull (fw_pass); + fw_pass = g_build_filename (TESTDATADIR_SRC, "colorhug", "firmware.bin", NULL); blob_pass = fu_common_get_contents_bytes (fw_pass, &error); g_assert_no_error (error); g_assert_nonnull (blob_pass); - sig_fn = fu_test_get_filename (TESTDATADIR_SRC, "colorhug/firmware.bin.p7b"); - g_assert_nonnull (sig_fn); + sig_fn = g_build_filename (TESTDATADIR_SRC, "colorhug", "firmware.bin.p7b", NULL); blob_sig = fu_common_get_contents_bytes (sig_fn, &error); g_assert_no_error (error); g_assert_nonnull (blob_sig); @@ -2406,8 +2379,7 @@ fu_keyring_pkcs7_func (void) g_assert_cmpstr (fu_keyring_result_get_authority (result_pass), == , "O=Linux Vendor Firmware Project,CN=LVFS CA"); /* verify will fail with a self-signed signature */ - sig_fn2 = fu_test_get_filename (TESTDATADIR_DST, "colorhug/firmware.bin.p7c"); - g_assert_nonnull (sig_fn2); + sig_fn2 = g_build_filename (TESTDATADIR_DST, "colorhug", "firmware.bin.p7c", NULL); blob_sig2 = fu_common_get_contents_bytes (sig_fn2, &error); g_assert_no_error (error); g_assert_nonnull (blob_sig2); @@ -2418,8 +2390,7 @@ fu_keyring_pkcs7_func (void) g_clear_error (&error); /* verify will fail with valid signature and different data */ - fw_fail = fu_test_get_filename (TESTDATADIR, "colorhug/colorhug-als-3.0.2.cab"); - g_assert_nonnull (fw_fail); + fw_fail = g_build_filename (TESTDATADIR_DST, "colorhug", "colorhug-als-3.0.2.cab", NULL); blob_fail = fu_common_get_contents_bytes (fw_fail, &error); g_assert_no_error (error); g_assert_nonnull (blob_fail); diff --git a/src/meson.build b/src/meson.build index f59722d3a..ac0d526de 100644 --- a/src/meson.build +++ b/src/meson.build @@ -295,7 +295,6 @@ if get_option('tests') c_args : [ '-DTESTDATADIR_SRC="' + testdatadir_src + '"', '-DTESTDATADIR_DST="' + testdatadir_dst + '"', - '-DTESTDATADIR="' + testdatadir_src + ':' + testdatadir_dst + '"', '-DPLUGINBUILDDIR="' + pluginbuilddir + '"', ], ) From 5beceda89b46b97560a424bb049be8ef075471ba Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Wed, 27 Nov 2019 06:39:04 -0600 Subject: [PATCH 62/74] trivial: Move progressbar out of libfwupdplugin The intention with f0f504c740144daadb8860a1d0512ed319d2ed62 was to not offer this in the plugin, but when rebasing 6b0e66354b1b7007cb525a3d3c8280bf9001e880 this was forgotten to be removed. --- libfwupdplugin/fu-self-test.c | 30 ----------------------- libfwupdplugin/fwupdplugin.h | 1 - libfwupdplugin/fwupdplugin.map | 7 ------ libfwupdplugin/meson.build | 2 -- po/POTFILES.in | 2 +- {libfwupdplugin => src}/fu-progressbar.c | 0 {libfwupdplugin => src}/fu-progressbar.h | 0 src/fu-self-test.c | 31 ++++++++++++++++++++++++ src/meson.build | 3 +++ 9 files changed, 35 insertions(+), 41 deletions(-) rename {libfwupdplugin => src}/fu-progressbar.c (100%) rename {libfwupdplugin => src}/fu-progressbar.h (100%) diff --git a/libfwupdplugin/fu-self-test.c b/libfwupdplugin/fu-self-test.c index 6eb2f95dd..ec379002c 100644 --- a/libfwupdplugin/fu-self-test.c +++ b/libfwupdplugin/fu-self-test.c @@ -591,34 +591,6 @@ fu_common_spawn_timeout_func (void) g_assert_cmpint (lines, ==, 1); } -static void -fu_progressbar_func (void) -{ - g_autoptr(FuProgressbar) progressbar = fu_progressbar_new (); - - fu_progressbar_set_length_status (progressbar, 20); - fu_progressbar_set_length_percentage (progressbar, 50); - - g_print ("\n"); - for (guint i = 0; i < 100; i++) { - fu_progressbar_update (progressbar, FWUPD_STATUS_DECOMPRESSING, i); - g_usleep (10000); - } - fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); - for (guint i = 0; i < 100; i++) { - guint pc = (i > 25 && i < 75) ? 0 : i; - fu_progressbar_update (progressbar, FWUPD_STATUS_LOADING, pc); - g_usleep (10000); - } - fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); - - for (guint i = 0; i < 5000; i++) { - fu_progressbar_update (progressbar, FWUPD_STATUS_LOADING, 0); - g_usleep (1000); - } - fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); -} - static void fu_common_endian_func (void) { @@ -1569,8 +1541,6 @@ main (int argc, char **argv) g_setenv ("FWUPD_OFFLINE_TRIGGER", "/tmp/fwupd-self-test/system-update", TRUE); g_setenv ("FWUPD_LOCALSTATEDIR", "/tmp/fwupd-self-test/var", TRUE); - if (g_test_slow ()) - g_test_add_func ("/fwupd/progressbar", fu_progressbar_func); g_test_add_func ("/fwupd/plugin{delay}", fu_plugin_delay_func); g_test_add_func ("/fwupd/plugin{quirks}", fu_plugin_quirks_func); g_test_add_func ("/fwupd/plugin{quirks-performance}", fu_plugin_quirks_performance_func); diff --git a/libfwupdplugin/fwupdplugin.h b/libfwupdplugin/fwupdplugin.h index 5c647cd55..6ef9271b1 100644 --- a/libfwupdplugin/fwupdplugin.h +++ b/libfwupdplugin/fwupdplugin.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/libfwupdplugin/fwupdplugin.map b/libfwupdplugin/fwupdplugin.map index e762f969b..333b305fe 100644 --- a/libfwupdplugin/fwupdplugin.map +++ b/libfwupdplugin/fwupdplugin.map @@ -113,13 +113,6 @@ LIBFWUPDPLUGIN_0.9.7 { fu_plugin_get_dmi_value; fu_plugin_runner_device_register; fu_plugin_set_hwids; - fu_progressbar_get_type; - fu_progressbar_new; - fu_progressbar_set_interactive; - fu_progressbar_set_length_percentage; - fu_progressbar_set_length_status; - fu_progressbar_set_title; - fu_progressbar_update; local: *; } LIBFWUPDPLUGIN_0.9.5; diff --git a/libfwupdplugin/meson.build b/libfwupdplugin/meson.build index 1d781eea1..13d8dd2ec 100644 --- a/libfwupdplugin/meson.build +++ b/libfwupdplugin/meson.build @@ -15,7 +15,6 @@ fwupdplugin_src = [ 'fu-ihex-firmware.c', 'fu-io-channel.c', 'fu-plugin.c', - 'fu-progressbar.c', 'fu-quirks.c', 'fu-smbios.c', 'fu-srec-firmware.c', @@ -41,7 +40,6 @@ fwupdplugin_headers = [ 'fu-ihex-firmware.h', 'fu-io-channel.h', 'fu-plugin.h', - 'fu-progressbar.h', 'fu-quirks.h', 'fu-smbios.h', 'fu-srec-firmware.h', diff --git a/po/POTFILES.in b/po/POTFILES.in index c47b5e05d..7494ccf29 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,6 +1,5 @@ data/remotes.d/lvfs.metainfo.xml data/remotes.d/lvfs-testing.metainfo.xml -libfwupdplugin/fu-progressbar.c policy/org.freedesktop.fwupd.policy.in plugins/dfu/dfu-tool.c plugins/uefi/fu-plugin-uefi.c @@ -10,6 +9,7 @@ src/fu-config.c src/fu-debug.c src/fu-main.c src/fu-offline.c +src/fu-progressbar.c src/fu-tool.c src/fu-util.c src/fu-util-common.c diff --git a/libfwupdplugin/fu-progressbar.c b/src/fu-progressbar.c similarity index 100% rename from libfwupdplugin/fu-progressbar.c rename to src/fu-progressbar.c diff --git a/libfwupdplugin/fu-progressbar.h b/src/fu-progressbar.h similarity index 100% rename from libfwupdplugin/fu-progressbar.h rename to src/fu-progressbar.h diff --git a/src/fu-self-test.c b/src/fu-self-test.c index cdec24c4b..6f0eb7793 100644 --- a/src/fu-self-test.c +++ b/src/fu-self-test.c @@ -24,6 +24,7 @@ #include "fu-install-task.h" #include "fu-plugin-private.h" #include "fu-plugin-list.h" +#include "fu-progressbar.h" #include "fu-hash.h" #include "fu-smbios-private.h" @@ -2751,6 +2752,34 @@ fu_memcpy_func (void) g_clear_error (&error); } +static void +fu_progressbar_func (void) +{ + g_autoptr(FuProgressbar) progressbar = fu_progressbar_new (); + + fu_progressbar_set_length_status (progressbar, 20); + fu_progressbar_set_length_percentage (progressbar, 50); + + g_print ("\n"); + for (guint i = 0; i < 100; i++) { + fu_progressbar_update (progressbar, FWUPD_STATUS_DECOMPRESSING, i); + g_usleep (10000); + } + fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); + for (guint i = 0; i < 100; i++) { + guint pc = (i > 25 && i < 75) ? 0 : i; + fu_progressbar_update (progressbar, FWUPD_STATUS_LOADING, pc); + g_usleep (10000); + } + fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); + + for (guint i = 0; i < 5000; i++) { + fu_progressbar_update (progressbar, FWUPD_STATUS_LOADING, 0); + g_usleep (1000); + } + fu_progressbar_update (progressbar, FWUPD_STATUS_IDLE, 0); +} + int main (int argc, char **argv) { @@ -2770,6 +2799,8 @@ main (int argc, char **argv) fu_self_test_mkroot (); /* tests go here */ + if (g_test_slow ()) + g_test_add_func ("/fwupd/progressbar", fu_progressbar_func); g_test_add_func ("/fwupd/plugin{build-hash}", fu_plugin_hash_func); g_test_add_func ("/fwupd/plugin{module}", fu_plugin_module_func); g_test_add_func ("/fwupd/memcpy", fu_memcpy_func); diff --git a/src/meson.build b/src/meson.build index ac0d526de..83e611977 100644 --- a/src/meson.build +++ b/src/meson.build @@ -29,6 +29,7 @@ fwupdmgr = executable( sources : [ 'fu-util.c', 'fu-history.c', + 'fu-progressbar.c', 'fu-util-common.c', systemd_src ], @@ -143,6 +144,7 @@ fwupdtool = executable( 'fu-keyring-result.c', 'fu-keyring-utils.c', 'fu-plugin-list.c', + 'fu-progressbar.c', 'fu-util-common.c', systemd_src ], @@ -266,6 +268,7 @@ if get_option('tests') 'fu-keyring-result.c', 'fu-keyring-utils.c', 'fu-plugin-list.c', + 'fu-progressbar.c', 'fu-self-test.c', systemd_src ], From bd947404043965b5cd5afd278696b01be1e44aa7 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Wed, 13 Nov 2019 03:03:01 -0500 Subject: [PATCH 63/74] plugins/coreboot: Get rid of FU_HWIDS_KEY_BIOS_VENDOR in coldplug In fu_plugin_startup we make sure that the FU_HWIDS_KEY_BIOS_VENDOR matches "coreboot", so there's no need to read it again. Remove the call to fu_plugin_get_dmi_value and drop the first call to fu_device_set_vendor as it gets overwritten below. Hardcode the id string for now. Signed-off-by: Patrick Rudolph --- plugins/coreboot/fu-plugin-coreboot.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/plugins/coreboot/fu-plugin-coreboot.c b/plugins/coreboot/fu-plugin-coreboot.c index a78368b3b..3ce5b4eae 100644 --- a/plugins/coreboot/fu-plugin-coreboot.c +++ b/plugins/coreboot/fu-plugin-coreboot.c @@ -28,7 +28,6 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) { const gchar *major; const gchar *minor; - const gchar *vendor; const gchar *version; GBytes *bios_table; gboolean updatable = FALSE; /* TODO: Implement update support */ @@ -45,15 +44,6 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) "HardwareID-10", }; - vendor = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VENDOR); - if (vendor == NULL) { - g_set_error (error, - G_IO_ERROR, - G_IO_ERROR_NOT_FOUND, - "Failed to get DMI value FU_HWIDS_KEY_BIOS_VENDOR"); - return FALSE; - } - version = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VERSION); if (version != NULL) triplet = fu_plugin_coreboot_version_string_to_triplet (version, error); @@ -90,8 +80,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) fu_device_set_version (dev, triplet, FWUPD_VERSION_FORMAT_TRIPLET); fu_device_set_summary (dev, "Open Source system boot firmware"); - fu_device_set_id (dev, vendor); - fu_device_set_vendor (dev, vendor); + fu_device_set_id (dev, "coreboot"); fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_INTERNAL); fu_device_add_icon (dev, "computer"); name = fu_plugin_coreboot_get_name_for_type (plugin, NULL); From b21c3af2eaded9de7e97f6226ea88451194e4e4a Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Wed, 13 Nov 2019 07:07:34 -0500 Subject: [PATCH 64/74] plugins/coreboot: Improve version detection Only on Lenovo devices the DMI version string is prefixed with CBETxxxx to make the thinkpad_acpi kernel module happy. Add a new quirk called "CorebootVersionQuirks" to detect platforms that need to cut of the prefix. Signed-off-by: Patrick Rudolph --- plugins/coreboot/README.md | 15 ++++++- plugins/coreboot/coreboot.quirk | 2 + plugins/coreboot/fu-coreboot-common.c | 59 +++++++++++++++++++++++++-- plugins/coreboot/fu-plugin-coreboot.c | 2 +- plugins/coreboot/fu-plugin-coreboot.h | 1 + plugins/coreboot/meson.build | 4 ++ 6 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 plugins/coreboot/coreboot.quirk diff --git a/plugins/coreboot/README.md b/plugins/coreboot/README.md index cfaf1aded..e7b55613e 100644 --- a/plugins/coreboot/README.md +++ b/plugins/coreboot/README.md @@ -20,13 +20,24 @@ coreboot can be detected the following ways: coreboot version string ----------------------- -The coreboot version string always starts with `CBET`. -After the prefix the *version*, *major*, *minor* string follows and finally +The coreboot version string can have an optional prefix (see below). +After the optional prefix the *major*, *minor* string follows and finally the *build string*, containing the exact commit and repository state, follows. +For example: +> 4.10-989-gc8a4e4b9c5-dirty + +**Exception on Lenovo devices:** + +The thinkpad_acpi kernel module requires a specific pattern in the DMI version +string. To satisfy those requirements coreboot adds the CBETxxxx prefix to the +DMI version string on all Lenovo devices. + For example: > CBET4000 4.10-989-gc8a4e4b9c5-dirty +The coreboot DMI version string always starts with `CBET`. + GUID Generation --------------- diff --git a/plugins/coreboot/coreboot.quirk b/plugins/coreboot/coreboot.quirk new file mode 100644 index 000000000..2884572b2 --- /dev/null +++ b/plugins/coreboot/coreboot.quirk @@ -0,0 +1,2 @@ +[SmbiosManufacturer=LENOVO] +CorebootVersionQuirks = lenovo-cbet-prefix diff --git a/plugins/coreboot/fu-coreboot-common.c b/plugins/coreboot/fu-coreboot-common.c index 19202a13b..3bb6f1b22 100644 --- a/plugins/coreboot/fu-coreboot-common.c +++ b/plugins/coreboot/fu-coreboot-common.c @@ -11,20 +11,37 @@ #include "fu-plugin-coreboot.h" +/** + * FU_QUIRKS_COREBOOT_VERSION: + * @key: The SMBIOS manufacturer name + * @value: One of the following: "lenovo-cbet-prefix" + * + * "lenovo-cbet-prefix" quirk: + * The thinkpad_acpi kernel module requires a specific pattern + * in the DMI version string. To satisfy those requirements + * coreboot adds the CBETxxxx prefix to the DMI version string + * on all Lenovo devices. The prefix isn't present in the + * version string found in coreboot tables, or on other + * coreboot enabled devices. + * + * Since: 1.3.5 + */ +#define FU_QUIRKS_COREBOOT_VERSION "CorebootVersionQuirks" +#define FU_QUIRK_CBET_PREFIX "lenovo-cbet-prefix" + /* Tries to convert the coreboot version string to a triplet string. * Returns NULL on error. */ gchar * fu_plugin_coreboot_version_string_to_triplet (const gchar *coreboot_version, GError **error) { - guint cb_version = 0; guint cb_major = 0; guint cb_minor = 0; guint cb_build = 0; gint rc; - rc = sscanf (coreboot_version, "CBET%u %u.%u-%u", &cb_version, &cb_major, - &cb_minor, &cb_build); + rc = sscanf (coreboot_version, "%u.%u-%u", &cb_major, &cb_minor, &cb_build); + if (rc < 0) { g_set_error (error, G_IO_ERROR, @@ -34,7 +51,7 @@ fu_plugin_coreboot_version_string_to_triplet (const gchar *coreboot_version, } /* Sanity check */ - if (cb_major == 0 || cb_version == 0) { + if (cb_major == 0) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA, @@ -62,3 +79,37 @@ fu_plugin_coreboot_get_name_for_type (FuPlugin *plugin, g_string_prepend (display_name, "coreboot System Firmware"); return g_string_free (display_name, FALSE); } + +/* Returns the version string with possible quirks applied */ +gchar * +fu_plugin_coreboot_get_version_string (FuPlugin *plugin) +{ + const gchar *version; + const gchar *manufacturer; + const gchar *quirk = NULL; + + version = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VERSION); + if (version == NULL) + return NULL; + + manufacturer = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_MANUFACTURER); + if (manufacturer != NULL) { + g_autofree gchar *group = NULL; + + /* any quirks match */ + group = g_strdup_printf ("SmbiosManufacturer=%s", manufacturer); + quirk = fu_plugin_lookup_quirk_by_id (plugin, group, + FU_QUIRKS_COREBOOT_VERSION); + } + + if (quirk == NULL) + return version; + + if (g_strcmp0(quirk, FU_QUIRK_CBET_PREFIX) == 0) { + if (strlen (version) > 9 && g_str_has_prefix (version, "CBET")) + version += 9; + return version; + } + + return version; +} diff --git a/plugins/coreboot/fu-plugin-coreboot.c b/plugins/coreboot/fu-plugin-coreboot.c index 3ce5b4eae..72dd2896c 100644 --- a/plugins/coreboot/fu-plugin-coreboot.c +++ b/plugins/coreboot/fu-plugin-coreboot.c @@ -44,7 +44,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error) "HardwareID-10", }; - version = fu_plugin_get_dmi_value (plugin, FU_HWIDS_KEY_BIOS_VERSION); + version = fu_plugin_coreboot_get_version_string (plugin); if (version != NULL) triplet = fu_plugin_coreboot_version_string_to_triplet (version, error); diff --git a/plugins/coreboot/fu-plugin-coreboot.h b/plugins/coreboot/fu-plugin-coreboot.h index e6260f6e4..436f2c844 100644 --- a/plugins/coreboot/fu-plugin-coreboot.h +++ b/plugins/coreboot/fu-plugin-coreboot.h @@ -13,3 +13,4 @@ gchar *fu_plugin_coreboot_version_string_to_triplet (const gchar *coreboot_vers GError **error); gchar *fu_plugin_coreboot_get_name_for_type (FuPlugin *plugin, const gchar *vboot_partition); +gchar *fu_plugin_coreboot_get_version_string (FuPlugin *plugin); diff --git a/plugins/coreboot/meson.build b/plugins/coreboot/meson.build index da0026971..2ec0270f9 100644 --- a/plugins/coreboot/meson.build +++ b/plugins/coreboot/meson.build @@ -1,5 +1,9 @@ cargs = ['-DG_LOG_DOMAIN="FuPluginCoreboot"'] +install_data(['coreboot.quirk'], + install_dir: join_paths(datadir, 'fwupd', 'quirks.d') +) + shared_module('fu_plugin_coreboot', sources : [ 'fu-plugin-coreboot.c', From 0ef2fde83f2a6f5ad9140b8451789b82ca8fb733 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Wed, 27 Nov 2019 06:52:27 -0600 Subject: [PATCH 65/74] trivial: libfwupdplugin: clarify name of self test --- libfwupdplugin/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfwupdplugin/meson.build b/libfwupdplugin/meson.build index 13d8dd2ec..84a4f9261 100644 --- a/libfwupdplugin/meson.build +++ b/libfwupdplugin/meson.build @@ -240,7 +240,7 @@ if get_option('tests') '-DPLUGINBUILDDIR="' + pluginbuilddir + '"', ], ) - test('fu-self-test', e, is_parallel:false, timeout:180) + test('fwupdplugin-self-test', e, is_parallel:false, timeout:180) endif fwupdplugin_incdir = include_directories('.') From 6e5fd3b3d801a0afcb40f12a54c86ed846220749 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 14:40:49 +0000 Subject: [PATCH 66/74] trivial: Fix coreboot commit to fix CI --- plugins/coreboot/fu-coreboot-common.c | 2 +- plugins/coreboot/fu-plugin-coreboot.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/coreboot/fu-coreboot-common.c b/plugins/coreboot/fu-coreboot-common.c index 3bb6f1b22..cfc55150d 100644 --- a/plugins/coreboot/fu-coreboot-common.c +++ b/plugins/coreboot/fu-coreboot-common.c @@ -81,7 +81,7 @@ fu_plugin_coreboot_get_name_for_type (FuPlugin *plugin, } /* Returns the version string with possible quirks applied */ -gchar * +const gchar * fu_plugin_coreboot_get_version_string (FuPlugin *plugin) { const gchar *version; diff --git a/plugins/coreboot/fu-plugin-coreboot.h b/plugins/coreboot/fu-plugin-coreboot.h index 436f2c844..442399d24 100644 --- a/plugins/coreboot/fu-plugin-coreboot.h +++ b/plugins/coreboot/fu-plugin-coreboot.h @@ -13,4 +13,4 @@ gchar *fu_plugin_coreboot_version_string_to_triplet (const gchar *coreboot_vers GError **error); gchar *fu_plugin_coreboot_get_name_for_type (FuPlugin *plugin, const gchar *vboot_partition); -gchar *fu_plugin_coreboot_get_version_string (FuPlugin *plugin); +const gchar *fu_plugin_coreboot_get_version_string (FuPlugin *plugin); From 83613aa9322b97db65b077fdf798071e24022a63 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 16:10:17 +0000 Subject: [PATCH 67/74] trivial: Add a BR for Fedora --- contrib/fwupd.spec.in | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/fwupd.spec.in b/contrib/fwupd.spec.in index e8d7b895e..50fc00be9 100644 --- a/contrib/fwupd.spec.in +++ b/contrib/fwupd.spec.in @@ -69,6 +69,7 @@ BuildRequires: help2man BuildRequires: json-glib-devel >= %{json_glib_version} BuildRequires: vala BuildRequires: bash-completion +BuildRequires: git-core %if 0%{?have_modem_manager} BuildRequires: ModemManager-glib-devel >= 1.10.0 From 6aceaf9409cd03ad847140196b2a3dfa858e7086 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 27 Nov 2019 16:36:17 +0000 Subject: [PATCH 68/74] trivial: Fix a NULL/FALSE confusion --- plugins/vli-usbhub/fu-vli-usbhub-pd-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/vli-usbhub/fu-vli-usbhub-pd-device.c b/plugins/vli-usbhub/fu-vli-usbhub-pd-device.c index 0ebbf7f08..848cef2aa 100644 --- a/plugins/vli-usbhub/fu-vli-usbhub-pd-device.c +++ b/plugins/vli-usbhub/fu-vli-usbhub-pd-device.c @@ -135,7 +135,7 @@ fu_vli_usbhub_pd_device_read_firmware (FuDevice *device, GError **error) /* open device */ locker = fu_device_locker_new (parent, error); if (locker == NULL) - return FALSE; + return NULL; /* read */ fu_device_set_status (FU_DEVICE (device), FWUPD_STATUS_DEVICE_VERIFY); From 923120e55fa44b4282d482106fcc02ba756cc601 Mon Sep 17 00:00:00 2001 From: Crag Wang Date: Thu, 28 Nov 2019 14:42:20 +0800 Subject: [PATCH 69/74] trivial: wacom: remove coretronic config from Moffett scope --- plugins/wacom-raw/wacom-raw.quirk | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/plugins/wacom-raw/wacom-raw.quirk b/plugins/wacom-raw/wacom-raw.quirk index 3829fa7f7..d87035a44 100644 --- a/plugins/wacom-raw/wacom-raw.quirk +++ b/plugins/wacom-raw/wacom-raw.quirk @@ -22,16 +22,6 @@ Guid = WacomAES Plugin = wacom_raw Guid = WacomAES -# Moffet 14-Coretronic-TPK -[DeviceInstanceId=HIDRAW\VEN_2D1F&DEV_4973] -Plugin = wacom_raw -Guid = WacomAES - -# Moffet 14-Coretronic-HH -[DeviceInstanceId=HIDRAW\VEN_2D1F&DEV_4974] -Plugin = wacom_raw -Guid = WacomAES - # Dell Latitude 5175 [DeviceInstanceId=HIDRAW\VEN_056A&DEV_4807] Plugin = wacom_raw From 6d80b84b959b970311c73bd71982227522a27322 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 29 Nov 2019 12:03:04 +0000 Subject: [PATCH 70/74] synaptics-prometheus: Reload the device version after update --- plugins/synaptics-prometheus/fu-synaprom-device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/synaptics-prometheus/fu-synaprom-device.c b/plugins/synaptics-prometheus/fu-synaprom-device.c index 45d1a4f51..c730ddcb6 100644 --- a/plugins/synaptics-prometheus/fu-synaprom-device.c +++ b/plugins/synaptics-prometheus/fu-synaprom-device.c @@ -204,7 +204,8 @@ fu_synaprom_device_setup (FuDevice *device, GError **error) } /* add updatable config child, if this is a production sensor */ - if (!fu_device_has_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER) && + if (fu_device_get_children (device)->len == 0 && + !fu_device_has_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER) && pkt.security[1] & FU_SYNAPROM_SECURITY1_PROD_SENSOR) { g_autoptr(FuSynapromConfig) cfg = fu_synaprom_config_new (self); if (!fu_device_setup (FU_DEVICE (cfg), error)) { @@ -454,6 +455,7 @@ fu_synaprom_device_class_init (FuSynapromDeviceClass *klass) klass_device->write_firmware = fu_synaprom_device_write_firmware; klass_device->prepare_firmware = fu_synaprom_device_prepare_fw; klass_device->setup = fu_synaprom_device_setup; + klass_device->reload = fu_synaprom_device_setup; klass_device->attach = fu_synaprom_device_attach; klass_device->detach = fu_synaprom_device_detach; klass_usb_device->open = fu_synaprom_device_open; From 1d797668fa824a6eb5d420955b955e556a02834e Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 29 Nov 2019 12:04:42 +0000 Subject: [PATCH 71/74] synaptics-prometheus: Reload the device version after IOTA update --- plugins/synaptics-prometheus/fu-synaprom-config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/synaptics-prometheus/fu-synaprom-config.c b/plugins/synaptics-prometheus/fu-synaprom-config.c index 480c1a517..b108b936c 100644 --- a/plugins/synaptics-prometheus/fu-synaprom-config.c +++ b/plugins/synaptics-prometheus/fu-synaprom-config.c @@ -265,6 +265,7 @@ fu_synaprom_config_class_init (FuSynapromConfigClass *klass) klass_device->open = fu_synaprom_config_open; klass_device->close = fu_synaprom_config_close; klass_device->setup = fu_synaprom_config_setup; + klass_device->reload = fu_synaprom_config_setup; klass_device->attach = fu_synaprom_config_attach; klass_device->detach = fu_synaprom_config_detach; } From 15daf69ad9a142c654c761e99c3f49754de7b07a Mon Sep 17 00:00:00 2001 From: Francois Berder <18538310+francois-berder@users.noreply.github.com> Date: Fri, 29 Nov 2019 11:00:08 +0000 Subject: [PATCH 72/74] Fix shifting integer by more than 31 in fu_util_filter_device Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com> --- src/fu-util.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/fu-util.c b/src/fu-util.c index 1b6eaa7fc..67abc47b2 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -146,12 +146,13 @@ static gboolean fu_util_filter_device (FuUtilPrivate *priv, FwupdDevice *dev) { for (guint i = 0; i < 64; i++) { - if (priv->filter_include & (1 << i)) { - if (!fwupd_device_has_flag (dev, (1 << i))) + FwupdDeviceFlags flag = 1LLU << i; + if (priv->filter_include & flag) { + if (!fwupd_device_has_flag (dev, flag)) return FALSE; } - if (priv->filter_exclude & (1 << i)) { - if (fwupd_device_has_flag (dev, (1 << i))) + if (priv->filter_exclude & flag) { + if (fwupd_device_has_flag (dev, flag)) return FALSE; } } From bb5385de76623c04bcc60e8fd7e516d581c7d25f Mon Sep 17 00:00:00 2001 From: Francois Berder <18538310+francois-berder@users.noreply.github.com> Date: Fri, 29 Nov 2019 11:01:49 +0000 Subject: [PATCH 73/74] plugins: Fix potential use of NULL pointer in fu_dell_dock_mst_write_register Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com> --- plugins/dell-dock/fu-dell-dock-i2c-mst.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/dell-dock/fu-dell-dock-i2c-mst.c b/plugins/dell-dock/fu-dell-dock-i2c-mst.c index de729209e..072b3eec4 100644 --- a/plugins/dell-dock/fu-dell-dock-i2c-mst.c +++ b/plugins/dell-dock/fu-dell-dock-i2c-mst.c @@ -185,12 +185,13 @@ fu_dell_dock_mst_write_register (FuDevice *symbiote, GError **error) { g_autofree guint8 *buffer = g_malloc0 (length + 4); - memcpy (buffer, &address, 4); - memcpy (buffer + 4, data, length); g_return_val_if_fail (symbiote != NULL, FALSE); g_return_val_if_fail (data != NULL, FALSE); + memcpy (buffer, &address, 4); + memcpy (buffer + 4, data, length); + /* write the offset we're querying */ return fu_dell_dock_hid_i2c_write (symbiote, buffer, length + 4, &mst_base_settings, error); From 713d20f79fa0e460c02f109d68f3ad5e825e6298 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 29 Nov 2019 12:32:27 +0000 Subject: [PATCH 74/74] Release fwupd 1.3.5 --- data/org.freedesktop.fwupd.metainfo.xml | 17 ++ po/ko.po | 388 ++++++++++++++++++++++++ 2 files changed, 405 insertions(+) diff --git a/data/org.freedesktop.fwupd.metainfo.xml b/data/org.freedesktop.fwupd.metainfo.xml index 1138bd1bb..3fb71ffe4 100644 --- a/data/org.freedesktop.fwupd.metainfo.xml +++ b/data/org.freedesktop.fwupd.metainfo.xml @@ -32,6 +32,23 @@ fwupdmgr + + +

This release adds the following features:

+
    +
  • Convert libfwupdprivate to a shared library libfwupdplugin
  • +
  • Create a REV_00 instance ID as this may be what the vendor needs to target
  • +
+

This release fixes the following bugs:

+
    +
  • Improve coreboot version detection
  • +
  • Invert default behavior to be safer for reboot and shutdown prompts
  • +
  • Reload the Synaptics prometheus device version after update
  • +
  • Use the correct unlocker when using GRWLock
  • +
  • Whitelist VIA USB hub PD and I²C devices
  • +
+
+

This release adds the following features:

diff --git a/po/ko.po b/po/ko.po index 5a7baa41c..08ba6a057 100644 --- a/po/ko.po +++ b/po/ko.po @@ -65,6 +65,13 @@ msgstr "%s ME 업데이트" msgid "%s System Update" msgstr "%s 시스템 업데이트" +#. TRANSLATORS: the Thunderbolt controller is a device that +#. * has other high speed Thunderbolt devices plugged into it; +#. * the first %s is the system name, e.g. 'ThinkPad P50` +#, c-format +msgid "%s Thunderbolt Controller Update" +msgstr "%s Thunderbolt 컨트롤러 업데이트" + #. TRANSLATORS: this is the fallback where we don't know if the release #. * is updating the system, the device, or a device class, or something else #. -- @@ -73,6 +80,21 @@ msgstr "%s 시스템 업데이트" msgid "%s Update" msgstr "%s 업데이트" +#. TRANSLATORS: warn the user before updating, %1 is a device name +#, c-format +msgid "%s and all connected devices may not be usable while updating." +msgstr "업데이트 중에는 %s 및 연결된 모든 장치를 사용할 수 없을 수도 있습니다." + +#. TRANSLATORS: warn the user before updating, %1 is a device name +#, c-format +msgid "%s must remain connected for the duration of the update to avoid damage." +msgstr "장치 손상을 방지하려면 업데이트 중 %s의 연결을 계속 유지해야 합니다." + +#. TRANSLATORS: warn the user before updating, %1 is a machine name +#, c-format +msgid "%s must remain plugged into a power source for the duration of the update to avoid damage." +msgstr "장치 손상을 방지하려면 업데이트 중 %s을(를) 전원에 계속 연결해 두어야 합니다." + #. TRANSLATORS: duration in days! #, c-format msgid "%u day" @@ -85,6 +107,12 @@ msgid "%u hour" msgid_plural "%u hours" msgstr[0] "%u시간" +#. TRANSLATORS: how many local devices can expect updates now +#, c-format +msgid "%u local device supported" +msgid_plural "%u local devices supported" +msgstr[0] "로컬 장치 %u개를 지원함" + #. TRANSLATORS: duration in minutes #, c-format msgid "%u minute" @@ -137,6 +165,10 @@ msgstr "%s의 별칭" msgid "Allow downgrading firmware versions" msgstr "펌웨어 다운그레이드를 허용합니다" +#. TRANSLATORS: command line option +msgid "Allow reinstalling existing firmware versions" +msgstr "기존 펌웨어 버전 재설치를 허용합니다" + #. TRANSLATORS: explain why we want to reboot msgid "An update requires a reboot to complete." msgstr "업데이트를 완료하려면 다시 시작해야 합니다." @@ -211,6 +243,14 @@ msgstr "이 머신의 펌웨어를 업데이트하려면 인증해야 합니다" msgid "Authentication is required to update the stored checksums for the device" msgstr "저장된 체크섬을 업데이트하려면 인증해야 합니다" +#. TRANSLATORS: Boolean value to automatically send reports +msgid "Automatic Reporting" +msgstr "자동 보고" + +#. TRANSLATORS: firmware version of bootloader +msgid "Bootloader Version" +msgstr "부트로더 버전" + #. TRANSLATORS: command description msgid "Build firmware using a sandbox" msgstr "샌드박스에서 펌웨어를 빌드합니다" @@ -228,6 +268,10 @@ msgstr "취소함" msgid "Changed" msgstr "바뀜" +#. TRANSLATORS: command description +msgid "Checks cryptographic hash matches firmware" +msgstr "암호화 해시가 펌웨어와 일치하는지 확인합니다" + #. TRANSLATORS: remote checksum msgid "Checksum" msgstr "체크섬" @@ -236,6 +280,10 @@ msgstr "체크섬" msgid "Choose a device:" msgstr "장치를 선택하십시오:" +#. TRANSLATORS: get interactive prompt +msgid "Choose a firmware type:" +msgstr "펌웨어 종류를 선택하십시오:" + #. TRANSLATORS: get interactive prompt msgid "Choose a release:" msgstr "출시 버전을 선택하십시오:" @@ -252,10 +300,22 @@ msgstr "최근 업데이트 결과를 지웁니다" msgid "Command not found" msgstr "명령을 찾을 수 없습니다" +#. TRANSLATORS: prompt to apply the update +msgid "Continue with update?" +msgstr "업데이트를 계속 진행하시겠습니까?" + #. TRANSLATORS: command description msgid "Convert firmware to DFU format" msgstr "펌웨어를 DFU 형식으로 변환" +#. TRANSLATORS: Device supports some form of checksum verification +msgid "Cryptographic hash verification is available" +msgstr "암호화 해시 검사 사용 가능" + +#. TRANSLATORS: version number of current firmware +msgid "Current version" +msgstr "현재 버전" + #. TRANSLATORS: DFU stands for device firmware update msgid "DFU Utility" msgstr "DFU 유틸리티" @@ -276,6 +336,14 @@ msgstr "설명" msgid "Detach to bootloader mode" msgstr "부트로더 모드로 전환" +#. TRANSLATORS: more details about the update link +msgid "Details" +msgstr "자세한 정보" + +#. TRANSLATORS: description of device ability +msgid "Device Flags" +msgstr "장치 플래그" + #. TRANSLATORS: ID for hardware, typically a SHA1 sum msgid "Device ID" msgstr "장치 ID" @@ -284,14 +352,38 @@ msgstr "장치 ID" msgid "Device added:" msgstr "장치 추가됨:" +#. TRANSLATORS: Device supports a safety mechanism for flashing +msgid "Device can recover flash failures" +msgstr "장치 업데이트 실패 시 복구 가능" + #. TRANSLATORS: this is when a device has been updated msgid "Device changed:" msgstr "장치 상태 바뀜:" +#. TRANSLATORS: Is locked and can be unlocked +msgid "Device is locked" +msgstr "장치가 잠김" + +#. TRANSLATORS: Device remains usable during update +msgid "Device is usable for the duration of the update" +msgstr "업데이트 중 장치를 사용할 수 있음" + #. TRANSLATORS: this is when a device is hotplugged msgid "Device removed:" msgstr "장치 제거됨:" +#. TRANSLATORS: Device supports a safety mechanism for flashing +msgid "Device stages updates" +msgstr "안전한 업데이트 지원" + +#. TRANSLATORS: Device update needs to be separately activated +msgid "Device update needs activation" +msgstr "장치 업데이트 활성화 필요" + +#. TRANSLATORS: Device will not return after update completes +msgid "Device will not re-appear after update completes" +msgstr "업데이트 후 장치가 다시 표시되지 않음" + #. TRANSLATORS: a list of successful updates msgid "Devices that have been updated successfully:" msgstr "성공적으로 업데이트된 장치:" @@ -323,6 +415,26 @@ msgstr "업데이트 후 다시 시작 검사하지 않기" msgid "Do not check for unreported history" msgstr "보고되지 않은 과거 기록 검사하지 않기" +#. TRANSLATORS: turn on all debugging +msgid "Do not include log domain prefix" +msgstr "로그 도메인 접두사를 포함하지 않기" + +#. TRANSLATORS: turn on all debugging +msgid "Do not include timestamp prefix" +msgstr "timestamp 접두사를 포함하지 않기" + +#. TRANSLATORS: command line option +msgid "Do not perform device safety checks" +msgstr "장치 안정성 검사를 실행하지 않습니다" + +msgid "Do not upload report at this time, but prompt again for future updates" +msgid_plural "Do not upload reports at this time, but prompt again for future updates" +msgstr[0] "지금 보고서를 업로드하지 않고 다음에 업데이트할 때 묻기" + +msgid "Do not upload report, and never ask to upload reports for future updates" +msgid_plural "Do not upload reports, and never ask to upload reports for future updates" +msgstr[0] "보고서를 업로드하지 않고 다음에 업데이트할 때에도 다시 묻지 않기" + #. TRANSLATORS: command line option msgid "Do not write to the history database" msgstr "과거 기록 데이터베이스에 기록하지 않기" @@ -359,6 +471,10 @@ msgstr "파일에 저장된 SMBIOS 데이터 덤프를 출력합니다" msgid "Dump details about a firmware file" msgstr "펌웨어 파일 세부 정보 출력" +#. TRANSLATORS: length of time the update takes to apply +msgid "Duration" +msgstr "예상 시간" + #. TRANSLATORS: ESP is EFI System Partition msgid "ESP specified was not valid" msgstr "지정한 ESP가 올바르지 않습니다" @@ -429,6 +545,10 @@ msgstr "특이 사항을 불러올 수 없음" msgid "Failed to parse arguments" msgstr "인자 해석에 실패했습니다" +#. TRANSLATORS: the user didn't read the man page +msgid "Failed to parse flags for --filter" +msgstr "--filter에 전달한 플래그 해석에 실패함" + #. TRANSLATORS: we could not reboot for some reason msgid "Failed to reboot" msgstr "다시 시작할 수 없음" @@ -461,6 +581,10 @@ msgstr "파일 이름" msgid "Filename Signature" msgstr "파일 이름 서명" +#. TRANSLATORS: command line option +msgid "Filter with a set of device flags using a ~ prefix to exclude, e.g. 'internal,~needs-reboot'" +msgstr "플래그로 장치를 필터하며, ~ 기호를 앞에 붙이면 제외할 수 있습니다. 예: 'internal,~needs-reboot'" + #. TRANSLATORS: program name msgid "Firmware Agent" msgstr "펌웨어 에이전트" @@ -500,6 +624,15 @@ msgstr "플래그" msgid "Force the action ignoring all warnings" msgstr "모든 경고를 무시하고 작업 강제 진행" +#. TRANSLATORS: global ID common to all similar hardware +msgid "GUID" +msgid_plural "GUIDs" +msgstr[0] "GUID" + +#. TRANSLATORS: command description +msgid "Get all device flags supported by fwupd" +msgstr "fwupd를 지원하는 모든 장치 정보를 가져옵니다" + #. TRANSLATORS: command description msgid "Get all devices and possible releases" msgstr "모든 장치와 릴리스 가져오기" @@ -536,10 +669,26 @@ msgstr "장치 펌웨어 릴리스를 가져옵니다" msgid "Gets the results from the last update" msgstr "최근 업데이트 결과를 가져옵니다" +#. TRANSLATORS: The hardware is waiting to be replugged +msgid "Hardware is waiting to be replugged" +msgstr "하드웨어를 다시 연결해야 함" + #. TRANSLATORS: daemon is inactive msgid "Idle…" msgstr "대기 중…" +#. TRANSLATORS: command line option +msgid "Ignore SSL strict checks when downloading files" +msgstr "파일을 다운로드할 때 SSL 엄격한 검사를 건너뜁니다" + +#. TRANSLATORS: Ignore validation safety checks when flashing this device +msgid "Ignore validation safety checks" +msgstr "장치 안정성 검사 무시" + +#. TRANSLATORS: length of time the update takes to apply +msgid "Install Duration" +msgstr "설치 예상 시간" + #. TRANSLATORS: command description msgid "Install a firmware blob on a device" msgstr "장치에 펌웨어 파일 설치" @@ -557,6 +706,10 @@ msgstr "서명된 장치 펌웨어 설치" msgid "Install signed system firmware" msgstr "서명된 시스템 펌웨어 설치" +#. TRANSLATORS: Install composite firmware on the parent before the child +msgid "Install to parent device first" +msgstr "부모 장치에 먼저 설치" + msgid "Install unsigned device firmware" msgstr "서명되지 않은 장치 펌웨어 설치" @@ -576,13 +729,34 @@ msgstr "펌웨어 업데이트 설치 중…" msgid "Installing on %s…" msgstr "%s에 설치 중..." +#. TRANSLATORS: Device cannot be removed easily +msgid "Internal device" +msgstr "내장 장치" + +#. TRANSLATORS: Is currently in bootloader mode +msgid "Is in bootloader mode" +msgstr "현재 부트로더 모드에 있음" + +#. TRANSLATORS: issue fixed with the release, e.g. CVE +msgid "Issue" +msgid_plural "Issues" +msgstr[0] "문제점" + msgid "Keyring" msgstr "키 모음" +#. TRANSLATORS: the original time/date the device was modified +msgid "Last modified" +msgstr "마지막으로 수정한 날짜" + #. TRANSLATORS: time remaining for completing firmware flash msgid "Less than one minute remaining" msgstr "1분 미만 남음" +#. TRANSLATORS: e.g. GPLv2+, Proprietary etc +msgid "License" +msgstr "라이선스" + msgid "Linux Vendor Firmware Service (stable firmware)" msgstr "리눅스 제조사 펌웨어 서비스(안정 버전 펌웨어)" @@ -593,14 +767,26 @@ msgstr "리눅스 제조사 펌웨어 서비스(테스트 버전 펌웨어)" msgid "List supported firmware updates" msgstr "지원하는 펌웨어 업데이트 목록 표시" +#. TRANSLATORS: command description +msgid "List the available firmware types" +msgstr "사용 가능한 펌웨어 종류를 표시합니다" + #. TRANSLATORS: parsing the firmware information msgid "Loading…" msgstr "불러오는 중…" +#. TRANSLATORS: command line option +msgid "Log output to FILE (typically for scripting use)" +msgstr "FILE로 로그를 출력합니다(스크립트 사용 시 유용함)" + #. TRANSLATORS: command line option msgid "Manually whitelist specific plugins" msgstr "지정한 플러그인을 수동으로 허용 목록에 추가" +#. TRANSLATORS: remote URI +msgid "Metadata Signature" +msgstr "메타데이터 서명" + #. TRANSLATORS: remote URI msgid "Metadata URI" msgstr "메타데이터 URI" @@ -609,6 +795,10 @@ msgstr "메타데이터 URI" msgid "Metadata can be obtained from the Linux Vendor Firmware Service." msgstr "리눅스 제조사 펌웨어 서비스에서 메타데이터를 가져올 수 있습니다." +#. TRANSLATORS: smallest version number installable on device +msgid "Minimum Version" +msgstr "최소 버전" + #. TRANSLATORS: error message #, c-format msgid "Mismatched daemon and client, use %s instead" @@ -632,9 +822,25 @@ msgstr "데몬 설정 수정" msgid "Monitor the daemon for events" msgstr "데몬 이벤트를 감시합니다" +#. TRANSLATORS: Requires a reboot to apply firmware or to reload hardware +msgid "Needs a reboot after installation" +msgstr "설치 후 다시 시작 필요함" + +#. TRANSLATORS: Requires system shutdown to apply firmware +msgid "Needs shutdown after installation" +msgstr "설치 후 종료 필요함" + +#. TRANSLATORS: version number of new firmware +msgid "New version" +msgstr "새 버전" + msgid "No action specified!" msgstr "동작을 지정하지 않았습니다!" +#. TRANSLATORS: nothing found +msgid "No firmware IDs found" +msgstr "펌웨어 ID를 찾을 수 없음" + #. TRANSLATORS: nothing attached that can be upgraded msgid "No hardware detected with firmware update capability" msgstr "펌웨어를 업데이트할 수 있는 하드웨어가 없음" @@ -643,10 +849,18 @@ msgstr "펌웨어를 업데이트할 수 있는 하드웨어가 없음" msgid "No plugins found" msgstr "플러그인을 찾을 수 없음" +#. TRANSLATORS: no repositories to download from +msgid "No releases available" +msgstr "사용 가능한 릴리스 없음" + #. TRANSLATORS: explain why no metadata available msgid "No remotes are currently enabled so no metadata is available." msgstr "원격 자원이 설정되지 않았으므로 메타데이터를 사용할 수 없습니다." +#. TRANSLATORS: no repositories to download from +msgid "No remotes available" +msgstr "원격 저장소 없음" + #. TRANSLATORS: nothing was updated offline msgid "No updates were applied" msgstr "적용된 업데이트 없음" @@ -663,6 +877,10 @@ msgstr "기본 ESP 경로 재정의" msgid "Override warnings and force the action" msgstr "경고를 무시하고 강제로 작업 진행" +#. TRANSLATORS: command description +msgid "Parse and show details about a firmware file" +msgstr "펌웨어 파일을 처리하고 세부 정보를 표시합니다" + #. TRANSLATORS: remote filename base msgid "Password" msgstr "암호" @@ -679,6 +897,10 @@ msgstr "진행률" msgid "Please enter a number from 0 to %u: " msgstr "0에서 %u까지의 숫자 중 하나를 입력하십시오:" +#. TRANSLATORS: version number of previous firmware +msgid "Previous version" +msgstr "이전 버전" + msgid "Print the version number" msgstr "버전 번호 표시" @@ -692,10 +914,18 @@ msgstr "우선 순위" msgid "Proceed with upload?" msgstr "업로드를 진행하시겠습니까?" +#. TRANSLATORS: a non-free software license +msgid "Proprietary" +msgstr "독점적" + #. TRANSLATORS: command line option msgid "Query for firmware update support" msgstr "펌웨어 업데이트 지원 조회" +#. TRANSLATORS: command description +msgid "Read a firmware blob from a device" +msgstr "장치에서 펌웨어 바이너리를 읽습니다" + #. TRANSLATORS: command description msgid "Read firmware from device into a file" msgstr "장치 펌웨어를 읽어 파일에 기록" @@ -704,6 +934,11 @@ msgstr "장치 펌웨어를 읽어 파일에 기록" msgid "Read firmware from one partition into a file" msgstr "파티션에서 펌웨어를 읽어 파일에 기록" +#. TRANSLATORS: %1 is a device name +#, c-format +msgid "Reading from %s…" +msgstr "%s에서 읽는 중..." + #. TRANSLATORS: reading from the flash chips msgid "Reading…" msgstr "읽는 중…" @@ -716,6 +951,10 @@ msgstr "다시 시작하는 중..." msgid "Refresh metadata from remote server" msgstr "원격 서버의 메타데이터를 새로 고칩니다" +#. TRANSLATORS: command description +msgid "Reinstall current firmware on the device." +msgstr "장치에 현재 펌웨어를 다시 설치합니다." + #. TRANSLATORS: the first replacement is a display name #. * e.g. "ColorHugALS" and the second is a version number #. * e.g. "1.2.3" @@ -740,6 +979,18 @@ msgstr "기존 펌웨어 파일의 데이터 교체" msgid "Report URI" msgstr "보고서 URI" +#. TRANSLATORS: Has been reported to a metadata server +msgid "Reported to remote server" +msgstr "원격 서버에 보고됨" + +#. TRANSLATORS: Must be plugged in to an outlet +msgid "Requires AC power" +msgstr "AC 전원 필요함" + +#. TRANSLATORS: Requires a bootloader mode to be manually enabled by the user +msgid "Requires a bootloader" +msgstr "부트로더 모드 진입 필요함" + #. TRANSLATORS: metadata is downloaded from the Internet msgid "Requires internet connection" msgstr "인터넷 연결 필요" @@ -780,6 +1031,14 @@ msgstr "가능하다면 다음에 다시 시작할 때 설치 예약" msgid "Scheduling…" msgstr "작업 계획 중…" +#. TRANSLATORS: Device has been chosen by the daemon for the user +msgid "Selected device" +msgstr "선택한 장치" + +#. TRANSLATORS: serial number of hardware +msgid "Serial Number" +msgstr "일련 번호" + #. TRANSLATORS: command description msgid "Set product ID on firmware file" msgstr "펌웨어 파일의 제품 ID 설정" @@ -865,16 +1124,82 @@ msgstr "클라이언트 인증서로 업로드된 데이터 서명" msgid "Signature" msgstr "서명" +#. TRANSLATORS: file size of the download +msgid "Size" +msgstr "크기" + +#. TRANSLATORS: source (as in code) link +msgid "Source" +msgstr "원본" + msgid "Specify Vendor/Product ID(s) of DFU device" msgstr "DFU 장치의 제조사/제품 ID 지정" msgid "Specify the number of bytes per USB transfer" msgstr "USB 전송 당 바이트 수 지정" +#. TRANSLATORS: success message -- where activation is making the new +#. * firmware take effect, usually after updating offline +msgid "Successfully activated all devices" +msgstr "모든 장치를 활성화함" + +#. TRANSLATORS: success message +msgid "Successfully disabled remote" +msgstr "원격 저장소를 비활성화함" + +#. TRANSLATORS: success message where we made the firmware on the +#. * device older than it was before +msgid "Successfully downgraded device" +msgstr "장치를 다운그레이드함" + +#. TRANSLATORS: success message -- where 'metadata' is information +#. * about available firmware on the remote server +msgid "Successfully downloaded new metadata: " +msgstr "새 메타데이터를 다운로드함:" + +#. TRANSLATORS: success message +msgid "Successfully enabled remote" +msgstr "원격 저장소를 활성화함" + +#. TRANSLATORS: success message +msgid "Successfully installed firmware" +msgstr "펌웨어 설치 성공" + +#. TRANSLATORS: success message -- a per-system setting value +msgid "Successfully modified configuration value" +msgstr "설정을 수정함" + +#. TRANSLATORS: success message for a per-remote setting change +msgid "Successfully modified remote" +msgstr "원격 저장소를 수정함" + +#. TRANSLATORS: success message -- the user can do this by-hand too +msgid "Successfully refreshed metadata manually" +msgstr "메타데이터를 수동으로 업데이트함" + +#. TRANSLATORS: success message when user refreshes device checksums +msgid "Successfully updated device checksums" +msgstr "장치 체크섬을 업데이트함" + +#. TRANSLATORS: success message -- where the user has uploaded +#. * success and/or failure reports to the remote server +#, c-format +msgid "Successfully uploaded %u report" +msgid_plural "Successfully uploaded %u reports" +msgstr[0] "보고서 %u개 업로드함" + +#. TRANSLATORS: success message when user verified device checksums +msgid "Successfully verified device checksums" +msgstr "장치 체크섬을 검증함" + #. TRANSLATORS: one line summary of device msgid "Summary" msgstr "요약" +#. TRANSLATORS: Is found in current metadata +msgid "Supported on remote server" +msgstr "원격 서버에서 지원함" + msgid "Target" msgstr "대상" @@ -911,6 +1236,10 @@ msgstr "UEFI 펌웨어 유틸리티" msgid "Unknown" msgstr "알 수 없음" +#. TRANSLATORS: Name of hardware +msgid "Unknown Device" +msgstr "알 수 없는 장치" + msgid "Unlock the device to allow access" msgstr "접근을 허용하려면 장치 잠금을 해제하십시오" @@ -927,6 +1256,23 @@ msgstr "업데이트 중 디버깅 플래그 설정 해제" msgid "Unsupported daemon version %s, client version is %s" msgstr "지원하지 않는 데몬 버전 %s, 클라이언트 버전 %s" +#. TRANSLATORS: Device is updatable in this or any other mode +msgid "Updatable" +msgstr "업데이트 가능" + +#. TRANSLATORS: error message from last update attempt +msgid "Update Error" +msgstr "업데이트 오류" + +#. TRANSLATORS: helpful messages from last update +#. TRANSLATORS: helpful messages for the update +msgid "Update Message" +msgstr "업데이트 메시지" + +#. TRANSLATORS: hardware state, e.g. "pending" +msgid "Update State" +msgstr "업데이트 상태" + #. TRANSLATORS: command description msgid "Update all devices that match local metadata" msgstr "로컬 메타데이터와 일치하는 모든 장치 업데이트" @@ -939,6 +1285,14 @@ msgstr "알 수 없는 이유로 업데이트가 실패했습니다. 더 많은 msgid "Update now?" msgstr "지금 업데이트하시겠습니까?" +#. TRANSLATORS: Update can only be done from offline mode +msgid "Update requires a reboot" +msgstr "업데이트 시 다시 시작 필요함" + +#. TRANSLATORS: command description +msgid "Update the stored cryptographic hash with current ROM contents" +msgstr "현재 ROM 내용으로 저장된 암호화 해시를 업데이트합니다" + msgid "Update the stored device verification information" msgstr "저장된 장치 검증 정보 업데이트" @@ -962,26 +1316,60 @@ msgstr "%2$s에서 %3$s(으)로 %1$s 업데이트 중... " msgid "Updating %s…" msgstr "%s 업데이트 중..." +#. TRANSLATORS: message letting the user know an upgrade is available +#. * %1 is the device name and %2 and %3 are version strings +#, c-format +msgid "Upgrade available for %s from %s to %s" +msgstr "%s 업그레이드 사용 가능: %s에서 %s(으)로" + #. TRANSLATORS: the server sent the user a small message msgid "Upload message:" msgstr "업로드 메시지:" +msgid "Upload report just this one time, but prompt again for future updates" +msgid_plural "Upload reports just this one time, but prompt again for future updates" +msgstr[0] "이번 한 번만 보고서를 업로드하고 다음에 업데이트할 때 묻기" + #. TRANSLATORS: ask the user to upload msgid "Upload report now?" msgstr "지금 보고서를 업로드하시겠습니까?" +msgid "Upload report this time and automatically upload reports after completing future updates" +msgid_plural "Upload reports this time and automatically upload reports after completing future updates" +msgstr[0] "이번 한 번 보고서를 업로드하고 다음에 업데이트할 때 보고서를 자동으로 업로드하기" + #. TRANSLATORS: explain why we want to upload msgid "Uploading firmware reports helps hardware vendors to quickly identify failing and successful updates on real devices." msgstr "펌웨어 보고서를 업로드하면 하드웨어 제작사에서 실제 장치에 업데이트를 적용했을 때 성공 및 실패 여부를 빠르게 알 수 있습니다." +#. TRANSLATORS: command line option +msgid "Use quirk flags when installing firmware" +msgstr "펌웨어를 설치할 때 quirk 플래그 사용" + +#. TRANSLATORS: User has been notified +msgid "User has been notified" +msgstr "사용자에게 알림이 표시됨" + #. TRANSLATORS: remote filename base msgid "Username" msgstr "사용자 이름" +#. TRANSLATORS: one line variant of release (e.g. 'Prerelease' or 'China') +msgid "Variant" +msgstr "파생형" + +#. TRANSLATORS: manufacturer of hardware +msgid "Vendor" +msgstr "제조사" + #. TRANSLATORS: verifying we wrote the firmware correctly msgid "Verifying…" msgstr "검증 중…" +#. TRANSLATORS: try to help +msgid "WARNING: Ignoring SSL strict checks, to do this automatically in the future export DISABLE_SSL_STRICT in your environment" +msgstr "경고: SSL 엄격 검사를 건너뜁니다. 이 옵션을 자동으로 지정하려면 DISABLE_SSL_STRICT 환경 변수를 지정하십시오" + #. TRANSLATORS: waiting for device to do something msgid "Waiting…" msgstr "기다리는 중…"