diff --git a/Tools/environment_install/install-prereqs-arch.sh b/Tools/environment_install/install-prereqs-arch.sh index 6b304799a7..6abdb7f592 100755 --- a/Tools/environment_install/install-prereqs-arch.sh +++ b/Tools/environment_install/install-prereqs-arch.sh @@ -33,6 +33,7 @@ PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect argparse matplotlib pyparsin ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major" ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2" ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL" +ARM_TARBALL_CHECKSUM="21134caa478bbf5352e239fbc6e2da3038f8d2207e089efc96c3b55f1edcd618" # Ardupilot Tools ARDUPILOT_TOOLS="ardupilot/Tools/autotest" @@ -85,9 +86,33 @@ pip3 -q install -U $PYTHON_PKGS if [ ! -d $OPT/$ARM_ROOT ]; then ( cd $OPT; - sudo wget --progress=dot:giga $ARM_TARBALL_URL; - sudo tar xjf ${ARM_TARBALL}; - sudo rm ${ARM_TARBALL}; + + # Check if file exists and verify checksum + download_required=false + if [ -e "$ARM_TARBALL" ]; then + echo "File exists. Verifying checksum..." + + # Calculate the checksum of the existing file + ACTUAL_CHECKSUM=$(sha256sum "$ARM_TARBALL" | awk '{ print $1 }') + + # Compare the actual checksum with the expected one + if [ "$ACTUAL_CHECKSUM" == "$ARM_TARBALL_CHECKSUM" ]; then + echo "Checksum valid. No need to redownload." + else + echo "Checksum invalid. Redownloading the file..." + download_required=true + sudo rm $ARM_TARBALL + fi + else + echo "File does not exist. Downloading..." + download_required=true + fi + + if $download_required; then + sudo wget -O "$ARM_TARBALL" --progress=dot:giga $ARM_TARBALL_URL + fi + + sudo tar xjf ${ARM_TARBALL} ) fi