Newer
Older

Olivier Stasse
committed
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/bin/bash
rm -rf "$build_dir" "$install_dir"
. `dirname $0`/common.sh
# Set debug mode
set -x
set -v
# Add robotpkg
sudo sh -c "echo \"deb [arch=amd64] http://robotpkg.openrobots.org/packages/debian/pub $(lsb_release -cs) robotpkg\" >> /etc/apt/sources.list "
curl http://robotpkg.openrobots.org/packages/debian/robotpkg.key | sudo apt-key add -
# show memory usage before install
sudo free -m -t
# Setup environment variables.
export APT_DEPENDENCIES="doxygen libboost-system-dev libboost-test-dev libboost-filesystem-dev libboost-program-options-dev libeigen3-dev liburdfdom-dev texlive-font-utils"
# Add Python dependency
export APT_DEPENDENCIES=$APT_DEPENDENCIES" libboost-python-dev robotpkg-py27-eigenpy python2.7-dev python-numpy gfortran libblas-dev liblapack-dev"
# Add Geometry dependencies
if [[ $BUILD_WITH_COLLISION_SUPPORT -eq ON ]]; then
export APT_DEPENDENCIES=$APT_DEPENDENCIES" robotpkg-hpp-fcl"
fi
##############################
# -- Helper functions -- #
##############################
_linux_setup_package_source()
{
# Speed up apt
${SUDO_CMD} sh -c "echo \"force-unsafe-io\" > /etc/dpkg/dpkg.cfg.d/02apt-speedup"
# Update the apt local cache.
${SUDO_CMD} apt-get update -qq
}
_osx_setup_package_source()
{
# Update homebrew
brew update
}
# setup_package_source
# ---------------------
#
# Setup the package source (e.g. homebrew on osx, apt on debian-like systems)
setup_package_source()
{
if [[ ${CI_OS_NAME} = linux ]]; then
_linux_setup_package_source
fi
if [[ ${CI_OS_NAME} = osx ]]; then
_osx_setup_package_source
fi
}
# setup_pbuilder
# --------------
#
# Setup a pbuilder environment
setup_pbuilder()
{
if `test x${DIST} = x`; then
echo "distribution is not set, skipping this build"
exit 0
fi
echo "Target distribution: ${DIST}"
# If we are, we install Debian package development tools and
# create a sid pbuilder. Package dependencies will be installed
# automatically.
${SUDO_CMD} apt-get install -qq \
debootstrap devscripts \
git-buildpackage debian-archive-keyring \
pkg-kde-tools dput eatmydata ccache
# Fix ccache use in pbuilder
${SUDO_CMD} addgroup --system --gid 1234 ccache
${SUDO_CMD} adduser --quiet --system --uid 1234 --ingroup ccache \
--home /var/cache/pbuilder --no-create-home pbuilder
${SUDO_CMD} mkdir -p /var/cache/pbuilder/ccache
${SUDO_CMD} chown -R pbuilder:ccache /var/cache/pbuilder/ccache
${SUDO_CMD} chmod -R g+ws /var/cache/pbuilder/ccache
# Remove previous sandbox.
${SUDO_CMD} rm -rf /var/cache/pbuilder/base-${DIST}.cow || true
# Create a pbuilder sandbox.
cp -f `dirname $0`/pbuilderrc $HOME/.pbuilderrc
sed -i "s|@DIST@|${DIST}|g" $HOME/.pbuilderrc
git-pbuilder create
# Speed up pbuilder.
echo "echo \"force-unsafe-io\" > /etc/dpkg/dpkg.cfg.d/02apt-speedup" | \
git-pbuilder login --save-after-exec
# Add additional PPAs
for ppa in ${DEBIAN_PPA}; do
echo "apt-add-repository ppa:${ppa}" | \
git-pbuilder login --save-after-exec
done
# Retrieve PPA package list.
git-pbuilder update
# FIXME There is something fishy here...
# ccache is not necessary in our case and may cause permission
# issues.
echo "apt-get -y remove ccache" | \
git-pbuilder login --save-after-exec
}
# catkin_git_dependency
# --------------------
#
# Clone catkin package into the workspace
# See arguments of build_git_dependency
# Branch defaults to $ROS_DISTRO instead of master
catkin_git_dependency()
{
git_dependency_parsing $1 $ROS_DISTRO
echo "--> Getting $git_dep (branch $git_dep_branch)"
CATKIN_DEP_WORKSPACE=/tmp/_ci/catkin_dep_ws
cd $CATKIN_DEP_WORKSPACE/src
$git_clone -b $git_dep_branch "$git_dep_uri" "$git_dep"
}
# catkin_build_workspace
# ----------------------
#
# Build catkin workspace
catkin_build_workspace()
{
CATKIN_DEP_WORKSPACE=/tmp/_ci/catkin_dep_ws
cd $CATKIN_DEP_WORKSPACE
catkin_make
}
# build_git_dependency
# --------------------
#
# Build a dependency directly from the Git development tree.
# First argument: repository's GitHub URL or repository's URI + optional branch
# For example: "jrl-umi3218/jrl-travis" or "jrl-umi3218/jrl-travis#dev"
# Or: user@host:path/to/repo or git@github.com:organization/repo#branch
build_git_dependency()
{
git_dependency_parsing $1
echo "--> Compiling $git_dep (branch $git_dep_branch)"
cd "$build_dir"
mkdir -p "$git_dep"
$git_clone -b $git_dep_branch "$git_dep_uri" "$git_dep"
cd "$git_dep"
mkdir -p build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:STRING="$install_dir" \
-DDISABLE_TESTS:BOOL=ON ${CMAKE_ADDITIONAL_OPTIONS}
make install || make
}
_osx_install_dependencies()
{
# Install user-specified packages
brew install cppcheck ${HOMEBREW_DEPENDENCIES}
}
_linux_install_dependencies()
{
# Add additional PPAs
for ppa in ${MASTER_PPA}; do
${SUDO_CMD} add-apt-repository -y ppa:${ppa}
done
${SUDO_CMD} apt-get update -qq
${SUDO_CMD} apt-get install -qq curl cppcheck ${APT_DEPENDENCIES}
# Install lcov from github
cd "$build_dir"
wget https://github.com/linux-test-project/lcov/releases/download/v1.12/lcov-1.12.tar.gz
tar zxvf lcov-1.12.tar.gz
cd lcov-1.12
# Reset lcov to release 1.12
${SUDO_CMD} make install
gem install coveralls-lcov
}
install_dependencies()
{
if [[ ${CI_OS_NAME} = linux ]]; then
_linux_install_dependencies
fi
if [[ ${CI_OS_NAME} = osx ]]; then
_osx_install_dependencies
fi
# and we build directly dependencies from the Git repository
for package in ${ROS_GIT_DEPENDENCIES}; do
catkin_git_dependency "$package"
done
if `test "x${ROS_GIT_DEPENDENCIES}" != x`; then
catkin_build_workspace
fi
for package in ${GIT_DEPENDENCIES}; do
build_git_dependency "$package"
done
}
#########################
# -- Main script -- #
#########################
# Print Git version
git --version
# Setup Git identity.
git config --global user.name "JRL/IDH Continuous Integration Tool"
git config --global user.email "jrl-idh+ci@gmail.com"
# Retrieve the submodules.
git submodule update --quiet --init --recursive
# Fetch tags to compute the distance between the last release tag
# and us.
git fetch --quiet --tags
# Shortcuts.
git_clone="git clone --quiet --recursive"
# Display environment
echo "Environment:"
env
setup_package_source
# Check if we are in a debian branch...
if [ -d debian ]; then
setup_pbuilder
else
if [ ! x${DIST} = x ]; then
echo "skipping this build"
exit 0
fi
install_dependencies
fi
# End debug mode
set +v
set +x