-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
In #11097 we added a quick version string hack that seems to do the following:
When Gitian building, after generating the source tarball (a la make dist), we invoke make -C src obj/build.h, as make dist does not:
Lines 245 to 248 in b499d85
| obj/build.h: FORCE | |
| @$(MKDIR_P) $(builddir)/obj | |
| @$(top_srcdir)/share/genbuild.sh "$(abs_top_builddir)/src/obj/build.h" \ | |
| "$(abs_top_srcdir)" |
We can see that this calls
share/genbuild.sh, which generates a src/obj/build.h containing version information obtained from git: Lines 1 to 53 in b499d85
| #!/bin/sh | |
| # Copyright (c) 2012-2016 The Bitcoin Core developers | |
| # Distributed under the MIT software license, see the accompanying | |
| # file COPYING or http://www.opensource.org/licenses/mit-license.php. | |
| export LC_ALL=C | |
| if [ $# -gt 1 ]; then | |
| cd "$2" || exit 1 | |
| fi | |
| if [ $# -gt 0 ]; then | |
| FILE="$1" | |
| shift | |
| if [ -f "$FILE" ]; then | |
| INFO="$(head -n 1 "$FILE")" | |
| fi | |
| else | |
| echo "Usage: $0 <filename> <srcroot>" | |
| exit 1 | |
| fi | |
| git_check_in_repo() { | |
| ! { git status --porcelain -uall --ignored "$@" 2>/dev/null || echo '??'; } | grep -q '?' | |
| } | |
| DESC="" | |
| SUFFIX="" | |
| 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 | |
| # if latest commit is tagged and not dirty, then override using the tag name | |
| RAWDESC=$(git describe --abbrev=0 2>/dev/null) | |
| if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then | |
| git diff-index --quiet HEAD -- && DESC=$RAWDESC | |
| fi | |
| # otherwise generate suffix from git, i.e. string like "59887e8-dirty" | |
| SUFFIX=$(git rev-parse --short HEAD) | |
| git diff-index --quiet HEAD -- || SUFFIX="$SUFFIX-dirty" | |
| fi | |
| if [ -n "$DESC" ]; then | |
| NEWINFO="#define BUILD_DESC \"$DESC\"" | |
| elif [ -n "$SUFFIX" ]; then | |
| NEWINFO="#define BUILD_SUFFIX $SUFFIX" | |
| else | |
| NEWINFO="// No build information available" | |
| fi | |
| # only update build.h if necessary | |
| if [ "$INFO" != "$NEWINFO" ]; then | |
| echo "$NEWINFO" >"$FILE" | |
| fi |
Then, for each architecture we build, we neuter share/genbuild.sh (as normal make will try to regenerate obj/build.h, but now lacks the build information as we're not in a git repository anymore) and copy over the generated src/obj/build.h mentioned above. All of this is being done before configureing, makeing, and make installing for the architecture:
bitcoin/contrib/gitian-descriptors/gitian-linux.yml
Lines 168 to 177 in b499d85
| # Workaround for tarball not building with the bare tag version | |
| echo '#!/bin/true' >share/genbuild.sh | |
| mkdir src/obj | |
| cp ../src/obj/build.h src/obj/ | |
| CONFIG_SITE=${BASEPREFIX}/${i}/share/config.site ./configure --prefix=/ --disable-ccache --disable-maintainer-mode --disable-dependency-tracking ${CONFIGFLAGS} CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" LDFLAGS="${HOST_LDFLAGS}" | |
| make ${MAKEOPTS} | |
| make ${MAKEOPTS} -C src check-security | |
| make ${MAKEOPTS} -C src check-symbols | |
| make install DESTDIR=${INSTALLPATH} |
Perhaps what we can do is simply add src/obj/build.h to EXTRA_DIST, and generate it in a dist-hook? Do non-existent files in EXTRA_DIST get their targets called? Source: https://www.gnu.org/software/automake/manual/html_node/The-dist-Hook.html