BuildID update script fixed
authorAlex Kirhenshtein <alk@netxms.org>
Mon, 14 Dec 2015 22:35:53 +0000 (00:35 +0200)
committerAlex Kirhenshtein <alk@netxms.org>
Mon, 14 Dec 2015 22:36:00 +0000 (00:36 +0200)
tools/updatetag.sh

index fc294d2..e998ef1 100755 (executable)
@@ -2,26 +2,15 @@
 
 HEADER="netxms-build-tag.h"
 
-git describe >/dev/null 2>/dev/null
-if test $? -eq 0; then
-       echo "Checking build tag"
-       BUILD_TAG=`git describe`
-       if test -f $HEADER; then
-               found=`cat $HEADER | grep "BUILDTAG:$BUILD_TAG" | wc -l`
-               if [ $found -gt 0 ]; then
-                       update="no"
-               else
-                       update="yes"
-               fi
-       else
-               update="yes"
-       fi
-       if test "x$update" = "xyes"; then
-               echo "/* BUILDTAG:$BUILD_TAG */" > $HEADER
-               echo "#ifndef _build_tag_h_" >> $HEADER
-               echo "#define _build_tag_h_" >> $HEADER
-               echo "#define NETXMS_BUILD_TAG _T(\"$BUILD_TAG\")" >> $HEADER
-               echo "#endif" >> $HEADER
-               echo "Build tag updated"
-       fi
+[ -f $HEADER ] || touch $HEADER
+
+BUILD_TAG=`git describe 2>/dev/null`
+[ -z $BUILD_TAG ] && BUILD_TAG=UNKNOWN
+if ! grep -q "BUILDTAG:$BUILD_TAG" $HEADER; then
+  echo "/* BUILDTAG:$BUILD_TAG */" > $HEADER
+  echo "#ifndef _build_tag_h_" >> $HEADER
+  echo "#define _build_tag_h_" >> $HEADER
+  echo "#define NETXMS_BUILD_TAG _T(\"$BUILD_TAG\")" >> $HEADER
+  echo "#endif" >> $HEADER
+  echo "Build tag updated"
 fi