Просмотр исходного кода

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
Jan Friesse 16 лет назад
Родитель
Сommit
9931d50b31
4 измененных файлов с 16 добавлено и 6 удалено
  1. 5 0
      configure.ac
  2. 1 1
      exec/Makefile.am
  3. 10 4
      exec/main.c
  4. 0 1
      exec/version.h

+ 5 - 0
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"

+ 1 - 1
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)

+ 10 - 4
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);

+ 0 - 1
exec/version.h

@@ -1 +0,0 @@
-#define RELEASE_VERSION "trunk"