[gnome-software/wip/hughsie/scope] appstream: Set the correct scope using the silo metadata
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/scope] appstream: Set the correct scope using the silo metadata
- Date: Thu, 18 Jul 2019 09:03:30 +0000 (UTC)
commit 800329af357865184aa88cec040adb61eb3668f7
Author: Richard Hughes <richard hughsie com>
Date: Thu Jul 18 09:36:47 2019 +0100
appstream: Set the correct scope using the silo metadata
We go to the trouble of setting this when creating two silos, but we were not
actually reading it until now. Also add the metadata for the self tests so they
reflect reality.
This ensures that applications created in GsAppstream have the correct scope
always set, and are never matched against incorrect versions.
plugins/core/gs-appstream.c | 12 +++++++++++-
plugins/core/gs-self-test.c | 3 +++
plugins/dummy/gs-self-test.c | 3 +++
plugins/epiphany/gs-self-test.c | 3 +++
plugins/modalias/gs-self-test.c | 3 +++
plugins/shell-extensions/gs-plugin-shell-extensions.c | 6 ++++++
6 files changed, 29 insertions(+), 1 deletion(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 2999ab44..379af06a 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -726,6 +726,17 @@ gs_appstream_refine_app (GsPlugin *plugin,
gs_app_set_metadata (app, "appstream::source-file", tmp);
}
+ /* set scope */
+ tmp = xb_node_query_text (component, "../info/scope", NULL);
+ if (tmp == NULL) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_NOT_SUPPORTED,
+ "silo scope unset");
+ return FALSE;
+ }
+ gs_app_set_scope (app, as_app_scope_from_string (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))
@@ -884,7 +895,6 @@ gs_appstream_refine_app (GsPlugin *plugin,
gs_app_add_source (app, tmp);
}
gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_PACKAGE);
- gs_app_set_scope (app, AS_APP_SCOPE_SYSTEM);
}
}
diff --git a/plugins/core/gs-self-test.c b/plugins/core/gs-self-test.c
index 247c86b3..de482a09 100644
--- a/plugins/core/gs-self-test.c
+++ b/plugins/core/gs-self-test.c
@@ -228,6 +228,9 @@ main (int argc, char **argv)
" <summary>Fedora Workstation</summary>\n"
" <pkgname>fedora-release</pkgname>\n"
" </component>\n"
+ " <info>\n"
+ " <scope>user</scope>\n"
+ " </info>\n"
"</components>\n";
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 23153e75..1ec9bf84 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -792,6 +792,9 @@ main (int argc, char **argv)
" <summary>Release specific tagline</summary>\n"
" <pkgname>fedora-release</pkgname>\n"
" </component>\n"
+ " <info>\n"
+ " <scope>user</scope>\n"
+ " </info>\n"
"</components>\n");
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
diff --git a/plugins/epiphany/gs-self-test.c b/plugins/epiphany/gs-self-test.c
index 7a3e5111..2d2f4788 100644
--- a/plugins/epiphany/gs-self-test.c
+++ b/plugins/epiphany/gs-self-test.c
@@ -68,6 +68,9 @@ main (int argc, char **argv)
" <pkgname>test</pkgname>\n"
" <icon type=\"remote\">file://%s</icon>\n"
" </component>\n"
+ " <info>\n"
+ " <scope>user</scope>\n"
+ " </info>\n"
"</components>\n", fn);
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
diff --git a/plugins/modalias/gs-self-test.c b/plugins/modalias/gs-self-test.c
index c1297b6f..17e5a8c4 100644
--- a/plugins/modalias/gs-self-test.c
+++ b/plugins/modalias/gs-self-test.c
@@ -68,6 +68,9 @@ main (int argc, char **argv)
" <modalias>pci:*</modalias>\n"
" </provides>\n"
" </component>\n"
+ " <info>\n"
+ " <scope>system</scope>\n"
+ " </info>\n"
"</components>\n");
g_setenv ("GS_SELF_TEST_APPSTREAM_XML", xml, TRUE);
g_setenv ("GS_SELF_TEST_CACHEDIR", tmp_root, TRUE);
diff --git a/plugins/shell-extensions/gs-plugin-shell-extensions.c
b/plugins/shell-extensions/gs-plugin-shell-extensions.c
index 979f680b..77dcb0c8 100644
--- a/plugins/shell-extensions/gs-plugin-shell-extensions.c
+++ b/plugins/shell-extensions/gs-plugin-shell-extensions.c
@@ -823,6 +823,7 @@ _check_silo (GsPlugin *plugin, GCancellable *cancellable, GError **error)
g_autoptr(GRWLockReaderLocker) reader_locker = NULL;
g_autoptr(GRWLockWriterLocker) writer_locker = NULL;
g_autoptr(XbBuilder) builder = xb_builder_new ();
+ g_autoptr(XbBuilderNode) info = NULL;
g_autoptr(XbBuilderSource) source = xb_builder_source_new ();
reader_locker = g_rw_lock_reader_locker_new (&priv->silo_lock);
@@ -844,6 +845,11 @@ _check_silo (GsPlugin *plugin, GCancellable *cancellable, GError **error)
XB_SILO_PROFILE_FLAG_DEBUG);
}
+ /* add metadata */
+ info = xb_builder_node_insert (NULL, "info", NULL);
+ xb_builder_node_insert_text (info, "scope", "user", NULL);
+ xb_builder_source_set_info (source, info);
+
/* add support for JSON files */
fn = gs_utils_get_cache_filename ("shell-extensions",
"gnome.json",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]