diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/genbuild_h/genbuild_h.sh | 25 |
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)" |