ardupilot/Tools/scripts/install-prereqs-ubuntu.sh

115 lines
3.0 KiB
Bash
Raw Normal View History

#!/bin/bash
set -e
OPT="/opt"
2016-10-13 13:49:39 -03:00
BASE_PKGS="build-essential ccache g++ gawk git make wget"
PYTHON_PKGS="future lxml pymavlink MAVProxy"
PX4_PKGS="python-argparse openocd flex bison libncurses5-dev \
autoconf texinfo libftdi-dev zlib1g-dev \
zip genromfs python-empy libc6-i386"
BEBOP_PKGS="g++-arm-linux-gnueabihf"
2016-10-13 13:49:39 -03:00
SITL_PKGS="libtool python-pip python-setuptools python-matplotlib python-serial python-scipy python-opencv python-numpy python-pyparsing realpath"
ASSUME_YES=false
2016-10-13 13:49:39 -03:00
UBUNTU_YEAR="15" # Ubuntu Year were changes append
UBUNTU_MONTH="10" # Ubuntu Month were changes append
2016-10-13 13:49:39 -03:00
version=$(lsb_release -r -s)
yrelease=$(echo "$version" | cut -d. -f1)
mrelease=$(echo "$version" | cut -d. -f2)
if [ "$yrelease" -ge "$UBUNTU_YEAR" ]; then
if [ "$yrelease" -gt "$UBUNTU_YEAR" ] || [ "$mrelease" -ge "$UBUNTU_MONTH" ]; then
SITL_PKGS+=" python-wxgtk3.0 libtool-bin"
else
SITL_PKGS+=" python-wxgtk2.8"
fi
fi
# GNU Tools for ARM Embedded Processors
# (see https://launchpad.net/gcc-arm-embedded/)
ARM_ROOT="gcc-arm-none-eabi-4_9-2015q3"
ARM_TARBALL="$ARM_ROOT-20150921-linux.tar.bz2"
ARM_TARBALL_URL="http://firmware.ardupilot.org/Tools/PX4-tools/$ARM_TARBALL"
# Ardupilot Tools
ARDUPILOT_TOOLS="Tools/autotest"
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
}
OPTIND=1 # Reset in case getopts has been used previously in the shell.
while getopts "y" opt; do
case "$opt" in
\?)
exit 1
;;
y) ASSUME_YES=true
;;
esac
done
if $ASSUME_YES; then
APT_GET="sudo apt-get -qq --assume-yes"
else
APT_GET="sudo apt-get"
fi
sudo usermod -a -G dialout $USER
$APT_GET remove modemmanager
$APT_GET update
$APT_GET install $BASE_PKGS $SITL_PKGS $PX4_PKGS $BEBOP_PKGS
2016-10-13 13:49:39 -03:00
sudo pip2 -q install -U $PYTHON_PKGS
if [ ! -d $OPT/$ARM_ROOT ]; then
(
cd $OPT;
sudo wget $ARM_TARBALL_URL;
sudo tar xjf ${ARM_TARBALL};
sudo rm ${ARM_TARBALL};
)
fi
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
ARDUPILOT_ROOT=$(realpath "$SCRIPT_DIR/../../")
exportline="export PATH=$OPT/$ARM_ROOT/bin:\$PATH";
grep -Fxq "$exportline" ~/.profile 2>/dev/null || {
if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [Y/n]?" ; then
echo $exportline >> ~/.profile
eval $exportline
else
echo "Skipping adding $OPT/$ARM_ROOT/bin to PATH."
fi
}
exportline2="export PATH=$ARDUPILOT_ROOT/$ARDUPILOT_TOOLS:\$PATH";
grep -Fxq "$exportline2" ~/.profile 2>/dev/null || {
if maybe_prompt_user "Add $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to your PATH [Y/n]?" ; then
echo $exportline2 >> ~/.profile
eval $exportline2
else
echo "Skipping adding $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to PATH."
fi
}
2015-04-05 16:38:08 -03:00
apt-cache search arm-none-eabi
2015-06-09 03:51:55 -03:00
(
cd $ARDUPILOT_ROOT
2015-06-09 03:51:55 -03:00
git submodule init
git submodule update
)