diff --git a/firmware/provide_gcc.sh b/firmware/provide_gcc.sh index 9444ac7d95..c3456d920d 100755 --- a/firmware/provide_gcc.sh +++ b/firmware/provide_gcc.sh @@ -6,6 +6,9 @@ set -e # URL to download original toolchain from URL="https://github.com/rusefi/build_support/raw/master/rusefi-arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz" +# This is the md5sum of the /bin/arm-none-eabi-ld executable within the archive, used for verifying we have the proper version. +# If you change the above URL, you will need to update this checksum as well. +MANIFEST_SUM="8e50ee1adb41acfd56fc38d74d6bb18e" # colloquial directory name, to afford re-use of script COLLOQUIAL="gcc-arm-none-eabi" # temporary working directory @@ -13,22 +16,23 @@ TMP_DIR="/tmp/rusefi-provide_gcc" archive="${URL##*/}" -# Cleanup prior [failed] runs -rm -rf "${TMP_DIR}" +SWD="$PWD" -# Download and extract archive -echo Downloading and extracting ${archive} -mkdir -p "${TMP_DIR}" -cd "${TMP_DIR}" -curl -L -o "${archive}" "${URL}" -tar -xaf "${archive}" -rm "${archive}" +# If the checksum file doesn't exist, or if its checksum doesn't match, then download and install the archive. +if [ ! -f "${TMP_DIR}"/*/bin/arm-none-eabi-ld ] ||\ + [ "$MANIFEST_SUM" != "$(md5sum ${TMP_DIR}/*/bin/arm-none-eabi-ld | cut -d ' ' -f 1)" ]; then + rm -rf "${TMP_DIR}" + # Download and extract archive + echo Downloading and extracting ${archive} + mkdir -p "${TMP_DIR}" + cd "${TMP_DIR}" + curl -L -o "${archive}" "${URL}" + tar -xaf "${archive}" + rm "${archive}" +else + echo "Toolkit already present" +fi # Create colloquially named link -archive_dir="$(echo *)" -cd - >/dev/null -mv "${TMP_DIR}/${archive_dir}" "$(pwd)" -ln -s "${archive_dir%/}" "${COLLOQUIAL}" - -# Delete downloaded archive -rm -rf "${TMP_DIR}" +cd "$SWD" +ln -s "${TMP_DIR}"/* "${COLLOQUIAL}"