-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_dependencies.sh
executable file
·111 lines (96 loc) · 3.17 KB
/
install_dependencies.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# Copyright 2021 Toyota Research Institute
set -e pipefail
#######################################
# Installs apt repository into system wide sources list.
#
# Arguments
# $1 -> name of the repository, to be used as sources list prefix.
# $2 -> url of the repository.
#######################################
install_apt_repo() {
REPO_NAME=$1
REPO_URL=$2
KEY_PATH=/usr/share/keyrings/ros-archive-keyring.gpg
if [ ! -f ${KEY_PATH} ]; then
apt update
apt install -y curl
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key \
-o ${KEY_PATH}
fi
if ! grep -q "^deb .*$REPO_URL" /etc/apt/sources.list /etc/apt/sources.list.d/*; then
echo "deb [signed-by=${KEY_PATH}] $REPO_URL $(lsb_release -cs) main" | \
tee --append /etc/apt/sources.list.d/$REPO_NAME.list > /dev/null
echo "Apt Repo '$REPO_NAME'..........................installed"
else
echo "Apt Repo '$REPO_NAME'..........................found"
fi
}
#######################################
# Installs basic workspace tools.
# Arguments:
# Version of ros.
# Returns:
# 0 if no error was detected, non-zero otherwise.
#######################################
function install_workspace_tools() {
local ros_distro=$1
apt install -y \
bash-completion \
build-essential \
curl \
gdb \
git \
mercurial \
python3 \
python3-setuptools \
python3-vcstool \
python3-rosdep \
python3-colcon-common-extensions \
ros-${ros_distro}-ament-cmake \
tmux
}
#######################################
# Installs clang suite packages.
# Arguments:
# Version of the clang suite package.
# Returns:
# 0 if no error was detected, non-zero otherwise.
#######################################
function install_clang_suite() {
local version=$1
apt install -y \
clang-${version} \
lldb-${version} \
lld-${version} \
clang-format-${version} \
clang-tidy-${version} \
libc++-${version}-dev \
libc++abi-${version}-dev
}
# In focal docker image, lsb_release is not available
apt update && apt install -y lsb-release
# Get correspondant ROS DISTRO.
declare -A ROS_DISTRO_MAP
ROS_DISTRO_MAP[focal]=foxy
ROS_DISTRO_MAP[bionic]=dashing
ROS_DISTRO_MAP[xenial]=bouncy
ROS_DISTRO=${ROS_DISTRO_MAP[$(lsb_release -sc)]}
# TODO: Exit if ROS DISTRO is unknown.
install_apt_repo "ros2-latest" "http://packages.ros.org/ros2/ubuntu"
apt update
# Define clang version.
CLANG_SUITE_VERSION=8
# Install dependencies.
install_workspace_tools ${ROS_DISTRO}
install_clang_suite ${CLANG_SUITE_VERSION}
# Source ros environments variables.
if ! grep -q "^source /opt/ros/$ROS_DISTRO/setup.bash" ~/.bashrc; then
cat >> ~/.bashrc <<< "source /opt/ros/$ROS_DISTRO/setup.bash"
fi
if ! grep -q "^export ROS_DISTRO=" ~/.bashrc; then
cat >> ~/.bashrc <<< "export ROS_DISTRO=$ROS_DISTRO"
fi
# We initialize rosdep and discard the stdout message
# that recommends to run rosdep update.
rosdep init > /dev/null