Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/builder-module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,7 @@ builder_module_build_helper (BuilderModule *self,
const char *ldflags = NULL;

gboolean autotools = FALSE, cmake = FALSE, cmake_ninja = FALSE, meson = FALSE, simple = FALSE, qmake = FALSE;
gboolean build_has_network = FALSE;
g_autoptr(GFile) configure_file = NULL;
g_autoptr(GFile) build_dir = NULL;
g_autofree char *build_dir_relative = NULL;
Expand Down Expand Up @@ -1796,6 +1797,8 @@ builder_module_build_helper (BuilderModule *self,
if (build_args == NULL)
return FALSE;

build_has_network = builder_options_build_has_network (build_args);

env = builder_options_get_env (self->build_options, context);
cflags = g_environ_getenv (env, "CFLAGS");
cxxflags = g_environ_getenv (env, "CXXFLAGS");
Expand Down Expand Up @@ -2020,6 +2023,8 @@ builder_module_build_helper (BuilderModule *self,
{
/* Meson's setup command is now meson setup */
g_ptr_array_add (configure_args_arr, g_strdup ("setup"));
if (!build_has_network)
g_ptr_array_add (configure_args_arr, g_strdup ("--wrap-mode=nodownload"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you copy over the lengthy comment form #643 as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

if (cmake || cmake_ninja)
Expand Down
30 changes: 30 additions & 0 deletions src/builder-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,36 @@ builder_options_get_build_args (BuilderOptions *self,
return (char **) g_ptr_array_free (g_steal_pointer (&array), FALSE);
}

gboolean
builder_options_build_has_network (char **build_args)
{
gboolean has_network = FALSE;

if (!build_args)
return FALSE;

/*
* The last arg passed to flatpak build wins:
*
* --unshare=network --share=network -> network enabled
* --share=network --unshare=network -> network disabled
*
* So we iterate through the entire list
*/

for (size_t i = 0; build_args[i]; i++)
{
const char *arg = build_args[i];

if (g_strcmp0 (arg, "--unshare=network") == 0)
has_network = FALSE;
else if (g_strcmp0 (arg, "--share=network") == 0)
has_network = TRUE;
}

return has_network;
}

char **
builder_options_get_test_args (BuilderOptions *self,
BuilderContext *context,
Expand Down
1 change: 1 addition & 0 deletions src/builder-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ gboolean builder_options_get_no_debuginfo_compression (BuilderOptions *self,
BuilderContext *context);
gboolean builder_options_get_strip (BuilderOptions *self,
BuilderContext *context);
gboolean builder_options_build_has_network (char **build_args);

G_DEFINE_AUTOPTR_CLEANUP_FUNC (BuilderOptions, g_object_unref)

Expand Down