[gnome-software/wip/hughsie/wildcard-legacy: 11/11] Support old-style AppStream files that rely on merging



commit 1f33e2ae679b7d0a67af0b5734b9bc7c5ddec757
Author: Richard Hughes <richard hughsie com>
Date:   Sun Jul 14 18:45:50 2019 +0100

    Support old-style AppStream files that rely on merging
    
    Old-style AppStream 'override' files have the following structure:
    
      <component type=desktop>
        <id>org.kde.amarok.desktop</id>
        <categories>
          <category>AudioVideo</category>
          <category>Featured</category>
        </categories>
      </component>
    
    We never want to return these as search results as they have a unique ID of
    '*/*/*/desktop/org.audacityteam.Audacity/*' which causes chaos if more than one
    plugin can refine the desktop ID.
    
    Fixes half of https://gitlab.gnome.org/GNOME/gnome-software/issues/699

 plugins/core/gs-appstream.c  | 12 +++++++++++-
 plugins/core/gs-self-test.c  |  1 +
 plugins/dummy/gs-self-test.c |  2 ++
 3 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 9a233d98..1be51998 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -720,8 +720,13 @@ gs_appstream_refine_app (GsPlugin *plugin,
 
        /* set name */
        tmp = xb_node_query_text (component, "name", NULL);
-       if (tmp != NULL)
+       if (tmp != NULL) {
                gs_app_set_name (app, GS_APP_QUALITY_HIGHEST, tmp);
+       } else {
+               /* this is a heuristic, but works even with old-style AppStream
+                * files without the merge attribute */
+               gs_app_add_quirk (app, GS_APP_QUIRK_IS_WILDCARD);
+       }
 
        /* set summary */
        tmp = xb_node_query_text (component, "summary", NULL);
@@ -1081,6 +1086,11 @@ gs_appstream_search (GsPlugin *plugin,
                        g_autoptr(GsApp) app = gs_appstream_create_app (plugin, silo, component, error);
                        if (app == NULL)
                                return FALSE;
+                       if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD)) {
+                               g_debug ("not returning wildcard %s",
+                                        gs_app_get_unique_id (app));
+                               continue;
+                       }
                        g_debug ("add %s", gs_app_get_unique_id (app));
                        gs_app_set_match_value (app, match_value);
                        gs_app_list_add (list, app);
diff --git a/plugins/core/gs-self-test.c b/plugins/core/gs-self-test.c
index 02a5a98c..247c86b3 100644
--- a/plugins/core/gs-self-test.c
+++ b/plugins/core/gs-self-test.c
@@ -224,6 +224,7 @@ main (int argc, char **argv)
                "  </component>\n"
                "  <component type=\"os-upgrade\">\n"
                "    <id>org.fedoraproject.Fedora-25</id>\n"
+               "    <name>Fedora</name>\n"
                "    <summary>Fedora Workstation</summary>\n"
                "    <pkgname>fedora-release</pkgname>\n"
                "  </component>\n"
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 8ca5f8ca..23153e75 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -748,6 +748,7 @@ main (int argc, char **argv)
                "<components version=\"0.9\">\n"
                "  <component type=\"desktop\">\n"
                "    <id>chiron.desktop</id>\n"
+               "    <name>Chiron</name>\n"
                "    <pkgname>chiron</pkgname>\n"
                "  </component>\n"
                "  <component type=\"desktop\">\n"
@@ -787,6 +788,7 @@ main (int argc, char **argv)
                "  </component>\n"
                "  <component type=\"os-upgrade\">\n"
                "    <id>org.fedoraproject.release-rawhide.upgrade</id>\n"
+               "    <name>Fedora Rawhide</name>\n"
                "    <summary>Release specific tagline</summary>\n"
                "    <pkgname>fedora-release</pkgname>\n"
                "  </component>\n"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]