From a74d569731ab19a81a1c125b9d65659408649265 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Sat, 7 Mar 2015 01:50:22 +0100 Subject: genbuild_h.sh: use the last git commit as timesource if available Change-Id: I1472265adac9406a86da22839199ec6bbdaa0c69 Signed-off-by: Alexander Couzens Reviewed-on: http://review.coreboot.org/8619 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- util/genbuild_h/genbuild_h.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'util/genbuild_h') 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)" -- cgit v1.2.3