[gnome-builder] flatpak: don't install deps during runtime install
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: don't install deps during runtime install
- Date: Fri, 10 Mar 2017 09:53:28 +0000 (UTC)
commit f6dfb9f7557da18ff3bcba595c8596fbb649cfbc
Author: Christian Hergert <chergert redhat com>
Date: Fri Mar 10 01:52:48 2017 -0800
flatpak: don't install deps during runtime install
Instead we'll rely on the user to install the package using the message
in the workbench. That provides a more clear flow of what they are doing
so they are not surprised by a pkexec dialog.
plugins/flatpak/gbp-flatpak-runtime-provider.c | 184 +-----------------------
1 files changed, 7 insertions(+), 177 deletions(-)
---
diff --git a/plugins/flatpak/gbp-flatpak-runtime-provider.c b/plugins/flatpak/gbp-flatpak-runtime-provider.c
index 68bf81d..1bcc5e1 100644
--- a/plugins/flatpak/gbp-flatpak-runtime-provider.c
+++ b/plugins/flatpak/gbp-flatpak-runtime-provider.c
@@ -344,179 +344,6 @@ gbp_flatpak_runtime_provider_locate_sdk_cb (GObject *object,
}
static void
-gbp_flatpak_runtime_provider_install_deps_worker (GTask *task,
- gpointer source_object,
- gpointer task_data,
- GCancellable *cancellable)
-{
- g_autoptr(GDBusConnection) bus = NULL;
- g_autoptr(GDBusProxy) proxy = NULL;
- g_autoptr(GError) error = NULL;
- g_autoptr(GVariant) reply = NULL;
- g_autoptr(GPtrArray) packages = NULL;
- gboolean retval = FALSE;
-
- IDE_ENTRY;
-
- g_assert (G_IS_TASK (task));
- g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
-
- /*
- * This will try to install both the flatpak and flatpak-builder packages
- * to ensure that we can run flatpak-builder on the host. Additionally,
- * we require flatpak just in case people somehow get Builder without
- * the flatpak program.
- */
-
- packages = g_ptr_array_new ();
-
- if (NULL == (bus = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, &error)))
- IDE_GOTO (failure);
-
- reply = g_dbus_connection_call_sync (bus,
- "org.freedesktop.PackageKit",
- "/org/freedesktop/PackageKit",
- "org.freedesktop.PackageKit.Query",
- "IsInstalled",
- g_variant_new ("(ss)", "flatpak", ""),
- G_VARIANT_TYPE ("(b)"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- cancellable,
- &error);
- if (reply == NULL)
- IDE_GOTO (failure);
-
- g_variant_get (reply, "(b)", &retval);
- g_clear_pointer (&reply, g_variant_unref);
-
- if (!retval)
- g_ptr_array_add (packages, "flatpak");
-
- reply = g_dbus_connection_call_sync (bus,
- "org.freedesktop.PackageKit",
- "/org/freedesktop/PackageKit",
- "org.freedesktop.PackageKit.Query",
- "IsInstalled",
- g_variant_new ("(ss)", "flatpak-builder", ""),
- G_VARIANT_TYPE ("(b)"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- cancellable,
- &error);
- if (reply == NULL)
- IDE_GOTO (failure);
-
- g_variant_get (reply, "(b)", &retval);
- g_clear_pointer (&reply, g_variant_unref);
-
- if (!retval)
- g_ptr_array_add (packages, "flatpak-builder");
-
- if (packages->len > 0)
- {
- g_autoptr(IdeSubprocessLauncher) launcher = NULL;
- g_autoptr(IdeSubprocess) subprocess = NULL;
-
- /* Launch a process to install flatpak-builder */
-
- launcher = ide_subprocess_launcher_new (0);
-
- ide_subprocess_launcher_set_run_on_host (launcher, TRUE);
-
- ide_subprocess_launcher_push_argv (launcher, "pkexec");
- ide_subprocess_launcher_push_argv (launcher, "pkcon");
- ide_subprocess_launcher_push_argv (launcher, "install");
- ide_subprocess_launcher_push_argv (launcher, "-y");
- ide_subprocess_launcher_push_argv (launcher, "-p");
- for (guint i = 0; i < packages->len; i++)
- ide_subprocess_launcher_push_argv (launcher, g_ptr_array_index (packages, i));
-
- if (!(subprocess = ide_subprocess_launcher_spawn (launcher, cancellable, &error)))
- IDE_GOTO (failure);
-
- if (!ide_subprocess_wait_check (subprocess, cancellable, &error))
- IDE_GOTO (failure);
- }
-
-failure:
- if (error != NULL)
- g_task_return_error (task, g_steal_pointer (&error));
- else
- g_task_return_boolean (task, TRUE);
-
- IDE_EXIT;
-}
-
-static void
-gbp_flatpak_runtime_provider_install_deps_async (GbpFlatpakRuntimeProvider *self,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- g_autoptr(GTask) task = NULL;
-
- IDE_ENTRY;
-
- g_assert (GBP_IS_FLATPAK_RUNTIME_PROVIDER (self));
- g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
-
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_source_tag (task, gbp_flatpak_runtime_provider_install_deps_async);
- g_task_run_in_thread (task, gbp_flatpak_runtime_provider_install_deps_worker);
-
- IDE_EXIT;
-}
-
-static gboolean
-gbp_flatpak_runtime_provider_install_deps_finish (GbpFlatpakRuntimeProvider *self,
- GAsyncResult *result,
- GError **error)
-{
- g_assert (GBP_IS_FLATPAK_RUNTIME_PROVIDER (self));
- g_assert (G_IS_TASK (result));
-
- return g_task_propagate_boolean (G_TASK (result), error);
-}
-
-static void
-gbp_flatpak_runtime_provider_install_deps_cb (GObject *object,
- GAsyncResult *result,
- gpointer user_data)
-{
- GbpFlatpakRuntimeProvider *self = (GbpFlatpakRuntimeProvider *)object;
- g_autoptr(GTask) task = user_data;
- g_autoptr(GError) error = NULL;
- InstallRuntime *install;
- GCancellable *cancellable;
-
- IDE_ENTRY;
-
- g_assert (GBP_IS_FLATPAK_RUNTIME_PROVIDER (self));
- g_assert (G_IS_ASYNC_RESULT (result));
- g_assert (G_IS_TASK (task));
-
- install = g_task_get_task_data (task);
- cancellable = g_task_get_cancellable (task);
-
- if (!gbp_flatpak_runtime_provider_install_deps_finish (self, result, &error))
- {
- g_task_return_error (task, g_steal_pointer (&error));
- IDE_EXIT;
- }
-
- gbp_flatpak_application_addin_locate_sdk_async (gbp_flatpak_application_addin_get_default (),
- install->id,
- install->arch,
- install->branch,
- cancellable,
- gbp_flatpak_runtime_provider_locate_sdk_cb,
- g_steal_pointer (&task));
-
- IDE_EXIT;
-}
-
-static void
gbp_flatpak_runtime_provider_install_async (IdeRuntimeProvider *provider,
const gchar *runtime_id,
GCancellable *cancellable,
@@ -560,10 +387,13 @@ gbp_flatpak_runtime_provider_install_async (IdeRuntimeProvider *provider,
g_task_set_task_data (task, install, (GDestroyNotify)install_runtime_free);
- gbp_flatpak_runtime_provider_install_deps_async (self,
- cancellable,
- gbp_flatpak_runtime_provider_install_deps_cb,
- g_steal_pointer (&task));
+ gbp_flatpak_application_addin_locate_sdk_async (gbp_flatpak_application_addin_get_default (),
+ install->id,
+ install->arch,
+ install->branch,
+ cancellable,
+ gbp_flatpak_runtime_provider_locate_sdk_cb,
+ g_steal_pointer (&task));
IDE_EXIT;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]