From 7bbfd6bc603ef4bcf07e43cea4b6e52724bd7750 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 12 Feb 2016 05:36:55 +0000 Subject: [PATCH 1/2] Bugfix: Only use git for build info if the repository is actually the right one Original-Github-Pull: #7522 Rebased-From: e98e3dde6a976a2c8f266ee963d6931fd4b37262 e98e3dde6a976a2c8f266ee963d6931fd4b37262 --- share/genbuild.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/genbuild.sh b/share/genbuild.sh index ecc96160e6..26c1baa4a8 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -18,9 +18,14 @@ else exit 1 fi +# This checks that we are actually part of the intended git repository, and not just getting info about some unrelated git repository that the code happens to be in a directory under +git_check_in_repo() { + ! { git status --porcelain -uall --ignored "$@" 2>/dev/null || echo '??'; } | grep -q '?' +} + GIT_TAG="" GIT_COMMIT="" -if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then +if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo share/genbuild.sh; then # clean 'dirty' status of touched files that haven't been modified git diff >/dev/null 2>/dev/null From dc4201038746cbda9dad1399e0595cd9b5bd260d Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 7 May 2020 01:46:47 +0000 Subject: [PATCH 2/2] build: Include tag name in release tarball for build.h --- contrib/guix/libexec/make_release_tarball.sh | 5 +++++ share/genbuild.sh | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/guix/libexec/make_release_tarball.sh b/contrib/guix/libexec/make_release_tarball.sh index f930b78e09..c99e6fb500 100755 --- a/contrib/guix/libexec/make_release_tarball.sh +++ b/contrib/guix/libexec/make_release_tarball.sh @@ -14,6 +14,11 @@ GIT_ARCHIVE="$1" DISTNAME="$2" git archive --prefix="${DISTNAME}/" HEAD | tar -xp + +# Generate correct build info file from git, before we lose git +GIT_BUILD_INFO="$(share/genbuild.sh /dev/stdout)" +sed 's/\/\/ No build information available/'"${GIT_BUILD_INFO}"'/' -i "${DISTNAME}/share/genbuild.sh" + cd "${DISTNAME}" ./autogen.sh diff --git a/share/genbuild.sh b/share/genbuild.sh index 26c1baa4a8..963113ae2c 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -45,7 +45,9 @@ if [ -n "$GIT_TAG" ]; then elif [ -n "$GIT_COMMIT" ]; then NEWINFO="#define BUILD_GIT_COMMIT \"$GIT_COMMIT\"" else - NEWINFO="// No build information available" + # NOTE: The NEWINFO line below this comment gets replaced by a string-match in contrib/guix/libexec/make_release_tarball.sh + # If changing it, update the script too! + NEWINFO='// No build information available' fi # only update build.h if necessary