Don't download ARM Gnu toolchain if present (#5005)

* check for downloaded toolkit

* rm if not

* force

* this might work better

* don't move, just link

* don't need glob

* try

* try correct path

* check file to prevent error

* fix quotes so globs work

* using an executable which contains version stamp

* docs etc

* fix path

* back to globs we go

* maybe the path is right this time
This commit is contained in:
David Holdeman 2023-01-24 21:33:58 -06:00 committed by GitHub
parent a31b498951
commit bbfbd134a1
1 changed files with 20 additions and 16 deletions

View File

@ -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}"