[gnome-software/wip/hughsie/flatpak3: 9/9] Don't create runtimes from AppStream metadata
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/flatpak3: 9/9] Don't create runtimes from AppStream metadata
- Date: Fri, 14 Jul 2017 14:55:22 +0000 (UTC)
commit 4fa20f9c0733c5ee94a0910259696715c9bc378e
Author: Richard Hughes <richard hughsie com>
Date: Fri Jul 14 13:36:24 2017 +0100
Don't create runtimes from AppStream metadata
We don't need to do this, and means:
* We don't bleed flatpak-concepts into the appstream plugin
* We don't have to worry about AppStream-created GsApp devices
plugins/core/gs-appstream.c | 68 +-----------------------------------------
plugins/core/gs-appstream.h | 3 --
plugins/flatpak/gs-flatpak.c | 52 ++++++++++++++++++++++++++++++-
3 files changed, 51 insertions(+), 72 deletions(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index ceb5c63..388a49a 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -318,53 +318,11 @@ gs_appstream_copy_metadata (GsApp *app, AsApp *item)
}
}
-GsApp *
-gs_appstream_create_runtime (GsPlugin *plugin,
- GsApp *parent,
- const gchar *runtime)
-{
- g_autofree gchar *source = NULL;
- g_auto(GStrv) split = NULL;
- g_autoptr(GsApp) app_cache = NULL;
- g_autoptr(GsApp) app = NULL;
-
- /* get the name/arch/branch */
- split = g_strsplit (runtime, "/", -1);
- if (g_strv_length (split) != 3)
- return NULL;
-
- /* create the complete GsApp from the single string */
- app = gs_plugin_app_new (plugin, split[0]);
- source = g_strdup_printf ("runtime/%s", runtime);
- gs_app_add_source (app, source);
- gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_FLATPAK);
- gs_app_set_kind (app, AS_APP_KIND_RUNTIME);
- gs_app_set_branch (app, split[2]);
- gs_app_set_scope (app, gs_app_get_scope (parent));
-
- /* search in the cache */
- app_cache = gs_plugin_cache_lookup (plugin, gs_app_get_unique_id (app));
- if (app_cache != NULL) {
- /* since the cached runtime can have been created somewhere else
- * (we're using a global cache), we need to make sure that a
- * source is set */
- if (gs_app_get_source_default (app_cache) == NULL)
- gs_app_add_source (app_cache, source);
- return g_steal_pointer (&app_cache);
- }
-
- /* save in the cache */
- gs_plugin_cache_add (plugin, NULL, app);
- return g_steal_pointer (&app);
-}
-
static void
gs_refine_item_management_plugin (GsPlugin *plugin, GsApp *app, AsApp *item)
{
GPtrArray *bundles;
const gchar *management_plugin = NULL;
- const gchar *runtime = NULL;
- guint i;
/* allow override */
management_plugin = as_app_get_metadata_item (item, "GnomeSoftware::Plugin");
@@ -373,33 +331,9 @@ gs_refine_item_management_plugin (GsPlugin *plugin, GsApp *app, AsApp *item)
/* find the default bundle kind */
bundles = as_app_get_bundles (item);
- for (i = 0; i < bundles->len; i++) {
+ for (guint i = 0; i < bundles->len; i++) {
AsBundle *bundle = g_ptr_array_index (bundles, i);
- AsBundleKind kind = as_bundle_get_kind (bundle);
-
gs_app_add_source (app, as_bundle_get_id (bundle));
-
- /* automatically add runtime */
- if (kind == AS_BUNDLE_KIND_FLATPAK &&
- gs_app_get_kind (app) != AS_APP_KIND_RUNTIME) {
- runtime = as_bundle_get_runtime (bundle);
- if (runtime != NULL) {
- g_autoptr(GsApp) app2 = NULL;
- app2 = gs_appstream_create_runtime (plugin, app, runtime);
- if (app2 != NULL) {
- if (app == app2) {
- g_warning ("%s runtime cannot have runtime!",
- gs_app_get_unique_id (app));
- break;
- }
- g_debug ("runtime for %s is %s",
- gs_app_get_unique_id (app),
- runtime);
- gs_app_set_update_runtime (app, app2);
- }
- }
- break;
- }
}
}
diff --git a/plugins/core/gs-appstream.h b/plugins/core/gs-appstream.h
index dab26d5..55a3d3f 100644
--- a/plugins/core/gs-appstream.h
+++ b/plugins/core/gs-appstream.h
@@ -33,9 +33,6 @@ gboolean gs_appstream_refine_app (GsPlugin *plugin,
GsApp *app,
AsApp *item,
GError **error);
-GsApp *gs_appstream_create_runtime (GsPlugin *plugin,
- GsApp *parent,
- const gchar *runtime);
gboolean gs_appstream_store_search (GsPlugin *plugin,
AsStore *store,
gchar **values,
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 3b13dda..42a3c4c 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -1589,6 +1589,54 @@ gs_plugin_refine_item_state (GsFlatpak *self,
}
static GsApp *
+gs_flatpak_create_runtime (GsPlugin *plugin, GsApp *parent, const gchar *runtime)
+{
+ g_autofree gchar *source = NULL;
+ g_auto(GStrv) split = NULL;
+ g_autoptr(GsApp) app_cache = NULL;
+ g_autoptr(GsApp) app = NULL;
+
+ /* get the name/arch/branch */
+ split = g_strsplit (runtime, "/", -1);
+ if (g_strv_length (split) != 3)
+ return NULL;
+
+ /* create the complete GsApp from the single string */
+ app = gs_plugin_app_new (plugin, split[0]);
+ source = g_strdup_printf ("runtime/%s", runtime);
+ gs_app_add_source (app, source);
+ gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_FLATPAK);
+ gs_app_set_kind (app, AS_APP_KIND_RUNTIME);
+ gs_app_set_branch (app, split[2]);
+ gs_app_set_scope (app, gs_app_get_scope (parent));
+
+ /* search in the cache */
+ app_cache = gs_plugin_cache_lookup (plugin, gs_app_get_unique_id (app));
+ if (app_cache != NULL) {
+ /* since the cached runtime can have been created somewhere else
+ * (we're using a global cache), we need to make sure that a
+ * source is set */
+ if (gs_app_get_source_default (app_cache) == NULL)
+ gs_app_add_source (app_cache, source);
+ return g_steal_pointer (&app_cache);
+ }
+
+
+ /* set superclassed app properties */
+ gs_flatpak_app_set_ref_kind (app, FLATPAK_REF_KIND_RUNTIME);
+ gs_flatpak_app_set_ref_name (app, split[0]);
+ gs_flatpak_app_set_ref_arch (app, split[1]);
+ gs_flatpak_app_set_ref_branch (app, split[2]);
+
+ /* we own this */
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
+
+ /* save in the cache */
+ gs_plugin_cache_add (plugin, NULL, app);
+ return g_steal_pointer (&app);
+}
+
+static GsApp *
gs_flatpak_create_runtime_from_metadata (GsFlatpak *self,
const GsApp *app,
const gchar *data,
@@ -1608,7 +1656,7 @@ gs_flatpak_create_runtime_from_metadata (GsFlatpak *self,
gs_utils_error_convert_gio (error);
return NULL;
}
- return gs_appstream_create_runtime (self->plugin, app, runtime);
+ return gs_flatpak_create_runtime (self->plugin, app, runtime);
}
static gboolean
@@ -1673,7 +1721,7 @@ gs_flatpak_set_app_metadata (GsFlatpak *self,
/* create runtime */
if (gs_app_get_runtime (app) == NULL) {
- app_runtime = gs_appstream_create_runtime (self->plugin, app, runtime);
+ app_runtime = gs_flatpak_create_runtime (self->plugin, app, runtime);
if (app_runtime != NULL) {
gs_plugin_refine_item_scope (self, app_runtime);
gs_app_set_runtime (app, app_runtime);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]