2021-12-13 07:54:31 +01:00
#!/usr/bin/env bash
#
2023-04-25 13:51:26 +02:00
# Copyright (c) 2018-2020 The Bitcoin Core developers
2021-12-13 07:54:31 +01:00
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL = C.UTF-8
2019-12-07 05:32:16 +01:00
if [ [ $DOCKER_NAME_TAG = = centos* ] ] ; then
export LC_ALL = en_US.utf8
fi
2020-01-22 21:09:07 +01:00
if [ [ $QEMU_USER_CMD = = qemu-s390* ] ] ; then
export LC_ALL = C
fi
2019-12-07 05:32:16 +01:00
2019-10-14 23:00:49 +02:00
if [ " $TRAVIS_OS_NAME " = = "osx" ] ; then
export PATH = " /usr/local/opt/ccache/libexec: $PATH "
${ CI_RETRY_EXE } pip3 install $PIP_PACKAGES
fi
2019-08-27 21:44:57 +02:00
mkdir -p " ${ BASE_SCRATCH_DIR } "
2019-11-04 14:23:04 +01:00
mkdir -p " ${ CCACHE_DIR } "
2020-02-12 15:19:50 +01:00
mkdir -p " ${ PREVIOUS_RELEASES_DIR } "
2021-12-13 07:54:31 +01:00
2019-12-05 21:56:12 +01:00
export ASAN_OPTIONS = "detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"
2022-03-25 08:09:24 +01:00
export LSAN_OPTIONS = " suppressions= ${ BASE_BUILD_DIR } /test/sanitizer_suppressions/lsan "
export TSAN_OPTIONS = " suppressions= ${ BASE_BUILD_DIR } /test/sanitizer_suppressions/tsan "
2019-12-04 19:22:23 +01:00
export UBSAN_OPTIONS = " suppressions= ${ BASE_BUILD_DIR } /test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1 "
2020-05-19 09:48:39 +02:00
env | grep -E '^(BASE_|QEMU_|CCACHE_|LC_ALL|BOOST_TEST_RANDOM|DEBIAN_FRONTEND|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS|TEST_PREVIOUS_RELEASES|PREVIOUS_RELEASES_DIR))' | tee /tmp/env
2021-12-13 07:54:31 +01:00
if [ [ $HOST = *-mingw32 ] ] ; then
DOCKER_ADMIN = "--cap-add SYS_ADMIN"
elif [ [ $BITCOIN_CONFIG = *--with-sanitizers= *address* ] ] ; then # If ran with (ASan + LSan), Docker needs access to ptrace (https://github.com/google/sanitizers/issues/764)
DOCKER_ADMIN = "--cap-add SYS_PTRACE"
fi
2019-12-03 17:00:58 +01:00
export P_CI_DIR = " $PWD "
2020-04-09 16:17:20 +02:00
if [ -z " $DANGER_RUN_CI_ON_HOST " ] ; then
2021-12-13 07:54:31 +01:00
echo " Creating $DOCKER_NAME_TAG container to run in "
${ CI_RETRY_EXE } docker pull " $DOCKER_NAME_TAG "
2019-11-20 22:41:45 +01:00
DOCKER_ID = $( docker run $DOCKER_ADMIN -idt \
2019-12-03 17:00:58 +01:00
--mount type = bind,src= $BASE_ROOT_DIR ,dst= /ro_base,readonly \
2019-11-20 22:41:45 +01:00
--mount type = bind,src= $CCACHE_DIR ,dst= $CCACHE_DIR \
2019-12-03 17:00:58 +01:00
--mount type = bind,src= $DEPENDS_DIR ,dst= $DEPENDS_DIR \
2020-02-12 15:19:50 +01:00
--mount type = bind,src= $PREVIOUS_RELEASES_DIR ,dst= $PREVIOUS_RELEASES_DIR \
2019-12-03 17:00:58 +01:00
-w $BASE_ROOT_DIR \
2019-11-20 22:41:45 +01:00
--env-file /tmp/env \
2020-02-10 14:50:29 +01:00
--name $CONTAINER_NAME \
2019-11-20 22:41:45 +01:00
$DOCKER_NAME_TAG )
2021-12-13 07:54:31 +01:00
DOCKER_EXEC ( ) {
2019-12-03 17:00:58 +01:00
docker exec $DOCKER_ID bash -c " export PATH= $BASE_SCRATCH_DIR /bins/:\$PATH && cd $P_CI_DIR && $* "
2021-12-13 07:54:31 +01:00
}
else
echo "Running on host system without docker wrapper"
DOCKER_EXEC ( ) {
2019-12-03 17:00:58 +01:00
bash -c " export PATH= $BASE_SCRATCH_DIR /bins/:\$PATH && cd $P_CI_DIR && $* "
2021-12-13 07:54:31 +01:00
}
fi
2020-04-29 17:14:10 +02:00
export -f DOCKER_EXEC
2021-12-13 07:54:31 +01:00
2019-11-04 14:23:04 +01:00
if [ -n " $DPKG_ADD_ARCH " ] ; then
DOCKER_EXEC dpkg --add-architecture " $DPKG_ADD_ARCH "
fi
2019-12-07 05:32:16 +01:00
if [ [ $DOCKER_NAME_TAG = = centos* ] ] ; then
${ CI_RETRY_EXE } DOCKER_EXEC yum -y install epel-release
${ CI_RETRY_EXE } DOCKER_EXEC yum -y install $DOCKER_PACKAGES $PACKAGES
2020-04-09 16:17:20 +02:00
elif [ " $CI_USE_APT_INSTALL " != "no" ] ; then
2019-10-14 23:00:49 +02:00
${ CI_RETRY_EXE } DOCKER_EXEC apt-get update
${ CI_RETRY_EXE } DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $DOCKER_PACKAGES
2023-05-13 19:44:39 +02:00
if [ -n " $PIP_PACKAGES " ] ; then
${ CI_RETRY_EXE } pip3 install --user $PIP_PACKAGES
fi
2019-10-14 23:00:49 +02:00
fi
2021-12-13 07:54:31 +01:00
2020-01-22 21:09:07 +01:00
if [ " $TRAVIS_OS_NAME " = = "osx" ] ; then
top -l 1 -s 0 | awk ' /PhysMem/ {print}'
echo " Number of CPUs: $( sysctl -n hw.logicalcpu) "
else
DOCKER_EXEC free -m -h
DOCKER_EXEC echo "Number of CPUs \(nproc\):" \$ \( nproc\)
2020-04-09 16:17:20 +02:00
DOCKER_EXEC echo $( lscpu | grep Endian)
2020-01-22 21:09:07 +01:00
DOCKER_EXEC echo "Free disk space:"
DOCKER_EXEC df -h
fi
2019-11-20 22:41:45 +01:00
if [ ! -d ${ DIR_QA_ASSETS } ] ; then
2020-03-25 18:36:47 +01:00
if [ " $RUN_FUZZ_TESTS " = "true" ] ; then
2019-11-20 22:41:45 +01:00
DOCKER_EXEC git clone https://github.com/bitcoin-core/qa-assets ${ DIR_QA_ASSETS }
2020-03-25 18:36:47 +01:00
fi
2019-11-20 22:41:45 +01:00
fi
export DIR_FUZZ_IN = ${ DIR_QA_ASSETS } /fuzz_seed_corpus/
2019-12-03 17:00:58 +01:00
DOCKER_EXEC mkdir -p " ${ BASE_SCRATCH_DIR } /sanitizer-output/ "
2019-11-20 22:41:45 +01:00
2020-04-09 16:17:20 +02:00
if [ -z " $DANGER_RUN_CI_ON_HOST " ] ; then
2019-12-03 17:00:58 +01:00
echo " Create $BASE_ROOT_DIR "
DOCKER_EXEC rsync -a /ro_base/ $BASE_ROOT_DIR
2019-11-20 22:41:45 +01:00
fi
2019-09-30 23:26:22 +02:00
if [ " $USE_BUSY_BOX " = "true" ] ; then
echo "Setup to use BusyBox utils"
DOCKER_EXEC mkdir -p $BASE_SCRATCH_DIR /bins/
# tar excluded for now because it requires passing in the exact archive type in ./depends (fixed in later BusyBox version)
# find excluded for now because it does not recognize the -delete option in ./depends (fixed in later BusyBox version)
# ar excluded for now because it does not recognize the -q option in ./depends (unknown if fixed)
# shellcheck disable=SC1010
DOCKER_EXEC for util in \$ \( busybox --list \| grep -v " ^ar $" \| grep -v " ^tar $" \| grep -v " ^find $" \) \; do ln -s \$ \( command -v busybox\) $BASE_SCRATCH_DIR /bins/\$ util\; done
# Print BusyBox version
DOCKER_EXEC patch --help
fi