Do not merge the existing firmware metadata with the submitted files
This commit is contained in:
parent
8bd4000c62
commit
1d8bc1c620
165
0001-Do-not-merge-the-existing-firmware-metadata-with-the.patch
Normal file
165
0001-Do-not-merge-the-existing-firmware-metadata-with-the.patch
Normal file
@ -0,0 +1,165 @@
|
||||
From 033ccba050c2d0f3e83461af211d5f99dac95404 Mon Sep 17 00:00:00 2001
|
||||
From: Richard Hughes <richard@hughsie.com>
|
||||
Date: Thu, 10 Sep 2015 14:51:28 +0100
|
||||
Subject: [PATCH] Do not merge the existing firmware metadata with the
|
||||
submitted files
|
||||
|
||||
This just causes confusion and makes things hard to debug.
|
||||
---
|
||||
src/fu-main.c | 84 ++++++++++++++++++++++++++++++++---------------------------
|
||||
1 file changed, 45 insertions(+), 39 deletions(-)
|
||||
|
||||
diff --git a/src/fu-main.c b/src/fu-main.c
|
||||
index 464be03..512e405 100644
|
||||
--- a/src/fu-main.c
|
||||
+++ b/src/fu-main.c
|
||||
@@ -63,6 +63,7 @@ typedef struct {
|
||||
FwupdStatus status;
|
||||
FuPending *pending;
|
||||
AsStore *store;
|
||||
+ guint store_changed_id;
|
||||
} FuMainPrivate;
|
||||
|
||||
typedef struct {
|
||||
@@ -575,23 +576,6 @@ fu_main_get_action_id_for_device (FuMainAuthHelper *helper)
|
||||
}
|
||||
|
||||
/**
|
||||
- * _as_store_set_priority:
|
||||
- **/
|
||||
-static void
|
||||
-_as_store_set_priority (AsStore *store, gint priority)
|
||||
-{
|
||||
- AsApp *app;
|
||||
- GPtrArray *apps;
|
||||
- guint i;
|
||||
-
|
||||
- apps = as_store_get_apps (store);
|
||||
- for (i = 0; i < apps->len; i++) {
|
||||
- app = g_ptr_array_index (apps, i);
|
||||
- as_app_set_priority (app, priority);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-/**
|
||||
* fu_main_daemon_update_metadata:
|
||||
*
|
||||
* Supports optionally GZipped AppStream files up to 1MiB in size.
|
||||
@@ -603,7 +587,6 @@ fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GErro
|
||||
_cleanup_bytes_unref_ GBytes *bytes = NULL;
|
||||
_cleanup_bytes_unref_ GBytes *bytes_raw = NULL;
|
||||
_cleanup_bytes_unref_ GBytes *bytes_sig = NULL;
|
||||
- _cleanup_object_unref_ AsStore *store = NULL;
|
||||
_cleanup_object_unref_ FuKeyring *kr = NULL;
|
||||
_cleanup_object_unref_ GConverter *converter = NULL;
|
||||
_cleanup_object_unref_ GFile *file = NULL;
|
||||
@@ -612,16 +595,6 @@ fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GErro
|
||||
_cleanup_object_unref_ GInputStream *stream = NULL;
|
||||
_cleanup_object_unref_ GInputStream *stream_sig = NULL;
|
||||
|
||||
- /* open existing file if it exists */
|
||||
- store = as_store_new ();
|
||||
- file = g_file_new_for_path ("/var/cache/app-info/xmls/fwupd.xml");
|
||||
- if (g_file_query_exists (file, NULL)) {
|
||||
- if (!as_store_from_file (store, file, NULL, NULL, error))
|
||||
- return FALSE;
|
||||
- /* ensure we don't merge existing entries */
|
||||
- _as_store_set_priority (store, -1);
|
||||
- }
|
||||
-
|
||||
/* read the entire file into memory */
|
||||
stream_fd = g_unix_input_stream_new (fd, TRUE);
|
||||
bytes_raw = g_input_stream_read_bytes (stream_fd, 0x100000, NULL, error);
|
||||
@@ -668,16 +641,16 @@ fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GErro
|
||||
return FALSE;
|
||||
|
||||
/* merge in the new contents */
|
||||
- g_debug ("Store was %i size", as_store_get_size (store));
|
||||
- if (!as_store_from_xml (store,
|
||||
+ as_store_remove_all (priv->store);
|
||||
+ if (!as_store_from_xml (priv->store,
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
NULL, error))
|
||||
return FALSE;
|
||||
- g_debug ("Store now %i size", as_store_get_size (store));
|
||||
|
||||
/* save the new file */
|
||||
- as_store_set_api_version (store, 0.9);
|
||||
- if (!as_store_to_file (store, file,
|
||||
+ as_store_set_api_version (priv->store, 0.9);
|
||||
+ file = g_file_new_for_path ("/var/cache/app-info/xmls/fwupd.xml");
|
||||
+ if (!as_store_to_file (priv->store, file,
|
||||
AS_NODE_TO_XML_FLAG_ADD_HEADER |
|
||||
AS_NODE_TO_XML_FLAG_FORMAT_MULTILINE |
|
||||
AS_NODE_TO_XML_FLAG_FORMAT_INDENT,
|
||||
@@ -685,14 +658,41 @@ fu_main_daemon_update_metadata (FuMainPrivate *priv, gint fd, gint fd_sig, GErro
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
- /* force the store to reload */
|
||||
- if (!as_store_load (priv->store,
|
||||
- AS_STORE_LOAD_FLAG_APP_INFO_SYSTEM,
|
||||
- NULL, error)) {
|
||||
- return FALSE;
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * fu_main_store_delay_cb:
|
||||
+ **/
|
||||
+static gboolean
|
||||
+fu_main_store_delay_cb (gpointer user_data)
|
||||
+{
|
||||
+ AsApp *app;
|
||||
+ GPtrArray *apps;
|
||||
+ guint i;
|
||||
+ FuMainPrivate *priv = (FuMainPrivate *) user_data;
|
||||
+
|
||||
+ g_debug ("devices now in store:");
|
||||
+ apps = as_store_get_apps (priv->store);
|
||||
+ for (i = 0; i < apps->len; i++) {
|
||||
+ app = g_ptr_array_index (apps, i);
|
||||
+ g_debug ("%i\t%s\t%s", i + 1,
|
||||
+ as_app_get_id (app),
|
||||
+ as_app_get_name (app, NULL));
|
||||
}
|
||||
+ priv->store_changed_id = 0;
|
||||
+ return G_SOURCE_REMOVE;
|
||||
+}
|
||||
|
||||
- return TRUE;
|
||||
+/**
|
||||
+ * fu_main_store_changed_cb:
|
||||
+ **/
|
||||
+static void
|
||||
+fu_main_store_changed_cb (AsStore *store, FuMainPrivate *priv)
|
||||
+{
|
||||
+ if (priv->store_changed_id != 0)
|
||||
+ return;
|
||||
+ priv->store_changed_id = g_timeout_add (200, fu_main_store_delay_cb, priv);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1519,6 +1519,10 @@ main (int argc, char *argv[])
|
||||
priv->loop = g_main_loop_new (NULL, FALSE);
|
||||
priv->pending = fu_pending_new ();
|
||||
priv->store = as_store_new ();
|
||||
+ g_signal_connect (priv->store, "changed",
|
||||
+ G_CALLBACK (fu_main_store_changed_cb), priv);
|
||||
+ as_store_set_watch_flags (priv->store, AS_STORE_WATCH_FLAG_ADDED |
|
||||
+ AS_STORE_WATCH_FLAG_REMOVED);
|
||||
|
||||
/* load AppStream */
|
||||
as_store_add_filter (priv->store, AS_ID_KIND_FIRMWARE);
|
||||
@@ -1612,6 +1616,8 @@ out:
|
||||
g_object_unref (priv->store);
|
||||
if (priv->introspection_daemon != NULL)
|
||||
g_dbus_node_info_unref (priv->introspection_daemon);
|
||||
+ if (priv->store_changed_id != 0)
|
||||
+ g_source_remove (priv->store_changed_id);
|
||||
g_object_unref (priv->pending);
|
||||
if (priv->providers != NULL)
|
||||
g_ptr_array_unref (priv->providers);
|
||||
--
|
||||
2.4.3
|
||||
|
@ -1,11 +1,14 @@
|
||||
Summary: Firmware update daemon
|
||||
Name: fwupd
|
||||
Version: 0.1.6
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
License: GPLv2+
|
||||
URL: https://github.com/hughsie/fwupd
|
||||
Source0: http://people.freedesktop.org/~hughsient/releases/%{name}-%{version}.tar.xz
|
||||
|
||||
# Already upstream
|
||||
Patch1: 0001-Do-not-merge-the-existing-firmware-metadata-with-the.patch
|
||||
|
||||
BuildRequires: docbook-utils
|
||||
BuildRequires: gettext
|
||||
BuildRequires: glib2-devel
|
||||
@ -45,6 +48,7 @@ Files for development with %{name}.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch1 -p1 -b .no-merge-fw
|
||||
|
||||
%build
|
||||
%configure \
|
||||
@ -108,6 +112,9 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
|
||||
%{_datadir}/gir-1.0/*.gir
|
||||
|
||||
%changelog
|
||||
* Thu Sep 10 2015 Richard Hughes <richard@hughsie.com> 0.1.6-3
|
||||
- Do not merge the existing firmware metadata with the submitted files
|
||||
|
||||
* Thu Sep 10 2015 Kalev Lember <klember@redhat.com> 0.1.6-2
|
||||
- Own system-update.target.wants directory
|
||||
- Make fwupd-sign obsoletes versioned
|
||||
|
Loading…
Reference in New Issue
Block a user