[gnome-software/uajain/remove-pkgname-fixup] appstream: Avoid adding <pkgname> to desktop files



commit e1af953883424847aa570565ac67f6f941f587cf
Author: Umang Jain <mailumangjain gmail com>
Date:   Mon Sep 30 08:57:52 2019 -0400

    appstream: Avoid adding <pkgname> to desktop files
    
    This basically achieves nothing as of now. Earlier it used
    to be a workaround for quering webapps but webapps' now already
    are marked with 'type=webapp' in appstream. Furthermore, the
    epiphany plugin doesn't adopt the webapp if it has a <pkgname>
    (See commit 9d7633ece771f3ec).
    
    This commit nukes the "AddDesktopPackageName" xmlb fixup to the
    desktop files which in turns makes the query take into account
    both the metadata-providing sources for a system installed app:
    a) It's desktop file b) It's appdata.
    The desktop file is converted into a appdata-like XML representation
    by appstream and pushed into the xmlb. It provides metadata-info
    such as icons whereas the real appdata can provide information
    like categories, description etc. Refining the GsApp object of an
    installed app against these two components (a) and (b) is necessary
    to properly populate it's metadata.

 plugins/core/gs-plugin-appstream.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 7979806b..ef91ee8f 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -93,17 +93,6 @@ gs_plugin_appstream_upgrade_cb (XbBuilderFixup *self,
        return TRUE;
 }
 
-static gboolean
-gs_plugin_appstream_add_pkgname_cb (XbBuilderFixup *self,
-                                   XbBuilderNode *bn,
-                                   gpointer user_data,
-                                   GError **error)
-{
-       if (g_strcmp0 (xb_builder_node_get_element (bn), "component") == 0)
-               xb_builder_node_insert_text (bn, "pkgname", "", NULL);
-       return TRUE;
-}
-
 static gboolean
 gs_plugin_appstream_add_icons_cb (XbBuilderFixup *self,
                                  XbBuilderNode *bn,
@@ -249,13 +238,6 @@ gs_plugin_appstream_load_desktop_fn (GsPlugin *plugin,
        xb_builder_source_add_adapter (source, "application/x-desktop",
                                       gs_plugin_appstream_load_desktop_cb, NULL, NULL);
 
-       /* add a dummy package name */
-       fixup = xb_builder_fixup_new ("AddDesktopPackageName",
-                                     gs_plugin_appstream_add_pkgname_cb,
-                                     plugin, NULL);
-       xb_builder_fixup_set_max_depth (fixup, 2);
-       xb_builder_source_add_fixup (source, fixup);
-
        /* add source */
        if (!xb_builder_source_load_file (source, file,
                                          XB_BUILDER_SOURCE_FLAG_WATCH_FILE,
@@ -720,7 +702,9 @@ gs_plugin_refine_from_id (GsPlugin *plugin,
        /* look in AppStream then fall back to AppData */
        xb_string_append_union (xpath, "components/component/id[text()='%s']/../pkgname/..", id);
        xb_string_append_union (xpath, "components/component[@type='webapp']/id[text()='%s']/..", id);
-       xb_string_append_union (xpath, "component/id[text()='%s']/../pkgname/..", id);
+       /* This query includes component from both the desktop file and AppData. The desktop file
+        * provides metadata such as icon and appdata provides metadata such as description, categories etc. 
*/
+       xb_string_append_union (xpath, "component/id[text()='%s']/..", id);
        components = xb_silo_query (priv->silo, xpath->str, 0, &error_local);
        if (components == NULL) {
                if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))


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