From 426963bff9e01d7d2f48d0e9eb232ccc11b33808 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 3 Dec 2010 17:09:00 +0300 Subject: [PATCH] Write release id if rspamd is built from hg. --- CMakeLists.txt | 23 +++++++++++++++++++++++ config.h.in | 1 + src/main.c | 4 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0b94609e..cfaa95ed3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ SET(RSPAMD_VERSION_MAJOR 0) SET(RSPAMD_VERSION_MINOR 3) SET(RSPAMD_VERSION_PATCH 3) + SET(RSPAMD_VERSION "${RSPAMD_VERSION_MAJOR}.${RSPAMD_VERSION_MINOR}.${RSPAMD_VERSION_PATCH}") SET(RSPAMD_MASTER_SITE_URL "http://bitbucket.org/vstakhov/rspamd") SET(RSPAMD_USER "nobody") @@ -484,6 +485,28 @@ IF(NOT DESTDIR) SET(DESTDIR $ENV{DESTDIR}) ENDIF(NOT DESTDIR) +# Try to detect tip version from hg +SET(ID "unknown") +FIND_PROGRAM(HG "hg") + +IF(HG) + EXECUTE_PROCESS(COMMAND ${HG} "id" OUTPUT_VARIABLE HG_ID) + IF(HG_ID) + STRING(REGEX MATCH ^[0-9a-z]+ ID "${HG_ID}") + ENDIF(HG_ID) +ELSE(HG) +# Now check .hg_archival.txt + FIND_FILE(HG_ARCH ".hg_archival.txt" "${CMAKE_CURRENT_SOURCE_DIR}") + IF(HG_ARCH) + FILE(READ ${HG_ARCH} HG_ID) + IF(HG_ID) + STRING(REGEX MATCH "node: [0-9a-z]+" _tmp "${HG_ID}") + STRING(SUBSTRING "${_tmp}" 6 12 ID) + ENDIF(HG_ID) + ENDIF(HG_ARCH) +ENDIF(HG) + + ################################ SOURCES SECTION ########################### SET(RSPAMDSRC src/modules.c diff --git a/config.h.in b/config.h.in index 645310a5e..ae9afee83 100644 --- a/config.h.in +++ b/config.h.in @@ -132,6 +132,7 @@ #cmakedefine HAVE_CLOCK_GETTIME 1 #define RVERSION "${RSPAMD_VERSION}" +#define RID "${ID}" #define RSPAMD_MASTER_SITE_URL "${RSPAMD_MASTER_SITE_URL}" #define MODULES_NUM ${RSPAMD_MODULES_NUM} diff --git a/src/main.c b/src/main.c index a2ae832bb..591dd6183 100644 --- a/src/main.c +++ b/src/main.c @@ -184,7 +184,7 @@ read_cmd_line (gint argc, gchar **argv, struct config_file *cfg) GOptionContext *context; context = g_option_context_new ("- run rspamd daemon"); - g_option_context_set_summary (context, "Summary:\n Rspamd daemon version " RVERSION); + g_option_context_set_summary (context, "Summary:\n Rspamd daemon version " RVERSION "\n Release id: " RID); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { fprintf (stderr, "option parsing failed: %s\n", error->message); @@ -879,7 +879,7 @@ main (gint argc, gchar **argv, gchar **env) config_logger (rspamd, TRUE); - msg_info ("rspamd " RVERSION " is starting"); + msg_info ("rspamd " RVERSION " is starting, build id: " RID); rspamd->cfg->cfg_name = memory_pool_strdup (rspamd->cfg->cfg_pool, rspamd->cfg->cfg_name); if (!rspamd->cfg->no_fork && daemon (0, 0) == -1) { -- 2.39.5