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: debian8)
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-python35/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 sdk/go/crunchrunner crunchrunner \
294 "Crunchrunner executes a command inside a container and uploads the output"
295 package_go_binary services/arv-git-httpd arvados-git-httpd \
296 "Provide authenticated http access to Arvados-hosted git repositories"
297 package_go_binary services/crunch-dispatch-local crunch-dispatch-local \
298 "Dispatch Crunch containers on the local system"
299 package_go_binary services/crunch-dispatch-slurm crunch-dispatch-slurm \
300 "Dispatch Crunch containers to a SLURM cluster"
301 package_go_binary services/crunch-run crunch-run \
302 "Supervise a single Crunch container"
303 package_go_binary services/crunchstat crunchstat \
304 "Gather cpu/memory/network statistics of running Crunch jobs"
305 package_go_binary services/health arvados-health \
306 "Check health of all Arvados cluster services"
307 package_go_binary services/keep-balance keep-balance \
308 "Rebalance and garbage-collect data blocks stored in Arvados Keep"
309 package_go_binary services/keepproxy keepproxy \
310 "Make a Keep cluster accessible to clients that are not on the LAN"
311 package_go_binary services/keepstore keepstore \
312 "Keep storage daemon, accessible to clients on the LAN"
313 package_go_binary services/keep-web keep-web \
314 "Static web hosting service for user data stored in Arvados Keep"
315 package_go_binary services/ws arvados-ws \
316 "Arvados Websocket server"
317 package_go_binary tools/sync-groups arvados-sync-groups \
318 "Synchronize remote groups into Arvados from an external source"
319 package_go_binary tools/keep-block-check keep-block-check \
320 "Verify that all data from one set of Keep servers to another was copied"
321 package_go_binary tools/keep-rsync keep-rsync \
322 "Copy all data from one set of Keep servers to another"
323 package_go_binary tools/keep-exercise keep-exercise \
324 "Performance testing tool for Arvados Keep"
327 fpm_build_virtualenv "arvados-python-client" "sdk/python"
328 fpm_build_virtualenv "arvados-python-client" "sdk/python" "python3"
331 fpm_build_virtualenv "arvados-cwl-runner" "sdk/cwl"
334 fpm_build_virtualenv "libpam-arvados" "sdk/pam"
337 fpm_build_virtualenv "arvados-fuse" "services/fuse"
340 fpm_build_virtualenv "arvados-node-manager" "services/nodemanager"
342 # The Docker image cleaner
343 fpm_build_virtualenv "arvados-docker-cleaner" "services/dockercleaner" "python3"
345 # The Arvados crunchstat-summary tool
346 fpm_build_virtualenv "crunchstat-summary" "tools/crunchstat-summary"
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 # Build the API server package
360 test_rails_package_presence arvados-api-server "$WORKSPACE/services/api"
361 if [[ "$?" == "0" ]]; then
362 handle_rails_package arvados-api-server "$WORKSPACE/services/api" \
363 "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
364 --description="Arvados API server - Arvados is a free and open source platform for big data science." \
365 --license="GNU Affero General Public License, version 3.0"
368 # Build the workbench server package
369 test_rails_package_presence arvados-workbench "$WORKSPACE/apps/workbench"
370 if [[ "$?" == "0" ]] ; then
373 cd "$WORKSPACE/apps/workbench"
375 # We need to bundle to be ready even when we build a package without vendor directory
376 # because asset compilation requires it.
377 bundle install --system >"$STDOUT_IF_DEBUG"
379 # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
380 # and we want that in the package, so it's easier to not exclude the tmp directory
381 # from the package - empty it instead.
385 # Set up application.yml and production.rb so that asset precompilation works
386 \cp config/application.yml.example config/application.yml -f
387 \cp config/environments/production.rb.example config/environments/production.rb -f
388 sed -i 's/secret_token: ~/secret_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/' config/application.yml
389 sed -i 's/keep_web_url: false/keep_web_url: exampledotcom/' config/application.yml
391 RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake npm:install >/dev/null
392 RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile >/dev/null
394 # Remove generated configuration files so they don't go in the package.
395 rm config/application.yml config/environments/production.rb
398 if [[ "$?" != "0" ]]; then
399 echo "ERROR: Asset precompilation failed"
402 handle_rails_package arvados-workbench "$WORKSPACE/apps/workbench" \
403 "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
404 --description="Arvados Workbench - Arvados is a free and open source platform for big data science." \
405 --license="GNU Affero General Public License, version 3.0"
409 # clean up temporary GOPATH