PUD: only update version.h when needed
authorFerry Huberts <ferry.huberts@pelagic.nl>
Sun, 5 Feb 2012 12:45:25 +0000 (13:45 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Sun, 5 Feb 2012 13:15:26 +0000 (14:15 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/scripts/makeVersionH
lib/pud/src/version.h

index cae02fb..daeae39 100755 (executable)
@@ -3,15 +3,26 @@
 set -e
 set -u
 
+if [[ ${#} -ne 2 ]]; then
+  echo "Need 2 arguments: outfile version"
+  exit 1
+fi
+
 outfile="${1}"
 version="${2}"
 
+
+outfileDir="$(dirname "${outfile}")"
+outfileName="$(basename "${outfile}")"
+tmpFile="$(mktemp --tmpdir="${outfileDir}" "${outfileName}.XXXXXXXXXX")"
+
+
 set +e
 sha="$(git describe 2> /dev/null)"
 set -e
 
 
-cat > "${outfile}" << EOF
+cat > "${tmpFile}" << EOF
 #ifndef _PUD_VERSION_H_
 #define _PUD_VERSION_H_
 
@@ -22,11 +33,25 @@ if [[ -z "${sha:-}" ]]; then
   sha="OLSRD_Unknown-g0000000"
 fi
 
-cat >> "${outfile}" << EOF
+cat >> "${tmpFile}" << EOF
 #define GIT_SHA    "${sha}"
 EOF
 
-cat >> "${outfile}" << EOF
+cat >> "${tmpFile}" << EOF
 
 #endif /* _PUD_VERSION_H_ */
 EOF
+
+
+set +e
+diff "${outfile}" "${tmpFile}" &> /dev/null
+declare -i diffResult=$?
+set -e
+
+if [[ ${diffResult} -eq 0 ]]; then
+  rm -f "${tmpFile}"
+else
+  echo "[${outfile}]"
+  mv "${tmpFile}" "${outfile}"
+fi
+
index bd9664c..884b7bd 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _PUD_VERSION_H_
 #define _PUD_VERSION_H_
 
-#define PLUGIN_VER "1.0.0"
+#define PLUGIN_VER "1.1.0"
 #define GIT_SHA    "OLSRD_Unknown-g0000000"
 
 #endif /* _PUD_VERSION_H_ */