[gnome-software] appstream: Set custom metadata key with the file name where we loaded data from



commit c7bdc2fee3bbd6811d4c93981b15ff5de9e3a142
Author: Kalev Lember <klember redhat com>
Date:   Tue Jan 22 16:04:22 2019 +0100

    appstream: Set custom metadata key with the file name where we loaded data from
    
    This allows other plugins (packagekit, rpm-ostree) to match the locally
    installed file name to the package name.

 plugins/core/gs-appstream.c        |  7 +++++++
 plugins/core/gs-plugin-appstream.c | 14 +++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 62fef53c..d5c6f449 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
  * Copyright (C) 2015-2017 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2018-2019 Kalev Lember <klember redhat com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -716,6 +717,12 @@ gs_appstream_refine_app (GsPlugin *plugin,
        if (tmp != NULL && gs_app_get_id (app) == NULL)
                gs_app_set_id (app, tmp);
 
+       /* set source */
+       tmp = xb_node_query_text (component, "info/filename", NULL);
+       if (tmp != NULL && gs_app_get_metadata_item (app, "appstream::source-file") == NULL) {
+               gs_app_set_metadata (app, "appstream::source-file", tmp);
+       }
+
        /* set content rating */
        if (refine_flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_CONTENT_RATING) {
                if (!gs_appstream_refine_app_content_ratings (plugin, app, component, error))
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 8ce04e82..623a16a9 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
  * Copyright (C) 2013-2014 Richard Hughes <richard hughsie com>
- * Copyright (C) 2015 Kalev Lember <klember redhat com>
+ * Copyright (C) 2015-2019 Kalev Lember <klember redhat com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -141,6 +141,7 @@ gs_plugin_appstream_load_appdata_fn (GsPlugin *plugin,
 {
        g_autoptr(GFile) file = g_file_new_for_path (filename);
        g_autoptr(XbBuilderFixup) fixup = NULL;
+       g_autoptr(XbBuilderNode) info = NULL;
        g_autoptr(XbBuilderSource) source = xb_builder_source_new ();
 
        /* add source */
@@ -158,6 +159,11 @@ gs_plugin_appstream_load_appdata_fn (GsPlugin *plugin,
        xb_builder_fixup_set_max_depth (fixup, 3);
        xb_builder_source_add_fixup (source, fixup);
 
+       /* add metadata */
+       info = xb_builder_node_insert (NULL, "info", NULL);
+       xb_builder_node_insert_text (info, "filename", filename, NULL);
+       xb_builder_source_set_info (source, info);
+
        /* success */
        xb_builder_import_source (builder, source);
        return TRUE;
@@ -224,6 +230,7 @@ gs_plugin_appstream_load_desktop_fn (GsPlugin *plugin,
 {
        g_autoptr(GFile) file = g_file_new_for_path (filename);
        g_autoptr(XbBuilderFixup) fixup = NULL;
+       g_autoptr(XbBuilderNode) info = NULL;
        g_autoptr(XbBuilderSource) source = xb_builder_source_new ();
 
        /* add support for desktop files */
@@ -247,6 +254,11 @@ gs_plugin_appstream_load_desktop_fn (GsPlugin *plugin,
                return FALSE;
        }
 
+       /* add metadata */
+       info = xb_builder_node_insert (NULL, "info", NULL);
+       xb_builder_node_insert_text (info, "filename", filename, NULL);
+       xb_builder_source_set_info (source, info);
+
        /* success */
        xb_builder_import_source (builder, source);
        return TRUE;


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