forked from Mirrors/flatpak-builder
Support --show-manifest
We want to use this in flathub to avoid all the problems we've having parsing json manifests via the python parser, which isn't *quite* compatible with json-glib (differs in comment and multiline string support for instance). Closes: #307 Approved by: alexlarssonauto
parent
28aaaaa55e
commit
aab7bcd5e9
|
@ -49,6 +49,12 @@
|
|||
<arg choice="opt" rep="repeat">OPTION</arg>
|
||||
<arg choice="plain">MANIFEST</arg>
|
||||
</cmdsynopsis>
|
||||
<cmdsynopsis>
|
||||
<command>flatpak-builder</command>
|
||||
<arg choice="plain">--show-manifest</arg>
|
||||
<arg choice="opt" rep="repeat">OPTION</arg>
|
||||
<arg choice="plain">MANIFEST</arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
|
@ -253,6 +259,23 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--show-manifest</option></term>
|
||||
|
||||
<listitem><para>
|
||||
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).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Only the <option>--verbose</option> option can be combined
|
||||
with this option.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--download-only</option></term>
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue