From 1af48b13bd09c25bac218cb947063fc7055f7ecf Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 3 Dec 2018 11:51:17 +0000 Subject: [PATCH] Correctly parse format the version numbers correctly using old metadata The LVFS has always sent components with the old-style '' section rather than the new-style '' section, and when using appstream-glib we just accepted either element name. Although the LVFS has just been fixed to use the new name, old metadata might be present on the system already. When all clients have downloaded new metadata we can revert this, perhaps in a couple of weeks time. Until then, the belt-and-braces approach is probably a good idea. Fixes https://github.com/hughsie/fwupd/issues/874 --- src/fu-engine.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/fu-engine.c b/src/fu-engine.c index 7904f21ab..8f6dc40fb 100644 --- a/src/fu-engine.c +++ b/src/fu-engine.c @@ -1774,6 +1774,17 @@ fu_engine_is_device_supported (FuEngine *self, FuDevice *device) return TRUE; } +static gboolean +fu_engine_appstream_upgrade_cb (XbBuilderFixup *self, + XbBuilderNode *bn, + gpointer user_data, + GError **error) +{ + if (g_strcmp0 (xb_builder_node_get_element (bn), "metadata") == 0) + xb_builder_node_set_element (bn, "custom"); + return TRUE; +} + static gboolean fu_engine_load_metadata_store (FuEngine *self, GError **error) { @@ -1801,6 +1812,7 @@ fu_engine_load_metadata_store (FuEngine *self, GError **error) const gchar *path = NULL; g_autoptr(GError) error_local = NULL; g_autoptr(GFile) file = NULL; + g_autoptr(XbBuilderFixup) fixup = NULL; g_autoptr(XbBuilderNode) custom = NULL; g_autoptr(XbBuilderSource) source = xb_builder_source_new (); @@ -1827,6 +1839,13 @@ fu_engine_load_metadata_store (FuEngine *self, GError **error) continue; } + /* fix up any legacy installed files */ + fixup = xb_builder_fixup_new ("AppStreamUpgrade", + fu_engine_appstream_upgrade_cb, + self, NULL); + xb_builder_fixup_set_max_depth (fixup, 3); + xb_builder_source_add_fixup (source, fixup); + /* add metadata */ custom = xb_builder_node_new ("custom"); xb_builder_node_insert_text (custom,