[gnome-builder/gnome-builder-3-32] flatpak: silence flatpak-build warnings in some cases



commit 9d61e3dfb0104b1ee50e9e59e8c7bc7ad62b03d3
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 26 13:51:57 2019 -0700

    flatpak: silence flatpak-build warnings in some cases
    
    Not related to the actual error, but a warning message which is not useful
    for the context in which we're using "flatpak build".
    
    Related #895

 src/plugins/flatpak/gbp-flatpak-runner.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/src/plugins/flatpak/gbp-flatpak-runner.c b/src/plugins/flatpak/gbp-flatpak-runner.c
index 5336d996e..a1c3a47fc 100644
--- a/src/plugins/flatpak/gbp-flatpak-runner.c
+++ b/src/plugins/flatpak/gbp-flatpak-runner.c
@@ -21,6 +21,7 @@
 #define G_LOG_DOMAIN "gbp-flatpak-runner"
 
 #include <errno.h>
+#include <flatpak.h>
 #include <stdlib.h>
 #include <glib/gi18n.h>
 #include <unistd.h>
@@ -39,6 +40,28 @@ struct _GbpFlatpakRunner
 
 G_DEFINE_TYPE (GbpFlatpakRunner, gbp_flatpak_runner, IDE_TYPE_RUNNER)
 
+static const gchar *
+get_user_install_path (void)
+{
+  static gchar *path;
+
+  if (g_once_init_enter (&path))
+    {
+      g_autoptr(GFile) file = NULL;
+      g_autoptr(FlatpakInstallation) installation = NULL;
+      gchar *real_path;
+
+      if ((installation = flatpak_installation_new_user (NULL, NULL)))
+        real_path = g_file_get_path (flatpak_installation_get_path (installation));
+      else
+        real_path = g_build_filename (g_get_user_data_dir (), "flatpak", NULL);
+
+      g_once_init_leave (&path, g_steal_pointer (&real_path));
+    }
+
+  return path;
+}
+
 static IdeSubprocessLauncher *
 gbp_flatpak_runner_create_launcher (IdeRunner *runner)
 {
@@ -124,6 +147,13 @@ gbp_flatpak_runner_fixup_launcher (IdeRunner             *runner,
 
   ide_subprocess_launcher_insert_argv (launcher, i++, "--talk-name=org.freedesktop.portal.*");
 
+  /* Override FLAPTAK_USER_DIR to keep flatpak from complaining */
+  if (!ide_subprocess_launcher_getenv (launcher, "FLATPAK_USER_DIR"))
+    ide_subprocess_launcher_setenv (launcher,
+                                    "FLATPAK_USER_DIR",
+                                    get_user_install_path (),
+                                    TRUE);
+
   /* Proxy environment stuff to the launcher */
   if ((env = ide_runner_get_environment (runner)) &&
       (environ_ = ide_environment_get_environ (env)))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]