build-export: Add --arch option

This patch adds the --arch option to the build-export builtin command.

Previously build-export derives this from the metadata and then falls back
to xdg_app_get_arch(), except that this does not work when the metadata does
not specify an arch (such as with extensions like .Debug or .Locale).

https://bugs.freedesktop.org/show_bug.cgi?id=95226
tingping/wmclass
Tristan Van Berkom 2016-04-30 22:43:39 +01:00 committed by Alexander Larsson
parent 4d21107f1c
commit 51e387159b
3 changed files with 26 additions and 7 deletions

View File

@ -33,6 +33,7 @@
static char *opt_subject;
static char *opt_body;
static char *opt_arch;
static gboolean opt_runtime;
static gboolean opt_update_appstream;
static char **opt_gpg_key_ids;
@ -45,6 +46,7 @@ static char *opt_metadata;
static GOptionEntry options[] = {
{ "subject", 's', 0, G_OPTION_ARG_STRING, &opt_subject, "One line subject", "SUBJECT" },
{ "body", 'b', 0, G_OPTION_ARG_STRING, &opt_body, "Full description", "BODY" },
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, "Architecture to export for (must be host compatible)", "ARCH" },
{ "runtime", 'r', 0, G_OPTION_ARG_NONE, &opt_runtime, "Commit runtime (/usr), not /app" },
{ "update-appstream", 0, 0, G_OPTION_ARG_NONE, &opt_runtime, "Update the appstream branch" },
{ "files", 0, 0, G_OPTION_ARG_STRING, &opt_files, "Use alternative directory for the files", "SUBDIR"},
@ -65,6 +67,12 @@ metadata_get_arch (GFile *file, char **out_arch, GError **error)
g_autofree char *runtime = NULL;
g_auto(GStrv) parts = NULL;
if (opt_arch != NULL)
{
*out_arch = g_strdup (opt_arch);
return TRUE;
}
keyfile = g_key_file_new ();
path = g_file_get_path (file);
if (!g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, error))

View File

@ -98,8 +98,9 @@ usage (GOptionContext *context, const char *message)
static const char skip_arg[] = "skip";
static gboolean
do_export (GError **error,
gboolean runtime,
do_export (BuilderContext *build_context,
GError **error,
gboolean runtime,
...)
{
va_list ap;
@ -113,6 +114,8 @@ do_export (GError **error,
g_ptr_array_add (args, g_strdup ("xdg-app"));
g_ptr_array_add (args, g_strdup ("build-export"));
g_ptr_array_add (args, g_strdup_printf ("--arch=%s", builder_context_get_arch (build_context)));
if (runtime)
g_ptr_array_add (args, g_strdup ("--runtime"));
@ -369,7 +372,7 @@ main (int argc,
g_print ("exporting %s to repo\n", builder_manifest_get_id (manifest));
if (!do_export (&error,
if (!do_export (build_context, &error,
builder_context_get_build_runtime (build_context),
"--exclude=/lib/debug/*",
"--include=/lib/debug/app",
@ -402,7 +405,7 @@ main (int argc,
metadata_arg = g_strdup_printf ("--metadata=%s", name);
files_arg = g_strconcat (builder_context_get_build_runtime (build_context) ? "--files=usr" : "--files=files",
"/share/runtime/locale/", NULL);
if (!do_export (&error, TRUE,
if (!do_export (build_context, &error, TRUE,
metadata_arg,
files_arg,
opt_repo, app_dir_path, builder_manifest_get_branch (manifest), NULL))
@ -418,7 +421,7 @@ main (int argc,
{
g_print ("exporting %s.Debug to repo\n", builder_manifest_get_id (manifest));
if (!do_export (&error, TRUE,
if (!do_export (build_context, &error, TRUE,
"--metadata=metadata.debuginfo",
builder_context_get_build_runtime (build_context) ? "--files=usr/lib/debug" : "--files=files/lib/debug",
opt_repo, app_dir_path, builder_manifest_get_branch (manifest), NULL))
@ -435,7 +438,7 @@ main (int argc,
{
g_print ("exporting %s to repo\n", platform_id);
if (!do_export (&error, TRUE,
if (!do_export (build_context, &error, TRUE,
"--metadata=metadata.platform",
"--files=platform",
builder_context_get_separate_locales (build_context) ? "--exclude=/share/runtime/locale/*/*" : skip_arg,
@ -467,7 +470,7 @@ main (int argc,
metadata_arg = g_strdup_printf ("--metadata=%s", name);
files_arg = g_strconcat ("--files=platform/share/runtime/locale/", NULL);
if (!do_export (&error, TRUE,
if (!do_export (build_context, &error, TRUE,
metadata_arg,
files_arg,
opt_repo, app_dir_path, builder_manifest_get_branch (manifest), NULL))

View File

@ -102,6 +102,14 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--arch=ARCH</option></term>
<listitem><para>
Specify the architecture component of the branch to export. Only host compatible architectures can be specified.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--exclude=PATTERN</option></term>