forked from Mirrors/flatpak-builder
builder: Add --keep-build-dirs option
This is useful if you want to later make changes to the built stuff.tingping/wmclass
parent
b716e0d8eb
commit
54c52d9363
|
@ -656,6 +656,7 @@ builder_manifest_download (BuilderManifest *self,
|
|||
|
||||
gboolean
|
||||
builder_manifest_build (BuilderManifest *self,
|
||||
gboolean keep_build_dir,
|
||||
BuilderCache *cache,
|
||||
BuilderContext *context,
|
||||
GError **error)
|
||||
|
@ -676,7 +677,7 @@ builder_manifest_build (BuilderManifest *self,
|
|||
{
|
||||
g_autofree char *body =
|
||||
g_strdup_printf ("Built %s\n", builder_module_get_name (m));
|
||||
if (!builder_module_build (m, context, error))
|
||||
if (!builder_module_build (m, keep_build_dir, context, error))
|
||||
return FALSE;
|
||||
if (!builder_cache_commit (cache, body, error))
|
||||
return FALSE;
|
||||
|
|
|
@ -51,6 +51,7 @@ gboolean builder_manifest_download (BuilderManifest *self,
|
|||
BuilderContext *context,
|
||||
GError **error);
|
||||
gboolean builder_manifest_build (BuilderManifest *self,
|
||||
gboolean keep_build_dir,
|
||||
BuilderCache *cache,
|
||||
BuilderContext *context,
|
||||
GError **error);
|
||||
|
|
|
@ -601,6 +601,7 @@ build (GFile *app_dir,
|
|||
|
||||
gboolean
|
||||
builder_module_build (BuilderModule *self,
|
||||
gboolean keep_build_dir,
|
||||
BuilderContext *context,
|
||||
GError **error)
|
||||
{
|
||||
|
@ -821,8 +822,31 @@ builder_module_build (BuilderModule *self,
|
|||
}
|
||||
}
|
||||
|
||||
if (!gs_shutil_rm_rf (source_dir, NULL, error))
|
||||
return FALSE;
|
||||
if (keep_build_dir)
|
||||
{
|
||||
g_autofree char *buildname_link = g_strdup_printf ("build-%s", self->name);
|
||||
g_autoptr(GFile) build_link = g_file_get_child (builder_context_get_state_dir (context),
|
||||
buildname_link);
|
||||
g_autoptr(GError) my_error = NULL;
|
||||
g_autofree char *buildname_target = g_path_get_basename (source_dir_path);
|
||||
|
||||
if (!g_file_delete (build_link, NULL, &my_error) &&
|
||||
!g_error_matches (my_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
||||
{
|
||||
g_propagate_error (error, g_steal_pointer (&my_error));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!g_file_make_symbolic_link (build_link,
|
||||
buildname_target,
|
||||
NULL, error))
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gs_shutil_rm_rf (source_dir, NULL, error))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ gboolean builder_module_extract_sources (BuilderModule *self,
|
|||
BuilderContext *context,
|
||||
GError **error);
|
||||
gboolean builder_module_build (BuilderModule *self,
|
||||
gboolean keep_build_dir,
|
||||
BuilderContext *context,
|
||||
GError **error);
|
||||
gboolean builder_module_update (BuilderModule *self,
|
||||
|
|
|
@ -38,6 +38,7 @@ static gboolean opt_download_only;
|
|||
static gboolean opt_build_only;
|
||||
static gboolean opt_disable_download;
|
||||
static gboolean opt_require_changes;
|
||||
static gboolean opt_keep_build_dirs;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL },
|
||||
|
@ -47,6 +48,7 @@ static GOptionEntry entries[] = {
|
|||
{ "download-only", 0, 0, G_OPTION_ARG_NONE, &opt_download_only, "Only download sources, don't build", NULL },
|
||||
{ "build-only", 0, 0, G_OPTION_ARG_NONE, &opt_build_only, "Stop after build, don't run clean and finish phases", NULL },
|
||||
{ "require-changes", 0, 0, G_OPTION_ARG_NONE, &opt_require_changes, "Don't create app dir if no changes", NULL },
|
||||
{ "keep-build-dirs", 0, 0, G_OPTION_ARG_NONE, &opt_keep_build_dirs, "Don't remove build directories after install", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
@ -199,7 +201,7 @@ main (int argc,
|
|||
}
|
||||
}
|
||||
|
||||
if (!builder_manifest_build (manifest, cache, build_context, &error))
|
||||
if (!builder_manifest_build (manifest, opt_keep_build_dirs, cache, build_context, &error))
|
||||
{
|
||||
g_print ("error: %s\n", error->message);
|
||||
return 1;
|
||||
|
|
|
@ -492,6 +492,15 @@
|
|||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--keep-build-dirs</option></term>
|
||||
|
||||
<listitem><para>
|
||||
Don't remote the sources and build after having built and installed each module.
|
||||
This also creates a symlink to the build directory with a stable name ("build-modulename").
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
|
Loading…
Reference in New Issue