Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/environment_install/install-prereqs-arch.sh
Views: 1798
#!/usr/bin/env bash1set -e2set -x34CWD=$(pwd)5OPT="/opt"67ASSUME_YES=false8QUIET=false9sep="##############################################"1011OPTIND=1 # Reset in case getopts has been used previously in the shell.12while getopts "yq" opt; do13case "$opt" in14\?)15exit 116;;17y) ASSUME_YES=true18;;19q) QUIET=true20;;21esac22done2324BASE_PKGS="base-devel ccache git gsfonts tk wget gcc"25SITL_PKGS="python-pip python-setuptools python-wheel python-wxpython opencv python-numpy python-scipy"26PX4_PKGS="lib32-glibc zip zlib ncurses"2728PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect argparse matplotlib pyparsing geocoder pyserial empy==3.3.4 dronecan packaging setuptools wheel"2930# GNU Tools for ARM Embedded Processors31# (see https://launchpad.net/gcc-arm-embedded/)32ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"33ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2"34ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL"35ARM_TARBALL_CHECKSUM="21134caa478bbf5352e239fbc6e2da3038f8d2207e089efc96c3b55f1edcd618"3637# Ardupilot Tools38ARDUPILOT_TOOLS="ardupilot/Tools/autotest"3940function maybe_prompt_user() {41if $ASSUME_YES; then42return 043else44read -p "$1"45if [[ $REPLY =~ ^[Yy]$ ]]; then46return 047else48return 149fi50fi51}5253sudo usermod -a -G uucp "$USER"5455sudo pacman -Syu --noconfirm --needed $BASE_PKGS $SITL_PKGS $PX4_PKGS5657python3 -m venv --system-site-packages "$HOME"/venv-ardupilot5859# activate it:60SOURCE_LINE="source $HOME/venv-ardupilot/bin/activate"61$SOURCE_LINE6263if [[ -z "${DO_PYTHON_VENV_ENV}" ]] && maybe_prompt_user "Make ArduPilot venv default for python [N/y]?" ; then64DO_PYTHON_VENV_ENV=165fi6667if [[ $DO_PYTHON_VENV_ENV -eq 1 ]]; then68echo "$SOURCE_LINE" >> ~/.bashrc69else70echo "Please use \`$SOURCE_LINE\` to activate the ArduPilot venv"71fi7273pip3 -q install -U $PYTHON_PKGS7475(76cd /usr/lib/ccache77if [ ! -f arm-none-eabi-g++ ]; then78sudo ln -s /usr/bin/ccache arm-none-eabi-g++79fi80if [ ! -f arm-none-eabi-g++ ]; then81sudo ln -s /usr/bin/ccache arm-none-eabi-gcc82fi83)8485if [ ! -d $OPT/$ARM_ROOT ]; then86(87cd $OPT;8889# Check if file exists and verify checksum90download_required=false91if [ -e "$ARM_TARBALL" ]; then92echo "File exists. Verifying checksum..."9394# Calculate the checksum of the existing file95ACTUAL_CHECKSUM=$(sha256sum "$ARM_TARBALL" | awk '{ print $1 }')9697# Compare the actual checksum with the expected one98if [ "$ACTUAL_CHECKSUM" == "$ARM_TARBALL_CHECKSUM" ]; then99echo "Checksum valid. No need to redownload."100else101echo "Checksum invalid. Redownloading the file..."102download_required=true103sudo rm $ARM_TARBALL104fi105else106echo "File does not exist. Downloading..."107download_required=true108fi109110if $download_required; then111sudo wget -O "$ARM_TARBALL" --progress=dot:giga $ARM_TARBALL_URL112fi113114sudo tar xjf ${ARM_TARBALL}115)116fi117118exportline="export PATH=$OPT/$ARM_ROOT/bin:\$PATH";119if ! grep -Fxq "$exportline" ~/.bashrc ; then120if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [N/y]?" ; then121echo "$exportline" >> ~/.bashrc122. "$HOME/.bashrc"123else124echo "Skipping adding $OPT/$ARM_ROOT/bin to PATH."125fi126fi127128exportline2="export PATH=$CWD/$ARDUPILOT_TOOLS:\$PATH";129if ! grep -Fxq "$exportline2" ~/.bashrc ; then130if maybe_prompt_user "Add $CWD/$ARDUPILOT_TOOLS to your PATH [N/y]?" ; then131echo "$exportline2" >> ~/.bashrc132. "$HOME/.bashrc"133else134echo "Skipping adding $CWD/$ARDUPILOT_TOOLS to PATH."135fi136fi137138SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))139(140cd "$SCRIPT_DIR"141git submodule update --init --recursive142)143144echo "Done. Please log out and log in again."145146147