Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 1aaafb8eeb2bc0b721891c2932222d83c397d2e1 1 parent 6dbcc3a
Kirill Kolyshkin kolyshkin authored
2  Makefile.am
View
@@ -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
2  autogen.sh
View
@@ -1,7 +1,7 @@
#!/bin/sh
set -e
-
+./setver.sh
aclocal
libtoolize --force --copy --automake
automake -afc
1  configure.ac
View
@@ -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
1  include/.gitignore
View
@@ -0,0 +1 @@
+version.h
1  include/version.h.in
View
@@ -0,0 +1 @@
+#define VERSION "@VERSION@"
45 setver.sh
View
@@ -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
1  src/vzctl.c
View
@@ -23,6 +23,7 @@
#include <signal.h>
#include <limits.h>
+#include "version.h"
#include "vzctl.h"
#include "env.h"
#include "logger.h"
Please sign in to comment.
Something went wrong with that request. Please try again.