From 1362be044724bb49d785ca2e296a3b43343c1690 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 7 Apr 2020 21:34:37 +0300 Subject: [PATCH] build: Drop make dist in gitian builds --- contrib/gitian-descriptors/gitian-linux.yml | 27 +++++-------------- contrib/gitian-descriptors/gitian-osx.yml | 25 +++++------------- contrib/gitian-descriptors/gitian-win.yml | 29 ++++++--------------- contrib/gitian-descriptors/make_git_archive | 20 ++++++++++++++ share/genbuild.sh | 6 +---- test/lint/lint-shell.sh | 10 ++++--- 6 files changed, 48 insertions(+), 69 deletions(-) create mode 100755 contrib/gitian-descriptors/make_git_archive diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml index a13a42d391..440ac0ce6c 100644 --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -140,18 +140,12 @@ script: | create_per-host_faketime_wrappers "${REFERENCE_DATETIME}" export PATH=${WRAP_DIR}:${PATH} - # Create the release tarball using (arbitrarily) the first host - ./autogen.sh - CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/ - make dist - SOURCEDIST=$(echo bitcoin-*.tar.gz) - DISTNAME=${SOURCEDIST/%.tar.gz} - - # Workaround for tarball not building with the bare tag version (prep) - make -C src obj/build.h + # Create the git archive, and define DISTNAME and GIT_ARCHIVE variables. + # shellcheck source=contrib/gitian-descriptors/make_git_archive + source contrib/gitian-descriptors/make_git_archive ORIGPATH="$PATH" - # Extract the release tarball into a dir for each host and build + # Extract the git archive into a dir for each host and build for i in ${HOSTS}; do export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} if [ "${i}" = "riscv64-linux-gnu" ]; then @@ -165,13 +159,9 @@ script: | cd distsrc-${i} INSTALLPATH="${PWD}/installed/${DISTNAME}" mkdir -p ${INSTALLPATH} - tar --strip-components=1 -xf ../$SOURCEDIST - - # 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/ + tar -xf $GIT_ARCHIVE + ./autogen.sh 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 @@ -183,12 +173,9 @@ script: | rm -rf ${DISTNAME}/lib/pkgconfig find ${DISTNAME}/bin -type f -executable -print0 | xargs -0 -n1 -I{} ../contrib/devtools/split-debug.sh {} {} {}.dbg find ${DISTNAME}/lib -type f -print0 | xargs -0 -n1 -I{} ../contrib/devtools/split-debug.sh {} {} {}.dbg - cp ../../README.md ${DISTNAME}/ + cp ../README.md ${DISTNAME}/ find ${DISTNAME} -not -name "*.dbg" | sort | tar --mtime="$REFERENCE_DATETIME" --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}.tar.gz find ${DISTNAME} -name "*.dbg" | sort | tar --mtime="$REFERENCE_DATETIME" --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}-debug.tar.gz cd ../../ rm -rf distsrc-${i} done - - mkdir -p ${OUTDIR}/src - git archive --output=${OUTDIR}/src/${DISTNAME}.tar.gz HEAD diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml index 58531c81b4..85072c9740 100644 --- a/contrib/gitian-descriptors/gitian-osx.yml +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -103,31 +103,21 @@ script: | create_per-host_faketime_wrappers "${REFERENCE_DATETIME}" export PATH=${WRAP_DIR}:${PATH} - # Create the release tarball using (arbitrarily) the first host - ./autogen.sh - CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/ - make dist - SOURCEDIST=$(echo bitcoin-*.tar.gz) - DISTNAME=${SOURCEDIST/%.tar.gz} - - # Workaround for tarball not building with the bare tag version (prep) - make -C src obj/build.h + # Create the git archive, and define DISTNAME and GIT_ARCHIVE variables. + # shellcheck source=contrib/gitian-descriptors/make_git_archive + source contrib/gitian-descriptors/make_git_archive ORIGPATH="$PATH" - # Extract the release tarball into a dir for each host and build + # Extract the git archive into a dir for each host and build for i in ${HOSTS}; do export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} mkdir -p distsrc-${i} cd distsrc-${i} INSTALLPATH="${PWD}/installed/${DISTNAME}" mkdir -p ${INSTALLPATH} - tar --strip-components=1 -xf ../$SOURCEDIST - - # 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/ + tar -xf $GIT_ARCHIVE + ./autogen.sh CONFIG_SITE=${BASEPREFIX}/${i}/share/config.site ./configure --prefix=/ --disable-ccache --disable-maintainer-mode --disable-dependency-tracking ${CONFIGFLAGS} make ${MAKEOPTS} make ${MAKEOPTS} -C src check-security @@ -160,7 +150,4 @@ script: | cd ../../ done - mkdir -p ${OUTDIR}/src - git archive --output=${OUTDIR}/src/${DISTNAME}.tar.gz HEAD - mv ${OUTDIR}/${DISTNAME}-x86_64-*.tar.gz ${OUTDIR}/${DISTNAME}-osx64.tar.gz diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml index c5eea97c77..27cf6e84c5 100644 --- a/contrib/gitian-descriptors/gitian-win.yml +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -110,38 +110,28 @@ script: | create_per-host_compiler_wrapper "${REFERENCE_DATETIME}" export PATH=${WRAP_DIR}:${PATH} - # Create the release tarball using (arbitrarily) the first host - ./autogen.sh - CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/ - make dist - SOURCEDIST=$(echo bitcoin-*.tar.gz) - DISTNAME=${SOURCEDIST/%.tar.gz} - - # Workaround for tarball not building with the bare tag version (prep) - make -C src obj/build.h + # Create the git archive, and define DISTNAME and GIT_ARCHIVE variables. + # shellcheck source=contrib/gitian-descriptors/make_git_archive + source contrib/gitian-descriptors/make_git_archive ORIGPATH="$PATH" - # Extract the release tarball into a dir for each host and build + # Extract the git archive into a dir for each host and build for i in ${HOSTS}; do export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} mkdir -p distsrc-${i} cd distsrc-${i} INSTALLPATH="${PWD}/installed/${DISTNAME}" mkdir -p ${INSTALLPATH} - tar --strip-components=1 -xf ../$SOURCEDIST - - # 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/ + tar -xf $GIT_ARCHIVE + ./autogen.sh CONFIG_SITE=${BASEPREFIX}/${i}/share/config.site ./configure --prefix=/ --disable-ccache --disable-maintainer-mode --disable-dependency-tracking ${CONFIGFLAGS} CFLAGS="${HOST_CFLAGS}" CXXFLAGS="${HOST_CXXFLAGS}" make ${MAKEOPTS} make ${MAKEOPTS} -C src check-security make ${MAKEOPTS} -C src check-symbols make deploy make install DESTDIR=${INSTALLPATH} - cp -f --target-directory="${OUTDIR}" ./bitcoin-*-setup-unsigned.exe + cp -f ./bitcoin-*-win64-setup-unsigned.exe ${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe cd installed mv ${DISTNAME}/bin/*.dll ${DISTNAME}/lib/ find . -name "lib*.la" -delete @@ -156,11 +146,8 @@ script: | rm -rf distsrc-${i} done - mkdir -p ${OUTDIR}/src - git archive --output=${OUTDIR}/src/${DISTNAME}.tar.gz HEAD - cp -rf contrib/windeploy $BUILD_DIR cd $BUILD_DIR/windeploy mkdir unsigned - cp $OUTDIR/bitcoin-*setup-unsigned.exe unsigned/ + cp ${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe unsigned/ find . | sort | tar --mtime="$REFERENCE_DATETIME" --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-win-unsigned.tar.gz diff --git a/contrib/gitian-descriptors/make_git_archive b/contrib/gitian-descriptors/make_git_archive new file mode 100755 index 0000000000..d922c94c60 --- /dev/null +++ b/contrib/gitian-descriptors/make_git_archive @@ -0,0 +1,20 @@ +# 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 be sourced into the gitian descriptors + +mkdir -p ${OUTDIR}/src +RECENT_TAG=$(git describe --abbrev=0 HEAD) +if [ $RECENT_TAG = $(git describe HEAD) ]; then + if [[ $RECENT_TAG == v* ]]; then + VERSION=${RECENT_TAG:1} + else + VERSION=$RECENT_TAG + fi +else + VERSION=$(git rev-parse --short HEAD) +fi +DISTNAME=bitcoin-${VERSION} +GIT_ARCHIVE="${OUTDIR}/src/${DISTNAME}.tar.gz" +git archive --output=$GIT_ARCHIVE HEAD diff --git a/share/genbuild.sh b/share/genbuild.sh index 197787d5e0..81fa2ed5d0 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -18,13 +18,9 @@ else 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 +if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then # clean 'dirty' status of touched files that haven't been modified git diff >/dev/null 2>/dev/null diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index f59b2c9945..d31ea14ea8 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -46,15 +46,17 @@ if ! command -v yq > /dev/null; then fi EXCLUDE_GITIAN=${EXCLUDE}",$(IFS=','; echo "${disabled_gitian[*]}")" +SHELLCHECK_CMD="shellcheck --external-sources --check-sourced $EXCLUDE_GITIAN" for descriptor in $(git ls-files -- 'contrib/gitian-descriptors/*.yml') do - echo - echo "$descriptor" + script=$(basename "$descriptor") # Use #!/bin/bash as gitian-builder/bin/gbuild does to complete a script. - SCRIPT=$'#!/bin/bash\n'$(yq -r .script "$descriptor") - if ! echo "$SCRIPT" | shellcheck "$EXCLUDE_GITIAN" -; then + echo "#!/bin/bash" > $script + yq -r .script "$descriptor" >> $script + if ! $SHELLCHECK_CMD $script; then EXIT_CODE=1 fi + rm $script done exit $EXIT_CODE