Skip to content

Commit

Permalink
Tools: Checksum for gcc-arm download on arch prereqs
Browse files Browse the repository at this point in the history
This will check to see if the tar.bz2 file exists and if it does it will
run a checksum and skip redownloading the file if its already there. If
the checksum fails or the file doesn't exist it will redownload the
file.

I ran into issues with the download taking so long that my sudo
permissions timed out and the install failed to complete. When rerunning
the script it would redownload the file even if the file was already
there. This change solves this issue.
  • Loading branch information
jmcudd committed Nov 8, 2024
1 parent b17f7a5 commit 21e90ba
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions Tools/environment_install/install-prereqs-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 21e90ba

Please sign in to comment.