main: Output YAML for --version

Equivalent of https://github.com/ostreedev/ostree/pull/691
Basically, it's nicer to parse.

Closes: #665
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-03-06 15:53:02 -05:00 committed by Atomic Bot
parent afbf0de286
commit 14a9135ea0
3 changed files with 17 additions and 5 deletions

View File

@ -156,7 +156,7 @@ AM_CONDITIONAL(BUILDOPT_COMPOSE_TOOLING, [test x$enable_compose_tooling = xyes])
AS_IF([test x$enable_compose_tooling = xyes], [
AC_DEFINE(HAVE_COMPOSE_TOOLING, 1, [Define if we are building compose tooling])
])
if test x$enable_compose_tooling != xno; then RPM_OSTREE_FEATURES="$RPM_OSTREE_FEATURES +compose"; fi
if test x$enable_compose_tooling != xno; then RPM_OSTREE_FEATURES="$RPM_OSTREE_FEATURES compose"; fi
dnl Try to automatically determine cmake type from CFLAGS
if $(echo $CFLAGS |grep -q -e "-O0"); then

View File

@ -146,10 +146,18 @@ rpmostree_option_context_parse (GOptionContext *context,
if (opt_version)
{
g_print ("%s", PACKAGE_STRING);
/* This should now be YAML, like `docker version`, so it's both nice to read
* possible to parse. The canonical implementation of this is in
* ostree/ot-main.c.
*/
g_auto(GStrv) features = g_strsplit (RPM_OSTREE_FEATURES, " ", -1);
g_print ("%s:\n", PACKAGE_NAME);
g_print (" Version: %s\n", PACKAGE_VERSION);
if (strlen (RPM_OSTREE_GITREV) > 0)
g_print (", git %s", RPM_OSTREE_GITREV);
g_print ("\n %s\n", RPM_OSTREE_FEATURES);
g_print (" Git: %s\n", RPM_OSTREE_GITREV);
g_print (" Features:\n");
for (char **iter = features; iter && *iter; iter++)
g_print (" - %s\n", *iter);
exit (EXIT_SUCCESS);
}

View File

@ -24,7 +24,7 @@ export RPMOSTREE_SUPPRESS_REQUIRES_ROOT_CHECK=yes
ensure_dbus
echo "1..16"
echo "1..17"
setup_os_repository "archive-z2" "syslinux"
@ -37,6 +37,10 @@ echo "ok setup"
OSTREE="ostree --repo=sysroot/ostree/repo"
REMOTE_OSTREE="ostree --repo=testos-repo --gpg-homedir=${test_tmpdir}/gpghome"
rpm-ostree --version > version.yaml
python -c 'import yaml; v=yaml.safe_load(open("version.yaml")); assert("Version" in v["rpm-ostree"])'
echo "ok yaml version"
# This initial deployment gets kicked off with some kernel arguments
$OSTREE remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
$OSTREE pull testos:testos/buildmaster/x86_64-runtime