[ofa-general] [PATCH] management/gen_ver.sh script

Sasha Khapyorsky sashak at voltaire.com
Sun Jan 6 14:58:13 PST 2008


This generates a version string which includes recent version as
specified in correspondent sub project's configure.in file, plus
git revision abbreviation in the case if sub-project HEAD is different
from recent tag, plus "-dirty" suffix if local uncommitted changes are
in the sub project tree. For example:

  $ ./gen_ver.sh opensm
  3.1.8-5a03b64-dirty

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 gen_ver.sh |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100755 gen_ver.sh

diff --git a/gen_ver.sh b/gen_ver.sh
new file mode 100755
index 0000000..3524182
--- /dev/null
+++ b/gen_ver.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# This generates a version string which includes recent version as
+# specified in correspondent sub project's configure.in file, plus
+# git revision abbreviation in the case if sub-project HEAD is different
+# from recent tag, plus "-dirty" suffix if local uncommitted changes are
+# in the sub project tree.
+#
+
+usage()
+{
+	echo "Usage: $0 <target>"
+	exit 2
+}
+
+test -z "$1" && usage
+
+package=$1
+
+cd `dirname $0`
+
+conf_file=$package/configure.in
+version=`cat $conf_file | sed -ne '/AC_INIT.*'$package'.*/s/^AC_INIT.*'$package', \(.*\),.*$/\1/p'`
+
+git diff --quiet $package-$version..HEAD -- $package > /dev/null 2>&1
+if [ $? -eq 1 ] ; then
+	abbr=`git rev-parse --short --verify HEAD 2>/dev/null`
+	if [ ! -z "$abbr" ] ; then
+		version="${version}-${abbr}"
+	fi
+fi
+
+git diff-index --quiet HEAD -- $package > /dev/null 2>&1
+if [ $? -eq 1 ] ; then
+	version="${version}-dirty"
+fi
+
+echo $version
-- 
1.5.4.rc2.38.gd6da3




More information about the general mailing list