builder: add a build finish option

With the option you can resume an application build where it left
off when calling flatpak-buidler --build-only
This commit is contained in:
Matt Watson
2016-10-07 15:41:46 -07:00
committed by Alexander Larsson
parent f9ed36e092
commit e968b87f6a
2 changed files with 44 additions and 21 deletions

View File

@@ -37,6 +37,7 @@ static gboolean opt_run;
static gboolean opt_disable_cache;
static gboolean opt_download_only;
static gboolean opt_build_only;
static gboolean opt_finish_only;
static gboolean opt_show_deps;
static gboolean opt_disable_download;
static gboolean opt_disable_updates;
@@ -64,6 +65,7 @@ static GOptionEntry entries[] = {
{ "disable-updates", 0, 0, G_OPTION_ARG_NONE, &opt_disable_updates, "Only download missing sources, never update to latest vcs version", NULL },
{ "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 },
{ "finish-only", 0, 0, G_OPTION_ARG_NONE, &opt_finish_only, "Only run clean and finish and export phases", NULL },
{ "show-deps", 0, 0, G_OPTION_ARG_NONE, &opt_show_deps, "List the dependencies of the json file (see --show-deps --help)", NULL },
{ "require-changes", 0, 0, G_OPTION_ARG_NONE, &opt_require_changes, "Don't create app dir or export 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 },
@@ -197,6 +199,7 @@ main (int argc,
g_autofree char **orig_argv;
gboolean is_run = FALSE;
gboolean is_show_deps = FALSE;
gboolean app_dir_is_empty = FALSE;
g_autoptr(FlatpakContext) arg_context = NULL;
int i, first_non_arg, orig_argc;
int argnr;
@@ -333,12 +336,14 @@ main (int argc,
return 1;
}
app_dir_is_empty = !g_file_query_exists (app_dir, NULL) ||
directory_is_empty (app_dir_path);
if (is_run)
{
g_assert (opt_run);
if (!g_file_query_exists (app_dir, NULL) ||
directory_is_empty (app_dir_path))
if (app_dir_is_empty)
{
g_printerr ("App dir '%s' is empty or doesn't exist.\n", app_dir_path);
return 1;
@@ -358,7 +363,7 @@ main (int argc,
g_assert (!opt_run);
g_assert (!opt_show_deps);
if (g_file_query_exists (app_dir, NULL) && !directory_is_empty (app_dir_path))
if (!opt_finish_only && !app_dir_is_empty)
{
if (opt_force_clean)
{
@@ -377,6 +382,11 @@ main (int argc,
return 1;
}
}
if (opt_finish_only && app_dir_is_empty)
{
g_printerr ("App dir '%s' is empty or doesn't exist.\n", app_dir_path);
return 1;
}
if (!builder_manifest_start (manifest, build_context, &error))
{
@@ -384,7 +394,8 @@ main (int argc,
return 1;
}
if (!opt_disable_download &&
if (!opt_finish_only &&
!opt_disable_download &&
!builder_manifest_download (manifest, !opt_disable_updates, build_context, &error))
{
g_printerr ("Failed to download sources: %s\n", error->message);
@@ -408,28 +419,31 @@ main (int argc,
builder_manifest_checksum (manifest, cache, build_context);
if (!builder_cache_lookup (cache, "init"))
if (!opt_finish_only)
{
g_autofree char *body =
g_strdup_printf ("Initialized %s\n",
builder_manifest_get_id (manifest));
if (!builder_manifest_init_app_dir (manifest, build_context, &error))
if (!builder_cache_lookup (cache, "init"))
{
g_autofree char *body =
g_strdup_printf ("Initialized %s\n",
builder_manifest_get_id (manifest));
if (!builder_manifest_init_app_dir (manifest, build_context, &error))
{
g_printerr ("Error: %s\n", error->message);
return 1;
}
if (!builder_cache_commit (cache, body, &error))
{
g_printerr ("Error: %s\n", error->message);
return 1;
}
}
if (!builder_manifest_build (manifest, cache, build_context, &error))
{
g_printerr ("Error: %s\n", error->message);
return 1;
}
if (!builder_cache_commit (cache, body, &error))
{
g_printerr ("Error: %s\n", error->message);
return 1;
}
}
if (!builder_manifest_build (manifest, cache, build_context, &error))
{
g_printerr ("Error: %s\n", error->message);
return 1;
}
if (!opt_build_only)

View File

@@ -659,6 +659,15 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--finish-only</option></term>
<listitem><para>
Only do the cleanup, finish and export stages, picking up
where a --build-only command left off.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--require-changes</option></term>