2017.10-2: Backport fix for --repo handling

https://github.com/projectatomic/rpm-ostree/pull/1101
This commit is contained in:
Jonathan Lebon 2017-11-13 03:17:49 +00:00
parent a43cbae1de
commit 774cabbaaa
2 changed files with 117 additions and 1 deletions

View File

@ -0,0 +1,111 @@
From 00fab1ec2336ec35bd20caff43635e2032b24c2f Mon Sep 17 00:00:00 2001
From: Jonathan Lebon <jlebon@redhat.com>
Date: Mon, 13 Nov 2017 03:09:00 +0000
Subject: [PATCH] compose CLI: fix --repo consuming two arguments
I was trying to figure out why:
rpm-ostree compose tree --repo repo/ manifest.json
would result in:
error: opendir(manifest.json): No such file or directory
It turned out to be because we had `--repo` in *both* the `install`
options and the `commit` options. This makes sense since both these
subcommands need to be given a repo. However, in the `tree` case, we
were adding both arrays, which meant we inherited two `GOptionEntry`s
for `--repo`. This confused glib2 which consumed not one but two CLI
arguments when looking for the argument associated with `--repo`.
Our CI didn't notice this because it uses the `--repo=foo` notation,
which doesn't throw off glib2.
Fix this by factoring out the `--repo` option into a separate array so
that in the `tree` case, it only gets added once. Exercise the fix in CI
by using the two argument notation for `--repo`.
Closes: #1101
Approved by: cgwalters
---
src/app/rpmostree-compose-builtin-tree.c | 14 ++++++++++++--
tests/compose-tests/libcomposetest.sh | 2 +-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/app/rpmostree-compose-builtin-tree.c b/src/app/rpmostree-compose-builtin-tree.c
index 9291e17..be66e62 100644
--- a/src/app/rpmostree-compose-builtin-tree.c
+++ b/src/app/rpmostree-compose-builtin-tree.c
@@ -58,13 +58,18 @@ static gboolean opt_dry_run;
static gboolean opt_print_only;
static char *opt_write_commitid_to;
+/* shared by both install & commit */
+static GOptionEntry common_option_entries[] = {
+ { "repo", 'r', 0, G_OPTION_ARG_STRING, &opt_repo, "Path to OSTree repository", "REPO" },
+ { NULL }
+};
+
static GOptionEntry install_option_entries[] = {
{ "force-nocache", 0, 0, G_OPTION_ARG_NONE, &opt_force_nocache, "Always create a new OSTree commit, even if nothing appears to have changed", NULL },
{ "cache-only", 0, 0, G_OPTION_ARG_NONE, &opt_cache_only, "Assume cache is present, do not attempt to update it", NULL },
{ "cachedir", 0, 0, G_OPTION_ARG_STRING, &opt_cachedir, "Cached state", "CACHEDIR" },
{ "proxy", 0, 0, G_OPTION_ARG_STRING, &opt_proxy, "HTTP proxy", "PROXY" },
{ "dry-run", 0, 0, G_OPTION_ARG_NONE, &opt_dry_run, "Just print the transaction and exit", NULL },
- { "repo", 'r', 0, G_OPTION_ARG_STRING, &opt_repo, "Path to OSTree repository", "REPO" },
{ "output-repodata-dir", 0, 0, G_OPTION_ARG_STRING, &opt_output_repodata_dir, "Save downloaded repodata in DIR", "DIR" },
{ "print-only", 0, 0, G_OPTION_ARG_NONE, &opt_print_only, "Just expand any includes and print treefile", NULL },
{ "touch-if-changed", 0, 0, G_OPTION_ARG_STRING, &opt_touch_if_changed, "Update the modification time on FILE if a new commit was created", "FILE" },
@@ -80,7 +85,6 @@ static GOptionEntry postprocess_option_entries[] = {
static GOptionEntry commit_option_entries[] = {
{ "add-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_strings, "Append given key and value (in string format) to metadata", "KEY=VALUE" },
{ "add-metadata-from-json", 0, 0, G_OPTION_ARG_STRING, &opt_metadata_json, "Parse the given JSON file as object, convert to GVariant, append to OSTree commit", "JSON" },
- { "repo", 'r', 0, G_OPTION_ARG_STRING, &opt_repo, "Path to OSTree repository", "REPO" },
{ "write-commitid-to", 0, 0, G_OPTION_ARG_STRING, &opt_write_commitid_to, "File to write the composed commitid to instead of updating the ref", "FILE" },
{ NULL }
};
@@ -1066,6 +1070,8 @@ rpmostree_compose_builtin_install (int argc,
GError **error)
{
g_autoptr(GOptionContext) context = g_option_context_new ("TREEFILE DESTDIR");
+ g_option_context_add_main_entries (context, common_option_entries, NULL);
+
if (!rpmostree_option_context_parse (context,
install_option_entries,
&argc, &argv,
@@ -1172,6 +1178,8 @@ rpmostree_compose_builtin_commit (int argc,
GError **error)
{
g_autoptr(GOptionContext) context = g_option_context_new ("TREEFILE ROOTFS");
+ g_option_context_add_main_entries (context, common_option_entries, NULL);
+
if (!rpmostree_option_context_parse (context,
commit_option_entries,
&argc, &argv,
@@ -1214,8 +1222,10 @@ rpmostree_compose_builtin_tree (int argc,
GError **error)
{
g_autoptr(GOptionContext) context = g_option_context_new ("TREEFILE");
+ g_option_context_add_main_entries (context, common_option_entries, NULL);
g_option_context_add_main_entries (context, install_option_entries, NULL);
g_option_context_add_main_entries (context, postprocess_option_entries, NULL);
+
if (!rpmostree_option_context_parse (context,
commit_option_entries,
&argc, &argv,
diff --git a/tests/compose-tests/libcomposetest.sh b/tests/compose-tests/libcomposetest.sh
index 94d9dc4..885b3cb 100644
--- a/tests/compose-tests/libcomposetest.sh
+++ b/tests/compose-tests/libcomposetest.sh
@@ -33,7 +33,7 @@ prepare_compose_test() {
export treeref=fedora/stable/x86_64/${name}
}
-compose_base_argv="--repo=${repobuild} --cache-only --cachedir=${test_compose_datadir}/cache"
+compose_base_argv="--repo ${repobuild} --cache-only --cachedir=${test_compose_datadir}/cache"
runcompose() {
rpm-ostree compose tree ${compose_base_argv} ${treefile} "$@"
ostree --repo=${repo} pull-local ${repobuild}
--
2.13.5

View File

@ -1,13 +1,14 @@
Summary: Hybrid image/package system Summary: Hybrid image/package system
Name: rpm-ostree Name: rpm-ostree
Version: 2017.10 Version: 2017.10
Release: 1%{?dist} Release: 2%{?dist}
#VCS: https://github.com/cgwalters/rpm-ostree #VCS: https://github.com/cgwalters/rpm-ostree
# This tarball is generated via "make -f Makefile.dist-packaging dist-snapshot" # This tarball is generated via "make -f Makefile.dist-packaging dist-snapshot"
Source0: rpm-ostree-%{version}.tar.xz Source0: rpm-ostree-%{version}.tar.xz
License: LGPLv2+ License: LGPLv2+
URL: https://github.com/projectatomic/rpm-ostree URL: https://github.com/projectatomic/rpm-ostree
Patch0: 0001-compose-CLI-fix-repo-consuming-two-arguments.patch
# We always run autogen.sh # We always run autogen.sh
BuildRequires: autoconf automake libtool git BuildRequires: autoconf automake libtool git
@ -151,6 +152,10 @@ python autofiles.py > files.devel \
%files devel -f files.devel %files devel -f files.devel
%changelog %changelog
* Sun Nov 14 2017 Jonathan Lebon <jlebon@redhat.com> - 2017.10-2
- Backport fix for --repo handling
https://github.com/projectatomic/rpm-ostree/pull/1101
* Thu Nov 02 2017 Colin Walters <walters@verbum.org> - 2017.10-1 * Thu Nov 02 2017 Colin Walters <walters@verbum.org> - 2017.10-1
- https://github.com/projectatomic/rpm-ostree/releases/tag/v2017.10 - https://github.com/projectatomic/rpm-ostree/releases/tag/v2017.10