[gnome-builder] flatpak: bundle flatpak-builder and use it



commit dcc12928fb5223742d010539222bf58cd7c9befd
Author: Christian Hergert <chergert redhat com>
Date:   Mon Nov 20 15:40:16 2017 -0800

    flatpak: bundle flatpak-builder and use it
    
    When running Builder from a flatpak, we can bundle flatpak-builder and let
    it use the HostCommand feature to execute programs on the host. This means
    that we are less likely to need to install flatpak-builder on peoples
    machines.

 build-aux/flatpak/org.gnome.Builder.json           |   11 ++++++++++-
 .../flatpak/gbp-flatpak-application-addin.c        |    8 ++++++++
 src/plugins/flatpak/gbp-flatpak-download-stage.c   |    4 +++-
 src/plugins/flatpak/gbp-flatpak-pipeline-addin.c   |    7 +++++++
 src/plugins/flatpak/gbp-flatpak-runner.c           |    4 ++++
 5 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Builder.json b/build-aux/flatpak/org.gnome.Builder.json
index b346462..994a9cb 100644
--- a/build-aux/flatpak/org.gnome.Builder.json
+++ b/build-aux/flatpak/org.gnome.Builder.json
@@ -610,7 +610,6 @@
                              "--with-system-install-dir=/var/lib/flatpak" ],
             "cleanup": [ "/etc/profile.d",
                          "/bin/flatpak",
-                         "/bin/flatpak-builder",
                          "/libexec",
                          "/lib/systemd",
                          "/share/dbus-1/interfaces/org.freedesktop.*",
@@ -626,6 +625,16 @@
             ]
         },
         {
+            "name": "flatpak-builder",
+            "config-opts": [ "--disable-documentation", "--disable-docbook-docs" ],
+            "sources": [
+                {
+                    "type": "git",
+                    "url": "https://github.com/flatpak/flatpak-builder.git";
+                }
+            ]
+        },
+        {
             "name": "gnome-builder",
             "buildsystem": "meson",
             "builddir": true,
diff --git a/src/plugins/flatpak/gbp-flatpak-application-addin.c 
b/src/plugins/flatpak/gbp-flatpak-application-addin.c
index 43016d6..976a726 100644
--- a/src/plugins/flatpak/gbp-flatpak-application-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-application-addin.c
@@ -1301,8 +1301,16 @@ gbp_flatpak_application_addin_check_sysdeps_async (GbpFlatpakApplicationAddin *s
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
   task = g_task_new (self, cancellable, callback, user_data);
+  g_task_set_priority (task, G_PRIORITY_LOW);
   g_task_set_source_tag (task, gbp_flatpak_application_addin_check_sysdeps_async);
 
+  if (ide_is_flatpak ())
+    {
+      /* We can use bundled flatpak-builder in flatpak */
+      g_task_return_boolean (task, TRUE);
+      IDE_EXIT;
+    }
+
   launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDOUT_SILENCE);
   ide_subprocess_launcher_set_clear_env (launcher, FALSE);
   ide_subprocess_launcher_set_run_on_host (launcher, TRUE);
diff --git a/src/plugins/flatpak/gbp-flatpak-download-stage.c 
b/src/plugins/flatpak/gbp-flatpak-download-stage.c
index b078608..4a6df7d 100644
--- a/src/plugins/flatpak/gbp-flatpak-download-stage.c
+++ b/src/plugins/flatpak/gbp-flatpak-download-stage.c
@@ -71,7 +71,9 @@ gbp_flatpak_download_stage_query (IdeBuildStage    *stage,
       launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE |
                                               G_SUBPROCESS_FLAGS_STDERR_PIPE);
 
-      ide_subprocess_launcher_set_run_on_host (launcher, TRUE);
+      /* Use our bundled flatpak-builder when possible */
+      ide_subprocess_launcher_set_run_on_host (launcher, !ide_is_flatpak ());
+
       ide_subprocess_launcher_set_clear_env (launcher, FALSE);
       ide_subprocess_launcher_set_cwd (launcher, src_dir);
 
diff --git a/src/plugins/flatpak/gbp-flatpak-pipeline-addin.c 
b/src/plugins/flatpak/gbp-flatpak-pipeline-addin.c
index 9e65744..eb43922 100644
--- a/src/plugins/flatpak/gbp-flatpak-pipeline-addin.c
+++ b/src/plugins/flatpak/gbp-flatpak-pipeline-addin.c
@@ -278,6 +278,13 @@ register_dependencies_stage (GbpFlatpakPipelineAddin  *self,
 
   ide_subprocess_launcher_set_cwd (launcher, src_dir);
 
+  /* If we're running inside of flatpak, we can use our bundled
+   * flatpak-builder instead of relying on the host. It knows how
+   * to run processes via the same HostCommand service.
+   */
+  if (ide_is_flatpak ())
+    ide_subprocess_launcher_set_run_on_host (launcher, FALSE);
+
   ide_subprocess_launcher_push_argv (launcher, "flatpak-builder");
   ide_subprocess_launcher_push_argv (launcher, "--ccache");
   ide_subprocess_launcher_push_argv (launcher, "--force-clean");
diff --git a/src/plugins/flatpak/gbp-flatpak-runner.c b/src/plugins/flatpak/gbp-flatpak-runner.c
index 758e0a0..11b422b 100644
--- a/src/plugins/flatpak/gbp-flatpak-runner.c
+++ b/src/plugins/flatpak/gbp-flatpak-runner.c
@@ -69,6 +69,10 @@ gbp_flatpak_runner_fixup_launcher (IdeRunner             *runner,
     {
       const gchar *manifest_path = gbp_flatpak_configuration_get_manifest_path (GBP_FLATPAK_CONFIGURATION 
(configuration));
 
+      /* Use our bundled flatpak-builder when possible */
+      if (ide_is_flatpak ())
+        ide_subprocess_launcher_set_run_on_host (launcher, FALSE);
+
       ide_subprocess_launcher_insert_argv (launcher, i++, "flatpak-builder");
       ide_subprocess_launcher_insert_argv (launcher, i++, "--run");
       ide_subprocess_launcher_insert_argv (launcher, i++, "--allow=devel");


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