2013-04-04 14:52:39 -03:00
|
|
|
#!/bin/bash
|
2018-03-01 20:24:06 -04:00
|
|
|
echo "---------- $0 start ----------"
|
2013-04-04 14:52:39 -03:00
|
|
|
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
|
2018-05-14 23:52:03 -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 xterm"
|
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/)
|
2019-01-06 01:11:58 -04:00
|
|
|
ARM_ROOT="gcc-arm-none-eabi-6-2017-q2-update"
|
|
|
|
ARM_TARBALL="$ARM_ROOT-linux.tar.bz2"
|
2018-07-18 21:56:57 -03:00
|
|
|
ARM_TARBALL_URL="http://firmware.ardupilot.org/Tools/STM32-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
|
|
|
|
|
2019-01-25 06:40:41 -04:00
|
|
|
if ! dpkg-query -l "lsb-release"; then
|
|
|
|
$APT_GET install lsb-release
|
|
|
|
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
|
|
|
|
|
2017-11-17 14:29:47 -04:00
|
|
|
if dpkg-query -l "modemmanager"; then
|
|
|
|
$APT_GET remove modemmanager
|
|
|
|
fi
|
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
|
|
|
|
|
2018-05-15 19:35:54 -03:00
|
|
|
RP=$(apt-cache search -n '^realpath$')
|
2018-05-17 00:30:05 -03:00
|
|
|
if [ -n "$RP" ]; then
|
|
|
|
BASE_PKGS+=" realpath"
|
2018-05-14 23:52:03 -03:00
|
|
|
fi
|
|
|
|
|
2016-11-03 16:10:56 -03:00
|
|
|
$APT_GET install $BASE_PKGS $SITL_PKGS $PX4_PKGS $ARM_LINUX_PKGS
|
2019-02-10 11:14:13 -04:00
|
|
|
pip2 -q install --user -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 || {
|
2019-01-25 06:59:53 -04:00
|
|
|
if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [N/y]?" ; 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 || {
|
2019-01-25 06:59:53 -04:00
|
|
|
if maybe_prompt_user "Add $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to your PATH [N/y]?" ; 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
|
2018-07-18 21:56:57 -03:00
|
|
|
git submodule update --init --recursive
|
2015-06-09 03:51:55 -03:00
|
|
|
)
|
2018-03-01 20:24:06 -04:00
|
|
|
echo "---------- $0 end ----------"
|