[gnome-software/wip/mcrha/flatpak-runtime-origin: 11/11] flatpak: Set runtime origin same as the application's
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/mcrha/flatpak-runtime-origin: 11/11] flatpak: Set runtime origin same as the application's
- Date: Wed, 9 Mar 2022 17:45:30 +0000 (UTC)
commit a92a0e136851f04dbf885eee040616a1896ffb08
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 21 21:28:58 2021 +0200
flatpak: Set runtime origin same as the application's
When the application's origin provides also the runtime, set the runtime's
origin to the applications' origin. This avoids pulling the runtime
from a different origin, when there are two or more remotes providing
the same runtime.
plugins/flatpak/gs-flatpak.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index 3b3b641fa..0dcd211f1 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -2287,13 +2287,15 @@ static GsApp *
gs_flatpak_create_runtime (GsFlatpak *self,
GsApp *parent,
const gchar *runtime,
- gboolean interactive)
+ gboolean interactive,
+ GCancellable *cancellable)
{
g_autofree gchar *source = NULL;
g_auto(GStrv) split = NULL;
g_autoptr(GsApp) app_cache = NULL;
g_autoptr(GsApp) app = NULL;
g_autoptr(GError) local_error = NULL;
+ const gchar *origin;
/* get the name/arch/branch */
split = g_strsplit (runtime, "/", -1);
@@ -2308,6 +2310,24 @@ gs_flatpak_create_runtime (GsFlatpak *self,
gs_app_set_kind (app, AS_COMPONENT_KIND_RUNTIME);
gs_app_set_branch (app, split[2]);
+ origin = gs_app_get_origin (parent);
+ if (origin != NULL) {
+ g_autoptr(FlatpakRemoteRef) xref = NULL;
+
+ xref = flatpak_installation_fetch_remote_ref_sync (gs_flatpak_get_installation (self,
interactive),
+ origin,
+ FLATPAK_REF_KIND_RUNTIME,
+ gs_app_get_id (app),
+ gs_flatpak_app_get_ref_arch (parent),
+ gs_app_get_branch (app),
+ cancellable,
+ NULL);
+
+ /* Prefer runtime from the same origin as the parent application */
+ if (xref)
+ gs_app_set_origin (app, origin);
+ }
+
/* search in the cache */
app_cache = gs_plugin_cache_lookup (self->plugin, gs_app_get_unique_id (app));
if (app_cache != NULL) {
@@ -2346,6 +2366,7 @@ gs_flatpak_set_app_metadata (GsFlatpak *self,
const gchar *data,
gsize length,
gboolean interactive,
+ GCancellable *cancellable,
GError **error)
{
gboolean secure = TRUE;
@@ -2399,7 +2420,7 @@ gs_flatpak_set_app_metadata (GsFlatpak *self,
gs_app_add_kudo (app, GS_APP_KUDO_SANDBOXED_SECURE);
/* create runtime */
- app_runtime = gs_flatpak_create_runtime (self, app, runtime, interactive);
+ app_runtime = gs_flatpak_create_runtime (self, app, runtime, interactive, cancellable);
if (app_runtime != NULL) {
gs_plugin_refine_item_scope (self, app_runtime);
gs_app_set_runtime (app, app_runtime);
@@ -2505,7 +2526,7 @@ gs_plugin_refine_item_metadata (GsFlatpak *self,
}
/* parse key file */
- if (!gs_flatpak_set_app_metadata (self, app, str, len, interactive, error))
+ if (!gs_flatpak_set_app_metadata (self, app, str, len, interactive, cancellable, error))
return FALSE;
return TRUE;
}
@@ -3477,6 +3498,7 @@ gs_flatpak_file_to_app_bundle (GsFlatpak *self,
g_bytes_get_data (metadata, NULL),
g_bytes_get_size (metadata),
interactive,
+ cancellable,
error))
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]