diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index c49553bec3..a4a17cf110 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -205,7 +205,8 @@ GIT_ARCHIVE="${DIST_ARCHIVE_BASE}/${DISTNAME}.tar.gz" # Create the source tarball if not already there if [ ! -e "$GIT_ARCHIVE" ]; then mkdir -p "$(dirname "$GIT_ARCHIVE")" - git archive --prefix="${DISTNAME}/" --output="$GIT_ARCHIVE" HEAD + CONFIG_SITE="${BASEPREFIX}/${HOST}/share/config.site" \ + contrib/guix/libexec/make_release_tarball.sh "${GIT_ARCHIVE}" "${DISTNAME}" fi mkdir -p "$OUTDIR" @@ -248,8 +249,6 @@ mkdir -p "$DISTSRC" # Extract the source tarball tar --strip-components=1 -xf "${GIT_ARCHIVE}" - ./autogen.sh - # Configure this DISTSRC for $HOST # shellcheck disable=SC2086 env CONFIG_SITE="${BASEPREFIX}/${HOST}/share/config.site" \ diff --git a/contrib/guix/libexec/make_release_tarball.sh b/contrib/guix/libexec/make_release_tarball.sh new file mode 100755 index 0000000000..c99e6fb500 --- /dev/null +++ b/contrib/guix/libexec/make_release_tarball.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Copyright (c) 2020 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# +# A helper script to generate source release tarball + +export LC_ALL=C +set -ex + +[ "$#" -ge 2 ] + +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 +./configure --prefix=/ --disable-ccache --disable-maintainer-mode --disable-dependency-tracking +make distclean + +cd .. +tar \ + --format=ustar \ + --exclude autom4te.cache \ + --exclude .deps \ + --exclude .git \ + --sort=name \ + --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 \ + --mtime="${REFERENCE_DATETIME}" \ + -c "${DISTNAME}" | \ + gzip -9n \ + >"${GIT_ARCHIVE}" + +rm -rf "${DISTNAME}" diff --git a/share/genbuild.sh b/share/genbuild.sh index ecc96160e6..963113ae2c 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 @@ -40,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