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

Merge trunk revision 2381 (mine conflict):
r2381 | honzaf | 2009-08-04 00:39:03 -0700 (Tue, 04 Aug 2009) | 6 lines

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/branches/flatiron@2433 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 16 лет назад
Родитель
Сommit
38e0190002
3 измененных файлов с 15 добавлено и 5 удалено
  1. 5 0
      configure.ac
  2. 10 4
      exec/main.c
  3. 0 1
      exec/version.h

+ 5 - 0
configure.ac

@@ -14,6 +14,11 @@ AC_CANONICAL_HOST
 
 
 AC_LANG([C])
 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
 dnl Fix default variables - "prefix" variable if not specified
 if test "$prefix" = "NONE"; then
 if test "$prefix" = "NONE"; then
 	prefix="/usr"
 	prefix="/usr"

+ 10 - 4
exec/main.c

@@ -83,7 +83,6 @@
 #include "apidef.h"
 #include "apidef.h"
 #include "service.h"
 #include "service.h"
 #include "schedwrk.h"
 #include "schedwrk.h"
-#include "version.h"
 #include "evil.h"
 #include "evil.h"
 
 
 LOGSYS_DECLARE_SYSTEM ("corosync",
 LOGSYS_DECLARE_SYSTEM ("corosync",
@@ -743,7 +742,7 @@ int main (int argc, char **argv)
 	background = 1;
 	background = 1;
 	setprio = 1;
 	setprio = 1;
 
 
- 	while ((ch = getopt (argc, argv, "fp")) != EOF) {
+	while ((ch = getopt (argc, argv, "fpv")) != EOF) {
 
 
 		switch (ch) {
 		switch (ch) {
 			case 'f':
 			case 'f':
@@ -752,12 +751,19 @@ int main (int argc, char **argv)
 				break;
 				break;
 			case 'p':
 			case 'p':
 				setprio = 0;
 				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;
 				break;
 			default:
 			default:
 				fprintf(stderr, \
 				fprintf(stderr, \
 					"usage:\n"\
 					"usage:\n"\
 					"        -f     : Start application in foreground.\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;
 				return EXIT_FAILURE;
 		}
 		}
 	}
 	}
@@ -776,7 +782,7 @@ int main (int argc, char **argv)
 
 
 	corosync_mlockall ();
 	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 (SIGINT, sigintr_handler);
 	(void)signal (SIGUSR2, sigusr2_handler);
 	(void)signal (SIGUSR2, sigusr2_handler);

+ 0 - 1
exec/version.h

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