mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-11 09:18:20 +03:00
core: Add from-file argument to compose
We don't want to have to pass a million arguments.
This commit is contained in:
parent
dbba4538e1
commit
0044ff133a
@ -30,12 +30,14 @@
|
||||
static char *subject;
|
||||
static char *body;
|
||||
static char *branch;
|
||||
static char *from_file_path;
|
||||
static gboolean recompose;
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" },
|
||||
{ "body", 'm', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" },
|
||||
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &branch, "Branch", "branch" },
|
||||
{ "from-file", 'F', 0, G_OPTION_ARG_STRING, &from_file_path, "Take list of branches to compose from FILE", "FILE" },
|
||||
{ "recompose", 0, 0, G_OPTION_ARG_NONE, &recompose, "Regenerate compose from existing branches", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
@ -92,6 +94,9 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
char *commit_checksum = NULL;
|
||||
GCancellable *cancellable = NULL;
|
||||
GFile *metadata_f = NULL;
|
||||
GFile *from_file = NULL;
|
||||
char *from_file_contents = NULL;
|
||||
char **from_file_args = NULL;
|
||||
OstreeMutableTree *mtree = NULL;
|
||||
gboolean skip_commit = FALSE;
|
||||
gboolean in_transaction = FALSE;
|
||||
@ -177,6 +182,31 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
g_hash_table_insert (seen_branches, g_strdup (branch_name), (char*)branch_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (from_file_path)
|
||||
{
|
||||
char **iter;
|
||||
|
||||
from_file = ot_gfile_new_for_path (from_file_path);
|
||||
if (!ot_gfile_load_contents_utf8 (from_file,
|
||||
&from_file_contents, NULL, NULL, error))
|
||||
goto out;
|
||||
|
||||
from_file_args = g_strsplit_set (from_file_contents, "\n", -1);
|
||||
|
||||
for (iter = from_file_args; *iter && **iter; iter++)
|
||||
{
|
||||
const char *src_branch = *iter;
|
||||
|
||||
if (seen_branches && g_hash_table_lookup (seen_branches, src_branch))
|
||||
continue;
|
||||
|
||||
if (!add_branch (repo, mtree, src_branch,
|
||||
&compose_metadata_builder,
|
||||
error))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
@ -272,5 +302,8 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
g_clear_object (&destf);
|
||||
g_clear_object (&metadata_f);
|
||||
g_clear_object (&mtree);
|
||||
g_clear_object (&from_file);
|
||||
g_free (from_file_contents);
|
||||
g_strfreev (from_file_args);
|
||||
return ret;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
echo "1..7"
|
||||
echo "1..8"
|
||||
|
||||
. libtest.sh
|
||||
|
||||
@ -99,3 +99,14 @@ $OSTREE checkout some-compose some-compose-checkout
|
||||
cd some-compose-checkout
|
||||
assert_file_has_content ./usr/bin/bar 'updated bar ELF file'
|
||||
echo 'ok recompose with args'
|
||||
|
||||
cd "${test_tmpdir}"
|
||||
echo artifact-libfoo-runtime > compose-contents.txt
|
||||
echo artifact-libfoo-devel >> compose-contents.txt
|
||||
echo artifact-barapp >> compose-contents.txt
|
||||
$OSTREE compose -b some-compose-from-file -s 'from file' -F compose-contents.txt
|
||||
rm -rf some-compose-checkout
|
||||
$OSTREE checkout some-compose-from-file some-compose-checkout
|
||||
cd some-compose-checkout
|
||||
assert_file_has_content ./usr/bin/bar 'updated bar ELF file'
|
||||
echo 'ok recompose from file'
|
||||
|
Loading…
Reference in New Issue
Block a user