summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2015-03-07 01:50:22 +0100
committerStefan Reinauer <stefan.reinauer@coreboot.org>2015-03-16 04:02:08 +0100
commita74d569731ab19a81a1c125b9d65659408649265 (patch)
treee64ad603eb9db7772d22b5b9db60b0403daf6b3a
parent83b05eb0a85d7b7ac0837cece67afabbdb46ea65 (diff)
genbuild_h.sh: use the last git commit as timesource if available
Change-Id: I1472265adac9406a86da22839199ec6bbdaa0c69 Signed-off-by: Alexander Couzens <lynxis@fe80.eu> Reviewed-on: http://review.coreboot.org/8619 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rwxr-xr-xutil/genbuild_h/genbuild_h.sh25
1 files changed, 15 insertions, 10 deletions
diff --git a/util/genbuild_h/genbuild_h.sh b/util/genbuild_h/genbuild_h.sh
index ffc696e707..b161dffcaf 100755
--- a/util/genbuild_h/genbuild_h.sh
+++ b/util/genbuild_h/genbuild_h.sh
@@ -18,7 +18,18 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
-DATE=$(date +%s)
+DATE=""
+GITREV=""
+TIMESOURCE=""
+if [ -d "${top}/.git" ] && [ -f "$(command -v git)" ]; then
+ GITREV=$(LANG= git log remotes/origin/master -1 --format=format:%h)
+ TIMESOURCE=git
+ DATE=$(git log --pretty=format:%ct -1)
+else
+ GITREV=Unknown
+ TIMESOURCE="LANG= TZ=UTC date"
+ DATE=$(date +%s)
+fi
#Print out the information that goes into build.h
printf "/* build system definitions (autogenerated) */\n"
@@ -27,15 +38,9 @@ printf "#define __BUILD_H\n\n"
printf "#define COREBOOT_VERSION %s\n" "\"$KERNELVERSION\""
#See if the build is running in a git repo and the git command is available
-if [ -d "${top}/.git" ] && [ -f "$(command -v git)" ]; then
- printf "/* %s UTC */\n" "$(LANG= TZ=UTC git log --date=local --pretty=format:%cd -1)"
- printf "#define COREBOOT_VERSION_TIMESTAMP %s\n" "$(git log --pretty=format:%ct -1)"
- printf "#define COREBOOT_ORIGIN_GIT_REVISION \"%s\"\n" "$(LANG= git log remotes/origin/master -1 --format=format:%h)"
-else
- printf "/* `LANG= TZ=UTC date` */\n"
- printf "#define COREBOOT_VERSION_TIMESTAMP %s\n" "$(LANG= date -d @$DATE +%s)"
- printf "#define COREBOOT_ORIGIN_GIT_REVISION \"Unknown\"\n"
-fi
+printf "/* timesource: $TIMESOURCE */\n"
+printf "#define COREBOOT_VERSION_TIMESTAMP $DATE\n"
+printf "#define COREBOOT_ORIGIN_GIT_REVISION \"$GITREV\"\n"
printf "#define COREBOOT_EXTRA_VERSION \"%s\"\n" "$COREBOOT_EXTRA_VERSION"
printf "#define COREBOOT_BUILD \"%s\"\n" "$(LANG= TZ=UTC date -d @$DATE)"