Denis Carikli (GNUtoo@no-log.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/11873
-gerrit
commit 6e4fd82da0cb8363200c60341aec1415e9e35113 Author: Denis 'GNUtoo' Carikli GNUtoo@no-log.org Date: Sun Oct 11 12:35:51 2015 +0200
genbuild_h: Report the git revision in use, and the upstream one it's based on
This fixes the following commit: "a74d569 genbuild_h.sh: use the last git commit as timesource if available"
This issue also affected reproducible builds when origin/master was not the same between build setup: different git revision ended up in the "revision" component in coreboot.rom's cbfs.
In such case the errors will inform the user what to do. Handling all possible configurations to find the upstream commit is not trivial. If such configuration is used, the build process will fail on purpose to prevent from silently introducing non-reproducible builds.
Change-Id: Id1ba8b1ee6d48eecd547df2b6302820719c578ac Signed-off-by: Denis 'GNUtoo' Carikli GNUtoo@no-log.org --- util/genbuild_h/genbuild_h.sh | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/util/genbuild_h/genbuild_h.sh b/util/genbuild_h/genbuild_h.sh index 0fac0d0..55cc75f 100755 --- a/util/genbuild_h/genbuild_h.sh +++ b/util/genbuild_h/genbuild_h.sh @@ -22,10 +22,36 @@ export LANG=C export LC_ALL=C export TZ=UTC
-top=`dirname $0`/../.. +# TODO: +# Handle git detached branches +# Handle git branches not tracking upstream remotes +# Detect which upstream we are using (coreboot, chromeOS) from git
+top=`dirname $0`/../.. if [ -d "${top}/.git" -a -x "$(command -v git)" ]; then - GITREV=$(LANG= git log remotes/origin/master -1 --format=format:%h) + if git branch | grep '^* (HEAD detached at ' > /dev/null ; then + printf " Error: Using a git branch is now required:\n" > /dev/stderr + printf " This is required because of reproducible builds.\n" > /dev/stderr + printf " Use git checkout -b <branchname>\n" > /dev/stderr + exit 1 + fi + + LOCAL_BRANCH=$(git branch | grep '^* ' | sed 's#^* ##') + if ! git config --get branch.${LOCAL_BRANCH}.merge > /dev/null ; then + printf " Error: Your local branch need to track a remote repository:\n" > /dev/stderr + printf " This is required because of reproducible builds.\n" > /dev/stderr + printf " Fix example: git branch --set-upstream-to=origin/master\n" > /dev/stderr + exit 1 + fi + + REMOTE_BRANCH_REF=$(git config --get branch.${LOCAL_BRANCH}.merge) + REMOTE_NAME=$(git config --get branch.${LOCAL_BRANCH}.remote) + REMOTE_BRANCH_NAME=$(basename ${REMOTE_BRANCH_REF}) + GITREV=$(LANG= git log HEAD -1 --format=format:%h) + UPSTREAM_GITREV_FULL=$(git merge-base HEAD \ + ${REMOTE_NAME}/${REMOTE_BRANCH_NAME}) + UPSTREAM_GITREV_SHORT=$(git log ${UPSTREAM_GITREV_FULL} --pretty="%h" \ + | head -n1) TIMESOURCE=git DATE=$(git log --pretty=format:%ct -1) else @@ -53,7 +79,8 @@ printf "#define COREBOOT_VERSION %s\n" ""$KERNELVERSION"" #See if the build is running in a git repo and the git command is available printf "/* timesource: $TIMESOURCE */\n" printf "#define COREBOOT_VERSION_TIMESTAMP $DATE\n" -printf "#define COREBOOT_ORIGIN_GIT_REVISION "$GITREV"\n" +printf "#define COREBOOT_UPSTREAM_GIT_REVISION "$UPSTREAM_GITREV"\n" +printf "#define COREBOOT_GIT_REVISION "$GITREV"\n"
printf "#define COREBOOT_EXTRA_VERSION "%s"\n" "$COREBOOT_EXTRA_VERSION" printf "#define COREBOOT_BUILD "$(our_date "$DATE")"\n"