[SeaBIOS] [PATCH] buildversion.h: use the last git commit as timesource if tree is clean

Alexander Couzens lynxis at fe80.eu
Thu Jun 4 00:40:59 CEST 2015


Additional set TZ=UTC to have predictable `date` output.

Signed-off-by: Alexander Couzens <lynxis at fe80.eu>
---
 scripts/buildversion.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/scripts/buildversion.sh b/scripts/buildversion.sh
index e5ce96c..8388afd 100755
--- a/scripts/buildversion.sh
+++ b/scripts/buildversion.sh
@@ -2,16 +2,22 @@
 # Script to generate a C file with version information.
 OUTFILE="$1"
 VAR16MODE="$2"
+DATE=$(date +%s)
 
 # Extract version info
 if [ -d .git -o -f .git ]; then
     VERSION="`git describe --tags --long --dirty`"
+    echo "$VERSION" | grep -q -- "-dirty$"
+    if [ $? -eq 1 ]; then
+        # clean tree use git date
+        DATE="$(git log --date=local --pretty=format:%ct -1)"
+    fi
 elif [ -f .version ]; then
     VERSION="`cat .version`"
 else
     VERSION="?"
 fi
-VERSION="${VERSION}-`date +"%Y%m%d_%H%M%S"`-`hostname`"
+VERSION="${VERSION}-$(TZ=UTC date -d @$DATE +%Y%m%d_%H%M%S)-`hostname`"
 echo "Version: ${VERSION}"
 
 # Build header file
-- 
2.4.2




More information about the SeaBIOS mailing list