From a7b2e20035ebb21f0b5054dbcdd810a916d5613b Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Thu, 29 Mar 2018 21:28:18 +0200 Subject: [PATCH] Fix empty OS Updates showing up --- empty-os-updates.patch | 290 +++++++++++++++++++++++++++++++++++++++++ gnome-software.spec | 6 +- 2 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 empty-os-updates.patch diff --git a/empty-os-updates.patch b/empty-os-updates.patch new file mode 100644 index 0000000..3683f16 --- /dev/null +++ b/empty-os-updates.patch @@ -0,0 +1,290 @@ +From c5cc2dc34fab191e9b40097fd1e53a84f3a47177 Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Wed, 21 Mar 2018 09:48:22 +0100 +Subject: [PATCH 1/9] generic updates: Don't put wildcard apps in the os update + object + +Wildcard apps are filtered from the updates list after refine() and we +may end up with an empty OsUpdate object if we add wildcard apps to it +and there are no other updates. + +Fixes: https://gitlab.gnome.org/GNOME/gnome-software/issues/332 + +https://bugzilla.redhat.com/show_bug.cgi?id=1558754 +--- + plugins/core/gs-plugin-generic-updates.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/plugins/core/gs-plugin-generic-updates.c b/plugins/core/gs-plugin-generic-updates.c +index 2fc805b7f157..733983a2929c 100644 +--- a/plugins/core/gs-plugin-generic-updates.c ++++ b/plugins/core/gs-plugin-generic-updates.c +@@ -96,6 +96,8 @@ gs_plugin_refine (GsPlugin *plugin, + /* do we have any packages left that are not apps? */ + for (guint i = 0; i < gs_app_list_length (list); i++) { + GsApp *app_tmp = gs_app_list_index (list, i); ++ if (gs_app_has_quirk (app_tmp, AS_APP_QUIRK_MATCH_ANY_PREFIX)) ++ continue; + if (gs_plugin_generic_updates_merge_os_update (app_tmp)) + gs_app_list_add (os_updates, app_tmp); + } +-- +2.16.2 + + +From d2fd28a7d86b1c7f379e1ebcf105cd4f86d76630 Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Wed, 21 Mar 2018 11:28:19 +0100 +Subject: [PATCH 2/9] Add a self test for the generic-updates plugin + +This also covers the fix in the previous commit. +--- + plugins/core/gs-self-test.c | 81 +++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 81 insertions(+) + +diff --git a/plugins/core/gs-self-test.c b/plugins/core/gs-self-test.c +index 66ab4fd28cc4..dc27daa37d5b 100644 +--- a/plugins/core/gs-self-test.c ++++ b/plugins/core/gs-self-test.c +@@ -104,6 +104,83 @@ gs_plugins_core_os_release_func (GsPluginLoader *plugin_loader) + g_assert (app3 == app); + } + ++static void ++gs_plugins_core_generic_updates_func (GsPluginLoader *plugin_loader) ++{ ++ gboolean ret; ++ GsApp *os_update; ++ GPtrArray *related; ++ g_autoptr(GsPluginJob) plugin_job = NULL; ++ g_autoptr(GsPluginJob) plugin_job2 = NULL; ++ g_autoptr(GError) error = NULL; ++ g_autoptr(GsApp) app1 = NULL; ++ g_autoptr(GsApp) app2 = NULL; ++ g_autoptr(GsApp) app_wildcard = NULL; ++ g_autoptr(GsAppList) list = NULL; ++ g_autoptr(GsAppList) list_wildcard = NULL; ++ ++ /* drop all caches */ ++ gs_plugin_loader_setup_again (plugin_loader); ++ ++ /* create a list with generic apps */ ++ list = gs_app_list_new (); ++ app1 = gs_app_new ("package1"); ++ app2 = gs_app_new ("package2"); ++ gs_app_set_kind (app1, AS_APP_KIND_GENERIC); ++ gs_app_set_kind (app2, AS_APP_KIND_GENERIC); ++ gs_app_set_state (app1, AS_APP_STATE_UPDATABLE); ++ gs_app_set_state (app2, AS_APP_STATE_UPDATABLE); ++ gs_app_add_source (app1, "package1"); ++ gs_app_add_source (app2, "package2"); ++ gs_app_list_add (list, app1); ++ gs_app_list_add (list, app2); ++ ++ /* refine to make the generic-updates plugin merge them into a single OsUpdate item */ ++ plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE, ++ "list", list, ++ "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS, ++ NULL); ++ ret = gs_plugin_loader_job_action (plugin_loader, plugin_job, NULL, &error); ++ gs_test_flush_main_context (); ++ g_assert_no_error (error); ++ g_assert (ret); ++ ++ /* make sure there is one entry, the os update */ ++ g_assert_cmpint (gs_app_list_length (list), ==, 1); ++ os_update = gs_app_list_index (list, 0); ++ ++ /* make sure the os update is valid */ ++ g_assert_cmpstr (gs_app_get_id (os_update), ==, "org.gnome.Software.OsUpdate"); ++ g_assert_cmpint (gs_app_get_kind (os_update), ==, AS_APP_KIND_OS_UPDATE); ++ g_assert (gs_app_has_quirk (os_update, AS_APP_QUIRK_IS_PROXY)); ++ ++ /* must have two related apps, the ones we added earlier */ ++ related = gs_app_get_related (os_update); ++ g_assert_cmpint (related->len, ==, 2); ++ ++ /* another test to make sure that we don't get an OsUpdate item created for wildcard apps */ ++ list_wildcard = gs_app_list_new (); ++ app_wildcard = gs_app_new ("nosuchapp.desktop"); ++ gs_app_add_quirk (app_wildcard, AS_APP_QUIRK_MATCH_ANY_PREFIX); ++ gs_app_set_kind (app_wildcard, AS_APP_KIND_GENERIC); ++ gs_app_list_add (list_wildcard, app_wildcard); ++ plugin_job2 = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE, ++ "list", list_wildcard, ++ "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS, ++ NULL); ++ ret = gs_plugin_loader_job_action (plugin_loader, plugin_job2, NULL, &error); ++ gs_test_flush_main_context (); ++ g_assert_no_error (error); ++ g_assert (ret); ++ ++ /* no OsUpdate item created */ ++ for (guint i = 0; i < gs_app_list_length (list_wildcard); i++) { ++ GsApp *app_tmp = gs_app_list_index (list_wildcard, i); ++ g_assert_cmpint (gs_app_get_kind (app_tmp), !=, AS_APP_KIND_OS_UPDATE); ++ g_assert (!gs_app_has_quirk (app_tmp, AS_APP_QUIRK_IS_PROXY)); ++ } ++} ++ + int + main (int argc, char **argv) + { +@@ -115,6 +192,7 @@ main (int argc, char **argv) + const gchar *xml; + const gchar *whitelist[] = { + "appstream", ++ "generic-updates", + "icons", + "os-release", + NULL +@@ -180,6 +258,9 @@ main (int argc, char **argv) + g_test_add_data_func ("/gnome-software/plugins/core/os-release", + plugin_loader, + (GTestDataFunc) gs_plugins_core_os_release_func); ++ g_test_add_data_func ("/gnome-software/plugins/core/generic-updates", ++ plugin_loader, ++ (GTestDataFunc) gs_plugins_core_generic_updates_func); + return g_test_run (); + } + +-- +2.16.2 + + +From 9eab01082b07acd525b8a390ab6b43136cf400a5 Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Thu, 22 Mar 2018 13:03:55 +0100 +Subject: [PATCH 5/9] generic updates: Only put packages in the OS Update item + +Make sure we don't put flatpaks in the OS Update item as this is by +design only for hiding low level system package updates. + +flatpaks use online updates and packages use offline updates; if we mix +them up in a single OS Update item this breaks the updates page where +we're supposed to group online and offline updates separately. + +https://gitlab.gnome.org/GNOME/gnome-software/issues/332 +--- + plugins/core/gs-plugin-generic-updates.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/plugins/core/gs-plugin-generic-updates.c b/plugins/core/gs-plugin-generic-updates.c +index 733983a2929c..d8e2db39e3df 100644 +--- a/plugins/core/gs-plugin-generic-updates.c ++++ b/plugins/core/gs-plugin-generic-updates.c +@@ -33,10 +33,16 @@ gs_plugin_initialize (GsPlugin *plugin) + static gboolean + gs_plugin_generic_updates_merge_os_update (GsApp *app) + { ++ /* this is only for grouping system-installed packages */ ++ if (gs_app_get_bundle_kind (app) != AS_BUNDLE_KIND_PACKAGE || ++ gs_app_get_scope (app) != AS_APP_SCOPE_SYSTEM) ++ return FALSE; ++ + if (gs_app_get_kind (app) == AS_APP_KIND_GENERIC) + return TRUE; + if (gs_app_get_kind (app) == AS_APP_KIND_SOURCE) + return TRUE; ++ + return FALSE; + } + +-- +2.16.2 + + +From 223b9f9a6bb5fc500aeee0a392ba909c0fdec097 Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Thu, 22 Mar 2018 14:08:49 +0100 +Subject: [PATCH 6/9] trivial: Fix the "OS Updates" self test + +Adapt the test now that we're only putting package updates in "OS +Updates" after commit 9eab01082b07acd525b8a390ab6b43136cf400a5. +--- + plugins/core/gs-self-test.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/plugins/core/gs-self-test.c b/plugins/core/gs-self-test.c +index dc27daa37d5b..da22aaebb231 100644 +--- a/plugins/core/gs-self-test.c ++++ b/plugins/core/gs-self-test.c +@@ -128,6 +128,10 @@ gs_plugins_core_generic_updates_func (GsPluginLoader *plugin_loader) + app2 = gs_app_new ("package2"); + gs_app_set_kind (app1, AS_APP_KIND_GENERIC); + gs_app_set_kind (app2, AS_APP_KIND_GENERIC); ++ gs_app_set_bundle_kind (app1, AS_BUNDLE_KIND_PACKAGE); ++ gs_app_set_bundle_kind (app2, AS_BUNDLE_KIND_PACKAGE); ++ gs_app_set_scope (app1, AS_APP_SCOPE_SYSTEM); ++ gs_app_set_scope (app2, AS_APP_SCOPE_SYSTEM); + gs_app_set_state (app1, AS_APP_STATE_UPDATABLE); + gs_app_set_state (app2, AS_APP_STATE_UPDATABLE); + gs_app_add_source (app1, "package1"); +-- +2.16.2 + + +From 22e217f3725307dce12d477bad2593912e2b72d6 Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Thu, 22 Mar 2018 14:33:02 +0100 +Subject: [PATCH 7/9] trivial: Fix dummy plugin self test + +Adapt for commit 9eab01082b07acd525b8a390ab6b43136cf400a5. +--- + plugins/dummy/gs-plugin-dummy.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c +index e238ab54c51e..5293fe3b3ddc 100644 +--- a/plugins/dummy/gs-plugin-dummy.c ++++ b/plugins/dummy/gs-plugin-dummy.c +@@ -384,6 +384,8 @@ gs_plugin_add_updates (GsPlugin *plugin, + gs_app_set_update_details (app, "Fix several memory leaks."); + gs_app_set_update_urgency (app, AS_URGENCY_KIND_LOW); + gs_app_set_kind (app, AS_APP_KIND_GENERIC); ++ gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE); ++ gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM); + gs_app_set_state (app, AS_APP_STATE_UPDATABLE); + gs_app_add_source (app, "libvirt-glib-devel"); + gs_app_add_source_id (app, "libvirt-glib-devel;0.0.1;noarch;fedora"); +@@ -398,6 +400,8 @@ gs_plugin_add_updates (GsPlugin *plugin, + gs_app_set_update_details (app, "Do not crash when using libvirt."); + gs_app_set_update_urgency (app, AS_URGENCY_KIND_HIGH); + gs_app_set_kind (app, AS_APP_KIND_GENERIC); ++ gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE); ++ gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM); + gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE); + gs_app_add_source (app, "chiron-libs"); + gs_app_add_source_id (app, "chiron-libs;0.0.1;i386;updates-testing"); +-- +2.16.2 + + +From 732951dbe669aa5db4e6a6157f7b71a6fbce51b6 Mon Sep 17 00:00:00 2001 +From: Kalev Lember +Date: Thu, 22 Mar 2018 15:05:20 +0100 +Subject: [PATCH 9/9] trivial: rpm-ostree: Set bundle kind and scope for + updates + +This ensures that updates get correctly grouped under "OS Updates" item +after commit 9eab01082b07acd525b8a390ab6b43136cf400a5. +--- + plugins/rpm-ostree/gs-plugin-rpm-ostree.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c +index cb3d3d4f9bad..aae2e6dbd6dc 100644 +--- a/plugins/rpm-ostree/gs-plugin-rpm-ostree.c ++++ b/plugins/rpm-ostree/gs-plugin-rpm-ostree.c +@@ -320,6 +320,8 @@ make_app (GVariant *variant) + gs_app_set_management_plugin (app, "rpm-ostree"); + gs_app_set_size_download (app, 0); + gs_app_set_kind (app, AS_APP_KIND_GENERIC); ++ gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE); ++ gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM); + + details = g_variant_get_child_value (variant, 2); + g_return_val_if_fail (details != NULL, NULL); +-- +2.16.2 + diff --git a/gnome-software.spec b/gnome-software.spec index e2c02ec..dd5938a 100644 --- a/gnome-software.spec +++ b/gnome-software.spec @@ -11,7 +11,7 @@ Name: gnome-software Version: 3.28.0 -Release: 4%{?dist} +Release: 5%{?dist} Summary: A software center for GNOME License: GPLv2+ @@ -22,6 +22,7 @@ Source0: https://download.gnome.org/sources/gnome-software/3.28/%{name}-%{vers Patch0: 0001-Revert-Revert-trivial-Use-new-libappstream-glib-to-b.patch Patch1: 0001-plugin-loader-Don-t-abort-for-refine-errors.patch Patch2: 0001-appstream-Don-t-compare-appstream-origin-to-package-.patch +Patch3: empty-os-updates.patch BuildRequires: gettext BuildRequires: libxslt @@ -215,6 +216,9 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop %{_mandir}/man1/gnome-software-editor.1* %changelog +* Thu Mar 29 2018 Kalev Lember - 3.28.0-5 +- Fix empty OS Updates showing up + * Thu Mar 15 2018 Kalev Lember - 3.28.0-4 - Fix opening results from gnome-shell search provider