Skip to content
Browse files

Added setver.sh, a script to set vzctl version from git

This one can be used for building vzctl from GIT, with the proper
version set in vzctl sources and spec file. This is good for:

1. people building vzctl from git
2. nightly builds (?)

version.h is needed for vzctl to be rebuilt when version string
changes.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
  • Loading branch information...
1 parent 6dbcc3a commit 1aaafb8eeb2bc0b721891c2932222d83c397d2e1 @kolyshkin kolyshkin committed
Showing with 51 additions and 2 deletions.
  1. +1 −1 Makefile.am
  2. +1 −1 autogen.sh
  3. +1 −0 configure.ac
  4. +1 −0 include/.gitignore
  5. +1 −0 include/version.h.in
  6. +45 −0 setver.sh
  7. +1 −0 src/vzctl.c
View
2 Makefile.am
@@ -24,7 +24,7 @@ SUBDIRS = bin \
noinst_HEADERS = $(wildcard include/*.h) \
$(wildcard include/linux/*.h)
-EXTRA_DIST = vzctl.spec
+EXTRA_DIST = vzctl.spec include/version.h.in
vzdir = /vz
vzcachedir = $(vzdir)/template/cache
View
2 autogen.sh
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
-
+./setver.sh
aclocal
libtoolize --force --copy --automake
automake -afc
View
1 configure.ac
@@ -138,6 +138,7 @@ AC_CONFIG_FILES([bin/Makefile
etc/network-scripts/Makefile
etc/udev/Makefile
etc/Makefile
+ include/version.h
man/Makefile
scripts/Makefile
src/lib/Makefile
View
1 include/.gitignore
@@ -0,0 +1 @@
+version.h
View
1 include/version.h.in
@@ -0,0 +1 @@
+#define VERSION "@VERSION@"
View
45 setver.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# Try to figure out version from git
+GIT_DESC=$(git describe | sed s'/^vzctl-//')
+GIT_V=$(echo $GIT_DESC | sed 's/-.*$//')
+ # 3.0.28-1-gf784152
+GIT_R=$(echo $GIT_DESC | sed 's/^[^-]*-\([1-9][0-9]*\)-g/git.\1./')
+test "$GIT_V" = "$GIT_R" && GIT_R="1"
+GIT_VR="${GIT_V}-${GIT_R}"
+
+CONF_V=$(grep AC_INIT configure.ac | \
+ sed 's/^[^,]*,[ ]\([^,]*\),.*$/\1/')
+
+read_spec() {
+ SPEC_V=$(awk '($1 == "Version:") {print $2}' vzctl.spec)
+ SPEC_R=$(awk '($1 == "Release:") {print $2}' vzctl.spec | \
+ sed 's/%.*$//')
+ SPEC_VR="${SPEC_V}-${SPEC_R}"
+}
+read_spec
+
+# Set version/release in spec from git
+if test "$GIT_VR" != "$SPEC_VR"; then
+# echo "Changing vzctl.spec:"
+ # Version: 3.0.28
+ # Release: 1%{?dist}
+ sed -i -e "s/^\(Version:[[:space:]]*\).*\$/\1$GIT_V/" \
+ -e "s/^\(Release:[[:space:]]*\)[^%]*\(%.*\)\$/\1$GIT_R\2/" \
+ vzctl.spec
+fi
+#grep -E -H '^Version:|^Release:' vzctl.spec
+
+# Set version in configure.ac from spec
+read_spec
+SPEC_VR=$(echo $SPEC_VR | sed 's/-1$//')
+if test "$CONF_V" != "$SPEC_VR"; then
+# echo "Changing configure.ac:"
+ # AC_INIT(vzctl, 3.0.28, devel@openvz.org)
+ sed -i "s/^\(AC_INIT(vzctl,[ ]\)[^,]*\(,.*\$\)/\1$SPEC_VR\2/" \
+ configure.ac
+ autoconf
+fi
+#grep -H '^AC_INIT' configure.ac
+
+exit 0
View
1 src/vzctl.c
@@ -23,6 +23,7 @@
#include <signal.h>
#include <limits.h>
+#include "version.h"
#include "vzctl.h"
#include "env.h"
#include "logger.h"

0 comments on commit 1aaafb8

Please sign in to comment.
Something went wrong with that request. Please try again.