Add --add/remove-tag options

We'd like to use these in flathub.

Closes: #268
Approved by: alexlarsson
auto
Alexander Larsson 2019-02-04 10:46:14 +01:00 committed by Atomic Bot
parent 21356f8616
commit ab72117fdd
4 changed files with 83 additions and 0 deletions

View File

@ -534,6 +534,24 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--add-tag=TAG</option></term>
<listitem><para>
Add this tag to the tags list of the manifest before building.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--remove-tag=TAG</option></term>
<listitem><para>
Remove this tag to the tags list of the manifest before building. The remove
happen before processing the --add-tag option, so if both are specified, then
--app-tag wins.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--install-deps-from=REMOTE</option></term>

View File

@ -74,6 +74,8 @@ static char *opt_gpg_homedir;
static char **opt_key_ids;
static char **opt_sources_dirs;
static char **opt_sources_urls;
static char **opt_add_tags;
static char **opt_remove_tags;
static int opt_jobs;
static char *opt_mirror_screenshots_url;
static char *opt_install_deps_from;
@ -89,6 +91,8 @@ static GOptionEntry entries[] = {
{ "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print version information and exit", NULL },
{ "arch", 0, 0, G_OPTION_ARG_STRING, &opt_arch, "Architecture to build for (must be host compatible)", "ARCH" },
{ "default-branch", 0, 0, G_OPTION_ARG_STRING, &opt_default_branch, "Change the default branch", "BRANCH" },
{ "add-tag", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_add_tags, "Add a tag to the build", "TAG"},
{ "remove-tag", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_remove_tags, "Remove a tag from the build", "TAG"},
{ "run", 0, 0, G_OPTION_ARG_NONE, &opt_run, "Run a command in the build directory (see --run --help)", NULL },
{ "ccache", 0, 0, G_OPTION_ARG_NONE, &opt_ccache, "Use ccache", NULL },
{ "disable-cache", 0, 0, G_OPTION_ARG_NONE, &opt_disable_cache, "Disable cache lookups", NULL },
@ -689,6 +693,12 @@ main (int argc,
return 1;
}
if (opt_remove_tags)
builder_manifest_remove_tags (manifest, (const char **)opt_remove_tags);
if (opt_add_tags)
builder_manifest_add_tags (manifest, (const char **)opt_add_tags);
if (opt_default_branch)
builder_context_set_default_branch (build_context, opt_default_branch);

View File

@ -1415,6 +1415,56 @@ builder_manifest_set_default_collection_id (BuilderManifest *self,
self->collection_id = g_strdup (default_collection_id);
}
void
builder_manifest_add_tags (BuilderManifest *self,
const char **add_tags)
{
GPtrArray *new_tags = g_ptr_array_new ();
int i;
for (i = 0; self->tags != NULL && self->tags[i] != NULL; i++)
g_ptr_array_add (new_tags, self->tags[i]);
for (i = 0; add_tags[i] != NULL; i++)
{
const char *new_tag = add_tags[i];
if (self->tags == NULL || !g_strv_contains ((const char **)self->tags, new_tag))
g_ptr_array_add (new_tags, g_strdup (new_tag));
}
g_ptr_array_add (new_tags, NULL);
g_free (self->tags);
self->tags = (char **)g_ptr_array_free (new_tags, FALSE);
}
void
builder_manifest_remove_tags (BuilderManifest *self,
const char **remove_tags)
{
GPtrArray *new_tags = g_ptr_array_new ();
int i;
if (self->tags)
{
for (i = 0; self->tags[i] != NULL; i++)
{
char *old_tag = self->tags[i];
if (g_strv_contains (remove_tags, old_tag))
g_free (old_tag);
else
g_ptr_array_add (new_tags, old_tag);
}
}
g_ptr_array_add (new_tags, NULL);
g_free (self->tags);
self->tags = (char **)g_ptr_array_free (new_tags, FALSE);
}
const char *
builder_manifest_get_extension_tag (BuilderManifest *self)
{

View File

@ -66,6 +66,11 @@ const char * builder_manifest_get_extension_tag (BuilderManifest *self);
void builder_manifest_set_default_collection_id (BuilderManifest *self,
const char *default_collection_id);
void builder_manifest_add_tags (BuilderManifest *self,
const char **add_tags);
void builder_manifest_remove_tags (BuilderManifest *self,
const char **remove_tags);
char ** builder_manifest_get_exclude_dirs (BuilderManifest *self);