Introduce git reference/tag tracking for debugging
authorIustin Pop <iustin@google.com>
Fri, 16 Jul 2010 08:18:24 +0000 (10:18 +0200)
committerIustin Pop <iustin@google.com>
Mon, 19 Jul 2010 13:24:28 +0000 (15:24 +0200)
This patch adds a new vcs-version file that is generated via git (and
can be adapted if VCS is changed) and then embebbded as VCS_VERSION in
the constants module.

This means two things:
- local modifications without committing to git (or when using a tar.gz
  archive + mods) will not be reflected
- version is fixed at the time of the last make regen-vcs-version (dist time,
  or devel/upload which calls this)

Thus this is more geared at developers rather than end users.

The patch:

- adds rules for generating the vcs-version file
- adds a dist-hook for re-generating the file (if possible) and copying
  the updated version to the distdir
- modifies devel/upload to re-generate the file before upload

The output of --version will look like:
gnt-cluster (ganeti v2.2.0beta0-184-gebca7e6) 2.2.0~beta0

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

Makefile.am
devel/upload.in
lib/cli.py
lib/constants.py

index 615ed85..c4d350b 100644 (file)
@@ -66,7 +66,8 @@ MAINTAINERCLEANFILES = \
        $(docpng) \
        $(maninput) \
        doc/install-quick.rst \
-       doc/news.rst
+       doc/news.rst \
+       vcs-version
 
 maintainer-clean-local:
        rm -rf $(BUILDTIME_DIRS)
@@ -501,8 +502,25 @@ man/%.8: man/%.8.in $(REPLACE_VARS_SED)
 man/%.html: man/%.html.in $(REPLACE_VARS_SED)
        sed -f $(REPLACE_VARS_SED) < $< > $@
 
-lib/_autoconf.py: Makefile stamp-directories
+vcs-version:
+       if test -d .git; then \
+         git describe > $@; \
+       elif test ! -f $@ ; then \
+         echo "Cannot auto-generate $@ file"; exit 1; \
+       fi
+
+.PHONY: regen-vcs-version
+regen-vcs-version:
        set -e; \
+       cd $(srcdir); \
+       if test -d .git; then \
+         rm -f vcs-version; \
+         $(MAKE) vcs-version; \
+       fi
+
+lib/_autoconf.py: Makefile stamp-directories vcs-version
+       set -e; \
+       VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
        { echo '# This file is automatically generated, do not edit!'; \
          echo '#'; \
          echo ''; \
@@ -547,6 +565,7 @@ lib/_autoconf.py: Makefile stamp-directories
          echo "DAEMONS_GROUP = '$(DAEMONS_GROUP)'"; \
          echo "MASTERD_USER = '$(MASTERD_USER)'"; \
          echo "RAPI_USER = '$(RAPI_USER)'"; \
+         echo "VCS_VERSION = '$$VCSVER'"; \
        } > $@
 
 $(REPLACE_VARS_SED): Makefile
@@ -620,7 +639,14 @@ lint: ganeti $(BUILT_SOURCES)
        @test -n "$(PYLINT)" || { echo 'pylint' not found during configure; exit 1; }
        $(PYLINT) $(LINT_OPTS) $(lint_python_code)
 
-# a dist hook rule for catching revision control directories
+# a dist hook rule for updating the vcs-version file; this is
+# hardcoded due to where it needs to build the file...
+dist-hook:
+       $(MAKE) regen-vcs-version && \
+       rm -f $(top_distdir)/vcs-version && \
+       cp -p $(srcdir)/vcs-version $(top_distdir)
+
+# a distcheck hook rule for catching revision control directories
 distcheck-hook:
        if find $(top_distdir) -name .svn -or -name .git | grep .; then \
                echo "Found revision control files in final archive." 1>&2; \
index f690453..885a51d 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright (C) 2006, 2007 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
 # This is a test script to ease development and testing on test clusters.
 # It should not be used to update production environments.
 
-# Usage: upload.sh node-{1,2,3}
+# Usage: upload node-{1,2,3}
 # it will upload the python libraries to
 # $prefix/lib/python2.4/site-packages/ganeti and the command line utils to
 # $prefix/sbin. It needs passwordless root login to the nodes.
@@ -64,6 +64,8 @@ done
 
 set ${hosts}
 
+make regen-vcs-version
+
 TXD=`mktemp -d`
 trap 'rm -rf $TXD' EXIT
 
index 92877e2..8c17e4b 100644 (file)
@@ -1033,7 +1033,8 @@ def _ParseArgs(argv, commands, aliases):
     binary = argv[0].split("/")[-1]
 
   if len(argv) > 1 and argv[1] == "--version":
-    ToStdout("%s (ganeti) %s", binary, constants.RELEASE_VERSION)
+    ToStdout("%s (ganeti %s) %s", binary, constants.VCS_VERSION,
+             constants.RELEASE_VERSION)
     # Quit right away. That way we don't have to care about this special
     # argument. optparse.py does it the same.
     sys.exit(0)
index eb38fb3..da52f13 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2006, 2007 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@ OS_API_V10 = 10
 OS_API_V15 = 15
 OS_API_V20 = 20
 OS_API_VERSIONS = frozenset([OS_API_V10, OS_API_V15, OS_API_V20])
+VCS_VERSION = _autoconf.VCS_VERSION
 EXPORT_VERSION = 0
 RAPI_VERSION = 2