2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 . `dirname "$(readlink -f "$0")"`/run-library.sh
7 . `dirname "$(readlink -f "$0")"`/libcloud-pin.sh
9 read -rd "\000" helpmessage <<EOF
10 $(basename $0): Build Arvados packages
13 WORKSPACE=/path/to/arvados $(basename $0) [options]
17 --build-bundle-packages (default: false)
18 Build api server and workbench packages with vendor/bundle included
20 Output debug information (default: false)
22 Distribution to build packages for (default: debian9)
23 --only-build <package>
24 Build only a specific package (or $ONLY_BUILD from environment)
26 Build command to execute (defaults to the run command defined in the
29 WORKSPACE=path Path to the Arvados source tree to build packages from
33 # Begin of user configuration
35 # set to --no-cache-dir to disable pip caching
38 MAINTAINER="Ward Vandewege <wvandewege@veritasgenetics.com>"
39 VENDOR="Veritas Genetics, Inc."
41 # End of user configuration
43 DEBUG=${ARVADOS_DEBUG:-0}
48 PARSEDOPTS=$(getopt --name "$0" --longoptions \
49 help,build-bundle-packages,debug,target:,only-build: \
55 eval set -- "$PARSEDOPTS"
56 while [ $# -gt 0 ]; do
59 echo >&2 "$helpmessage"
67 ONLY_BUILD="$2"; shift
77 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
85 if [[ "$COMMAND" != "" ]]; then
86 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET"
89 STDOUT_IF_DEBUG=/dev/null
90 STDERR_IF_DEBUG=/dev/null
92 if [[ "$DEBUG" != 0 ]]; then
93 STDOUT_IF_DEBUG=/dev/stdout
94 STDERR_IF_DEBUG=/dev/stderr
98 declare -a PYTHON_BACKPORTS PYTHON3_BACKPORTS
101 PYTHON3_VERSION=$(python3 -c 'import sys; print("{v.major}.{v.minor}".format(v=sys.version_info))')
103 ## These defaults are suitable for any Debian-based distribution.
104 # You can customize them as needed in distro sections below.
105 PYTHON2_PACKAGE=python$PYTHON2_VERSION
106 PYTHON2_PKG_PREFIX=python
108 PYTHON2_INSTALL_LIB=lib/python$PYTHON2_VERSION/dist-packages
110 PYTHON3_PACKAGE=python$PYTHON3_VERSION
111 PYTHON3_PKG_PREFIX=python3
113 PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/dist-packages
114 ## End Debian Python defaults.
125 PYTHON2_PACKAGE=$(rpm -qf "$(which python$PYTHON2_VERSION)" --queryformat '%{NAME}\n')
126 PYTHON2_PKG_PREFIX=$PYTHON2_PACKAGE
127 PYTHON2_INSTALL_LIB=lib/python$PYTHON2_VERSION/site-packages
128 PYTHON3_PACKAGE=$(rpm -qf "$(which python$PYTHON3_VERSION)" --queryformat '%{NAME}\n')
129 PYTHON3_PKG_PREFIX=$PYTHON3_PACKAGE
130 PYTHON3_PREFIX=/opt/rh/rh-python36/root/usr
131 PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/site-packages
132 export PYCURL_SSL_LIBRARY=nss
135 echo -e "$0: Unknown target '$TARGET'.\n" >&2
141 if ! [[ -n "$WORKSPACE" ]]; then
142 echo >&2 "$helpmessage"
144 echo >&2 "Error: WORKSPACE environment variable not set"
150 fpm --version >/dev/null 2>&1
152 if [[ "$?" != 0 ]]; then
153 echo >&2 "$helpmessage"
155 echo >&2 "Error: fpm not found"
160 PYTHON2_FPM_INSTALLER=(--python-easyinstall "$(find_python_program easy_install-$PYTHON2_VERSION easy_install)")
161 install3=$(find_python_program easy_install-$PYTHON3_VERSION easy_install3 pip-$PYTHON3_VERSION pip3)
162 if [[ $install3 =~ easy_ ]]; then
163 PYTHON3_FPM_INSTALLER=(--python-easyinstall "$install3")
165 PYTHON3_FPM_INSTALLER=(--python-pip "$install3")
168 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
169 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`" # absolutized and normalized
170 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
171 # error; for some reason, the path is not accessible
172 # to the script (e.g. permissions re-evaled after suid)
176 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
177 debug_echo "Workspace is $WORKSPACE"
179 if [[ -f /etc/profile.d/rvm.sh ]]; then
180 source /etc/profile.d/rvm.sh
181 GEM="rvm-exec default gem"
186 # Make all files world-readable -- jenkins runs with umask 027, and has checked
187 # out our git tree here
188 chmod o+r "$WORKSPACE" -R
190 # More cleanup - make sure all executables that we'll package are 755
192 find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
194 # Now fix our umask to something better suited to building and publishing
198 debug_echo "umask is" `umask`
200 if [[ ! -d "$WORKSPACE/packages/$TARGET" ]]; then
201 mkdir -p $WORKSPACE/packages/$TARGET
202 chown --reference="$WORKSPACE" "$WORKSPACE/packages/$TARGET"
206 debug_echo -e "\nPerl packages\n"
208 if [[ -z "$ONLY_BUILD" ]] || [[ "libarvados-perl" = "$ONLY_BUILD" ]] ; then
209 cd "$WORKSPACE/sdk/perl"
210 libarvados_perl_version="$(version_from_git)"
212 cd $WORKSPACE/packages/$TARGET
213 test_package_presence libarvados-perl "$libarvados_perl_version"
215 if [[ "$?" == "0" ]]; then
216 cd "$WORKSPACE/sdk/perl"
218 if [[ -e Makefile ]]; then
219 make realclean >"$STDOUT_IF_DEBUG"
221 find -maxdepth 1 \( -name 'MANIFEST*' -or -name "libarvados-perl*.$FORMAT" \) \
225 perl Makefile.PL INSTALL_BASE=install >"$STDOUT_IF_DEBUG" && \
226 make install INSTALLDIRS=perl >"$STDOUT_IF_DEBUG" && \
227 fpm_build install/lib/=/usr/share libarvados-perl \
228 dir "$(version_from_git)" install/man/=/usr/share/man \
229 "$WORKSPACE/apache-2.0.txt=/usr/share/doc/libarvados-perl/apache-2.0.txt" && \
230 mv --no-clobber libarvados-perl*.$FORMAT "$WORKSPACE/packages/$TARGET/"
235 debug_echo -e "\nRuby gems\n"
237 FPM_GEM_PREFIX=$($GEM environment gemdir)
239 cd "$WORKSPACE/sdk/ruby"
240 handle_ruby_gem arvados
242 cd "$WORKSPACE/sdk/cli"
243 handle_ruby_gem arvados-cli
245 cd "$WORKSPACE/services/login-sync"
246 handle_ruby_gem arvados-login-sync
249 debug_echo -e "\nPython packages\n"
254 COMMIT_HASH=$(format_last_commit_here "%H")
255 arvados_src_version="$(version_from_git)"
257 cd $WORKSPACE/packages/$TARGET
258 test_package_presence arvados-src $arvados_src_version src ""
260 if [[ "$?" == "0" ]]; then
262 SRC_BUILD_DIR=$(mktemp -d)
263 # mktemp creates the directory with 0700 permissions by default
264 chmod 755 $SRC_BUILD_DIR
265 git clone $DASHQ_UNLESS_DEBUG "$WORKSPACE/.git" "$SRC_BUILD_DIR"
268 # go into detached-head state
269 git checkout $DASHQ_UNLESS_DEBUG "$COMMIT_HASH"
270 echo "$COMMIT_HASH" >git-commit.version
273 PKG_VERSION=$(version_from_git)
274 cd $WORKSPACE/packages/$TARGET
275 fpm_build $SRC_BUILD_DIR/=/usr/local/arvados/src arvados-src 'dir' "$PKG_VERSION" "--exclude=usr/local/arvados/src/.git" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=The Arvados source code" "--architecture=all"
277 rm -rf "$SRC_BUILD_DIR"
282 cd $WORKSPACE/packages/$TARGET
283 export GOPATH=$(mktemp -d)
284 go get github.com/kardianos/govendor
285 package_go_binary cmd/arvados-client arvados-client \
286 "Arvados command line tool (beta)"
287 package_go_binary cmd/arvados-server arvados-server \
288 "Arvados server daemons"
289 package_go_binary cmd/arvados-server arvados-controller \
290 "Arvados cluster controller daemon"
291 package_go_binary cmd/arvados-server arvados-dispatch-cloud \
292 "Arvados cluster cloud dispatch"
293 package_go_binary services/arv-git-httpd arvados-git-httpd \
294 "Provide authenticated http access to Arvados-hosted git repositories"
295 package_go_binary services/crunch-dispatch-local crunch-dispatch-local \
296 "Dispatch Crunch containers on the local system"
297 package_go_binary services/crunch-dispatch-slurm crunch-dispatch-slurm \
298 "Dispatch Crunch containers to a SLURM cluster"
299 package_go_binary services/crunch-run crunch-run \
300 "Supervise a single Crunch container"
301 package_go_binary services/crunchstat crunchstat \
302 "Gather cpu/memory/network statistics of running Crunch jobs"
303 package_go_binary services/health arvados-health \
304 "Check health of all Arvados cluster services"
305 package_go_binary services/keep-balance keep-balance \
306 "Rebalance and garbage-collect data blocks stored in Arvados Keep"
307 package_go_binary services/keepproxy keepproxy \
308 "Make a Keep cluster accessible to clients that are not on the LAN"
309 package_go_binary services/keepstore keepstore \
310 "Keep storage daemon, accessible to clients on the LAN"
311 package_go_binary services/keep-web keep-web \
312 "Static web hosting service for user data stored in Arvados Keep"
313 package_go_binary services/ws arvados-ws \
314 "Arvados Websocket server"
315 package_go_binary tools/sync-groups arvados-sync-groups \
316 "Synchronize remote groups into Arvados from an external source"
317 package_go_binary tools/keep-block-check keep-block-check \
318 "Verify that all data from one set of Keep servers to another was copied"
319 package_go_binary tools/keep-rsync keep-rsync \
320 "Copy all data from one set of Keep servers to another"
321 package_go_binary tools/keep-exercise keep-exercise \
322 "Performance testing tool for Arvados Keep"
324 # The Python SDK - Should be built first because it's needed by others
325 fpm_build_virtualenv "arvados-python-client" "sdk/python"
328 fpm_build_virtualenv "arvados-cwl-runner" "sdk/cwl"
331 fpm_build_virtualenv "libpam-arvados" "sdk/pam"
334 fpm_build_virtualenv "arvados-fuse" "services/fuse"
337 fpm_build_virtualenv "arvados-node-manager" "services/nodemanager"
339 # The Arvados crunchstat-summary tool
340 fpm_build_virtualenv "crunchstat-summary" "tools/crunchstat-summary"
342 # The Python SDK - Python3 package
343 fpm_build_virtualenv "arvados-python-client" "sdk/python" "python3"
345 # The Docker image cleaner
346 fpm_build_virtualenv "arvados-docker-cleaner" "services/dockercleaner" "python3"
348 # The cwltest package, which lives out of tree
350 if [[ -e "$WORKSPACE/cwltest" ]]; then
351 rm -rf "$WORKSPACE/cwltest"
353 git clone https://github.com/common-workflow-language/cwltest.git
354 # signal to our build script that we want a cwltest executable installed in /usr/bin/
355 mkdir cwltest/bin && touch cwltest/bin/cwltest
356 fpm_build_virtualenv "cwltest" "cwltest"
357 rm -rf "$WORKSPACE/cwltest"
359 calculate_go_package_version arvados_server_version cmd/arvados-server
360 arvados_server_iteration=$(default_iteration "arvados-server" "$arvados_server_version" "go")
362 # Build the API server package
363 test_rails_package_presence arvados-api-server "$WORKSPACE/services/api"
364 if [[ "$?" == "0" ]]; then
365 handle_rails_package arvados-api-server "$WORKSPACE/services/api" \
366 "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
367 --description="Arvados API server - Arvados is a free and open source platform for big data science." \
368 --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
371 # Build the workbench server package
372 test_rails_package_presence arvados-workbench "$WORKSPACE/apps/workbench"
373 if [[ "$?" == "0" ]] ; then
377 # The workbench package has a build-time dependency on the arvados-server
378 # package for config manipulation, so install it first.
379 cd $WORKSPACE/cmd/arvados-server
380 get_complete_package_name arvados_server_pkgname arvados-server ${arvados_server_version} go
382 arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/${arvados_server_pkgname}"
383 if [[ ! -e ${arvados_server_pkg_path} ]]; then
384 arvados_server_pkg_path="$WORKSPACE/packages/$TARGET/processed/${arvados_server_pkgname}"
386 if [[ "$FORMAT" == "deb" ]]; then
387 dpkg -i ${arvados_server_pkg_path}
389 rpm -i ${arvados_server_pkg_path}
392 cd "$WORKSPACE/apps/workbench"
394 # We need to bundle to be ready even when we build a package without vendor directory
395 # because asset compilation requires it.
396 bundle install --system >"$STDOUT_IF_DEBUG"
398 # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
399 # and we want that in the package, so it's easier to not exclude the tmp directory
400 # from the package - empty it instead.
404 # Set up an appropriate config.yml
405 arvados-server config-dump -config <(cat /etc/arvados/config.yml 2>/dev/null || echo "Clusters: {zzzzz: {}}") > /tmp/x
406 mkdir -p /etc/arvados/
407 mv /tmp/x /etc/arvados/config.yml
408 perl -p -i -e 'BEGIN{undef $/;} s/WebDAV(.*?):\n( *)ExternalURL: ""/WebDAV$1:\n$2ExternalURL: "example.com"/g' /etc/arvados/config.yml
410 RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake npm:install >"$STDOUT_IF_DEBUG"
411 RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile >"$STDOUT_IF_DEBUG"
413 # Remove generated configuration files so they don't go in the package.
417 if [[ "$?" != "0" ]]; then
418 echo "ERROR: Asset precompilation failed"
421 handle_rails_package arvados-workbench "$WORKSPACE/apps/workbench" \
422 "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
423 --description="Arvados Workbench - Arvados is a free and open source platform for big data science." \
424 --license="GNU Affero General Public License, version 3.0" --depends "arvados-server = ${arvados_server_version}-${arvados_server_iteration}"
428 # clean up temporary GOPATH