From e55d345ab49609e820bbaea8cd236b0ccda2852f Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 2 Sep 2015 08:57:00 +0300 Subject: [PATCH] Added --version-full which prints version and commit ID. --- .../Tutorials/Administration-Tutorial.md | 1 + Documentation/maxscale.1 | 3 +++ server/core/gateway.c | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Documentation/Tutorials/Administration-Tutorial.md b/Documentation/Tutorials/Administration-Tutorial.md index 48e90952c..364ca7e41 100644 --- a/Documentation/Tutorials/Administration-Tutorial.md +++ b/Documentation/Tutorials/Administration-Tutorial.md @@ -44,6 +44,7 @@ Switch|Long Option|Description `-s [yes no]`|`--syslog=[yes no]`|log messages to syslog (default:yes) `-S [yes no]`|`--maxscalelog=[yes no]`|log messages to MaxScale log (default: yes) `-v`|`--version`|print version info and exit +`-V`|`--version-full`|print version info and the commit ID the binary was built from `-?`|`--help`|show this help diff --git a/Documentation/maxscale.1 b/Documentation/maxscale.1 index 104eaa235..d24b3b47e 100644 --- a/Documentation/maxscale.1 +++ b/Documentation/maxscale.1 @@ -56,6 +56,9 @@ Log messages to MaxScale's own log files. .BR "-v, --version" Print version information and exit. .TP +.BR "-V, --version-full" +Print full version information including the Git commit the binary was built from and exit. +.TP .BR "-?, --help" Show the help information for MaxScale and exit. diff --git a/server/core/gateway.c b/server/core/gateway.c index 99a654939..2d85b20e2 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -160,6 +160,8 @@ static bool libmysqld_started = FALSE; */ static bool daemon_mode = true; +static const char* maxscale_commit = MAXSCALE_COMMIT; + const char *progname = NULL; static struct option long_options[] = { {"homedir", required_argument, 0, 'c'}, @@ -178,6 +180,7 @@ static struct option long_options[] = { {"user",required_argument,0,'U'}, {"version", no_argument, 0, 'v'}, {"help", no_argument, 0, '?'}, + {"version-full", no_argument, 0, 'V'}, {0, 0, 0, 0} }; static int cnf_preparser(void* data, const char* section, const char* name, const char* value); @@ -395,9 +398,9 @@ sigfatal_handler (int i) LOGFILE_ERROR, "Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i))); - skygw_log_write_flush(LE,"Commit ID: "MAXSCALE_COMMIT" System name: %s " + skygw_log_write_flush(LE,"Commit ID: %s System name: %s " "Release string: %s Embedded library version: %s", - cnf->sysname, cnf->release_string, cnf->version_string); + maxscale_commit, cnf->sysname, cnf->release_string, cnf->version_string); { void *addrs[128]; @@ -1015,6 +1018,7 @@ static void usage(void) " -s, --syslog=[yes|no] log messages to syslog (default:yes)\n" " -S, --maxscalelog=[yes|no] log messages to MaxScale log (default: yes)\n" " -v, --version print version info and exit\n" + " -V, --version-full print full version info and exit\n" " -?, --help show this help\n" , progname); } @@ -1118,7 +1122,7 @@ int main(int argc, char **argv) } } - while ((opt = getopt_long(argc, argv, "dc:f:l:vs:S:?L:D:C:B:U:A:P:", + while ((opt = getopt_long(argc, argv, "dc:f:l:vVs:S:?L:D:C:B:U:A:P:", long_options, &option_index)) != -1) { bool succp = true; @@ -1154,7 +1158,12 @@ int main(int argc, char **argv) case 'v': rc = EXIT_SUCCESS; printf("MaxScale %s\n", MAXSCALE_VERSION); - goto return_main; + goto return_main; + + case 'V': + rc = EXIT_SUCCESS; + printf("MaxScale %s - %s\n", MAXSCALE_VERSION, maxscale_commit); + goto return_main; case 'l': if (strncasecmp(optarg, "file", PATH_MAX) == 0)