PUD: make git version optional
authorFerry Huberts <ferry.huberts@pelagic.nl>
Fri, 5 Aug 2011 12:01:40 +0000 (14:01 +0200)
committerFerry Huberts <f.huberts@mindef.nl>
Thu, 18 Aug 2011 13:02:05 +0000 (15:02 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/scripts/makeVersionH
lib/pud/src/pudOlsrdPlugin.c

index d0ee0a4..70ee4ef 100755 (executable)
@@ -6,8 +6,9 @@ set -u
 outfile="${1}"
 version="${2}"
 
-sha="$(git describe)"
-
+set +e
+sha="$(git describe 2> /dev/null)"
+set -e
 
 
 cat > "${outfile}" << EOF
@@ -15,7 +16,15 @@ cat > "${outfile}" << EOF
 #define _PUD_VERSION_H_
 
 #define PLUGIN_VER "${version}"
+EOF
+
+if [[ -n "${sha:-}" ]]; then
+  cat >> "${outfile}" << EOF
 #define GIT_SHA    "${sha}"
+EOF
+fi
+
+cat >> "${outfile}" << EOF
 
 #endif /* _PUD_VERSION_H_ */
 EOF
index 95f7b0b..a06f16e 100644 (file)
 int olsrd_plugin_init(void) {
        bool retval = initPud();
        if (retval) {
-               olsr_printf(0, "%s\n", PUD_PLUGIN_NAME_LONG " (" GIT_SHA ")");
+               olsr_printf(0, "%s\n", PUD_PLUGIN_NAME_LONG
+#ifdef GIT_SHA
+                               " (" GIT_SHA ")"
+#endif
+               );
        }
        return (retval ? 1 : 0);
 }