[ostree] core: Add from-file argument to compose
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Add from-file argument to compose
- Date: Wed, 11 Jan 2012 18:44:03 +0000 (UTC)
commit 0044ff133a35f7925b11f4e5d2c6aeaa76ca4ea7
Author: Colin Walters <walters verbum org>
Date: Tue Jan 10 18:55:00 2012 -0500
core: Add from-file argument to compose
We don't want to have to pass a million arguments.
src/ostree/ot-builtin-compose.c | 33 +++++++++++++++++++++++++++++++++
tests/t0004-compose.sh | 13 ++++++++++++-
2 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/src/ostree/ot-builtin-compose.c b/src/ostree/ot-builtin-compose.c
index 3fc18b3..9bbc915 100644
--- a/src/ostree/ot-builtin-compose.c
+++ b/src/ostree/ot-builtin-compose.c
@@ -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;
}
diff --git a/tests/t0004-compose.sh b/tests/t0004-compose.sh
index 5014c00..8ec351e 100755
--- a/tests/t0004-compose.sh
+++ b/tests/t0004-compose.sh
@@ -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'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]