[gnome-builder] flatpak: allow forcing SDK update
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: allow forcing SDK update
- Date: Wed, 17 Nov 2021 09:00:49 +0000 (UTC)
commit f29cb3bc1b65ec6b0020fff75da63857bfff562e
Author: Christian Hergert <chergert redhat com>
Date: Wed Nov 17 01:00:41 2021 -0800
flatpak: allow forcing SDK update
.../flatpak/daemon/ipc-flatpak-service-impl.c | 37 +++++++++++++++-------
.../daemon/org.gnome.Builder.Flatpak.Service.xml | 1 +
src/plugins/flatpak/daemon/test-install.c | 1 +
src/plugins/flatpak/gbp-flatpak-runtime-provider.c | 1 +
src/plugins/flatpak/gbp-flatpak-sdk-stage.c | 1 +
5 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
index 48333dfc8..547ee03e1 100644
--- a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
+++ b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
@@ -675,6 +675,7 @@ typedef struct
FlatpakRef *fref;
char *ref;
char *remote;
+ guint update : 1;
} InstallRef;
typedef struct
@@ -742,7 +743,6 @@ install_worker (GTask *task,
GCancellable *cancellable)
{
InstallState *state = task_data;
- IpcFlatpakServiceImpl *self = source_object;
g_autoptr(GError) error = NULL;
g_autoptr(GPtrArray) ref_ids = NULL;
g_autoptr(GHashTable) transactions = NULL;
@@ -808,14 +808,25 @@ install_worker (GTask *task,
}
/* Add ref as install or update to installation's transaction */
- if ((is_installed (self, ir->fref) &&
- !flatpak_transaction_add_update (transaction, ir->ref, NULL, NULL, &error)) ||
- !flatpak_transaction_add_install (transaction, ir->remote, ir->ref, NULL, &error))
+ if (ir->update)
{
- g_warning ("Failed to add ref to transaction: %s", error->message);
- complete_wrapped_error (g_steal_pointer (&state->invocation), g_error_copy (error));
- g_task_return_error (task, g_steal_pointer (&error));
- return;
+ if (!flatpak_transaction_add_update (transaction, ir->ref, NULL, NULL, &error))
+ {
+ g_warning ("Failed to add update ref to transaction: %s", error->message);
+ complete_wrapped_error (g_steal_pointer (&state->invocation), g_error_copy (error));
+ g_task_return_error (task, g_steal_pointer (&error));
+ return;
+ }
+ }
+ else
+ {
+ if (!flatpak_transaction_add_install (transaction, ir->remote, ir->ref, NULL, &error))
+ {
+ g_warning ("Failed to add install ref to transaction: %s", error->message);
+ complete_wrapped_error (g_steal_pointer (&state->invocation), g_error_copy (error));
+ g_task_return_error (task, g_steal_pointer (&error));
+ return;
+ }
}
}
@@ -1034,6 +1045,7 @@ static gboolean
ipc_flatpak_service_impl_install (IpcFlatpakService *service,
GDBusMethodInvocation *invocation,
const char * const *full_ref_names,
+ gboolean if_not_exists,
const char *transfer_path,
const char *parent_window)
{
@@ -1081,9 +1093,12 @@ ipc_flatpak_service_impl_install (IpcFlatpakService *service,
if (!g_str_has_prefix (name, "runtime/") && !g_str_has_prefix (name, "app/"))
name = adjusted = g_strdup_printf ("runtime/%s", full_ref_names[i]);
- ref = flatpak_ref_parse (name, NULL);
- if (ref != NULL && is_installed (self, ref))
- continue;
+ if ((ref = flatpak_ref_parse (name, NULL)))
+ {
+ iref.update = is_installed (self, ref);
+ if (if_not_exists && iref.update)
+ continue;
+ }
if (ref == NULL ||
!(iref.remote = find_remote_for_ref (self, ref, NULL)))
diff --git a/src/plugins/flatpak/daemon/org.gnome.Builder.Flatpak.Service.xml
b/src/plugins/flatpak/daemon/org.gnome.Builder.Flatpak.Service.xml
index 01e15c44c..0ad8a70c5 100644
--- a/src/plugins/flatpak/daemon/org.gnome.Builder.Flatpak.Service.xml
+++ b/src/plugins/flatpak/daemon/org.gnome.Builder.Flatpak.Service.xml
@@ -82,6 +82,7 @@
-->
<method name="Install">
<arg name="full_ref_name" direction="in" type="as"/>
+ <arg name="if_not_exists" direction="in" type="b"/>
<arg name="transfer" direction="in" type="o"/>
<arg name="parent_window" direction="in" type="s"/>
</method>
diff --git a/src/plugins/flatpak/daemon/test-install.c b/src/plugins/flatpak/daemon/test-install.c
index 7cf9aecaf..2fc474502 100644
--- a/src/plugins/flatpak/daemon/test-install.c
+++ b/src/plugins/flatpak/daemon/test-install.c
@@ -137,6 +137,7 @@ main (gint argc,
g_message ("Installing %s", argv[1]);
ipc_flatpak_service_call_install (service,
(const char * const *)all->pdata,
+ FALSE,
transfer_path,
"",
NULL,
diff --git a/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
b/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
index 2ff31f3a4..6f49ffa50 100644
--- a/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
+++ b/src/plugins/flatpak/gbp-flatpak-runtime-provider.c
@@ -327,6 +327,7 @@ gbp_flatpak_runtime_provider_bootstrap_complete (gpointer data)
ipc_flatpak_service_call_install (state->service,
(const char * const *)state->to_install->pdata,
+ TRUE,
state->transfer_path,
"",
ide_task_get_cancellable (task),
diff --git a/src/plugins/flatpak/gbp-flatpak-sdk-stage.c b/src/plugins/flatpak/gbp-flatpak-sdk-stage.c
index 0e79ded70..4975e94d1 100644
--- a/src/plugins/flatpak/gbp-flatpak-sdk-stage.c
+++ b/src/plugins/flatpak/gbp-flatpak-sdk-stage.c
@@ -145,6 +145,7 @@ gbp_flatpak_sdk_stage_build_async (IdePipelineStage *stage,
ipc_flatpak_service_call_install (service,
(const char * const *)self->sdks,
+ FALSE,
transfer_path,
"",
ide_task_get_cancellable (task),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]