From 9931d50b315a885b824db88d1e65d5f34c58adbf Mon Sep 17 00:00:00 2001 From: Jan Friesse Date: Tue, 4 Aug 2009 07:39:03 +0000 Subject: [PATCH] Support for -v (version) feature This can be usefull for easier way to get informations of the corosync version from users. Version and SVN revision (get by svninfo -c) are displayed. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2381 fd59a12c-fef9-0310-b244-a6a79926bd2f --- configure.ac | 5 +++++ exec/Makefile.am | 2 +- exec/main.c | 14 ++++++++++---- exec/version.h | 1 - 4 files changed, 16 insertions(+), 6 deletions(-) delete mode 100644 exec/version.h diff --git a/configure.ac b/configure.ac index 3fb46233..6d82a4a6 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,11 @@ AC_CANONICAL_HOST AC_LANG([C]) +# Define SVN revision +AC_DEFINE([SVN_REVISION],["m4_esyscmd([svnversion >/dev/null 2>&1 && \ + svnversion -n || \ + echo -n exported])"], [SVN revision]) + dnl Fix default variables - "prefix" variable if not specified if test "$prefix" = "NONE"; then prefix="/usr" diff --git a/exec/Makefile.am b/exec/Makefile.am index 5f83c648..8361a645 100644 --- a/exec/Makefile.am +++ b/exec/Makefile.am @@ -70,7 +70,7 @@ SHARED_LIBS_SO_TWO = $(SHARED_LIBS:%.so.$(SONAME)=%.so.$(SOMAJOR)) noinst_HEADERS = apidef.h crypto.h mainconfig.h main.h \ quorum.h service.h sync.h timer.h tlist.h totemconfig.h \ totemmrp.h totemnet.h totemudp.h totemiba.h totemrrp.h \ - totemsrp.h util.h version.h vsf.h wthread.h schedwrk.h \ + totemsrp.h util.h vsf.h wthread.h schedwrk.h \ evil.h syncv2.h EXTRA_DIST = $(LCRSO_SRC) diff --git a/exec/main.c b/exec/main.c index 96919b63..f85f7736 100644 --- a/exec/main.c +++ b/exec/main.c @@ -83,7 +83,6 @@ #include "apidef.h" #include "service.h" #include "schedwrk.h" -#include "version.h" #include "evil.h" LOGSYS_DECLARE_SYSTEM ("corosync", @@ -757,7 +756,7 @@ int main (int argc, char **argv) background = 1; setprio = 1; - while ((ch = getopt (argc, argv, "fp")) != EOF) { + while ((ch = getopt (argc, argv, "fpv")) != EOF) { switch (ch) { case 'f': @@ -766,12 +765,19 @@ int main (int argc, char **argv) break; case 'p': setprio = 0; + break; + case 'v': + printf ("Corosync Cluster Engine, version '%s' SVN revision '%s'\n", VERSION, SVN_REVISION); + printf ("Copyright (c) 2006-2009 Red Hat, Inc.\n"); + return EXIT_SUCCESS; + break; default: fprintf(stderr, \ "usage:\n"\ " -f : Start application in foreground.\n"\ - " -p : Do not set process priority. \n"); + " -p : Do not set process priority. \n"\ + " -v : Display version and SVN revision of Corosync and exit.\n"); return EXIT_FAILURE; } } @@ -790,7 +796,7 @@ int main (int argc, char **argv) corosync_mlockall (); - log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine ('%s'): started and ready to provide service.\n", RELEASE_VERSION); + log_printf (LOGSYS_LEVEL_NOTICE, "Corosync Cluster Engine ('%s'): started and ready to provide service.\n", VERSION); (void)signal (SIGINT, sigintr_handler); (void)signal (SIGUSR2, sigusr2_handler); diff --git a/exec/version.h b/exec/version.h deleted file mode 100644 index 6c21615f..00000000 --- a/exec/version.h +++ /dev/null @@ -1 +0,0 @@ -#define RELEASE_VERSION "trunk"