[SeaBIOS] [PATCH 2/2] buildversion.h: use the last git commit as timestamp if available

Alexander Couzens lynxis at fe80.eu
Sat Mar 7 18:45:30 CET 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, 5 insertions(+), 3 deletions(-)

diff --git a/scripts/buildversion.sh b/scripts/buildversion.sh
index 16c043f..f63b9a0 100755
--- a/scripts/buildversion.sh
+++ b/scripts/buildversion.sh
@@ -2,16 +2,18 @@
 # 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`"
+    VERSION="$(git describe --tags --long --dirty)"
+    DATE="$(git log --date=local --pretty=format:%ct -1)"
 elif [ -f .version ]; then
-    VERSION="`cat .version`"
+    VERSION="$(cat .version)"
 else
     VERSION="?"
 fi
-VERSION="${VERSION}-`date +"%Y%m%d_%H%M%S"`"
+VERSION="${VERSION}-$(TZ=UTC date -d @$DATE +%Y%m%d_%H%M%S)"
 echo "Version: ${VERSION}"
 
 # Build header file
-- 
2.3.1




More information about the SeaBIOS mailing list