diff --git a/doc/flatpak-builder.xml b/doc/flatpak-builder.xml
index b9395f93..d457da97 100644
--- a/doc/flatpak-builder.xml
+++ b/doc/flatpak-builder.xml
@@ -49,6 +49,12 @@
OPTION
MANIFEST
+
+ flatpak-builder
+ --show-manifest
+ OPTION
+ MANIFEST
+
@@ -253,6 +259,23 @@
+
+
+
+
+ Loads the manifest, including any included files and prints it in a canonical json format.
+ This is useful for tools that want to handle manifest files to avoid having to support both
+ yaml and json, as well as some non-standard json handling that is supported (for example
+ comments and multiline strings).
+
+
+
+ Only the option can be combined
+ with this option.
+
+
+
+
diff --git a/src/builder-main.c b/src/builder-main.c
index 13c810fc..a5f66015 100644
--- a/src/builder-main.c
+++ b/src/builder-main.c
@@ -47,6 +47,7 @@ static gboolean opt_build_only;
static gboolean opt_finish_only;
static gboolean opt_export_only;
static gboolean opt_show_deps;
+static gboolean opt_show_manifest;
static gboolean opt_disable_download;
static gboolean opt_disable_updates;
static gboolean opt_ccache;
@@ -109,6 +110,7 @@ static GOptionEntry entries[] = {
{ "export-only", 0, 0, G_OPTION_ARG_NONE, &opt_export_only, "Only run export phase", NULL },
{ "allow-missing-runtimes", 0, 0, G_OPTION_ARG_NONE, &opt_allow_missing_runtimes, "Don't fail if runtime and sdk missing", NULL },
{ "show-deps", 0, 0, G_OPTION_ARG_NONE, &opt_show_deps, "List the dependencies of the json file (see --show-deps --help)", NULL },
+ { "show-manifest", 0, 0, G_OPTION_ARG_NONE, &opt_show_manifest, "Print out the manifest file in standard json format (see --show-manifest --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 },
{ "delete-build-dirs", 0, 0, G_OPTION_ARG_NONE, &opt_delete_build_dirs, "Always remove build directories, even after build failure", NULL },
@@ -152,7 +154,13 @@ static GOptionEntry run_entries[] = {
static GOptionEntry show_deps_entries[] = {
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL },
- { "show-deps", 0, 0, G_OPTION_ARG_NONE, &opt_show_deps, "List the dependencies of the json file (see --show-deps --help)", NULL },
+ { "show-deps", 0, 0, G_OPTION_ARG_NONE, &opt_show_deps, "List the dependencies of the json file", NULL },
+ { NULL }
+};
+
+static GOptionEntry show_manifest_entries[] = {
+ { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL },
+ { "show-manifest", 0, 0, G_OPTION_ARG_NONE, &opt_show_manifest, "Print out the manifest file in standard json format", NULL },
{ NULL }
};
@@ -379,6 +387,7 @@ main (int argc,
g_autofree char **orig_argv = NULL;
gboolean is_run = FALSE;
gboolean is_show_deps = FALSE;
+ gboolean is_show_manifest = FALSE;
gboolean app_dir_is_empty = FALSE;
gboolean prune_unused_stages = FALSE;
g_autoptr(FlatpakContext) arg_context = NULL;
@@ -426,6 +435,8 @@ main (int argc,
is_run = TRUE;
if (strcmp (argv[i], "--show-deps") == 0)
is_show_deps = TRUE;
+ if (strcmp (argv[i], "--show-manifest") == 0)
+ is_show_manifest = TRUE;
}
if (is_run)
@@ -443,6 +454,11 @@ main (int argc,
context = g_option_context_new ("MANIFEST - Show manifest dependencies");
g_option_context_add_main_entries (context, show_deps_entries, NULL);
}
+ else if (is_show_manifest)
+ {
+ context = g_option_context_new ("MANIFEST - Show manifest");
+ g_option_context_add_main_entries (context, show_manifest_entries, NULL);
+ }
else
{
context = g_option_context_new ("DIRECTORY MANIFEST - Build manifest");
@@ -466,7 +482,7 @@ main (int argc,
argnr = 1;
- if (!is_show_deps)
+ if (!is_show_deps && !is_show_manifest)
{
if (argc == argnr)
return usage (context, "DIRECTORY must be specified");
@@ -574,7 +590,7 @@ main (int argc,
if (opt_disable_updates)
{
mirror_flags |= FLATPAK_GIT_MIRROR_FLAGS_UPDATE;
- }
+ }
if (!builder_git_mirror_repo (opt_from_git,
NULL,
@@ -673,6 +689,13 @@ main (int argc,
return 0;
}
+ if (is_show_manifest)
+ {
+ g_autofree char *json = builder_manifest_serialize (manifest);
+ g_print ("%s\n", json);
+ return 0;
+ }
+
if (opt_install_deps_from != NULL)
{
if (!builder_manifest_install_deps (manifest, build_context, opt_install_deps_from, opt_user, opt_installation,
diff --git a/src/builder-manifest.c b/src/builder-manifest.c
index f5c51684..c9bb95c8 100644
--- a/src/builder-manifest.c
+++ b/src/builder-manifest.c
@@ -1289,7 +1289,7 @@ serializable_iface_init (JsonSerializableIface *serializable_iface)
serializable_iface->get_property = builder_serializable_get_property;
}
-static char *
+char *
builder_manifest_serialize (BuilderManifest *self)
{
JsonNode *node;
diff --git a/src/builder-manifest.h b/src/builder-manifest.h
index e4f31d94..1d656c96 100644
--- a/src/builder-manifest.h
+++ b/src/builder-manifest.h
@@ -134,6 +134,7 @@ gboolean builder_manifest_create_platform (BuilderManifest *self,
BuilderCache *cache,
BuilderContext *context,
GError **error);
+char * builder_manifest_serialize (BuilderManifest *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BuilderManifest, g_object_unref)