CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/environment_install/install-prereqs-ubuntu.sh
Views: 1798
1
#!/usr/bin/env bash
2
echo "---------- $0 start ----------"
3
set -e
4
set -x
5
6
if [ $EUID == 0 ]; then
7
echo "Please do not run this script as root; don't sudo it!"
8
exit 1
9
fi
10
11
OPT="/opt"
12
# Ardupilot Tools
13
ARDUPILOT_TOOLS="Tools/autotest"
14
15
ASSUME_YES=false
16
QUIET=false
17
sep="##############################################"
18
19
OPTIND=1 # Reset in case getopts has been used previously in the shell.
20
while getopts "yq" opt; do
21
case "$opt" in
22
\?)
23
exit 1
24
;;
25
y) ASSUME_YES=true
26
;;
27
q) QUIET=true
28
;;
29
esac
30
done
31
32
APT_GET="sudo apt-get"
33
if $ASSUME_YES; then
34
APT_GET="$APT_GET --assume-yes"
35
fi
36
if $QUIET; then
37
APT_GET="$APT_GET -qq"
38
fi
39
40
# update apt package list
41
$APT_GET update
42
43
function package_is_installed() {
44
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
45
}
46
47
function heading() {
48
echo "$sep"
49
echo $*
50
echo "$sep"
51
}
52
53
# Install lsb-release as it is needed to check Ubuntu version
54
if ! package_is_installed "lsb-release"; then
55
heading "Installing lsb-release"
56
$APT_GET install lsb-release
57
echo "Done!"
58
fi
59
60
# Checking Ubuntu release to adapt software version to install
61
RELEASE_CODENAME=$(lsb_release -c -s)
62
63
# translate Mint-codenames to Ubuntu-codenames based on https://www.linuxmint.com/download_all.php
64
case ${RELEASE_CODENAME} in
65
wilma)
66
RELEASE_CODENAME='noble'
67
;;
68
vanessa)
69
RELEASE_CODENAME='jammy'
70
;;
71
una | uma | ulyssa | ulyana | jolnir)
72
RELEASE_CODENAME='focal'
73
;;
74
tricia | tina | tessa | tara)
75
RELEASE_CODENAME='bionic'
76
;;
77
elsie)
78
RELEASE_CODENAME='bullseye'
79
;;
80
esac
81
82
PYTHON_V="python3" # starting from ubuntu 20.04, python isn't symlink to default python interpreter
83
PIP=pip3
84
85
if [ ${RELEASE_CODENAME} == 'bionic' ] ; then
86
echo "ArduPilot no longer supports developing on this operating system that has reached end of standard support."
87
exit 1
88
elif [ ${RELEASE_CODENAME} == 'bookworm' ]; then
89
SITLFML_VERSION="2.5"
90
SITLCFML_VERSION="2.5"
91
PYTHON_V="python3"
92
PIP=pip3
93
elif [ ${RELEASE_CODENAME} == 'buster' ]; then
94
SITLFML_VERSION="2.5"
95
SITLCFML_VERSION="2.5"
96
PYTHON_V="python3"
97
PIP=pip3
98
elif [ ${RELEASE_CODENAME} == 'focal' ]; then
99
SITLFML_VERSION="2.5"
100
SITLCFML_VERSION="2.5"
101
PYTHON_V="python3"
102
PIP=pip3
103
elif [ ${RELEASE_CODENAME} == 'jammy' ]; then
104
SITLFML_VERSION="2.5"
105
SITLCFML_VERSION="2.5"
106
PYTHON_V="python3"
107
PIP=pip3
108
elif [ ${RELEASE_CODENAME} == 'lunar' ]; then
109
SITLFML_VERSION="2.5"
110
SITLCFML_VERSION="2.5"
111
PYTHON_V="python3"
112
PIP=pip3
113
elif [ ${RELEASE_CODENAME} == 'mantic' ]; then
114
SITLFML_VERSION="2.5"
115
SITLCFML_VERSION="2.5"
116
PYTHON_V="python3"
117
PIP=pip3
118
elif [ ${RELEASE_CODENAME} == 'noble' ]; then
119
SITLFML_VERSION="2.6"
120
SITLCFML_VERSION="2.6"
121
PYTHON_V="python3"
122
PIP=pip3
123
elif [ ${RELEASE_CODENAME} == 'oracular' ]; then
124
SITLFML_VERSION="2.6"
125
SITLCFML_VERSION="2.6"
126
PYTHON_V="python3"
127
PIP=pip3
128
elif [ ${RELEASE_CODENAME} == 'groovy' ] ||
129
[ ${RELEASE_CODENAME} == 'bullseye' ]; then
130
SITLFML_VERSION="2.5"
131
SITLCFML_VERSION="2.5"
132
PYTHON_V="python3"
133
PIP=pip3
134
else
135
# We assume APT based system, so let's try with apt-cache first.
136
SITLCFML_VERSION=$(apt-cache search -n '^libcsfml-audio' | cut -d" " -f1 | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?')
137
SITLFML_VERSION=$(apt-cache search -n '^libsfml-audio' | cut -d" " -f1 | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?')
138
# If we cannot retrieve the number with apt-cache, try a last time with dpkg-query
139
re='^[+-]?[0-9]+([.][0-9]+)?$'
140
if ! [[ $SITLCFML_VERSION =~ $re ]] || ! [[ $SITLFML_VERSION =~ $re ]] ; then
141
# Extract the floating point number that is the version of the libcsfml package.
142
SITLCFML_VERSION=$(dpkg-query --search libcsfml-audio | cut -d":" -f1 | grep libcsfml-audio | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?')
143
# And same for libsfml-audio.
144
SITLFML_VERSION=$(dpkg-query --search libsfml-audio | cut -d":" -f1 | grep libsfml-audio | head -1 | grep -Eo '[+-]?[0-9]+([.][0-9]+)?')
145
fi
146
fi
147
148
# Check whether the specific ARM pkg-config package is available or whether we should emulate the effect of installing it.
149
# Check if we need to manually install libtool-bin
150
ARM_PKG_CONFIG_NOT_PRESENT=0
151
if [ -z "$(apt-cache search -n '^pkg-config-arm-linux-gnueabihf')" ]; then
152
ARM_PKG_CONFIG_NOT_PRESENT=$(dpkg-query --search pkg-config-arm-linux-gnueabihf |& grep -c "dpkg-query:")
153
fi
154
if [ "$ARM_PKG_CONFIG_NOT_PRESENT" -eq 1 ]; then
155
INSTALL_PKG_CONFIG=""
156
# No need to install Ubuntu's pkg-config-arm-linux-gnueabihf, instead install the base pkg-config.
157
$APT_GET install pkg-config
158
if [ -f /usr/share/pkg-config-crosswrapper ]; then
159
# We are on non-Ubuntu so simulate effect of installing pkg-config-arm-linux-gnueabihf.
160
sudo ln -sf /usr/share/pkg-config-crosswrapper /usr/bin/arm-linux-gnueabihf-pkg-config
161
else
162
echo "Warning: unable to link to pkg-config-crosswrapper"
163
fi
164
else
165
# Package is available so install it later.
166
INSTALL_PKG_CONFIG="pkg-config-arm-linux-gnueabihf"
167
fi
168
169
# Lists of packages to install
170
BASE_PKGS="build-essential ccache g++ gawk git make wget valgrind screen python3-pexpect astyle"
171
PYTHON_PKGS="future lxml pymavlink pyserial MAVProxy geocoder empy==3.3.4 ptyprocess dronecan"
172
PYTHON_PKGS="$PYTHON_PKGS flake8 junitparser wsproto tabulate"
173
174
# add some Python packages required for commonly-used MAVProxy modules and hex file generation:
175
if [[ $SKIP_AP_EXT_ENV -ne 1 ]]; then
176
PYTHON_PKGS="$PYTHON_PKGS pygame intelhex"
177
fi
178
ARM_LINUX_PKGS="g++-arm-linux-gnueabihf $INSTALL_PKG_CONFIG"
179
# python-wxgtk packages are added to SITL_PKGS below
180
181
if [ ${RELEASE_CODENAME} == 'bookworm' ] ||
182
[ ${RELEASE_CODENAME} == 'lunar' ] ||
183
[ ${RELEASE_CODENAME} == 'mantic' ] ||
184
[ ${RELEASE_CODENAME} == 'noble' ] ||
185
[ ${RELEASE_CODENAME} == 'oracular' ]; then
186
# on Lunar (and presumably later releases), we install in venv, below
187
PYTHON_PKGS+=" numpy pyparsing psutil"
188
SITL_PKGS="python3-dev"
189
else
190
SITL_PKGS="libtool libxml2-dev libxslt1-dev ${PYTHON_V}-dev ${PYTHON_V}-pip ${PYTHON_V}-setuptools ${PYTHON_V}-numpy ${PYTHON_V}-pyparsing ${PYTHON_V}-psutil"
191
fi
192
193
# add some packages required for commonly-used MAVProxy modules:
194
if [[ $SKIP_AP_GRAPHIC_ENV -ne 1 ]]; then
195
if [ ${RELEASE_CODENAME} == 'bookworm' ] ||
196
[ ${RELEASE_CODENAME} == 'lunar' ] ||
197
[ ${RELEASE_CODENAME} == 'mantic' ] ||
198
[ ${RELEASE_CODENAME} == 'noble' ] ||
199
[ ${RELEASE_CODENAME} == 'oracular' ]; then
200
PYTHON_PKGS+=" matplotlib scipy opencv-python pyyaml"
201
SITL_PKGS+=" xterm xfonts-base libcsfml-dev libcsfml-audio${SITLCFML_VERSION} libcsfml-dev libcsfml-graphics${SITLCFML_VERSION} libcsfml-network${SITLCFML_VERSION} libcsfml-system${SITLCFML_VERSION} libcsfml-window${SITLCFML_VERSION} libsfml-audio${SITLFML_VERSION} libsfml-dev libsfml-graphics${SITLFML_VERSION} libsfml-network${SITLFML_VERSION} libsfml-system${SITLFML_VERSION} libsfml-window${SITLFML_VERSION}"
202
else
203
SITL_PKGS="$SITL_PKGS xterm xfonts-base ${PYTHON_V}-matplotlib ${PYTHON_V}-serial ${PYTHON_V}-scipy ${PYTHON_V}-opencv libcsfml-dev libcsfml-audio${SITLCFML_VERSION} libcsfml-dev libcsfml-graphics${SITLCFML_VERSION} libcsfml-network${SITLCFML_VERSION} libcsfml-system${SITLCFML_VERSION} libcsfml-window${SITLCFML_VERSION} libsfml-audio${SITLFML_VERSION} libsfml-dev libsfml-graphics${SITLFML_VERSION} libsfml-network${SITLFML_VERSION} libsfml-system${SITLFML_VERSION} libsfml-window${SITLFML_VERSION} ${PYTHON_V}-yaml"
204
fi
205
fi
206
if [[ $SKIP_AP_COV_ENV -ne 1 ]]; then
207
# Coverage utilities
208
COVERAGE_PKGS="lcov gcovr"
209
fi
210
211
# ArduPilot official Toolchain for STM32 boards
212
function install_arm_none_eabi_toolchain() {
213
# GNU Tools for ARM Embedded Processors
214
# (see https://launchpad.net/gcc-arm-embedded/)
215
ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"
216
case $(uname -m) in
217
x86_64)
218
if [ ! -d $OPT/$ARM_ROOT ]; then
219
(
220
cd $OPT
221
heading "Installing toolchain for STM32 Boards"
222
echo "Installing toolchain for STM32 Boards"
223
echo "Downloading from ArduPilot server"
224
sudo wget --progress=dot:giga https://firmware.ardupilot.org/Tools/STM32-tools/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
225
echo "Installing..."
226
sudo chmod -R 777 gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
227
sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
228
echo "... Cleaning"
229
sudo rm gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
230
)
231
fi
232
echo "Registering STM32 Toolchain for ccache"
233
sudo ln -s -f $CCACHE_PATH /usr/lib/ccache/arm-none-eabi-g++
234
sudo ln -s -f $CCACHE_PATH /usr/lib/ccache/arm-none-eabi-gcc
235
echo "Done!";;
236
237
aarch64)
238
if [ ! -d $OPT/$ARM_ROOT ]; then
239
(
240
cd $OPT
241
heading "Installing toolchain for STM32 Boards"
242
echo "Installing toolchain for STM32 Boards"
243
echo "Downloading from ArduPilot server"
244
sudo wget --progress=dot:giga https://firmware.ardupilot.org/Tools/STM32-tools/gcc-arm-none-eabi-10-2020-q4-major-aarch64-linux.tar.bz2
245
echo "Installing..."
246
sudo chmod -R 777 gcc-arm-none-eabi-10-2020-q4-major-aarch64-linux.tar.bz2
247
sudo tar xjf gcc-arm-none-eabi-10-2020-q4-major-aarch64-linux.tar.bz2
248
echo "... Cleaning"
249
sudo rm gcc-arm-none-eabi-10-2020-q4-major-aarch64-linux.tar.bz2
250
)
251
fi
252
echo "Registering STM32 Toolchain for ccache"
253
sudo ln -s -f $CCACHE_PATH /usr/lib/ccache/arm-none-eabi-g++
254
sudo ln -s -f $CCACHE_PATH /usr/lib/ccache/arm-none-eabi-gcc
255
echo "Done!";;
256
esac
257
}
258
259
function maybe_prompt_user() {
260
if $ASSUME_YES; then
261
return 0
262
else
263
read -p "$1"
264
if [[ $REPLY =~ ^[Yy]$ ]]; then
265
return 0
266
else
267
return 1
268
fi
269
fi
270
}
271
272
heading "Add user to dialout group to allow managing serial ports"
273
sudo usermod -a -G dialout $USER
274
echo "Done!"
275
276
# Add back python symlink to python interpreter on Ubuntu >= 20.04
277
if [ ${RELEASE_CODENAME} == 'focal' ];
278
then
279
BASE_PKGS+=" python-is-python3"
280
SITL_PKGS+=" libpython3-stdlib" # for argparse
281
elif [ ${RELEASE_CODENAME} == 'groovy' ] ||
282
[ ${RELEASE_CODENAME} == 'bullseye' ] ||
283
[ ${RELEASE_CODENAME} == 'jammy' ]; then
284
BASE_PKGS+=" python-is-python3"
285
SITL_PKGS+=" libpython3-stdlib" # for argparse
286
elif [ ${RELEASE_CODENAME} == 'bookworm' ]; then
287
SITL_PKGS+=" libpython3-stdlib" # for argparse
288
elif [ ${RELEASE_CODENAME} == 'lunar' ]; then
289
SITL_PKGS+=" libpython3-stdlib" # for argparse
290
elif [ ${RELEASE_CODENAME} == 'buster' ]; then
291
SITL_PKGS+=" libpython3-stdlib" # for argparse
292
elif [ ${RELEASE_CODENAME} != 'mantic' ] &&
293
[ ${RELEASE_CODENAME} != 'noble' ] &&
294
[ ${RELEASE_CODENAME} != 'oracular' ]; then
295
SITL_PKGS+=" python-argparse"
296
fi
297
298
# Check for graphical package for MAVProxy
299
if [[ $SKIP_AP_GRAPHIC_ENV -ne 1 ]]; then
300
if [ ${RELEASE_CODENAME} == 'bullseye' ] ||
301
[ ${RELEASE_CODENAME} == 'buster' ]; then
302
SITL_PKGS+=" libjpeg62-turbo-dev"
303
elif [ ${RELEASE_CODENAME} == 'groovy' ] ||
304
[ ${RELEASE_CODENAME} == 'focal' ]; then
305
SITL_PKGS+=" libjpeg8-dev"
306
elif [ ${RELEASE_CODENAME} == 'bookworm' ]; then
307
SITL_PKGS+=" libgtk-3-dev libwxgtk3.2-dev "
308
elif [ ${RELEASE_CODENAME} == 'lunar' ]; then
309
SITL_PKGS+=" libgtk-3-dev libwxgtk3.2-dev "
310
elif [ ${RELEASE_CODENAME} == 'mantic' ]; then
311
SITL_PKGS+=" libgtk-3-dev libwxgtk3.2-dev "
312
# see below
313
elif [ ${RELEASE_CODENAME} == 'noble' ]; then
314
SITL_PKGS+=" libgtk-3-dev libwxgtk3.2-dev "
315
# see below
316
elif [ ${RELEASE_CODENAME} == 'oracular' ]; then
317
SITL_PKGS+=" libgtk-3-dev libwxgtk3.2-dev "
318
# see below
319
elif apt-cache search python-wxgtk3.0 | grep wx; then
320
SITL_PKGS+=" python-wxgtk3.0"
321
elif apt-cache search python3-wxgtk4.0 | grep wx; then
322
# see below
323
:
324
else
325
# we only support back to trusty:
326
SITL_PKGS+=" python-wxgtk2.8"
327
SITL_PKGS+=" fonts-freefont-ttf libfreetype6-dev libjpeg8-dev libpng12-0 libportmidi-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev" # for pygame
328
fi
329
330
if [ ${RELEASE_CODENAME} == 'bookworm' ]; then
331
PYTHON_PKGS+=" opencv-python"
332
SITL_PKGS+=" python3-wxgtk4.0"
333
SITL_PKGS+=" fonts-freefont-ttf libfreetype6-dev libpng16-16 libportmidi-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev" # for pygame
334
elif [ ${RELEASE_CODENAME} == 'lunar' ]; then
335
PYTHON_PKGS+=" wxpython opencv-python"
336
SITL_PKGS+=" python3-wxgtk4.0"
337
SITL_PKGS+=" fonts-freefont-ttf libfreetype6-dev libpng16-16 libportmidi-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev" # for pygame
338
elif [ ${RELEASE_CODENAME} == 'mantic' ] ||
339
[ ${RELEASE_CODENAME} == 'noble' ] ||
340
[ ${RELEASE_CODENAME} == 'oracular' ]; then
341
PYTHON_PKGS+=" wxpython opencv-python"
342
SITL_PKGS+=" python3-wxgtk4.0"
343
SITL_PKGS+=" fonts-freefont-ttf libfreetype6-dev libpng16-16 libportmidi-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev" # for pygame
344
elif [ ${RELEASE_CODENAME} == 'bullseye' ] ||
345
[ ${RELEASE_CODENAME} == 'groovy' ] ||
346
[ ${RELEASE_CODENAME} == 'buster' ] ||
347
[ ${RELEASE_CODENAME} == 'focal' ] ||
348
[ ${RELEASE_CODENAME} == 'jammy' ]; then
349
SITL_PKGS+=" python3-wxgtk4.0"
350
SITL_PKGS+=" fonts-freefont-ttf libfreetype6-dev libpng16-16 libportmidi-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev" # for pygame
351
fi
352
fi
353
354
# Check if we need to manually install realpath
355
RP=$(apt-cache search -n '^realpath$')
356
if [ -n "$RP" ]; then
357
BASE_PKGS+=" realpath"
358
fi
359
360
# Check if we need to manually install libtool-bin
361
LBTBIN=$(apt-cache search -n '^libtool-bin')
362
if [ -n "$LBTBIN" ]; then
363
SITL_PKGS+=" libtool-bin"
364
fi
365
366
SITL_PKGS+=" ppp"
367
368
# Install all packages
369
$APT_GET install $BASE_PKGS $SITL_PKGS $PX4_PKGS $ARM_LINUX_PKGS $COVERAGE_PKGS
370
371
if [[ $SKIP_AP_GRAPHIC_ENV -ne 1 ]]; then
372
# If xfonts-base was just installed, you need to rebuild the font information cache.
373
# https://discuss.ardupilot.org/t/using-the-gdb-window-on-a-high-dpi-display/128150/2
374
fc-cache
375
fi
376
377
heading "Check if we are inside docker environment..."
378
IS_DOCKER=false
379
if [[ ${AP_DOCKER_BUILD:-0} -eq 1 ]] || [[ -f /.dockerenv ]] || grep -Eq '(lxc|docker)' /proc/1/cgroup ; then
380
IS_DOCKER=true
381
fi
382
echo "Done!"
383
384
SHELL_LOGIN=".profile"
385
if $IS_DOCKER; then
386
echo "Inside docker, we add the tools path into .bashrc directly"
387
SHELL_LOGIN=".ardupilot_env"
388
echo "# ArduPilot env file. Need to be loaded by your Shell." > ~/$SHELL_LOGIN
389
fi
390
391
PIP_USER_ARGUMENT="--user"
392
393
# create a Python venv on more recent releases:
394
PYTHON_VENV_PACKAGE=""
395
if [ ${RELEASE_CODENAME} == 'bookworm' ] ||
396
[ ${RELEASE_CODENAME} == 'lunar' ] ||
397
[ ${RELEASE_CODENAME} == 'mantic' ]; then
398
PYTHON_VENV_PACKAGE=python3.11-venv
399
elif [ ${RELEASE_CODENAME} == 'noble' ]; then
400
PYTHON_VENV_PACKAGE=python3.12-venv
401
elif [ ${RELEASE_CODENAME} == 'oracular' ]; then
402
PYTHON_VENV_PACKAGE=python3.12-venv
403
fi
404
405
if [ -n "$PYTHON_VENV_PACKAGE" ]; then
406
$APT_GET install $PYTHON_VENV_PACKAGE
407
python3 -m venv --system-site-packages $HOME/venv-ardupilot
408
409
# activate it:
410
SOURCE_LINE="source $HOME/venv-ardupilot/bin/activate"
411
$SOURCE_LINE
412
PIP_USER_ARGUMENT=""
413
414
if [[ -z "${DO_PYTHON_VENV_ENV}" ]] && maybe_prompt_user "Make ArduPilot venv default for python [N/y]?" ; then
415
DO_PYTHON_VENV_ENV=1
416
fi
417
418
if [[ $DO_PYTHON_VENV_ENV -eq 1 ]]; then
419
echo $SOURCE_LINE >> ~/$SHELL_LOGIN
420
else
421
echo "Please use \`$SOURCE_LINE\` to activate the ArduPilot venv"
422
fi
423
fi
424
425
# try update packaging, setuptools and wheel before installing pip package that may need compilation
426
SETUPTOOLS="setuptools"
427
if [ ${RELEASE_CODENAME} == 'focal' ]; then
428
SETUPTOOLS=setuptools==70.3.0
429
fi
430
$PIP install $PIP_USER_ARGUMENT -U pip packaging $SETUPTOOLS wheel
431
432
if [ "$GITHUB_ACTIONS" == "true" ]; then
433
PIP_USER_ARGUMENT+=" --progress-bar off"
434
fi
435
436
if [ ${RELEASE_CODENAME} == 'bookworm' ] ||
437
[ ${RELEASE_CODENAME} == 'lunar' ] ||
438
[ ${RELEASE_CODENAME} == 'mantic' ] ||
439
[ ${RELEASE_CODENAME} == 'noble' ] ||
440
[ ${RELEASE_CODENAME} == 'oracular' ]; then
441
# must do this ahead of wxPython pip3 run :-/
442
$PIP install $PIP_USER_ARGUMENT -U attrdict3
443
fi
444
445
# install Python packages one-at-a-time so it is clear which package
446
# is causing problems:
447
for PACKAGE in $PYTHON_PKGS; do
448
$PIP install $PIP_USER_ARGUMENT -U $PACKAGE
449
done
450
451
if [[ -z "${DO_AP_STM_ENV}" ]] && maybe_prompt_user "Install ArduPilot STM32 toolchain [N/y]?" ; then
452
DO_AP_STM_ENV=1
453
fi
454
455
heading "Removing modemmanager and brltty package that could conflict with firmware uploading"
456
if package_is_installed "modemmanager"; then
457
$APT_GET remove modemmanager
458
fi
459
if package_is_installed "brltty"; then
460
$APT_GET remove brltty
461
fi
462
echo "Done!"
463
464
CCACHE_PATH=$(which ccache)
465
if [[ $DO_AP_STM_ENV -eq 1 ]]; then
466
install_arm_none_eabi_toolchain
467
fi
468
469
heading "Adding ArduPilot Tools to environment"
470
471
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
472
ARDUPILOT_ROOT=$(realpath "$SCRIPT_DIR/../../")
473
474
if [[ $DO_AP_STM_ENV -eq 1 ]]; then
475
exportline="export PATH=$OPT/$ARM_ROOT/bin:\$PATH";
476
grep -Fxq "$exportline" ~/$SHELL_LOGIN 2>/dev/null || {
477
if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [N/y]?" ; then
478
echo $exportline >> ~/$SHELL_LOGIN
479
eval $exportline
480
else
481
echo "Skipping adding $OPT/$ARM_ROOT/bin to PATH."
482
fi
483
}
484
fi
485
486
exportline2="export PATH=$ARDUPILOT_ROOT/$ARDUPILOT_TOOLS:\$PATH";
487
grep -Fxq "$exportline2" ~/$SHELL_LOGIN 2>/dev/null || {
488
if maybe_prompt_user "Add $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to your PATH [N/y]?" ; then
489
echo $exportline2 >> ~/$SHELL_LOGIN
490
eval $exportline2
491
else
492
echo "Skipping adding $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to PATH."
493
fi
494
}
495
496
if [[ $SKIP_AP_COMPLETION_ENV -ne 1 ]]; then
497
exportline3="source $ARDUPILOT_ROOT/Tools/completion/completion.bash";
498
grep -Fxq "$exportline3" ~/$SHELL_LOGIN 2>/dev/null || {
499
if maybe_prompt_user "Add ArduPilot Bash Completion to your bash shell [N/y]?" ; then
500
echo $exportline3 >> ~/.bashrc
501
eval $exportline3
502
else
503
echo "Skipping adding ArduPilot Bash Completion."
504
fi
505
}
506
fi
507
508
exportline4="export PATH=/usr/lib/ccache:\$PATH";
509
grep -Fxq "$exportline4" ~/$SHELL_LOGIN 2>/dev/null || {
510
if maybe_prompt_user "Append CCache to your PATH [N/y]?" ; then
511
echo $exportline4 >> ~/$SHELL_LOGIN
512
eval $exportline4
513
else
514
echo "Skipping appending CCache to PATH."
515
fi
516
}
517
echo "Done!"
518
519
if [[ $SKIP_AP_GIT_CHECK -ne 1 ]]; then
520
if [ -d ".git" ]; then
521
heading "Update git submodules"
522
cd $ARDUPILOT_ROOT
523
git submodule update --init --recursive
524
echo "Done!"
525
fi
526
fi
527
528
if $IS_DOCKER; then
529
echo "Finalizing ArduPilot env for Docker"
530
echo "source ~/.ardupilot_env">> ~/.bashrc
531
fi
532
533
echo "---------- $0 end ----------"
534
535