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-openSUSE-Tumbleweed.sh
Views: 1798
1
#!/usr/bin/env bash
2
echo "---------- $0 start ----------"
3
set -e
4
set -x
5
set +H
6
7
if [ $EUID == 0 ]; then
8
echo "Please do not run this script as root; don't sudo it!"
9
exit 1
10
fi
11
12
13
OPT="/opt"
14
# Ardupilot Tools
15
ARDUPILOT_TOOLS="Tools/autotest"
16
17
ASSUME_YES=false
18
QUIET=false
19
sep="##############################################"
20
21
OPTIND=1 # Reset in case getopts has been used previously in the shell.
22
while getopts "yq" opt; do
23
case "$opt" in
24
\?)
25
exit 1
26
;;
27
y) ASSUME_YES=true
28
;;
29
q) QUIET=true
30
;;
31
esac
32
done
33
34
ZYPPER="sudo zypper in --no-recommends"
35
if $ASSUME_YES; then
36
ZYPPER="sudo zypper in -y --no-recommends"
37
fi
38
PIP3=pip3
39
if $QUIET; then
40
PIP3="pip3 -q"
41
fi
42
43
function package_is_installed() {
44
rpm -q $1 &>/dev/null
45
}
46
47
function heading() {
48
echo "$sep"
49
echo $*
50
echo "$sep"
51
}
52
53
#Install python3 1st, as openSUSE TW WSL does not come with preinstalled python
54
$ZYPPER python3 || echo "Check zypper output for errors"
55
56
#As tumbleweed can have many python versions, we need to know which one is currently active
57
PYPKGVER=python$(python3 --version | cut -d' ' -f2 | awk -F. '{print $1$2}')
58
59
BASE_PKGS="patterns-devel-base-devel_basis ccache git axel valgrind screen gcc-c++ xterm free-ttf-fonts sfml2-devel zip glibc-devel-static rsync"
60
SITL_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"
61
62
PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect argparse pyparsing geocoder pyserial empy==3.3.4 ptyprocess dronecan"
63
PYTHON_PKGS+=" flake8 junitparser pygame intelhex psutil pyyaml"
64
# GNU Tools for ARM Embedded Processors
65
# (see https://launchpad.net/gcc-arm-embedded/)
66
ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"
67
ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2"
68
ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL"
69
70
ARM_LINUX_ROOT=gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf
71
ARM_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"
72
ARM_LINUX_TARBALL="gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz"
73
74
function maybe_prompt_user() {
75
if $ASSUME_YES; then
76
return 0
77
else
78
read -p "$1"
79
if [[ $REPLY =~ ^[Yy]$ ]]; then
80
return 0
81
else
82
return 1
83
fi
84
fi
85
}
86
87
sudo usermod -a -G dialout "$USER"
88
89
$ZYPPER $BASE_PKGS $SITL_PKGS || echo "Check zypper output for errors"
90
91
python3 -m venv "$HOME"/venv-ardupilot
92
93
SHELL_LOGIN=".profile"
94
# activate it:
95
SOURCE_LINE="source $HOME/venv-ardupilot/bin/activate"
96
$SOURCE_LINE
97
98
if ! grep -Fxq "$SOURCE_LINE" ~/.bashrc; then
99
if [[ -z "${DO_PYTHON_VENV_ENV}" ]] && maybe_prompt_user "Make ArduPilot venv default for python [N/y]?" ; then
100
DO_PYTHON_VENV_ENV=1
101
fi
102
103
if [[ $DO_PYTHON_VENV_ENV -eq 1 ]]; then
104
echo $SOURCE_LINE >> ~/.bashrc
105
else
106
echo "Please use \`$SOURCE_LINE\` to activate the ArduPilot venv"
107
fi
108
fi
109
110
$PIP3 install -U pip packaging setuptools wheel
111
$PIP3 install -U attrdict3
112
$PIP3 install -U $PYTHON_PKGS
113
114
(
115
cd /usr/lib64/ccache
116
for C in arm-none-eabi-g++ arm-none-eabi-gcc arm-linux-gnueabihf-g++ arm-linux-gnueabihf-gcc; do
117
if [ ! -f "$C" ]; then
118
sudo ln -s ../../bin/ccache "$C"
119
fi
120
done
121
)
122
123
ccache --set-config sloppiness=file_macro,locale,time_macros
124
ccache --set-config ignore_options="--specs=nano.specs --specs=nosys.specs"
125
126
if [ ! -d $OPT/$ARM_ROOT ]; then
127
(
128
cd $OPT;
129
sudo axel -a -c $ARM_TARBALL_URL;
130
sudo tar xjf ${ARM_TARBALL};
131
sudo rm ${ARM_TARBALL};
132
)
133
fi
134
135
if [ ! -d $OPT/$ARM_LINUX_ROOT ]; then
136
(
137
cd $OPT;
138
sudo axel -a -c "${ARM_LINUX_GCC_URL}";
139
sudo tar xf ${ARM_LINUX_TARBALL};
140
sudo rm ${ARM_LINUX_TARBALL};
141
)
142
fi
143
144
heading "Removing modemmanager and brltty package that could conflict with firmware uploading"
145
if package_is_installed "ModemManager"; then
146
sudo zypper rm ModemManager
147
fi
148
if package_is_installed "brltty"; then
149
sudo zypper rm brltty
150
fi
151
echo "Done!"
152
153
heading "Adding ArduPilot Tools to environment"
154
155
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
156
ARDUPILOT_ROOT=$(realpath "$SCRIPT_DIR/../../")
157
158
159
exportline="export PATH=$OPT/$ARM_ROOT/bin:\$PATH";
160
if ! grep -Fxq "$exportline" ~/$SHELL_LOGIN ; then
161
if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [N/y]?" ; then
162
echo $exportline >> ~/$SHELL_LOGIN
163
else
164
echo "Skipping adding $OPT/$ARM_ROOT/bin to PATH."
165
fi
166
fi
167
168
exportline1="export PATH=$OPT/$ARM_LINUX_ROOT/bin:\$PATH";
169
if ! grep -Fxq "$exportline1" ~/$SHELL_LOGIN ; then
170
if maybe_prompt_user "Add $OPT/$ARM_LINUX_ROOT/bin to your PATH [N/y]?" ; then
171
echo $exportline1 >> ~/$SHELL_LOGIN
172
else
173
echo "Skipping adding $OPT/$ARM_LINUX_ROOT/bin to PATH."
174
fi
175
fi
176
177
exportline2="export PATH=$ARDUPILOT_ROOT/$ARDUPILOT_TOOLS:\$PATH";
178
if ! grep -Fxq "$exportline2" ~/$SHELL_LOGIN ; then
179
if maybe_prompt_user "Add $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to your PATH [N/y]?" ; then
180
echo $exportline2 >> ~/$SHELL_LOGIN
181
else
182
echo "Skipping adding $ARDUPILOT_ROOT/$ARDUPILOT_TOOLS to PATH."
183
fi
184
fi
185
186
exportline3="source $ARDUPILOT_ROOT/Tools/completion/completion.bash";
187
if ! grep -Fxq "$exportline3" ~/.bashrc ; then
188
if maybe_prompt_user "Add ArduPilot Bash Completion to your bash shell [N/y]?" ; then
189
echo $exportline3 >> ~/.bashrc
190
else
191
echo "Skipping adding ArduPilot Bash Completion."
192
fi
193
fi
194
195
exportline4="export PATH=/usr/lib64/ccache:\$PATH";
196
if ! grep -Fxq "$exportline4" ~/$SHELL_LOGIN ; then
197
if maybe_prompt_user "Append CCache to your PATH [N/y]?" ; then
198
echo $exportline4 >> ~/$SHELL_LOGIN
199
else
200
echo "Skipping appending CCache to PATH."
201
fi
202
fi
203
echo "Done!"
204
205
if [[ $SKIP_AP_GIT_CHECK -ne 1 ]]; then
206
cd "$ARDUPILOT_ROOT"
207
if [ -d ".git" ]; then
208
heading "Update git submodules"
209
cd $ARDUPILOT_ROOT
210
git submodule update --init --recursive
211
echo "Done!"
212
fi
213
fi
214
215
echo "---------- $0 end ----------"
216
echo "Done. Please log out and log in again."
217
218