2023-12-04 05:55:08 -04:00
|
|
|
#!/usr/bin/env bash
|
2015-07-31 13:54:12 -03:00
|
|
|
set -e
|
2016-11-03 08:09:41 -03:00
|
|
|
set -x
|
2015-07-31 13:54:12 -03:00
|
|
|
|
|
|
|
CWD=$(pwd)
|
|
|
|
OPT="/opt"
|
|
|
|
|
2021-10-05 05:53:39 -03:00
|
|
|
ASSUME_YES=false
|
|
|
|
QUIET=false
|
|
|
|
sep="##############################################"
|
|
|
|
|
|
|
|
OPTIND=1 # Reset in case getopts has been used previously in the shell.
|
|
|
|
while getopts "yq" opt; do
|
|
|
|
case "$opt" in
|
|
|
|
\?)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
y) ASSUME_YES=true
|
|
|
|
;;
|
|
|
|
q) QUIET=true
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
BASE_PKGS="base-devel ccache git gsfonts tk wget gcc"
|
2022-05-16 07:27:07 -03:00
|
|
|
SITL_PKGS="python-pip python-setuptools python-wheel python-wxpython opencv python-numpy python-scipy"
|
2021-01-03 17:48:19 -04:00
|
|
|
PX4_PKGS="lib32-glibc zip zlib ncurses"
|
2015-07-31 13:54:12 -03:00
|
|
|
|
2024-07-22 09:08:12 -03:00
|
|
|
PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect argparse matplotlib pyparsing geocoder pyserial empy==3.3.4 dronecan packaging setuptools wheel"
|
2015-07-31 13:54:12 -03:00
|
|
|
|
|
|
|
# GNU Tools for ARM Embedded Processors
|
|
|
|
# (see https://launchpad.net/gcc-arm-embedded/)
|
2021-07-25 19:06:40 -03:00
|
|
|
ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"
|
|
|
|
ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2"
|
2019-12-07 16:44:14 -04:00
|
|
|
ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL"
|
2024-11-07 12:43:56 -04:00
|
|
|
ARM_TARBALL_CHECKSUM="21134caa478bbf5352e239fbc6e2da3038f8d2207e089efc96c3b55f1edcd618"
|
2015-07-31 13:54:12 -03:00
|
|
|
|
|
|
|
# Ardupilot Tools
|
|
|
|
ARDUPILOT_TOOLS="ardupilot/Tools/autotest"
|
|
|
|
|
2021-10-05 05:53:39 -03:00
|
|
|
function maybe_prompt_user() {
|
|
|
|
if $ASSUME_YES; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
read -p "$1"
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
2015-07-31 13:54:12 -03:00
|
|
|
}
|
|
|
|
|
2023-08-07 06:33:05 -03:00
|
|
|
sudo usermod -a -G uucp "$USER"
|
2015-07-31 13:54:12 -03:00
|
|
|
|
2023-09-05 11:04:00 -03:00
|
|
|
sudo pacman -Syu --noconfirm --needed $BASE_PKGS $SITL_PKGS $PX4_PKGS
|
2023-08-07 06:33:05 -03:00
|
|
|
|
2024-09-07 16:56:26 -03:00
|
|
|
python3 -m venv --system-site-packages "$HOME"/venv-ardupilot
|
2023-08-07 06:33:05 -03:00
|
|
|
|
|
|
|
# activate it:
|
|
|
|
SOURCE_LINE="source $HOME/venv-ardupilot/bin/activate"
|
|
|
|
$SOURCE_LINE
|
|
|
|
|
|
|
|
if [[ -z "${DO_PYTHON_VENV_ENV}" ]] && maybe_prompt_user "Make ArduPilot venv default for python [N/y]?" ; then
|
|
|
|
DO_PYTHON_VENV_ENV=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $DO_PYTHON_VENV_ENV -eq 1 ]]; then
|
|
|
|
echo "$SOURCE_LINE" >> ~/.bashrc
|
2024-09-11 05:39:24 -03:00
|
|
|
else
|
|
|
|
echo "Please use \`$SOURCE_LINE\` to activate the ArduPilot venv"
|
2023-08-07 06:33:05 -03:00
|
|
|
fi
|
|
|
|
|
|
|
|
pip3 -q install -U $PYTHON_PKGS
|
2015-07-31 13:54:12 -03:00
|
|
|
|
2015-08-12 00:15:48 -03:00
|
|
|
(
|
2018-02-05 19:59:27 -04:00
|
|
|
cd /usr/lib/ccache
|
|
|
|
if [ ! -f arm-none-eabi-g++ ]; then
|
|
|
|
sudo ln -s /usr/bin/ccache arm-none-eabi-g++
|
|
|
|
fi
|
|
|
|
if [ ! -f arm-none-eabi-g++ ]; then
|
|
|
|
sudo ln -s /usr/bin/ccache arm-none-eabi-gcc
|
|
|
|
fi
|
2015-08-12 00:15:48 -03:00
|
|
|
)
|
|
|
|
|
2015-07-31 13:54:12 -03:00
|
|
|
if [ ! -d $OPT/$ARM_ROOT ]; then
|
|
|
|
(
|
|
|
|
cd $OPT;
|
2024-11-07 12:43:56 -04:00
|
|
|
|
|
|
|
# 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}
|
2015-07-31 13:54:12 -03:00
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
|
|
|
exportline="export PATH=$OPT/$ARM_ROOT/bin:\$PATH";
|
|
|
|
if ! grep -Fxq "$exportline" ~/.bashrc ; then
|
2021-10-05 05:53:39 -03:00
|
|
|
if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [N/y]?" ; then
|
2015-07-31 13:54:12 -03:00
|
|
|
echo "$exportline" >> ~/.bashrc
|
2023-08-07 06:33:05 -03:00
|
|
|
. "$HOME/.bashrc"
|
2015-07-31 13:54:12 -03:00
|
|
|
else
|
|
|
|
echo "Skipping adding $OPT/$ARM_ROOT/bin to PATH."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
exportline2="export PATH=$CWD/$ARDUPILOT_TOOLS:\$PATH";
|
|
|
|
if ! grep -Fxq "$exportline2" ~/.bashrc ; then
|
2021-10-05 05:53:39 -03:00
|
|
|
if maybe_prompt_user "Add $CWD/$ARDUPILOT_TOOLS to your PATH [N/y]?" ; then
|
2015-07-31 13:54:12 -03:00
|
|
|
echo "$exportline2" >> ~/.bashrc
|
2023-08-07 06:33:05 -03:00
|
|
|
. "$HOME/.bashrc"
|
2015-07-31 13:54:12 -03:00
|
|
|
else
|
|
|
|
echo "Skipping adding $CWD/$ARDUPILOT_TOOLS to PATH."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2018-02-06 14:28:40 -04:00
|
|
|
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
|
2015-07-31 13:54:12 -03:00
|
|
|
(
|
2023-08-07 06:33:05 -03:00
|
|
|
cd "$SCRIPT_DIR"
|
2018-07-18 21:56:57 -03:00
|
|
|
git submodule update --init --recursive
|
2015-07-31 13:54:12 -03:00
|
|
|
)
|
|
|
|
|
|
|
|
echo "Done. Please log out and log in again."
|