-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathinstall.sh
executable file
·153 lines (131 loc) · 4.13 KB
/
install.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# Get this script's path
pushd "$(dirname "$0")" > /dev/null
SCRIPTPATH=$(pwd)
popd > /dev/null
set -e
source "$SCRIPTPATH/support/fun.cfg"
USAGE="Usage: \n install [OPTIONS...]
\n\n
Help Options:
\n
-h,--help \tShow help options
\n\n
Application Options:
\n
-i,--install \tInstall options [base|app|all], example: -i all
\n
-b,--branch \tBranch to install, example: -b devel
\n
-r,--ros \tROS distro to install, example: -r noetic"
# Default
INSTALL_OPT="all"
BRANCH_OPT="devel"
ROS_DISTRO_OPT=
PYTHON_NAME="python3"
UBUNTU=$(lsb_release -cs)
wolf_banner
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
echo -e "$USAGE"
exit 0
fi
while [[ -n "$1" ]]; do
case "$1" in
-i|--install)
INSTALL_OPT="$2"
shift
;;
-b|--branch)
BRANCH_OPT="$2"
shift
;;
-r|--ros)
ROS_DISTRO_OPT="$2"
shift
;;
*)
print_warn "Option $1 not recognized!"
echo -e "$USAGE"
exit 1
;;
esac
shift
done
# Validate install options
if [[ "$INSTALL_OPT" != "base" && "$INSTALL_OPT" != "app" && "$INSTALL_OPT" != "all" ]]; then
print_warn "Wrong install option!"
echo -e "$USAGE"
exit 1
fi
print_info "Selected install option: $INSTALL_OPT"
# Determine ROS distro
if [[ -z "$ROS_DISTRO_OPT" ]]; then
if [[ "$UBUNTU" == "jammy" ]]; then
ROS_DISTRO_OPT="humble"
elif [[ "$UBUNTU" == "focal" ]]; then
ROS_DISTRO_OPT="noetic"
else
print_warn "Unsupported Ubuntu version! Only 20.04 (focal) and 22.04 (jammy) are supported."
exit 1
fi
fi
print_info "Selected ROS distro option: $ROS_DISTRO_OPT"
print_info "Selected BRANCH option: $BRANCH_OPT"
# Set ROS-related variables
case "$ROS_DISTRO_OPT" in
noetic)
ROS_VERSION_NAME="ros"
ROS_DISTRO="$ROS_DISTRO_OPT"
LIST_FILE="/etc/apt/sources.list.d/ros-latest.list"
;;
foxy|humble)
ROS_VERSION_NAME="ros2"
ROS_DISTRO="$ROS_DISTRO_OPT"
LIST_FILE="/etc/apt/sources.list.d/ros2.list"
;;
*)
print_warn "Unsupported ROS distro! Only noetic, foxy, and humble are supported."
exit 1
;;
esac
# Install base components
if [[ "$INSTALL_OPT" == "base" || "$INSTALL_OPT" == "all" ]]; then
# Define variables
LIST_FILE="/etc/apt/sources.list.d/ros2.list"
KEY_FILE="/usr/share/keyrings/ros-archive-keyring.gpg"
ROS_REPO="http://packages.ros.org/${ROS_VERSION_NAME}/ubuntu"
# Check if the repository is already added
if grep -q "${ROS_REPO}" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then
print_info "ROS repository is already present. Skipping repository setup."
else
print_info "Adding ROS repository..."
echo "deb [signed-by=${KEY_FILE}] ${ROS_REPO} $(lsb_release -cs) main" | sudo tee "$LIST_FILE"
wget -qO - https://raw.githubusercontent.com/ros/rosdistro/master/ros.key | sudo tee "$KEY_FILE"
fi
# Update package list
sudo apt-get update
print_info "Installing system libraries..."
grep -v '#' "$SCRIPTPATH/config/${ROS_VERSION_NAME}/sys_deps_list.txt" | xargs sudo apt-get install -y
print_info "Installing Python libraries..."
grep -v '#' "$SCRIPTPATH/config/${ROS_VERSION_NAME}/python_deps_list.txt" | xargs printf -- "${PYTHON_NAME}-%s\n" | xargs sudo apt-get install -y
print_info "Installing ROS packages..."
grep -v '#' "$SCRIPTPATH/config/${ROS_VERSION_NAME}/ros_deps_list.txt" | xargs printf -- "ros-${ROS_DISTRO}-%s\n" | xargs sudo apt-get install -y
sudo ldconfig
sudo rosdep init || true
rosdep update
fi
# Install application components
if [[ "$INSTALL_OPT" == "app" || "$INSTALL_OPT" == "all" ]]; then
/bin/bash "$SCRIPTPATH/support/get_debians.sh"
print_info "Installing WoLF debian packages..."
sudo dpkg -i --force-overwrite "$SCRIPTPATH/debs/$BRANCH_OPT/$UBUNTU/"*.deb
fi
# Update Bashrc
for LINE in "source /opt/ros/${ROS_DISTRO}/setup.bash" "source /opt/ocs2/setup.sh" "export XBOT_ROOT=/opt/ros/${ROS_DISTRO}"; do
if ! grep -Fwq "$LINE" ~/.bashrc; then
print_info "Adding $LINE to .bashrc"
echo "$LINE" >> ~/.bashrc
else
print_info "$LINE is already in .bashrc"
fi
done