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-arch.sh
Views: 1798
1
#!/usr/bin/env bash
2
set -e
3
set -x
4
5
CWD=$(pwd)
6
OPT="/opt"
7
8
ASSUME_YES=false
9
QUIET=false
10
sep="##############################################"
11
12
OPTIND=1 # Reset in case getopts has been used previously in the shell.
13
while getopts "yq" opt; do
14
case "$opt" in
15
\?)
16
exit 1
17
;;
18
y) ASSUME_YES=true
19
;;
20
q) QUIET=true
21
;;
22
esac
23
done
24
25
BASE_PKGS="base-devel ccache git gsfonts tk wget gcc"
26
SITL_PKGS="python-pip python-setuptools python-wheel python-wxpython opencv python-numpy python-scipy"
27
PX4_PKGS="lib32-glibc zip zlib ncurses"
28
29
PYTHON_PKGS="future lxml pymavlink MAVProxy pexpect argparse matplotlib pyparsing geocoder pyserial empy==3.3.4 dronecan packaging setuptools wheel"
30
31
# GNU Tools for ARM Embedded Processors
32
# (see https://launchpad.net/gcc-arm-embedded/)
33
ARM_ROOT="gcc-arm-none-eabi-10-2020-q4-major"
34
ARM_TARBALL="$ARM_ROOT-x86_64-linux.tar.bz2"
35
ARM_TARBALL_URL="https://firmware.ardupilot.org/Tools/STM32-tools/$ARM_TARBALL"
36
ARM_TARBALL_CHECKSUM="21134caa478bbf5352e239fbc6e2da3038f8d2207e089efc96c3b55f1edcd618"
37
38
# Ardupilot Tools
39
ARDUPILOT_TOOLS="ardupilot/Tools/autotest"
40
41
function maybe_prompt_user() {
42
if $ASSUME_YES; then
43
return 0
44
else
45
read -p "$1"
46
if [[ $REPLY =~ ^[Yy]$ ]]; then
47
return 0
48
else
49
return 1
50
fi
51
fi
52
}
53
54
sudo usermod -a -G uucp "$USER"
55
56
sudo pacman -Syu --noconfirm --needed $BASE_PKGS $SITL_PKGS $PX4_PKGS
57
58
python3 -m venv --system-site-packages "$HOME"/venv-ardupilot
59
60
# activate it:
61
SOURCE_LINE="source $HOME/venv-ardupilot/bin/activate"
62
$SOURCE_LINE
63
64
if [[ -z "${DO_PYTHON_VENV_ENV}" ]] && maybe_prompt_user "Make ArduPilot venv default for python [N/y]?" ; then
65
DO_PYTHON_VENV_ENV=1
66
fi
67
68
if [[ $DO_PYTHON_VENV_ENV -eq 1 ]]; then
69
echo "$SOURCE_LINE" >> ~/.bashrc
70
else
71
echo "Please use \`$SOURCE_LINE\` to activate the ArduPilot venv"
72
fi
73
74
pip3 -q install -U $PYTHON_PKGS
75
76
(
77
cd /usr/lib/ccache
78
if [ ! -f arm-none-eabi-g++ ]; then
79
sudo ln -s /usr/bin/ccache arm-none-eabi-g++
80
fi
81
if [ ! -f arm-none-eabi-g++ ]; then
82
sudo ln -s /usr/bin/ccache arm-none-eabi-gcc
83
fi
84
)
85
86
if [ ! -d $OPT/$ARM_ROOT ]; then
87
(
88
cd $OPT;
89
90
# Check if file exists and verify checksum
91
download_required=false
92
if [ -e "$ARM_TARBALL" ]; then
93
echo "File exists. Verifying checksum..."
94
95
# Calculate the checksum of the existing file
96
ACTUAL_CHECKSUM=$(sha256sum "$ARM_TARBALL" | awk '{ print $1 }')
97
98
# Compare the actual checksum with the expected one
99
if [ "$ACTUAL_CHECKSUM" == "$ARM_TARBALL_CHECKSUM" ]; then
100
echo "Checksum valid. No need to redownload."
101
else
102
echo "Checksum invalid. Redownloading the file..."
103
download_required=true
104
sudo rm $ARM_TARBALL
105
fi
106
else
107
echo "File does not exist. Downloading..."
108
download_required=true
109
fi
110
111
if $download_required; then
112
sudo wget -O "$ARM_TARBALL" --progress=dot:giga $ARM_TARBALL_URL
113
fi
114
115
sudo tar xjf ${ARM_TARBALL}
116
)
117
fi
118
119
exportline="export PATH=$OPT/$ARM_ROOT/bin:\$PATH";
120
if ! grep -Fxq "$exportline" ~/.bashrc ; then
121
if maybe_prompt_user "Add $OPT/$ARM_ROOT/bin to your PATH [N/y]?" ; then
122
echo "$exportline" >> ~/.bashrc
123
. "$HOME/.bashrc"
124
else
125
echo "Skipping adding $OPT/$ARM_ROOT/bin to PATH."
126
fi
127
fi
128
129
exportline2="export PATH=$CWD/$ARDUPILOT_TOOLS:\$PATH";
130
if ! grep -Fxq "$exportline2" ~/.bashrc ; then
131
if maybe_prompt_user "Add $CWD/$ARDUPILOT_TOOLS to your PATH [N/y]?" ; then
132
echo "$exportline2" >> ~/.bashrc
133
. "$HOME/.bashrc"
134
else
135
echo "Skipping adding $CWD/$ARDUPILOT_TOOLS to PATH."
136
fi
137
fi
138
139
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
140
(
141
cd "$SCRIPT_DIR"
142
git submodule update --init --recursive
143
)
144
145
echo "Done. Please log out and log in again."
146
147