2021-11-15 13:43:05 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-10-31 13:26:54 +00:00
|
|
|
|
2019-10-31 14:18:35 +00:00
|
|
|
set -eu
|
2019-10-31 13:26:54 +00:00
|
|
|
|
2019-10-31 20:28:32 +00:00
|
|
|
VERSIONS=(
|
2022-12-09 11:31:30 +00:00
|
|
|
"v1.3.0-alpha.1-hotfix.2"
|
2019-10-31 20:28:32 +00:00
|
|
|
)
|
2019-10-31 16:51:36 +00:00
|
|
|
FLAVOURS=(
|
2019-11-09 09:02:34 +00:00
|
|
|
"general"
|
|
|
|
"minimal"
|
|
|
|
"mainnet"
|
2019-10-31 16:51:36 +00:00
|
|
|
)
|
2019-10-31 13:26:54 +00:00
|
|
|
|
2019-10-31 17:30:17 +00:00
|
|
|
# signal handler (we only care about the Ctrl+C generated SIGINT)
|
|
|
|
REL_PATH="$(dirname "${BASH_SOURCE[0]}")"
|
2020-10-09 12:45:36 +00:00
|
|
|
ABS_PATH="$(cd "${REL_PATH}"; pwd)"
|
2019-10-31 17:30:17 +00:00
|
|
|
cleanup() {
|
|
|
|
echo -e "\nCtrl+C pressed. Cleaning up."
|
|
|
|
cd "$ABS_PATH"
|
|
|
|
rm -rf tarballs tests-*
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
trap cleanup SIGINT
|
|
|
|
|
2019-10-31 16:51:36 +00:00
|
|
|
dl_version() {
|
|
|
|
[[ -z "$1" ]] && { echo "usage: dl_version() vX.Y.Z"; exit 1; }
|
|
|
|
version="$1"
|
2019-10-31 13:26:54 +00:00
|
|
|
|
2019-10-31 16:51:36 +00:00
|
|
|
mkdir -p "tarballs/${version}"
|
|
|
|
pushd "tarballs/${version}" >/dev/null
|
|
|
|
for flavour in "${FLAVOURS[@]}"; do
|
|
|
|
if [[ ! -e "${flavour}.tar.gz" ]]; then
|
|
|
|
echo "Downloading: ${version}/${flavour}.tar.gz"
|
2022-12-06 14:09:28 +00:00
|
|
|
curl --location --remote-name --silent --show-error --retry 3 --retry-all-errors \
|
2021-08-23 05:50:25 +00:00
|
|
|
"https://github.com/ethereum/consensus-spec-tests/releases/download/${version}/${flavour}.tar.gz" \
|
2019-10-31 16:51:36 +00:00
|
|
|
|| {
|
|
|
|
echo "Curl failed. Aborting"
|
|
|
|
rm -f "${flavour}.tar.gz"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
popd >/dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
unpack_version() {
|
|
|
|
[[ -z "$1" ]] && { echo "usage: unpack_version() vX.Y.Z"; exit 1; }
|
|
|
|
version="$1"
|
|
|
|
|
|
|
|
dl_version "$version"
|
|
|
|
|
|
|
|
# suppress warnings when unpacking with GNU tar an archive created with BSD tar (probably on macOS)
|
|
|
|
EXTRA_TAR_PARAMS=""
|
2019-10-31 22:10:52 +00:00
|
|
|
tar --version | grep -qi 'gnu' && EXTRA_TAR_PARAMS="--warning=no-unknown-keyword --ignore-zeros"
|
2019-10-31 16:51:36 +00:00
|
|
|
|
|
|
|
if [[ ! -d "tests-${version}" ]]; then
|
|
|
|
for flavour in "${FLAVOURS[@]}"; do
|
|
|
|
echo "Unpacking: ${version}/${flavour}.tar.gz"
|
2019-10-31 21:52:04 +00:00
|
|
|
mkdir -p "tests-${version}"
|
2020-09-24 10:38:23 +00:00
|
|
|
tar -C "tests-${version}" --strip-components 1 ${EXTRA_TAR_PARAMS} --exclude=phase1 -xzf \
|
2019-10-31 16:51:36 +00:00
|
|
|
"tarballs/${version}/${flavour}.tar.gz" \
|
|
|
|
|| {
|
|
|
|
echo "Tar failed. Aborting."
|
|
|
|
rm -rf "tests-${version}"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-10-31 20:28:32 +00:00
|
|
|
# download and unpack
|
|
|
|
for version in "${VERSIONS[@]}"; do
|
2019-10-31 16:51:36 +00:00
|
|
|
unpack_version "$version"
|
|
|
|
done
|
2019-10-31 14:18:35 +00:00
|
|
|
|
2019-10-31 20:28:32 +00:00
|
|
|
# delete tarballs and unpacked data from old versions
|
|
|
|
for tpath in tarballs/*; do
|
|
|
|
tdir="$(basename "$tpath")"
|
|
|
|
if [[ ! " ${VERSIONS[@]} " =~ " $tdir " ]]; then
|
|
|
|
rm -rf "$tpath"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
for tpath in tests-*; do
|
2020-10-09 12:45:36 +00:00
|
|
|
tver="$(echo "$tpath" | sed -e's/^tests-//')"
|
2019-10-31 20:28:32 +00:00
|
|
|
if [[ ! " ${VERSIONS[@]} " =~ " $tver " ]]; then
|
|
|
|
rm -rf "$tpath"
|
|
|
|
fi
|
|
|
|
done
|