[gnome-builder] flatpak: add option to ignore system installations
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: add option to ignore system installations
- Date: Fri, 19 Nov 2021 05:24:28 +0000 (UTC)
commit 192c7d39c788da8e54620f3d8cf8171af8b39a8c
Author: Christian Hergert <chergert redhat com>
Date: Thu Nov 18 21:22:43 2021 -0800
flatpak: add option to ignore system installations
Mostly helpful for tracking down issues when using tests.
src/plugins/flatpak/daemon/gnome-builder-flatpak.c | 4 +-
.../flatpak/daemon/ipc-flatpak-service-impl.c | 78 ++++++++++++++++++++--
.../flatpak/daemon/ipc-flatpak-service-impl.h | 2 +-
src/plugins/flatpak/daemon/test-flatpak.c | 4 ++
4 files changed, 79 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/flatpak/daemon/gnome-builder-flatpak.c
b/src/plugins/flatpak/daemon/gnome-builder-flatpak.c
index c21df5d02..dd43d7564 100644
--- a/src/plugins/flatpak/daemon/gnome-builder-flatpak.c
+++ b/src/plugins/flatpak/daemon/gnome-builder-flatpak.c
@@ -118,10 +118,12 @@ static int read_fileno = STDIN_FILENO;
static int write_fileno = STDOUT_FILENO;
static char *data_dir;
static gboolean verbose;
+static gboolean ignore_system_installations;
static GOptionEntry main_entries[] = {
{ "read-fd", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_INT, &read_fileno },
{ "write-fd", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_INT, &write_fileno },
{ "data-dir", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &data_dir },
+ { "ignore-system", 0, 0, G_OPTION_ARG_NONE, &ignore_system_installations },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose },
{ 0 }
};
@@ -216,7 +218,7 @@ main (gint argc,
ipc_flatpak_repo_load (data_dir);
- service = ipc_flatpak_service_impl_new ();
+ service = ipc_flatpak_service_impl_new (ignore_system_installations);
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service),
connection,
diff --git a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
index 53da4b041..3a85afcff 100644
--- a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
+++ b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.c
@@ -70,6 +70,7 @@ struct _IpcFlatpakServiceImpl
GHashTable *installs;
GPtrArray *runtimes;
GPtrArray *installs_ordered;
+ guint ignore_system_installations : 1;
};
static void ipc_flatpak_service_impl_install_changed_cb (IpcFlatpakServiceImpl *self,
@@ -94,6 +95,14 @@ static gboolean runtime_equal (const Runtime
const Runtime *b);
static void is_known_free (IsKnown *state);
+enum {
+ PROP_0,
+ PROP_IGNORE_SYSTEM_INSTALLATIONS,
+ N_PROPS
+};
+
+static GParamSpec *properties [N_PROPS];
+
static void
resolve_extension_state_free (ResolveExtensionState *state)
{
@@ -1553,7 +1562,7 @@ service_iface_init (IpcFlatpakServiceIface *iface)
}
G_DEFINE_FINAL_TYPE_WITH_CODE (IpcFlatpakServiceImpl, ipc_flatpak_service_impl,
IPC_TYPE_FLATPAK_SERVICE_SKELETON,
- G_IMPLEMENT_INTERFACE (IPC_TYPE_FLATPAK_SERVICE, service_iface_init))
+ G_IMPLEMENT_INTERFACE (IPC_TYPE_FLATPAK_SERVICE, service_iface_init))
static void
ipc_flatpak_service_impl_constructed (GObject *object)
@@ -1567,12 +1576,17 @@ ipc_flatpak_service_impl_constructed (GObject *object)
G_OBJECT_CLASS (ipc_flatpak_service_impl_parent_class)->constructed (object);
- ipc_flatpak_service_set_default_arch (IPC_FLATPAK_SERVICE (self), flatpak_get_default_arch ());
+ ipc_flatpak_service_set_default_arch (IPC_FLATPAK_SERVICE (self),
+ flatpak_get_default_arch ());
- if ((installations = flatpak_get_system_installations (NULL, NULL)))
+ /* Add system installations unless disabled */
+ if (!self->ignore_system_installations)
{
- for (guint i = 0; i < installations->len; i++)
- add_installation (self, g_ptr_array_index (installations, i), NULL);
+ if ((installations = flatpak_get_system_installations (NULL, NULL)))
+ {
+ for (guint i = 0; i < installations->len; i++)
+ add_installation (self, g_ptr_array_index (installations, i), NULL);
+ }
}
/* Fallback for SDKs not available elsewhere */
@@ -1600,6 +1614,43 @@ ipc_flatpak_service_impl_finalize (GObject *object)
G_OBJECT_CLASS (ipc_flatpak_service_impl_parent_class)->finalize (object);
}
+static void
+ipc_flatpak_service_impl_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ IpcFlatpakServiceImpl *self = IPC_FLATPAK_SERVICE_IMPL (object);
+
+ switch (prop_id)
+ {
+ case PROP_IGNORE_SYSTEM_INSTALLATIONS:
+ g_value_set_boolean (value, self->ignore_system_installations);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ipc_flatpak_service_impl_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ IpcFlatpakServiceImpl *self = IPC_FLATPAK_SERVICE_IMPL (object);
+
+ switch (prop_id)
+ {
+ case PROP_IGNORE_SYSTEM_INSTALLATIONS:
+ self->ignore_system_installations = g_value_get_boolean (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
static void
ipc_flatpak_service_impl_class_init (IpcFlatpakServiceImplClass *klass)
{
@@ -1607,6 +1658,17 @@ ipc_flatpak_service_impl_class_init (IpcFlatpakServiceImplClass *klass)
object_class->constructed = ipc_flatpak_service_impl_constructed;
object_class->finalize = ipc_flatpak_service_impl_finalize;
+ object_class->get_property = ipc_flatpak_service_impl_get_property;
+ object_class->set_property = ipc_flatpak_service_impl_set_property;
+
+ properties [PROP_IGNORE_SYSTEM_INSTALLATIONS] =
+ g_param_spec_boolean ("ignore-system-installations",
+ "Ignore System Installations",
+ "Ignore System Installations",
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@@ -1621,7 +1683,9 @@ ipc_flatpak_service_impl_init (IpcFlatpakServiceImpl *self)
}
IpcFlatpakService *
-ipc_flatpak_service_impl_new (void)
+ipc_flatpak_service_impl_new (gboolean ignore_system_installations)
{
- return g_object_new (IPC_TYPE_FLATPAK_SERVICE_IMPL, NULL);
+ return g_object_new (IPC_TYPE_FLATPAK_SERVICE_IMPL,
+ "ignore-system-installations", ignore_system_installations,
+ NULL);
}
diff --git a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.h
b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.h
index 0ab95b9d8..379e54384 100644
--- a/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.h
+++ b/src/plugins/flatpak/daemon/ipc-flatpak-service-impl.h
@@ -28,6 +28,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IpcFlatpakServiceImpl, ipc_flatpak_service_impl, IPC, FLATPAK_SERVICE_IMPL,
IpcFlatpakServiceSkeleton)
-IpcFlatpakService *ipc_flatpak_service_impl_new (void);
+IpcFlatpakService *ipc_flatpak_service_impl_new (gboolean ignore_system_installations);
G_END_DECLS
diff --git a/src/plugins/flatpak/daemon/test-flatpak.c b/src/plugins/flatpak/daemon/test-flatpak.c
index b4927ac7c..99368f45f 100644
--- a/src/plugins/flatpak/daemon/test-flatpak.c
+++ b/src/plugins/flatpak/daemon/test-flatpak.c
@@ -191,9 +191,11 @@ add_install_cb (GObject *object,
}
static gboolean ignore_home;
+static gboolean ignore_system;
static char *data_dir;
static GOptionEntry main_entries[] = {
{ "ignore-home", 'i', 0, G_OPTION_ARG_NONE, &ignore_home, "Ignore --user flatpak installation" },
+ { "ignore-system", 's', 0, G_OPTION_ARG_NONE, &ignore_system, "Ignore --system flatpak installation" },
{ "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, "Set the data directory to use" },
{ 0 }
};
@@ -236,6 +238,8 @@ main (gint argc,
g_message ("Using %s for test data directory", data_dir);
+ if (ignore_system)
+ g_ptr_array_add (args, (char *)"--ignore-system");
g_ptr_array_add (args, (char *)"--verbose");
g_ptr_array_add (args, (char *)"--data-dir");
g_ptr_array_add (args, data_dir);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]