1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 13:38:12 +00:00
trezor-firmware/legacy/script/toolchain-download

55 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# script/toolchain-download: Download and extract the GNU Arm Embedded toolchain
2018-06-27 16:12:18 +00:00
# for building the TREZOR firmware.
set -e
cd "$(dirname "$0")/../vendor"
readonly URL="https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2"
readonly SHA256SUM="9910b6b5df12efe564dbb3856bf1599d4c16178a6f28bd8a23c9e5c3edc219e4"
readonly FILENAME="$(basename "$URL")"
readonly DIRECTORY="gcc-arm-none-eabi-5_4-2016q2"
if [ "$(uname)" != "Linux" ]; then
printf "Unsupported platform\n" >&2
exit 1
fi
validate_download() {
printf "$SHA256SUM $FILENAME" | sha256sum -c
}
download_file() {
curl -LC- "$URL" -o "$FILENAME"
}
extract_download() {
local temporary_dir="$(mktemp -d ./toolchain.XXXXXXXXXX)"
trap "rm -rf $temporary_dir" EXIT
tar -xf "$FILENAME" -C "$temporary_dir"
mv "$temporary_dir/$DIRECTORY" .
rm -f "$FILENAME"
}
if [ ! -d "$DIRECTORY" ]; then
if ! validate_download; then
2018-06-27 16:12:18 +00:00
download_file
validate_download
fi
extract_download
fi
# init toolchain as repository so Git will skip it
git init -q "$DIRECTORY"
# update toolchain symlink
ln -snf "$DIRECTORY" toolchain
# sanity-check extracted toolchain
toolchain/bin/arm-none-eabi-gcc --version >/dev/null