2013-04-04 14:52:39 -03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2016-11-03 08:09:41 -03:00
|
|
|
set -x
|
2013-04-04 14:52:39 -03:00
|
|
|
|
2014-07-06 02:40:39 -03:00
|
|
|
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 \
|
2016-11-21 10:55:26 -04:00
|
|
|
zip genromfs python-empy cmake cmake-data"
|
2016-11-03 16:12:40 -03:00
|
|
|
ARM_LINUX_PKGS="g++-arm-linux-gnueabihf pkg-config-arm-linux-gnueabihf"
|
2018-03-31 10:23:51 -03:00
|
|
|
# python-wxgtk packages are added to SITL_PKGS below
|
2016-10-16 06:30:32 -03:00
|
|
|
SITL_PKGS="libtool libxml2-dev libxslt1-dev python-dev python-pip python-setuptools python-matplotlib python-serial python-scipy python-opencv python-numpy python-pyparsing realpath"
|
2013-04-04 14:52:39 -03:00
|
|
|
ASSUME_YES=false
|
2018-02-05 22:23:00 -04:00
|
|
|
QUIET=false
|
2013-04-04 14:52:39 -03:00
|
|
|
|
2016-11-21 10:55:26 -04:00
|
|
|
MACHINE_TYPE=$(uname -m)
|
|
|
|
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
|
|
|
|
PX4_PKGS+=" libc6-i386"
|
|
|
|
else
|
2016-11-26 15:27:15 -04:00
|
|
|
echo "no extra pkgs for i386"
|
2016-11-21 10:55:26 -04:00
|
|
|
fi
|
|
|
|
|
2014-02-02 19:41:14 -04:00
|
|
|
# GNU Tools for ARM Embedded Processors
|
|
|
|
# (see https://launchpad.net/gcc-arm-embedded/)
|
2015-10-20 01:28:13 -03:00
|
|
|
ARM_ROOT="gcc-arm-none-eabi-4_9-2015q3"
|
2015-10-20 01:54:44 -03:00
|
|
|
ARM_TARBALL="$ARM_ROOT-20150921-linux.tar.bz2"
|
2016-03-25 02:46:11 -03:00
|
|
|
ARM_TARBALL_URL="http://firmware.ardupilot.org/Tools/PX4-tools/$ARM_TARBALL"
|
2014-02-02 19:41:14 -04:00
|
|
|
|
2014-07-05 20:27:15 -03:00
|
|
|
# Ardupilot Tools
|
2016-04-18 23:19:22 -03:00
|
|
|
ARDUPILOT_TOOLS="Tools/autotest"
|
2014-07-05 20:27:15 -03:00
|
|
|
|
2013-04-04 14:52: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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
;;
|
2018-02-05 22:23:00 -04:00
|
|
|
q) QUIET=true
|
|
|
|
;;
|
2013-04-04 14:52:39 -03:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2018-02-05 22:23:00 -04:00
|
|
|
APT_GET="sudo apt-get"
|
2013-04-04 14:52:39 -03:00
|
|
|
if $ASSUME_YES; then
|
2018-02-05 22:23:00 -04:00
|
|
|
APT_GET="$APT_GET --assume-yes"
|
|
|
|
fi
|
|
|
|
if $QUIET; then
|
|
|
|
APT_GET="$APT_GET -qq"
|
2013-04-04 14:52:39 -03:00
|
|
|
fi
|
|
|
|
|
2016-10-20 02:29:51 -03:00
|
|
|
# possibly grab a newer cmake for older ubuntu releases
|
|
|
|
read -r UBUNTU_CODENAME <<<$(lsb_release -c -s)
|
|
|
|
if [ "$UBUNTU_CODENAME" = "precise" ]; then
|
|
|
|
sudo add-apt-repository ppa:george-edison55/precise-backports -y
|
|
|
|
elif [ "$UBUNTU_CODENAME" = "trusty" ]; then
|
|
|
|
sudo add-apt-repository ppa:george-edison55/cmake-3.x -y
|
|
|
|
fi
|
|
|
|
|
2014-07-05 20:27:15 -03:00
|
|
|
sudo usermod -a -G dialout $USER
|
|
|
|
|
|
|
|
$APT_GET remove modemmanager
|
2013-04-04 14:52:39 -03:00
|
|
|
$APT_GET update
|
2018-03-31 10:23:51 -03:00
|
|
|
|
|
|
|
if apt-cache search python-wxgtk3.0 | grep wx; then
|
|
|
|
SITL_PKGS+=" python-wxgtk3.0 libtool-bin"
|
|
|
|
else
|
|
|
|
# we only support back to trusty:
|
|
|
|
SITL_PKGS+=" python-wxgtk2.8"
|
|
|
|
fi
|
|
|
|
|
2016-11-03 16:10:56 -03:00
|
|
|
$APT_GET install $BASE_PKGS $SITL_PKGS $PX4_PKGS $ARM_LINUX_PKGS
|
2016-10-13 13:49:39 -03:00
|
|
|
sudo pip2 -q install -U $PYTHON_PKGS
|
2014-07-05 20:27:15 -03:00
|
|
|
|
2014-07-06 02:40:39 -03:00
|
|
|
if [ ! -d $OPT/$ARM_ROOT ]; then
|
2013-04-04 14:52:39 -03:00
|
|
|
(
|
2014-07-06 02:40:39 -03:00
|
|
|
cd $OPT;
|
|
|
|
sudo wget $ARM_TARBALL_URL;
|
|
|
|
sudo tar xjf ${ARM_TARBALL};
|
|
|
|
sudo rm ${ARM_TARBALL};
|
2013-04-04 14:52:39 -03:00
|
|
|
)
|
|
|
|
fi
|
2014-07-05 20:27:15 -03:00
|
|
|
|
2016-04-18 23:19:22 -03:00
|
|
|
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
|
|
|
|
ARDUPILOT_ROOT=$(realpath "$SCRIPT_DIR/../../")
|
|
|
|
|
2014-07-06 02:40:39 -03:00
|
|
|
exportline="export PATH=$OPT/$ARM_ROOT/bin:\$PATH";
|
2016-04-18 23:09:31 -03:00
|
|
|
grep -Fxq "$exportline" ~/.profile 2>/dev/null || {
|
2014-07-06 02:40:39 -03:00
|
|
|
if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [Y/n]?" ; then
|
2013-04-04 14:52:39 -03:00
|
|
|
echo $exportline >> ~/.profile
|
2016-04-18 23:33:24 -03:00
|
|
|
eval $exportline
|
2013-04-04 14:52:39 -03:00
|
|
|
else
|
2014-07-06 02:40:39 -03:00
|
|
|
echo "Skipping adding $OPT/$ARM_ROOT/bin to PATH."
|
2013-04-04 14:52:39 -03:00
|
|
|
fi
|
2016-04-18 23:09:31 -03:00
|
|
|
}
|
2014-07-05 20:27:15 -03:00
|
|
|
|
2016-04-18 23:19:22 -03:00
|
|
|
exportline2="export PATH=$ARDUPILOT_ROOT/$ARDUPILOT_TOOLS:\$PATH";
|
2016-04-18 23:09:31 -03:00
|
|
|
grep -Fxq "$exportline2" ~/.profile 2>/dev/null || {
|
2016-04-18 23:19:22 -03:00
|
|
|
if maybe_prompt_user "Add $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to your PATH [Y/n]?" ; then
|
2014-07-05 20:27:15 -03:00
|
|
|
echo $exportline2 >> ~/.profile
|
2016-04-18 23:33:24 -03:00
|
|
|
eval $exportline2
|
2014-07-05 20:27:15 -03:00
|
|
|
else
|
2016-04-18 23:19:22 -03:00
|
|
|
echo "Skipping adding $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to PATH."
|
2014-07-05 20:27:15 -03:00
|
|
|
fi
|
2016-04-18 23:09:31 -03:00
|
|
|
}
|
2014-07-05 20:27:15 -03:00
|
|
|
|
2015-04-05 16:38:08 -03:00
|
|
|
apt-cache search arm-none-eabi
|
2015-06-09 03:51:55 -03:00
|
|
|
|
|
|
|
(
|
2016-04-18 23:19:22 -03:00
|
|
|
cd $ARDUPILOT_ROOT
|
2015-06-09 03:51:55 -03:00
|
|
|
git submodule init
|
|
|
|
git submodule update
|
|
|
|
)
|