Commit f24091a0 authored by Christian Hergert's avatar Christian Hergert
Browse files

flatpak: bundle flatpak-builder in our flatpak

This allows us to stay more up-to-date with flatpak-builder, since it knows
how to execute commands on the host using HostCommand.

It also means we don't have to check for flatpak-builder on the host when
bundled in flatpak. So that is one less thing to go wrong on install.

There are a few tricks going on with the environment variables to make sure
that the flatpak commands running on the host find the right installation.
parent e3d13640
......@@ -655,6 +655,15 @@
}
]
},
{
"name": "flatpak-builder",
"sources": [
{
"type": "git",
"url": "https://github.com/flatpak/flatpak-builder"
}
]
},
{
"name": "gnome-builder",
"buildsystem": "meson",
......
......@@ -1302,10 +1302,17 @@ gbp_flatpak_application_addin_check_sysdeps_async (GbpFlatpakApplicationAddin *s
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gbp_flatpak_application_addin_check_sysdeps_async);
g_task_set_priority (task, G_PRIORITY_LOW);
if (ide_is_flatpak ())
{
/* We bundle flatpak-builder with Builder from flatpak */
g_task_return_boolean (task, TRUE);
return;
}
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);
ide_subprocess_launcher_push_argv (launcher, "which");
ide_subprocess_launcher_push_argv (launcher, "flatpak-builder");
......
......@@ -93,9 +93,17 @@ 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);
ide_subprocess_launcher_set_clear_env (launcher, FALSE);
ide_subprocess_launcher_set_cwd (launcher, src_dir);
ide_subprocess_launcher_set_run_on_host (launcher, FALSE);
if (ide_is_flatpak ())
{
g_autofree gchar *user_dir = NULL;
user_dir = g_build_filename (g_get_home_dir (), ".local", "share", "flatpak", NULL);
ide_subprocess_launcher_setenv (launcher, "FLATPAK_USER_DIR", user_dir, TRUE);
ide_subprocess_launcher_setenv (launcher, "XDG_RUNTIME_DIR", g_get_user_runtime_dir (), TRUE);
}
ide_subprocess_launcher_push_argv (launcher, "flatpak-builder");
ide_subprocess_launcher_push_argv (launcher, "--ccache");
......
......@@ -71,7 +71,6 @@ sniff_flatpak_builder_version (GbpFlatpakPipelineAddin *self)
g_assert (GBP_IS_FLATPAK_PIPELINE_ADDIN (self));
launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE);
ide_subprocess_launcher_set_run_on_host (launcher, TRUE);
ide_subprocess_launcher_set_clear_env (launcher, FALSE);
ide_subprocess_launcher_setenv (launcher, "LANG", "C", TRUE);
ide_subprocess_launcher_push_argv (launcher, "flatpak-builder");
......@@ -304,10 +303,10 @@ register_dependencies_stage (GbpFlatpakPipelineAddin *self,
{
g_autoptr(IdeBuildStage) stage = NULL;
g_autoptr(IdeSubprocessLauncher) launcher = NULL;
g_autofree gchar *manifest_path = NULL;
g_autofree gchar *staging_dir = NULL;
g_autofree gchar *stop_at_option = NULL;
IdeConfiguration *config;
g_autofree gchar *manifest_path = NULL;
const gchar *primary_module;
const gchar *src_dir;
guint stage_id;
......@@ -333,6 +332,17 @@ register_dependencies_stage (GbpFlatpakPipelineAddin *self,
launcher = create_subprocess_launcher ();
ide_subprocess_launcher_set_cwd (launcher, src_dir);
ide_subprocess_launcher_set_run_on_host (launcher, FALSE);
ide_subprocess_launcher_set_clear_env (launcher, FALSE);
if (ide_is_flatpak ())
{
g_autofree gchar *user_dir = NULL;
user_dir = g_build_filename (g_get_home_dir (), ".local", "share", "flatpak", NULL);
ide_subprocess_launcher_setenv (launcher, "FLATPAK_USER_DIR", user_dir, TRUE);
ide_subprocess_launcher_setenv (launcher, "XDG_RUNTIME_DIR", g_get_user_runtime_dir (), TRUE);
}
ide_subprocess_launcher_push_argv (launcher, "flatpak-builder");
ide_subprocess_launcher_push_argv (launcher, "--ccache");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment