Changeset: 570e19da841b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=570e19da841b
Added Files:
common/utils/revision.c
Modified Files:
NT/Makefile
bootstrap
clients/mapiclient/mclient.c
clients/mapiclient/msqldump.c
common/utils/Makefile.ag
common/utils/mutils.h
rpm.mk.in
tools/merovingian/client/monetdb.c
tools/merovingian/daemon/argvcmds.c
tools/merovingian/daemon/merovingian.c
tools/mserver/monet_version.c.in
tools/mserver/mserver5.c
Branch: default
Log Message:
Include Mercurial revision ID in version strings.
Most programs have a way to print the version information. This
information now includes the revision ID (hg id -i) of the changeset
from which the binary was built. For released versions, the
information does not include this but instead gives the release name.
In either case, this uniquely identifies the sources used to build the
binary.
diffs (truncated from 326 to 300 lines):
diff --git a/NT/Makefile b/NT/Makefile
--- a/NT/Makefile
+++ b/NT/Makefile
@@ -19,7 +19,7 @@ all: _all
!INCLUDE "$(NT)\rules.msc"
-_all: update_winconfig_conds_py "$(srcdir)\Makefile.msc" monetdb_config.h
unistd.h .monetdb
+_all: update_winconfig_conds_py "$(srcdir)\Makefile.msc" monetdb_config.h
unistd.h .monetdb monetdb_hgversion.h
$(MAKE) /nologo /f "$(srcdir)\Makefile.msc" "prefix=$(prefix)"
"bits=$(bits)" all
install: targetdirs all
@@ -34,6 +34,9 @@ install: targetdirs all
monetdb_config.h: "$(TOPDIR)\winconfig_conds.py" "$(NT)\monetdb_config.h.in"
$(CONFIGURE) "$(NT)\monetdb_config.h.in" > monetdb_config.h
+monetdb_hgversion.h:
+ $(ECHO) #undef MERCURIAL_ID > monetdb_hgversion.h
+
unistd.h:
$(ECHO) #ifndef UNISTD_H > unistd.h
$(ECHO) #define UNISTD_H >> unistd.h
diff --git a/bootstrap b/bootstrap
--- a/bootstrap
+++ b/bootstrap
@@ -62,6 +62,8 @@ aclocal$amv ${_m4_extra_dirs} || exit $?
autoheader || exit $?
automake$amv --add-missing --copy --foreign || exit $?
autoconf || exit $?
+# a bit hacky: add dependency on monetdb_hgversion.h for
common/utils/revision.c
+sed -i~ '/revision.*:/s;$; ../../monetdb_hgversion.h;' common/utils/Makefile.am
if [ -f buildtools/conf/install-sh -a ! -x buildtools/conf/install-sh ]; then
chmod +x buildtools/conf/install-sh
fi
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -35,7 +35,9 @@
#endif
#include "stream.h"
#include "msqldump.h"
+#define LIBMUTILS 1
#include "mprompt.h"
+#include "mutils.h" /* mercurial_revision */
#include "dotmonetdb.h"
#include <locale.h>
@@ -3428,13 +3430,22 @@ main(int argc, char **argv)
user = strdup(optarg);
user_set_as_flag = true;
break;
- case 'v':
+ case 'v': {
+ const char *rev = mercurial_revision();
mnstr_printf(toConsole,
- "mclient, the MonetDB interactive terminal
(%s)\n",
- MONETDB_RELEASE);
+ "mclient, the MonetDB interactive "
+ "terminal, version %s", VERSION);
+ /* coverity[pointless_string_compare] */
+ if (strcmp(MONETDB_RELEASE, "unreleased") != 0)
+ mnstr_printf(toConsole, " (%s)",
+ MONETDB_RELEASE);
+ else if (strcmp(rev, "Unknown") != 0)
+ mnstr_printf(toConsole, " (hg id: %s)", rev);
+ mnstr_printf(toConsole, "\n");
#ifdef HAVE_LIBREADLINE
mnstr_printf(toConsole,
- "support for command-line editing
compiled-in\n");
+ "support for command-line editing "
+ "compiled-in\n");
#endif
#ifdef HAVE_ICONV
#ifdef HAVE_NL_LANGINFO
@@ -3442,9 +3453,11 @@ main(int argc, char **argv)
encoding = nl_langinfo(CODESET);
#endif
mnstr_printf(toConsole,
- "character encoding: %s\n", encoding ?
encoding : "utf-8 (default)");
+ "character encoding: %s\n",
+ encoding ? encoding : "utf-8 (default)");
#endif
return 0;
+ }
case 'w':
assert(optarg);
pagewidth = atoi(optarg);
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -22,7 +22,9 @@
#include "stream.h"
#include "msqldump.h"
+#define LIBMUTILS 1
#include "mprompt.h"
+#include "mutils.h" /* mercurial_revision */
#include "dotmonetdb.h"
__declspec(noreturn) static void usage(const char *prog, int xit)
@@ -77,13 +79,14 @@ main(int argc, char **argv)
{"Xdebug", 0, 0, 'X'},
{"user", 1, 0, 'u'},
{"quiet", 0, 0, 'q'},
+ {"version", 0, 0, 'v'},
{"help", 0, 0, '?'},
{0, 0, 0, 0}
};
parse_dotmonetdb(&user, &passwd, &dbname, NULL, NULL, NULL, NULL);
- while ((c = getopt_long(argc, argv, "h:p:d:Dft:NXu:q?", long_options,
NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "h:p:d:Dft:NXu:qv?", long_options,
NULL)) != -1) {
switch (c) {
case 'u':
if (user)
@@ -125,6 +128,18 @@ main(int argc, char **argv)
case 'X':
trace = true;
break;
+ case 'v': {
+ const char *rev = mercurial_revision();
+ printf("msqldump, the MonetDB interactive database "
+ "dump tool, version %s", VERSION);
+ /* coverity[pointless_string_compare] */
+ if (strcmp(MONETDB_RELEASE, "unreleased") != 0)
+ printf(" (%s)", MONETDB_RELEASE);
+ else if (strcmp(rev, "Unknown") != 0)
+ printf(" (hg id: %s)", rev);
+ printf("\n");
+ return 0;
+ }
case '?':
/* a bit of a hack: look at the option that the
current `c' is based on and see if we recognize
diff --git a/common/utils/Makefile.ag b/common/utils/Makefile.ag
--- a/common/utils/Makefile.ag
+++ b/common/utils/Makefile.ag
@@ -8,11 +8,11 @@
MTSAFE
-INCLUDES = $(openssl_CFLAGS)
+INCLUDES = ../.. $(openssl_CFLAGS)
lib_mutils = {
NOINST
- SOURCES = mutils.h mutils.c prompt.c mprompt.h
+ SOURCES = mutils.h mutils.c prompt.c mprompt.h revision.c
}
lib_mcrypt = {
diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -72,4 +72,7 @@ mutils_export void print_trace(void);
* this function. */
mutils_export char *get_bin_path(void);
+/* Returns the Mercurial changeset of the current checkout, if available */
+mutils_export const char *mercurial_revision(void);
+
#endif /* _MUTILS_H_ */
diff --git a/common/utils/revision.c b/common/utils/revision.c
new file mode 100644
--- /dev/null
+++ b/common/utils/revision.c
@@ -0,0 +1,26 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2018 MonetDB B.V.
+ */
+
+#include "monetdb_config.h"
+#include "monetdb_hgversion.h"
+#include <string.h>
+#include "mutils.h"
+
+static const char revision[] =
+#ifdef MERCURIAL_ID
+ MERCURIAL_ID
+#else
+ "Unknown"
+#endif
+ ;
+
+const char *
+mercurial_revision(void)
+{
+ return revision;
+}
diff --git a/rpm.mk.in b/rpm.mk.in
--- a/rpm.mk.in
+++ b/rpm.mk.in
@@ -30,3 +30,9 @@ rpm: MonetDB.spec $(top_builddir)/$(dist
srpm: MonetDB.spec $(top_builddir)/$(distdir).tar.bz2 $(rpmtopdir)/rpmmacros
$(RPMBUILD) $(RPMBUILDARGS) --define="dist %{?undefined}" -ts
$(top_builddir)/$(distdir).tar.bz2
+
+all: monetdb_hgversion.h
+
+monetdb_hgversion.h: always
+ if [ -d "$(srcdir)"/.hg ] && hgid=`(cd "$(srcdir)"; hg id -i)
2>/dev/null`; then echo "#define MERCURIAL_ID \"$$hgid\"" >
monetdb_hgversion.h.new; if [ -f monetdb_hgversion.h ] && cmp -s
monetdb_hgversion.h monetdb_hgversion.h.new; then rm -f
monetdb_hgversion.h.new; else mv -f monetdb_hgversion.h.new
monetdb_hgversion.h; fi; elif [ ! -f monetdb_hgversion.h ]; then touch
monetdb_hgversion.h; fi
+always:
diff --git a/tools/merovingian/client/monetdb.c
b/tools/merovingian/client/monetdb.c
--- a/tools/merovingian/client/monetdb.c
+++ b/tools/merovingian/client/monetdb.c
@@ -177,8 +177,14 @@ command_help(int argc, char *argv[])
static void
command_version(void)
{
- printf("MonetDB Database Server Toolkit v%s (%s)\n",
- VERSION, MONETDB_RELEASE);
+ const char *rev = mercurial_revision();
+ printf("MonetDB Database Server Toolkit v%s", VERSION);
+ /* coverity[pointless_string_compare] */
+ if (strcmp(MONETDB_RELEASE, "unreleased") != 0)
+ printf(" (%s)", MONETDB_RELEASE);
+ else if (strcmp(rev, "Unknown") != 0)
+ printf(" (hg id: %s)", rev);
+ printf("\n");
}
static int
diff --git a/tools/merovingian/daemon/argvcmds.c
b/tools/merovingian/daemon/argvcmds.c
--- a/tools/merovingian/daemon/argvcmds.c
+++ b/tools/merovingian/daemon/argvcmds.c
@@ -65,9 +65,15 @@ command_help(int argc, char *argv[])
int
command_version(void)
{
- printf("MonetDB Database Server v%s (%s)\n",
- VERSION, MONETDB_RELEASE);
- return(0);
+ const char *rev = mercurial_revision();
+ printf("MonetDB Database Server v%s", VERSION);
+ /* coverity[pointless_string_compare] */
+ if (strcmp(MONETDB_RELEASE, "unreleased") != 0)
+ printf(" (%s)", MONETDB_RELEASE);
+ else if (strcmp(rev, "Unknown") != 0)
+ printf(" (hg id: %s)", rev);
+ printf("\n");
+ return 0;
}
int
diff --git a/tools/merovingian/daemon/merovingian.c
b/tools/merovingian/daemon/merovingian.c
--- a/tools/merovingian/daemon/merovingian.c
+++ b/tools/merovingian/daemon/merovingian.c
@@ -883,8 +883,16 @@ main(int argc, char *argv[])
Mfprintf(pidfile, "%d\n", (int)d->pid);
fclose(pidfile);
- Mfprintf(stdout, "Merovingian %s (%s) starting\n",
- VERSION, MONETDB_RELEASE);
+ {
+ const char *rev = mercurial_revision();
+ Mfprintf(stdout, "Merovingian %s", VERSION);
+ /* coverity[pointless_string_compare] */
+ if (strcmp(MONETDB_RELEASE, "unreleased") != 0)
+ Mfprintf(stdout, " (%s)", MONETDB_RELEASE);
+ else if (strcmp(rev, "Unknown") != 0)
+ Mfprintf(stdout, " (hg id: %s)", rev);
+ Mfprintf(stdout, " starting\n");
+ }
Mfprintf(stdout, "monitoring dbfarm %s\n", dbfarm);
/* open up connections */
diff --git a/tools/mserver/monet_version.c.in b/tools/mserver/monet_version.c.in
--- a/tools/mserver/monet_version.c.in
+++ b/tools/mserver/monet_version.c.in
@@ -11,6 +11,7 @@
#include "monetdb_config.h"
#include "mal.h"
#include "monet_version.h"
+#include "mutils.h"
#ifdef HAVE_LIBPCRE
#include <pcre.h>
#endif
@@ -47,11 +48,14 @@ monet_version(void)
sz_mem_gb = (dbl)(MT_npages() * MT_pagesize()) / (1024.0 * 1024.0 *
1024.0);
cores = MT_check_nr_cores();
- printf("MonetDB 5 server v%s ", VERSION);
+ const char *rev = mercurial_revision();
+ printf("MonetDB 5 server %s", VERSION);
/* coverity[pointless_string_compare] */
if (strcmp(MONETDB_RELEASE, "unreleased") != 0)
- printf("\"%s\" ", MONETDB_RELEASE);
- printf("(%zu-bit%s)\n",
+ printf(" (%s)", MONETDB_RELEASE);
+ else if (strcmp(rev, "Unknown") != 0)
+ printf(" (hg id: %s)", rev);
+ printf(" (%zu-bit%s)\n",
(size_t) (sizeof(ptr) * 8),
#ifdef HAVE_HGE
", 128-bit integers"
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list