forked from AMZ-Racing/fsd_skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_dependencies.sh
executable file
·201 lines (164 loc) · 6.39 KB
/
update_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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
# Sonja Brits <britss@ethz.ch> - FSD Driverless 2019
# Adapted from work by Huub Hendrikx <hhendrik@ethz.ch>
# Apt packages
WSTOOL_PACKAGE="python-wstool"
CHECKINSTALL_PACKAGE="checkinstall"
ROS_PACKAGE=(
"ros-melodic-desktop-full"
"ros-melodic-ros-base"
)
FSD_WORKPACKAGES=(
'1_perception'
'2_estimation'
'3_control'
)
BLACKLIST_PACKAGES=''
###################################
# Decide whether to include fssim #
###################################
case $1 in
-f|--fssim)
FSSIM="TRUE"
;;
esac
printf "FSSIM is..."
if [ -z $FSSIM ]; then
echo "DISABLED"
BLACKLIST_PACKAGES='fssim_interface fssim'
else
echo "ENABLED"
FSD_WORKPACKAGES=("${FSD_WORKPACKAGES[@]}" 'fssim_interface')
fi
#####################################
# Set paths #
#####################################
FSD_DEPENDENCY_FILE="dependencies.rosinstall"
# TODO: check whether cpplint is installed
CPPLINT_PACKAGE="cpplint"
ABSOLUTE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TOP_LEVEL_DIR_NAME="$(basename "${ABSOLUTE_PATH}")"
FSD_ROOT_VAR=$( cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)
FSD_ROSDEP_DIR="${ABSOLUTE_PATH}/src/4_continuous_integration/rosdep"
ROSDEP_SOURCES_TARGET="/etc/ros/rosdep/sources.list.d"
red=$'\e[1;31m'
green=$'\e[1;32m'
blue=$'\e[1;34m'
end=$'\e[0m'
printf "\n"
printf "Formula Student Driverless dependency updater\n"
printf "Version 2.0 - 2019"
printf "\n\n"
printf "First checking some things...\n"
#########################################
# Check installed packages #
#########################################
printf "Checking if ROS is installed... "
package_OK=$(dpkg-query -W --showformat='${Status}\n' "${ROS_PACKAGE[0]}" 2> /dev/null|grep "install ok installed")
if [ "" == "$package_OK" ]; then
package_OK=$(dpkg-query -W --showformat='${Status}\n' "${ROS_PACKAGE[1]}" 2> /dev/null|grep "install ok installed")
fi
if [ "" == "$package_OK" ]; then
printf "[${red}NO${end}]\n"
printf "Please install the ROS using: 'sudo apt install ros-melodic-desktop-full' or 'sudo apt install ros-melodic-ros-base'\n"
exit 1
fi
printf "[${green}YES${end}]\n"
printf "Checking if checkinstall is installed... "
package_OK=$(dpkg-query -W --showformat='${Status}\n' "${CHECKINSTALL_PACKAGE}" 2> /dev/null|grep "install ok installed")
if [ "" == "$package_OK" ]; then
printf "[${red}NO${end}]\n"
printf "Please install the checkinstall package using: 'sudo apt install checkinstall'\n"
exit 1
fi
printf "[${green}YES${end}]\n"
#########################################
# Add nice aliases to ~/.bashrc #
#########################################
if [ -z "$FSD_ROOT" ]; then
printf "Setting Aliases and Variables..."
if ! grep -Fxq "export FSD_ROOT=$FSD_ROOT_VAR" ~/.bashrc; then
printf "\nAdding export FSD_ROOT to ~/.bashrc... "
echo "" >> ~/.bashrc
echo "# FSD 2019 Environment variables" >> ~/.bashrc
echo "export FSD_ROOT=$FSD_ROOT_VAR" >> ~/.bashrc
fi
if ! grep -Fxq "# FSD aliases source" ~/.bashrc; then
FSD_ROOT=${FSD_ROOT_VAR}
printf "\nAdding alias commands to ~/.bashrc... "
echo "" >> ~/.bashrc
echo "source ${FSD_ROOT}/fsd_environment.sh" >> ~/.bashrc
fi
else
printf "Aliases and Environment variables has been set... "
fi
printf "[${green}YES${end}]\n"
printf "ALL CHECKS PASSED [${green}YES${end}]\n"
############################################
# Update the git repositories using wstool #
############################################
read -p "Do you want to get/update the repositories (Y/n)? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]] || [ -z $REPLY ]; then
if [ -e "${ABSOLUTE_PATH}/.rosinstall" ]; then
printf "Rosinstall file found in top level directory! So we are removing it!\n"
rm ${ABSOLUTE_PATH}/.rosinstall
fi
printf "We detected that your are running update_dependencies for the first time!\n"
INIT_RESULT="$(cd "${ABSOLUTE_PATH}" && wstool init)"
printf "${INIT_RESULT}\n"
printf "Merging each workpackage into toplevel dependency list...\n"
for i in ${FSD_WORKPACKAGES[@]}; do
FSD_WP_DEPENDENCY_FILE="${ABSOLUTE_PATH}/src/${i}/${FSD_DEPENDENCY_FILE}"
printf "${blue}\n${i}${end}\n"
printf "Using dependencies in ${FSD_WP_DEPENDENCY_FILE}\n "
WS_MERGE_RESULT="$(cd "${ABSOLUTE_PATH}" && wstool merge "${FSD_WP_DEPENDENCY_FILE}")"
printf "${WS_MERGE_RESULT}"
printf "\n"
done
printf "\n Updating all repositories now...\n"
cd ${ABSOLUTE_PATH}
wstool update
fi
###################################################
# Update the binary dependencies using rosdep #
###################################################
read -p "Do you want to install/update the projects dependencies (Y/n)? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]] || [ -z $REPLY ]; then
# Place our FSD dependencies in the rosdep sources folder
printf "\n\nCopying FSD's ROS dependency list to rosdep sources folder\n"
printf "Target folder: ${ROSDEP_SOURCES_TARGET}\n"
printf "Sudo might ask for your password now!\n"
COPY_FAILED_MESSAGE="[${red}COPY FAILED: The dependency update might fail now!${end}]\n"
sudo cp "${FSD_ROSDEP_DIR}/fsd-dependencies.yaml" "${ROSDEP_SOURCES_TARGET}/" || { printf "$COPY_FAILED_MESSAGE" ; }
sudo cp ${FSD_ROSDEP_DIR}/*.rdmanifest "${ROSDEP_SOURCES_TARGET}/" || { printf "$COPY_FAILED_MESSAGE" ; }
sudo cp "${FSD_ROSDEP_DIR}/10-fsd-dependencies.list" "${ROSDEP_SOURCES_TARGET}/" || { printf "$COPY_FAILED_MESSAGE" ; }
sudo apt-get update
# Update rosdep
rosdep update
# Install the dependencies
rosdep install --from-paths "${ABSOLUTE_PATH}/" -r -i -y || { printf "[${red}ROSDEP FAILED${end}]\n" ;}
fi
#################################################
# Configure catkin workpace #
#################################################
echo "Blacklisting packages: " ${BLACKLIST_PACKAGES}
catkin init
if [ -n "${BLACKLIST_PACKAGES}" ]; then
catkin config --blacklist ${BLACKLIST_PACKAGES} --cmake-args -DCMAKE_BUILD_TYPE=Release
else
catkin config --no-blacklist --cmake-args -DCMAKE_BUILD_TYPE=Release
fi
#################################################
# If fssim enabled update deps #
#################################################
if [ ! -z $FSSIM ]; then
printf "Updating FSSIM dependencies..."
cd src/fssim/
git pull
git checkout melodic-devel
./update_dependencies.sh
git lfs pull
cd ../../
fi