Add a --version argument that also outputs features

And use it in the tests to skip libarchive tests when the build
doesn't support it.
This commit is contained in:
Colin Walters 2013-05-01 19:15:06 -04:00
parent b1ace57ef8
commit 82f444020e
4 changed files with 32 additions and 0 deletions

View File

@ -17,6 +17,7 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_CPPFLAGS = -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \
-DOSTREE_FEATURES='"$(OSTREE_FEATURES)"' \
-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_34 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_34 \
-DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_40 -DSOUP_VERSION_MAX_ALLOWED=SOUP_VERSION_40
AM_CFLAGS = $(WARN_CFLAGS)

View File

@ -28,6 +28,9 @@ AC_SUBST(WARN_CFLAGS)
LT_PREREQ([2.2.4])
LT_INIT([disable-static])
OSTREE_FEATURES=""
AC_SUBST([OSTREE_FEATURES])
AC_ARG_ENABLE(triggers-only,
AS_HELP_STRING([--enable-triggers-only], [Only build and install triggers]),,
enable_triggers_only=no)
@ -70,12 +73,14 @@ AS_IF([test x$enable_embedded_dependencies = xyes], [
])
AS_IF([test x$have_soup = xyes], [
PKG_CHECK_MODULES(OT_DEP_SOUP, $SOUP_DEPENDENCY)
AC_DEFINE(HAVE_LIBSOUP, 1, [Define if we have libsoup.pc])
with_soup=yes
], [
with_soup=no
])
], [ with_soup=no ])
])
if test x$with_soup != xno; then OSTREE_FEATURES="$OSTREE_FEATURES +libsoup"; fi
AM_CONDITIONAL(USE_LIBSOUP, test x$with_soup != xno)
LIBARCHIVE_DEPENDENCY="libarchive >= 2.8.0"
@ -117,6 +122,7 @@ AS_IF([ test x$with_libarchive != xno ], [
with_libarchive=no
])
], [ with_libarchive=no ])
if test x$with_libarchive != xno; then OSTREE_FEATURES="$OSTREE_FEATURES +libarchive"; fi
AM_CONDITIONAL(USE_LIBARCHIVE, test $with_libarchive != no)
AS_IF([test x$cross_compiling != xyes && test -d /etc/kernel && test x$enable_triggers_only != xyes ],

View File

@ -29,6 +29,13 @@
#include "ot-main.h"
#include "otutil.h"
static gboolean opt_version;
static GOptionEntry main_options[] = {
{ "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Display version", NULL },
{ NULL }
};
int
ostree_usage (char **argv,
OstreeCommand *commands,
@ -80,6 +87,7 @@ ostree_run (int argc,
OstreeCommand *commands,
GError **res_error)
{
GOptionContext *optcontext;
OstreeCommand *command;
GError *error = NULL;
int cmd_argc;
@ -104,6 +112,19 @@ ostree_run (int argc,
if (argc < 2)
return ostree_usage (argv, commands, TRUE);
optcontext = g_option_context_new ("COMMAND [OPTIONS...]");
g_option_context_add_main_entries (optcontext, main_options, NULL);
g_option_context_set_ignore_unknown_options (optcontext, TRUE);
if (!g_option_context_parse (optcontext, &argc, &argv, &error))
goto out;
if (opt_version)
{
g_print ("%s\n %s\n", PACKAGE_STRING, OSTREE_FEATURES);
return 0;
}
have_repo_arg = g_str_has_prefix (argv[1], "--repo=");
if (have_repo_arg)

View File

@ -19,6 +19,10 @@
set -e
if ! ostree --version | grep -q -e '\+libarchive'; then
exit 77
fi
echo "1..7"
. $(dirname $0)/libtest.sh