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-openSUSE-Tumbleweed.sh
Views: 1798
#!/usr/bin/env bash1echo "---------- $0 start ----------"2set -e3set -x4set +H56if [ $EUID == 0 ]; then7echo "Please do not run this script as root; don't sudo it!"8exit 19fi101112OPT="/opt"13# Ardupilot Tools14ARDUPILOT_TOOLS="Tools/autotest"1516ASSUME_YES=false17QUIET=false18sep="##############################################"1920OPTIND=1 # Reset in case getopts has been used previously in the shell.21while getopts "yq" opt; do22case "$opt" in23\?)24exit 125;;26y) ASSUME_YES=true27;;28q) QUIET=true29;;30esac31done3233ZYPPER="sudo zypper in --no-recommends"34if $ASSUME_YES; then35ZYPPER="sudo zypper in -y --no-recommends"36fi37PIP3=pip338if $QUIET; then39PIP3="pip3 -q"40fi4142function package_is_installed() {43rpm -q $1 &>/dev/null44}4546function heading() {47echo "$sep"48echo $*49echo "$sep"50}5152#Install python3 1st, as openSUSE TW WSL does not come with preinstalled python53$ZYPPER python3 || echo "Check zypper output for errors"5455#As tumbleweed can have many python versions, we need to know which one is currently active56PYPKGVER=python$(python3 --version | cut -d' ' -f2 | awk -F. '{print $1$2}')5758BASE_PKGS="patterns-devel-base-devel_basis ccache git axel valgrind screen gcc-c++ xterm free-ttf-fonts sfml2-devel zip glibc-devel-static rsync"59SITL_PKGS="${PYPKGVER}-pip ${PYPKGVER}-devel ${PYPKGVER}-setuptools ${PYPKGVER}-wheel ${PYPKGVER}-lxml ${PYPKGVER}-pyaml ${PYPKGVER}-wxPython ${PYPKGVER}-pyparsing ${PYPKGVER}-opencv ${PYPKGVER}-numpy ${PYPKGVER}-scipy ${PYPKGVER}-matplotlib"6061PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect argparse pyparsing geocoder pyserial empy==3.3.4 ptyprocess dronecan"62PYTHON_PKGS+=" flake8 junitparser pygame intelhex psutil pyyaml"63# GNU Tools for ARM Embedded Processors64# (see https://launchpad.net/gcc-arm-embedded/)65ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"66ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2"67ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL"6869ARM_LINUX_ROOT=gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf70ARM_LINUX_GCC_URL="https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz"71ARM_LINUX_TARBALL="gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz"7273function maybe_prompt_user() {74if $ASSUME_YES; then75return 076else77read -p "$1"78if [[ $REPLY =~ ^[Yy]$ ]]; then79return 080else81return 182fi83fi84}8586sudo usermod -a -G dialout "$USER"8788$ZYPPER $BASE_PKGS $SITL_PKGS || echo "Check zypper output for errors"8990python3 -m venv "$HOME"/venv-ardupilot9192SHELL_LOGIN=".profile"93# activate it:94SOURCE_LINE="source $HOME/venv-ardupilot/bin/activate"95$SOURCE_LINE9697if ! grep -Fxq "$SOURCE_LINE" ~/.bashrc; then98if [[ -z "${DO_PYTHON_VENV_ENV}" ]] && maybe_prompt_user "Make ArduPilot venv default for python [N/y]?" ; then99DO_PYTHON_VENV_ENV=1100fi101102if [[ $DO_PYTHON_VENV_ENV -eq 1 ]]; then103echo $SOURCE_LINE >> ~/.bashrc104else105echo "Please use \`$SOURCE_LINE\` to activate the ArduPilot venv"106fi107fi108109$PIP3 install -U pip packaging setuptools wheel110$PIP3 install -U attrdict3111$PIP3 install -U $PYTHON_PKGS112113(114cd /usr/lib64/ccache115for C in arm-none-eabi-g++ arm-none-eabi-gcc arm-linux-gnueabihf-g++ arm-linux-gnueabihf-gcc; do116if [ ! -f "$C" ]; then117sudo ln -s ../../bin/ccache "$C"118fi119done120)121122ccache --set-config sloppiness=file_macro,locale,time_macros123ccache --set-config ignore_options="--specs=nano.specs --specs=nosys.specs"124125if [ ! -d $OPT/$ARM_ROOT ]; then126(127cd $OPT;128sudo axel -a -c $ARM_TARBALL_URL;129sudo tar xjf ${ARM_TARBALL};130sudo rm ${ARM_TARBALL};131)132fi133134if [ ! -d $OPT/$ARM_LINUX_ROOT ]; then135(136cd $OPT;137sudo axel -a -c "${ARM_LINUX_GCC_URL}";138sudo tar xf ${ARM_LINUX_TARBALL};139sudo rm ${ARM_LINUX_TARBALL};140)141fi142143heading "Removing modemmanager and brltty package that could conflict with firmware uploading"144if package_is_installed "ModemManager"; then145sudo zypper rm ModemManager146fi147if package_is_installed "brltty"; then148sudo zypper rm brltty149fi150echo "Done!"151152heading "Adding ArduPilot Tools to environment"153154SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))155ARDUPILOT_ROOT=$(realpath "$SCRIPT_DIR/../../")156157158exportline="export PATH=$OPT/$ARM_ROOT/bin:\$PATH";159if ! grep -Fxq "$exportline" ~/$SHELL_LOGIN ; then160if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [N/y]?" ; then161echo $exportline >> ~/$SHELL_LOGIN162else163echo "Skipping adding $OPT/$ARM_ROOT/bin to PATH."164fi165fi166167exportline1="export PATH=$OPT/$ARM_LINUX_ROOT/bin:\$PATH";168if ! grep -Fxq "$exportline1" ~/$SHELL_LOGIN ; then169if maybe_prompt_user "Add $OPT/$ARM_LINUX_ROOT/bin to your PATH [N/y]?" ; then170echo $exportline1 >> ~/$SHELL_LOGIN171else172echo "Skipping adding $OPT/$ARM_LINUX_ROOT/bin to PATH."173fi174fi175176exportline2="export PATH=$ARDUPILOT_ROOT/$ARDUPILOT_TOOLS:\$PATH";177if ! grep -Fxq "$exportline2" ~/$SHELL_LOGIN ; then178if maybe_prompt_user "Add $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to your PATH [N/y]?" ; then179echo $exportline2 >> ~/$SHELL_LOGIN180else181echo "Skipping adding $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to PATH."182fi183fi184185exportline3="source $ARDUPILOT_ROOT/Tools/completion/completion.bash";186if ! grep -Fxq "$exportline3" ~/.bashrc ; then187if maybe_prompt_user "Add ArduPilot Bash Completion to your bash shell [N/y]?" ; then188echo $exportline3 >> ~/.bashrc189else190echo "Skipping adding ArduPilot Bash Completion."191fi192fi193194exportline4="export PATH=/usr/lib64/ccache:\$PATH";195if ! grep -Fxq "$exportline4" ~/$SHELL_LOGIN ; then196if maybe_prompt_user "Append CCache to your PATH [N/y]?" ; then197echo $exportline4 >> ~/$SHELL_LOGIN198else199echo "Skipping appending CCache to PATH."200fi201fi202echo "Done!"203204if [[ $SKIP_AP_GIT_CHECK -ne 1 ]]; then205cd "$ARDUPILOT_ROOT"206if [ -d ".git" ]; then207heading "Update git submodules"208cd $ARDUPILOT_ROOT209git submodule update --init --recursive210echo "Done!"211fi212fi213214echo "---------- $0 end ----------"215echo "Done. Please log out and log in again."216217218