summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/GenerateBuild.cmake1
-rw-r--r--cmake/Version.cmake19
-rw-r--r--inc/dnbd3/build.h.in1
-rw-r--r--inc/dnbd3/version.h.in2
-rw-r--r--src/bench/main.c2
-rw-r--r--src/client/client.c4
-rw-r--r--src/fuse/main.c4
-rw-r--r--src/server/rpc.c2
-rw-r--r--src/server/server.c8
9 files changed, 29 insertions, 14 deletions
diff --git a/cmake/GenerateBuild.cmake b/cmake/GenerateBuild.cmake
index 020eb84..96b2906 100644
--- a/cmake/GenerateBuild.cmake
+++ b/cmake/GenerateBuild.cmake
@@ -5,6 +5,7 @@
# set current build type of the project
set(DNBD3_BUILD ${BUILD_TYPE})
+string(TIMESTAMP DNBD3_BUILD_DATE "%Y-%m-%d" UTC)
# write dnbd3 build type into a new C source file based on the specified build file template
configure_file(${BUILD_INPUT_FILE_TEMPLATE} ${BUILD_OUTPUT_FILE})
diff --git a/cmake/Version.cmake b/cmake/Version.cmake
index 5f63a31..75e99e3 100644
--- a/cmake/Version.cmake
+++ b/cmake/Version.cmake
@@ -36,7 +36,7 @@ macro(get_repository_version REPOSITORY_VERSION VERSION_HEADER_FILE VERSION_BUIL
if(EXISTS ${VERSION_HEADER_FILE})
# get version information from the generated version header of the source package
file(READ ${VERSION_HEADER_FILE} GIT_VERSION)
- string(REGEX MATCH "\"(([0-9]+:)?[0-9][A-Za-z0-9.+~-]*)\"" GIT_VERSION ${GIT_VERSION})
+ string(REGEX MATCH "DNBD3_VERSION\s+\"([0-9][A-Za-z0-9.+~-]*)\"" GIT_VERSION ${GIT_VERSION})
set(GIT_VERSION "${CMAKE_MATCH_1}")
else(EXISTS ${VERSION_HEADER_FILE})
# get detailed Git version information from Git repository
@@ -44,14 +44,18 @@ macro(get_repository_version REPOSITORY_VERSION VERSION_HEADER_FILE VERSION_BUIL
WORKING_DIRECTORY ${REPOSITORY_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- # remove the first letter of the version to satisfy packaging rules
- string(REGEX MATCH "([0-9]+:)?[0-9][A-Za-z0-9.+~-]*" GIT_VERSION ${GIT_VERSION})
+ execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
+ WORKING_DIRECTORY ${REPOSITORY_DIR}
+ OUTPUT_VARIABLE GIT_BRANCH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
# overwrite version from Git if version is unknown
if(GIT_VERSION STREQUAL "")
set(GIT_VERSION "unknown")
endif(GIT_VERSION STREQUAL "")
+ if(GIT_BRANCH STREQUAL "")
+ set(GIT_BRANCH "unknown")
+ endif(GIT_BRANCH STREQUAL "")
# get status of Git repository
execute_process(COMMAND ${GIT_EXECUTABLE} status --porcelain
@@ -62,7 +66,7 @@ macro(get_repository_version REPOSITORY_VERSION VERSION_HEADER_FILE VERSION_BUIL
# check if Git repository is dirty
if(NOT GIT_STATUS STREQUAL "")
# the Git repository is dirty, thus extend the version information
- set(GIT_VERSION "${GIT_VERSION}-modified")
+ set(GIT_VERSION "${GIT_VERSION}+MOD")
# print a message in Release build configuration to warn about the dirty repository
if(${VERSION_BUILD_TYPE} MATCHES "Release")
@@ -71,6 +75,7 @@ macro(get_repository_version REPOSITORY_VERSION VERSION_HEADER_FILE VERSION_BUIL
endif(NOT GIT_STATUS STREQUAL "")
endif(EXISTS ${VERSION_HEADER_FILE})
- # return version to caller
- set(${REPOSITORY_VERSION} ${GIT_VERSION})
+ # remove the first letter of the version to satisfy packaging rules
+ # and return to caller
+ string(REGEX MATCH "([0-9]+:)?[0-9][A-Za-z0-9.+~-]*" ${REPOSITORY_VERSION} ${GIT_VERSION})
endmacro(get_repository_version)
diff --git a/inc/dnbd3/build.h.in b/inc/dnbd3/build.h.in
index 80537ea..062ed17 100644
--- a/inc/dnbd3/build.h.in
+++ b/inc/dnbd3/build.h.in
@@ -6,5 +6,6 @@
#define BUILD_H_
#define DNBD3_BUILD "@DNBD3_BUILD@"
+#define DNBD3_BUILD_DATE "@DNBD3_BUILD_DATE@"
#endif /* BUILD_H_ */
diff --git a/inc/dnbd3/version.h.in b/inc/dnbd3/version.h.in
index 94bd2c4..a3eff45 100644
--- a/inc/dnbd3/version.h.in
+++ b/inc/dnbd3/version.h.in
@@ -6,5 +6,7 @@
#define VERSION_H_
#define DNBD3_VERSION "@DNBD3_VERSION@"
+#define DNBD3_BRANCH "@GIT_BRANCH@"
+#define DNBD3_VERSION_LONG "@GIT_VERSION@, branch @GIT_BRANCH@"
#endif /* VERSION_H_ */
diff --git a/src/bench/main.c b/src/bench/main.c
index d195e26..37e2821 100644
--- a/src/bench/main.c
+++ b/src/bench/main.c
@@ -20,7 +20,7 @@
static void printUsage(char *argv0, int exitCode)
{
- printf( "Version: %s\n", DNBD3_VERSION );
+ printf( "Version: %s\n", DNBD3_VERSION_LONG );
printf( "Usage: %s [--debug] --host <serverAddress(es)> --image <imageName> [--rid revision]\n", argv0 );
printf( "Or: %s [-d] -h <serverAddress(es)> -i <imageName> [-r revision]\n", argv0 );
printf( " -h --host List of space separated hosts to use\n" );
diff --git a/src/client/client.c b/src/client/client.c
index cb13682..41e6c32 100644
--- a/src/client/client.c
+++ b/src/client/client.c
@@ -21,6 +21,7 @@
#include <dnbd3/config/client.h>
#include <dnbd3/types.h>
#include <dnbd3/version.h>
+#include <dnbd3/build.h>
#include <stdio.h>
#include <stdlib.h>
@@ -729,5 +730,6 @@ static void dnbd3_print_help(char *argv_0)
void dnbd3_print_version()
{
- printf( "dnbd3-client version: %s\n", DNBD3_VERSION );
+ printf( "dnbd3-client version: %s\n", DNBD3_VERSION_LONG );
+ printf( "Built: %s\n", DNBD3_BUILD_DATE );
}
diff --git a/src/fuse/main.c b/src/fuse/main.c
index 8963e6d..e06f6e8 100644
--- a/src/fuse/main.c
+++ b/src/fuse/main.c
@@ -11,6 +11,7 @@
#include "connection.h"
#include "helper.h"
#include <dnbd3/version.h>
+#include <dnbd3/build.h>
#include <dnbd3/shared/protocol.h>
#include <dnbd3/shared/log.h>
@@ -273,7 +274,8 @@ static struct fuse_lowlevel_ops image_oper = {
static void printVersion()
{
char *arg[] = { "foo", "-V" };
- printf( "dnbd3-fuse version: %s\n", DNBD3_VERSION );
+ printf( "dnbd3-fuse version: %s\n", DNBD3_VERSION_LONG );
+ printf( "Built: %s\n", DNBD3_BUILD_DATE );
printf( "Protocol version: %d\n", (int)PROTOCOL_VERSION );
struct fuse_args args = FUSE_ARGS_INIT( 2, arg );
fuse_parse_cmdline( &args, NULL, NULL, NULL );
diff --git a/src/server/rpc.c b/src/server/rpc.c
index 9bef5ee..566f35c 100644
--- a/src/server/rpc.c
+++ b/src/server/rpc.c
@@ -312,7 +312,7 @@ static bool handleStatus(int sock, int permissions, struct field *fields, size_t
"runId", randomRunId );
}
if ( version ) {
- json_object_set_new( statisticsJson, "version", json_string( DNBD3_VERSION ) );
+ json_object_set_new( statisticsJson, "version", json_string( DNBD3_VERSION_LONG ", built " DNBD3_BUILD_DATE ) );
json_object_set_new( statisticsJson, "build", json_string( DNBD3_BUILD ) );
}
if ( space ) {
diff --git a/src/server/server.c b/src/server/server.c
index ec2e24c..6d1366f 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -106,7 +106,8 @@ static void queueJobInternal(job_t *job);
*/
void dnbd3_printHelp(char *argv_0)
{
- printf( "Version: %s\n\n", DNBD3_VERSION );
+ printf( "Version: %s\n\n", DNBD3_VERSION_LONG );
+ printf( "Built: %s\n", DNBD3_BUILD_DATE );
printf( "Usage: %s [OPTIONS]...\n", argv_0 );
printf( "Start the DNBD3 server\n" );
printf( "-c or --config Configuration directory (default /etc/dnbd3-server/)\n" );
@@ -131,7 +132,8 @@ void dnbd3_printHelp(char *argv_0)
*/
void dnbd3_printVersion()
{
- printf( "dnbd3-server version: %s\n", DNBD3_VERSION );
+ printf( "dnbd3-server version: %s\n", DNBD3_VERSION_LONG );
+ printf( "Built: %s\n", DNBD3_BUILD_DATE );
exit( 0 );
}
@@ -373,7 +375,7 @@ int main(int argc, char *argv[])
logadd( LOG_INFO, "DNBD3 server starting...." );
logadd( LOG_INFO, "Machine type: " DNBD3_ENDIAN_MODE );
logadd( LOG_INFO, "Build Type: %s", DNBD3_BUILD );
- logadd( LOG_INFO, "Version: %s", DNBD3_VERSION );
+ logadd( LOG_INFO, "Version: %s, built %s", DNBD3_VERSION_LONG, DNBD3_BUILD_DATE );
if ( altservers_load() < 0 ) {
logadd( LOG_WARNING, "Could not load alt-servers. Does the file exist in %s?", _configDir );