2022-09-28 14:24:42 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
mkdir -p "$(dirname "$0")"/../dependencies
|
|
|
|
cd "$(dirname "$0")"/../dependencies
|
|
|
|
|
|
|
|
unameOut="$(uname -s)"
|
|
|
|
case "${unameOut}" in
|
|
|
|
Linux*)
|
|
|
|
criterion_suffix=
|
|
|
|
machine=linux;;
|
|
|
|
Darwin*)
|
|
|
|
criterion_suffix=
|
|
|
|
machine=osx;;
|
|
|
|
MINGW*)
|
|
|
|
criterion_suffix=-mingw
|
|
|
|
machine=windows;;
|
|
|
|
*)
|
|
|
|
criterion_suffix=
|
|
|
|
machine=linux
|
|
|
|
esac
|
2023-02-21 06:23:48 -08:00
|
|
|
unameOut="$(uname -m)"
|
|
|
|
case "${unameOut}" in
|
|
|
|
arm64*)
|
|
|
|
arch=aarch64;;
|
|
|
|
*)
|
|
|
|
arch=x86_64
|
|
|
|
esac
|
2022-09-28 14:24:42 -07:00
|
|
|
|
|
|
|
download() {
|
|
|
|
declare url="$1/$2/$3"
|
|
|
|
declare filename=$3
|
|
|
|
declare wget_args=(
|
|
|
|
"$url" -O "$filename"
|
|
|
|
"--progress=dot:giga"
|
|
|
|
"--retry-connrefused"
|
|
|
|
"--read-timeout=30"
|
|
|
|
)
|
|
|
|
declare curl_args=(
|
|
|
|
-L "$url" -o "$filename"
|
|
|
|
)
|
|
|
|
if hash wget 2>/dev/null; then
|
|
|
|
wget_or_curl="wget ${wget_args[*]}"
|
|
|
|
elif hash curl 2>/dev/null; then
|
|
|
|
wget_or_curl="curl ${curl_args[*]}"
|
|
|
|
else
|
|
|
|
echo "Error: Neither curl nor wget were found" >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -x
|
|
|
|
if $wget_or_curl; then
|
|
|
|
tar --strip-components 1 -jxf "$filename" || return 1
|
|
|
|
{ set +x; } 2>/dev/null
|
|
|
|
rm -rf "$filename"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
get() {
|
|
|
|
declare version=$1
|
|
|
|
declare dirname=$2
|
|
|
|
declare job=$3
|
|
|
|
declare cache_root=~/.cache/solana
|
|
|
|
declare cache_dirname="$cache_root/$version/$dirname"
|
|
|
|
declare cache_partial_dirname="$cache_dirname"_partial
|
|
|
|
|
|
|
|
if [[ -r $cache_dirname ]]; then
|
|
|
|
ln -sf "$cache_dirname" "$dirname" || return 1
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf "$cache_partial_dirname" || return 1
|
|
|
|
mkdir -p "$cache_partial_dirname" || return 1
|
|
|
|
pushd "$cache_partial_dirname"
|
|
|
|
|
|
|
|
if $job; then
|
|
|
|
popd
|
|
|
|
mv "$cache_partial_dirname" "$cache_dirname" || return 1
|
|
|
|
ln -sf "$cache_dirname" "$dirname" || return 1
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
popd
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install Criterion
|
|
|
|
if [[ $machine == "linux" ]]; then
|
|
|
|
version=v2.3.3
|
|
|
|
else
|
|
|
|
version=v2.3.2
|
|
|
|
fi
|
|
|
|
if [[ ! -e criterion-$version.md || ! -e criterion ]]; then
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
rm -rf criterion*
|
|
|
|
job="download \
|
|
|
|
https://github.com/Snaipe/Criterion/releases/download \
|
|
|
|
$version \
|
|
|
|
criterion-$version-$machine$criterion_suffix-x86_64.tar.bz2 \
|
|
|
|
criterion"
|
|
|
|
get $version criterion "$job"
|
|
|
|
)
|
|
|
|
exitcode=$?
|
|
|
|
if [[ $exitcode -ne 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
touch criterion-$version.md
|
|
|
|
fi
|
|
|
|
|
2023-03-22 07:41:40 -07:00
|
|
|
# Install platform tools
|
2024-02-27 12:58:26 -08:00
|
|
|
version=v1.41
|
2023-03-22 07:41:40 -07:00
|
|
|
if [[ ! -e platform-tools-$version.md || ! -e platform-tools ]]; then
|
2022-09-28 14:24:42 -07:00
|
|
|
(
|
|
|
|
set -e
|
2023-03-22 07:41:40 -07:00
|
|
|
rm -rf platform-tools*
|
2022-09-28 14:24:42 -07:00
|
|
|
job="download \
|
2024-02-27 12:58:26 -08:00
|
|
|
https://github.com/anza-xyz/platform-tools/releases/download \
|
2022-09-28 14:24:42 -07:00
|
|
|
$version \
|
2023-03-22 07:41:40 -07:00
|
|
|
platform-tools-${machine}-${arch}.tar.bz2 \
|
|
|
|
platform-tools"
|
|
|
|
get $version platform-tools "$job"
|
2022-09-28 14:24:42 -07:00
|
|
|
)
|
|
|
|
exitcode=$?
|
|
|
|
if [[ $exitcode -ne 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-03-22 07:41:40 -07:00
|
|
|
touch platform-tools-$version.md
|
2022-09-28 14:24:42 -07:00
|
|
|
set -ex
|
2023-03-22 07:41:40 -07:00
|
|
|
./platform-tools/rust/bin/rustc --version
|
|
|
|
./platform-tools/rust/bin/rustc --print sysroot
|
2022-09-28 14:24:42 -07:00
|
|
|
set +e
|
2023-03-22 07:41:40 -07:00
|
|
|
rustup toolchain uninstall solana
|
2022-09-28 14:24:42 -07:00
|
|
|
set -e
|
2023-03-22 07:41:40 -07:00
|
|
|
rustup toolchain link solana platform-tools/rust
|
2022-09-28 14:24:42 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|