]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_ver: show the git sha1 version in the logs
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 3 Mar 2009 23:32:20 +0000 (15:32 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 3 Mar 2009 23:32:20 +0000 (15:32 -0800)
Makefile.am
src/Makefile.am
src/ceph_ver.c [new file with mode: 0644]
src/common/common_init.cc
src/make_version [new file with mode: 0755]

index cef7f2c98b42d25e0bf8dbeff360eb63f2a7e50e..9c07832b0e59cb8f586fb1fe7d4d82504723b74c 100644 (file)
@@ -1,3 +1,6 @@
 AUTOMAKE_OPTIONS = gnu
 EXTRA_DIST = debian autogen.sh ceph.spec.in
 SUBDIRS = src
+
+dist-hook:
+       src/make_version
index b4bbb1783c8cbf9591c4ee4fd106be65d89adb19..3ba554cd42da9ae053961f74f412d0c519495d86 100644 (file)
@@ -160,7 +160,7 @@ AM_LDFLAGS =
 noinst_LIBRARIES = \
        libcommon.a libcrush.a \
        libmon.a libmds.a libosdc.a libosd.a libclient.a \
-       libos.a libebofs.a 
+       libos.a libebofs.a
 
 noinst_LIBRARIES += libcrush_so.a #libcephclient_so.a
 
@@ -177,6 +177,11 @@ install-data-local:
        $(install_sh_SCRIPT) -m 0600 sample.ceph.conf $(DESTDIR)$(sysconfdir)/ceph/sample.ceph.conf
        $(install_sh_SCRIPT) -m 0600 sample.cluster.conf $(DESTDIR)$(sysconfdir)/ceph/sample.cluster.conf
 
+ceph_ver.h : $(all_sources)
+#      ./make_version
+
+ceph_ver.c : ceph_ver.h
+
 # cleaning
 clean-local:
        -rm *.so
@@ -185,6 +190,11 @@ clean-local:
 
 # libs
 libcommon_a_SOURCES = \
+       ceph_ver.c \
+       $(libcommon_files)
+
+# this list ommits the ceph_ver.c file
+libcommon_files = \
        common/LogClient.cc \
        msg/Message.cc \
        common/Logger.cc \
@@ -568,3 +578,11 @@ noinst_HEADERS = \
         osdc/Objecter.h\
        sample.ceph.conf\
        sample.cluster.conf
+
+all_sources = $(cmon_SOURCES) $(ceph_SOURCES) $(mkmonfs_SOURCES) $(monmaptool_SOURCES) \
+       $(crushtool_SOURCES) $(osdmaptool_SOURCES) $(cconf_SOURCES) $(mount_ceph_SOURCES) $(cmds_SOURCES) \
+       $(dumpjournal_SOURCES) $(cosd_SOURCES) $(dupstore_SOURCES) $(streamtest_SOURCES) $(csyn_SOURCES)  \
+       $(testmsgr_SOURCES) $(cfuse_SOURCES) $(fakefuse_SOURCES) $(psim_SOURCES) \
+       $(libcrush_so_a_SOURCES) $(libcommon_files) $(libcrush_a_SOURCES)  \
+       $(libmon_a_SOURCES) $(libmds_a_SOURCES) $(libebofs_a_SOURCES) $(libos_a_SOURCES) $(libosd_a_SOURCES) \
+       $(libosdc_a_SOURCES) $(libclient_a_SOURCES)
diff --git a/src/ceph_ver.c b/src/ceph_ver.c
new file mode 100644 (file)
index 0000000..e1be389
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include "acconfig.h"
+#include "ceph_ver.h"
+
+#define CONCAT_VER_SYMBOL(x) ceph_ver__##x
+
+#define DEFINE_VER_SYMBOL(x) int CONCAT_VER_SYMBOL(x)
+
+DEFINE_VER_SYMBOL(CEPH_GIT_VER);
+
+#define CEPH_VER VERSION "-" #CEPH_GIT_VER
+
index d87ee8493d9fcc5448246b4deb2d14123f46d80f..0ec564bc4993ae4c11023b742311a966cc1dad45 100644 (file)
@@ -2,6 +2,11 @@
 #include "config.h"
 #include "tls.h"
 
+#include "ceph_ver.h"
+
+#define _STR(x) #x
+#define STRINGIFY(x) _STR(x)
+
 void common_init(std::vector<const char*>& args, bool open)
 {
   tls_init();
@@ -12,5 +17,7 @@ void common_init(std::vector<const char*>& args, bool open)
   // open log file?
  if (open)
     _dout_open_log();
+
+  generic_dout(0) << "ceph version " << VERSION << " (" << STRINGIFY(CEPH_GIT_VER) << ")" << dendl;
 }
 
diff --git a/src/make_version b/src/make_version
new file mode 100755 (executable)
index 0000000..5da346e
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+
+dname=`dirname $0`
+
+git_ver=`git-rev-parse HEAD 2>/dev/null`
+
+[ -e $dname/.make_last_ver ] && \
+  [ -e $dname/ceph_ver.h ] && \
+  [ "$git_ver" == "`cat $dname/.make_last_ver`" ] && exit
+
+
+print_all() {
+echo "#ifndef __CEPH_VERSION_H"
+echo "#define __CEPH_VERSION_H"
+echo
+echo "#define CEPH_GIT_VER `git-rev-parse HEAD 2>/dev/null`"
+echo
+echo "#endif"
+
+}
+
+print_all > $dname/ceph_ver.h
+
+echo $git_ver > $dname/.make_last_ver
+