5824: Merge branch 'master' into 5824-keep-web-workbench
[arvados-dev.git] / jenkins / run-build-packages.sh
1 #!/bin/bash
2
3 . `dirname "$(readlink -f "$0")"`/run-library.sh
4 . `dirname "$(readlink -f "$0")"`/libcloud-pin
5
6 read -rd "\000" helpmessage <<EOF
7 $(basename $0): Build Arvados packages
8
9 Syntax:
10         WORKSPACE=/path/to/arvados $(basename $0) [options]
11
12 Options:
13
14 --build-bundle-packages  (default: false)
15     Build api server and workbench packages with vendor/bundle included
16 --debug
17     Output debug information (default: false)
18 --target
19     Distribution to build packages for (default: debian7)
20 --command
21     Build command to execute (defaults to the run command defined in the
22     Docker image)
23
24 WORKSPACE=path         Path to the Arvados source tree to build packages from
25
26 EOF
27
28 EXITCODE=0
29 DEBUG=${ARVADOS_DEBUG:-0}
30 BUILD_BUNDLE_PACKAGES=0
31 TARGET=debian7
32 COMMAND=
33
34 PARSEDOPTS=$(getopt --name "$0" --longoptions \
35     help,build-bundle-packages,debug,target: \
36     -- "" "$@")
37 if [ $? -ne 0 ]; then
38     exit 1
39 fi
40
41 eval set -- "$PARSEDOPTS"
42 while [ $# -gt 0 ]; do
43     case "$1" in
44         --help)
45             echo >&2 "$helpmessage"
46             echo >&2
47             exit 1
48             ;;
49         --target)
50             TARGET="$2"; shift
51             ;;
52         --debug)
53             DEBUG=1
54             ;;
55         --build-bundle-packages)
56             BUILD_BUNDLE_PACKAGES=1
57             ;;
58         --command)
59             COMMAND="$2"; shift
60             ;;
61         --)
62             if [ $# -gt 1 ]; then
63                 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
64                 exit 1
65             fi
66             ;;
67     esac
68     shift
69 done
70
71 if [[ "$COMMAND" != "" ]]; then
72   COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET"
73 fi
74
75 STDOUT_IF_DEBUG=/dev/null
76 STDERR_IF_DEBUG=/dev/null
77 DASHQ_UNLESS_DEBUG=-q
78 if [[ "$DEBUG" != 0 ]]; then
79     STDOUT_IF_DEBUG=/dev/stdout
80     STDERR_IF_DEBUG=/dev/stderr
81     DASHQ_UNLESS_DEBUG=
82 fi
83
84 declare -a PYTHON_BACKPORTS PYTHON3_BACKPORTS
85
86 PYTHON2_VERSION=2.7
87 PYTHON3_VERSION=$(python3 -c 'import sys; print("{v.major}.{v.minor}".format(v=sys.version_info))')
88
89 case "$TARGET" in
90     debian7)
91         FORMAT=deb
92         PYTHON2_PACKAGE=python$PYTHON2_VERSION
93         PYTHON2_PKG_PREFIX=python
94         PYTHON3_PACKAGE=python$PYTHON3_VERSION
95         PYTHON3_PKG_PREFIX=python3
96         PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
97             oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
98             rsa uritemplate httplib2 ws4py \
99             pykka requests six pyexecjs jsonschema \
100             ciso8601 pycrypto backports.ssl_match_hostname pycurl llfuse)
101         PYTHON3_BACKPORTS=(docker-py six requests websocket-client)
102         ;;
103     debian8)
104         FORMAT=deb
105         PYTHON2_PACKAGE=python$PYTHON2_VERSION
106         PYTHON2_PKG_PREFIX=python
107         PYTHON3_PACKAGE=python$PYTHON3_VERSION
108         PYTHON3_PKG_PREFIX=python3
109         PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
110             oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
111             rsa uritemplate httplib2 ws4py \
112             pykka requests six pyexecjs jsonschema \
113             ciso8601 pycrypto backports.ssl_match_hostname pycurl llfuse)
114         PYTHON3_BACKPORTS=(docker-py six requests websocket-client)
115         ;;
116     ubuntu1204)
117         FORMAT=deb
118         PYTHON2_PACKAGE=python$PYTHON2_VERSION
119         PYTHON2_PKG_PREFIX=python
120         PYTHON3_PACKAGE=python$PYTHON3_VERSION
121         PYTHON3_PKG_PREFIX=python3
122         PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
123             oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
124             rsa uritemplate httplib2 ws4py \
125             pykka requests six pyexecjs jsonschema \
126             ciso8601 pycrypto backports.ssl_match_hostname pycurl llfuse)
127         PYTHON3_BACKPORTS=(docker-py six requests websocket-client)
128         ;;
129     ubuntu1404)
130         FORMAT=deb
131         PYTHON2_PACKAGE=python$PYTHON2_VERSION
132         PYTHON2_PKG_PREFIX=python
133         PYTHON3_PACKAGE=python$PYTHON3_VERSION
134         PYTHON3_PKG_PREFIX=python3
135         PYTHON_BACKPORTS=(pyasn1==0.1.7 pyvcf pyasn1-modules==0.0.5 llfuse ciso8601 \
136             google-api-python-client six uritemplate oauth2client httplib2 \
137             rsa pycurl backports.ssl_match_hostname)
138         PYTHON3_BACKPORTS=(docker-py requests websocket-client)
139         ;;
140     centos6)
141         FORMAT=rpm
142         PYTHON2_PACKAGE=$(rpm -qf "$(which python$PYTHON2_VERSION)" --queryformat '%{NAME}\n')
143         PYTHON2_PKG_PREFIX=$PYTHON2_PACKAGE
144         PYTHON3_PACKAGE=$(rpm -qf "$(which python$PYTHON3_VERSION)" --queryformat '%{NAME}\n')
145         PYTHON3_PKG_PREFIX=$PYTHON3_PACKAGE
146         PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
147             oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
148             rsa uritemplate httplib2 ws4py \
149             pykka requests six pyexecjs jsonschema \
150             ciso8601 pycrypto backports.ssl_match_hostname pycurl
151             python-daemon lockfile llfuse 'pbr<1.0')
152         PYTHON3_BACKPORTS=(docker-py six requests websocket-client)
153         export PYCURL_SSL_LIBRARY=nss
154         ;;
155     *)
156         echo -e "$0: Unknown target '$TARGET'.\n" >&2
157         exit 1
158         ;;
159 esac
160
161
162 if ! [[ -n "$WORKSPACE" ]]; then
163   echo >&2 "$helpmessage"
164   echo >&2
165   echo >&2 "Error: WORKSPACE environment variable not set"
166   echo >&2
167   exit 1
168 fi
169
170 # Test for fpm
171 fpm --version >/dev/null 2>&1
172
173 if [[ "$?" != 0 ]]; then
174   echo >&2 "$helpmessage"
175   echo >&2
176   echo >&2 "Error: fpm not found"
177   echo >&2
178   exit 1
179 fi
180
181 EASY_INSTALL2=$(find_easy_install -$PYTHON2_VERSION "")
182 EASY_INSTALL3=$(find_easy_install -$PYTHON3_VERSION 3)
183
184 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
185 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`"  # absolutized and normalized
186 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
187   # error; for some reason, the path is not accessible
188   # to the script (e.g. permissions re-evaled after suid)
189   exit 1  # fail
190 fi
191
192 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
193 debug_echo "Workspace is $WORKSPACE"
194
195 if [[ -f /etc/profile.d/rvm.sh ]]; then
196     source /etc/profile.d/rvm.sh
197     GEM="rvm-exec default gem"
198 else
199     GEM=gem
200 fi
201
202 # Make all files world-readable -- jenkins runs with umask 027, and has checked
203 # out our git tree here
204 chmod o+r "$WORKSPACE" -R
205
206 # More cleanup - make sure all executables that we'll package are 755
207 find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
208
209 # Now fix our umask to something better suited to building and publishing
210 # gems and packages
211 umask 0022
212
213 debug_echo "umask is" `umask`
214
215 if [[ ! -d "$WORKSPACE/packages/$TARGET" ]]; then
216   mkdir -p $WORKSPACE/packages/$TARGET
217 fi
218
219 # Perl packages
220 debug_echo -e "\nPerl packages\n"
221
222 cd "$WORKSPACE/sdk/perl"
223
224 if [[ -e Makefile ]]; then
225   make realclean >"$STDOUT_IF_DEBUG"
226 fi
227 find -maxdepth 1 \( -name 'MANIFEST*' -or -name "libarvados-perl*.$FORMAT" \) \
228     -delete
229 rm -rf install
230
231 perl Makefile.PL INSTALL_BASE=install >"$STDOUT_IF_DEBUG" && \
232     make install INSTALLDIRS=perl >"$STDOUT_IF_DEBUG" && \
233     fpm_build install/lib/=/usr/share libarvados-perl \
234     "Curoverse, Inc." dir "$(version_from_git)" install/man/=/usr/share/man && \
235     mv libarvados-perl*.$FORMAT "$WORKSPACE/packages/$TARGET/"
236
237 # Ruby gems
238 debug_echo -e "\nRuby gems\n"
239
240 FPM_GEM_PREFIX=$($GEM environment gemdir)
241
242 cd "$WORKSPACE/sdk/ruby"
243 handle_ruby_gem arvados
244
245 cd "$WORKSPACE/sdk/cli"
246 handle_ruby_gem arvados-cli
247
248 cd "$WORKSPACE/services/login-sync"
249 handle_ruby_gem arvados-login-sync
250
251 # Python packages
252 debug_echo -e "\nPython packages\n"
253
254 cd "$WORKSPACE/sdk/pam"
255 handle_python_package
256
257 cd "$WORKSPACE/sdk/python"
258 handle_python_package
259
260 cd "$WORKSPACE/services/fuse"
261 handle_python_package
262
263 cd "$WORKSPACE/services/nodemanager"
264 handle_python_package
265
266 # arvados-src
267 (
268     set -e
269
270     cd "$WORKSPACE"
271     COMMIT_HASH=$(format_last_commit_here "%H")
272
273     SRC_BUILD_DIR=$(mktemp -d)
274     # mktemp creates the directory with 0700 permissions by default
275     chmod 755 $SRC_BUILD_DIR
276     git clone $DASHQ_UNLESS_DEBUG "$WORKSPACE/.git" "$SRC_BUILD_DIR"
277     cd "$SRC_BUILD_DIR"
278
279     # go into detached-head state
280     git checkout $DASHQ_UNLESS_DEBUG "$COMMIT_HASH"
281     echo "$COMMIT_HASH" >git-commit.version
282
283     cd "$SRC_BUILD_DIR"
284     PKG_VERSION=$(version_from_git)
285     cd $WORKSPACE/packages/$TARGET
286     fpm_build $SRC_BUILD_DIR/=/usr/local/arvados/src arvados-src 'Curoverse, Inc.' '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"
287
288     rm -r "$SRC_BUILD_DIR"
289 )
290
291 # Keep
292 export GOPATH=$(mktemp -d)
293 mkdir -p "$GOPATH/src/git.curoverse.com"
294 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git"
295
296 # keepstore
297 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/keepstore"
298 PKG_VERSION=$(version_from_git)
299 go get "git.curoverse.com/arvados.git/services/keepstore"
300 cd $WORKSPACE/packages/$TARGET
301 fpm_build $GOPATH/bin/keepstore=/usr/bin/keepstore keepstore 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Keepstore is the Keep storage daemon, accessible to clients on the LAN"
302
303 # Get GO SDK version
304 cd "$GOPATH/src/git.curoverse.com/arvados.git/sdk/go"
305 GO_SDK_VERSION=$(version_from_git)
306 GO_SDK_TIMESTAMP=$(timestamp_from_git)
307
308 # keepproxy
309 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/keepproxy"
310 KEEPPROXY_VERSION=$(version_from_git)
311 KEEPPROXY_TIMESTAMP=$(timestamp_from_git)
312
313 if [[ "$GO_SDK_TIMESTAMP" -gt "$KEEPPROXY_TIMESTAMP" ]]; then
314   PKG_VERSION=$GO_SDK_VERSION
315 else
316   PKG_VERSION=$KEEPPROXY_VERSION
317 fi
318
319 go get "git.curoverse.com/arvados.git/services/keepproxy"
320 cd $WORKSPACE/packages/$TARGET
321 fpm_build $GOPATH/bin/keepproxy=/usr/bin/keepproxy keepproxy 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Keepproxy makes a Keep cluster accessible to clients that are not on the LAN"
322
323 # keep-web
324 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/keep-web"
325 KEEP_WEB_VERSION=$(version_from_git)
326 KEEP_WEB_TIMESTAMP=$(timestamp_from_git)
327
328 if [[ "$GO_SDK_TIMESTAMP" -gt "$KEEP_WEB_TIMESTAMP" ]]; then
329   PKG_VERSION=$GO_SDK_VERSION
330 else
331   PKG_VERSION=$KEEP_WEB_VERSION
332 fi
333
334 go get "git.curoverse.com/arvados.git/services/keep-web"
335 cd $WORKSPACE/packages/$TARGET
336 fpm_build $GOPATH/bin/keep-web=/usr/bin/keep-web keep-web 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Static web hosting service for user data stored in Arvados Keep"
337
338 # datamanager
339 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/datamanager"
340 DATAMANAGER_VERSION=$(version_from_git)
341 DATAMANAGER_TIMESTAMP=$(timestamp_from_git)
342
343 if [[ "$GO_SDK_TIMESTAMP" -gt "$DATAMANAGER_TIMESTAMP" ]]; then
344   PKG_VERSION=$GO_SDK_VERSION
345 else
346   PKG_VERSION=$DATAMANAGER_VERSION
347 fi
348
349 go get "git.curoverse.com/arvados.git/services/datamanager"
350 cd $WORKSPACE/packages/$TARGET
351 fpm_build $GOPATH/bin/datamanager=/usr/bin/arvados-data-manager arvados-data-manager 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Datamanager ensures block replication levels, reports on disk usage and determines which blocks should be deleted when space is needed."
352
353 # arv-git-httpd
354 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/arv-git-httpd"
355 ARVGITHTTPD_VERSION=$(version_from_git)
356 ARVGITHTTPD_TIMESTAMP=$(timestamp_from_git)
357
358 if [[ "$GO_SDK_TIMESTAMP" -gt "$ARVGITHTTPD_TIMESTAMP" ]]; then
359   PKG_VERSION=$GO_SDK_VERSION
360 else
361   PKG_VERSION=$ARVGITHTTPD_VERSION
362 fi
363
364 go get "git.curoverse.com/arvados.git/services/arv-git-httpd"
365 cd $WORKSPACE/packages/$TARGET
366 fpm_build $GOPATH/bin/arv-git-httpd=/usr/bin/arvados-git-httpd arvados-git-httpd 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Provides authenticated http access to Arvados-hosted git repositories."
367
368 # crunchstat
369 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/crunchstat"
370 PKG_VERSION=$(version_from_git)
371 go get "git.curoverse.com/arvados.git/services/crunchstat"
372 cd $WORKSPACE/packages/$TARGET
373 fpm_build $GOPATH/bin/crunchstat=/usr/bin/crunchstat crunchstat 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Crunchstat gathers cpu/memory/network statistics of running Crunch jobs"
374
375 # The Python SDK
376 # Please resist the temptation to add --no-python-fix-name to the fpm call here
377 # (which would remove the python- prefix from the package name), because this
378 # package is a dependency of arvados-fuse, and fpm can not omit the python-
379 # prefix from only one of the dependencies of a package...  Maybe I could
380 # whip up a patch and send it upstream, but that will be for another day. Ward,
381 # 2014-05-15
382 cd $WORKSPACE/packages/$TARGET
383 rm -rf "$WORKSPACE/sdk/python/build"
384 fpm_build $WORKSPACE/sdk/python "${PYTHON2_PKG_PREFIX}-arvados-python-client" 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/sdk/python/arvados_python_client.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados Python SDK" --deb-recommends=git
385
386 # The PAM module
387 if [[ $TARGET =~ debian|ubuntu ]]; then
388     cd $WORKSPACE/packages/$TARGET
389     rm -rf "$WORKSPACE/sdk/pam/build"
390     fpm_build $WORKSPACE/sdk/pam libpam-arvados 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/sdk/pam/arvados_pam.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=PAM module for authenticating shell logins using Arvados API tokens" --depends libpam-python
391 fi
392
393 # The FUSE driver
394 # Please see comment about --no-python-fix-name above; we stay consistent and do
395 # not omit the python- prefix first.
396 cd $WORKSPACE/packages/$TARGET
397 rm -rf "$WORKSPACE/services/fuse/build"
398 fpm_build $WORKSPACE/services/fuse "${PYTHON2_PKG_PREFIX}-arvados-fuse" 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/services/fuse/arvados_fuse.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Keep FUSE driver"
399
400 # The node manager
401 cd $WORKSPACE/packages/$TARGET
402 rm -rf "$WORKSPACE/services/nodemanager/build"
403 fpm_build $WORKSPACE/services/nodemanager arvados-node-manager 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/services/nodemanager/arvados_node_manager.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados node manager"
404
405 # The Docker image cleaner
406 cd $WORKSPACE/packages/$TARGET
407 rm -rf "$WORKSPACE/services/dockercleaner/build"
408 fpm_build $WORKSPACE/services/dockercleaner arvados-docker-cleaner 'Curoverse, Inc.' 'python3' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/services/dockercleaner/arvados_docker_cleaner.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados Docker image cleaner"
409
410 # Forked libcloud
411 LIBCLOUD_DIR=$(mktemp -d)
412 (
413     cd $LIBCLOUD_DIR
414     git clone $DASHQ_UNLESS_DEBUG https://github.com/curoverse/libcloud.git .
415     git checkout apache-libcloud-$LIBCLOUD_PIN
416     # libcloud is absurdly noisy without -q, so force -q here
417     OLD_DASHQ_UNLESS_DEBUG=$DASHQ_UNLESS_DEBUG
418     DASHQ_UNLESS_DEBUG=-q
419     handle_python_package
420     DASHQ_UNLESS_DEBUG=$OLD_DASHQ_UNLESS_DEBUG
421 )
422 fpm_build $LIBCLOUD_DIR "$PYTHON2_PKG_PREFIX"-apache-libcloud
423 rm -rf $LIBCLOUD_DIR
424
425 # A few dependencies
426 for deppkg in "${PYTHON_BACKPORTS[@]}"; do
427     outname=$(echo "$deppkg" | sed -e 's/^python-//' -e 's/[<=>].*//' -e 's/_/-/g' -e "s/^/${PYTHON2_PKG_PREFIX}-/")
428     fpm_build "$deppkg" "$outname"
429 done
430
431 # Python 3 dependencies
432 for deppkg in "${PYTHON3_BACKPORTS[@]}"; do
433     outname=$(echo "$deppkg" | sed -e 's/^python-//' -e 's/[<=>].*//' -e 's/_/-/g' -e "s/^/${PYTHON3_PKG_PREFIX}-/")
434     # The empty string is the vendor argument: these aren't Curoverse software.
435     fpm_build "$deppkg" "$outname" "" python3
436 done
437
438 # Build the API server package
439
440 cd "$WORKSPACE/services/api"
441
442 API_VERSION=$(version_from_git)
443 PACKAGE_NAME=arvados-api-server
444
445 if [[ ! -d "$WORKSPACE/services/api/tmp" ]]; then
446   mkdir $WORKSPACE/services/api/tmp
447 fi
448
449
450 if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
451   bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
452 fi
453
454 /usr/bin/git rev-parse HEAD > git-commit.version
455
456 cd $WORKSPACE/packages/$TARGET
457
458 # Annoyingly, we require a database.yml file for rake assets:precompile to work. So for now,
459 # we do that in the upgrade script.
460 # TODO: add bogus database.yml file so we can precompile the assets and put them in the
461 # package. Then remove that database.yml file again. It has to be a valid file though.
462 #RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile
463
464 # This is the complete package with vendor/bundle included.
465 # It's big, so we do not build it by default.
466 if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
467   declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward@curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados API server - Arvados is a free and open source platform for big data science.'" "--license='GNU Affero General Public License, version 3.0'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}-with-bundle" "-v" "$API_VERSION" "-x" "var/www/arvados-api/current/tmp" "-x" "var/www/arvados-api/current/log" "-x" "var/www/arvados-api/current/vendor/cache/*" "-x" "var/www/arvados-api/current/coverage" "-x" "var/www/arvados-api/current/Capfile*" "-x" "var/www/arvados-api/current/config/deploy*" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-api-server-extras/postinst.sh" "$WORKSPACE/services/api/=/var/www/arvados-api/current" "$RUN_BUILD_PACKAGES_PATH/arvados-api-server-extras/arvados-api-server-upgrade.sh=/usr/local/bin/arvados-api-server-upgrade.sh")
468
469   debug_echo -e "\n${COMMAND_ARR[@]}\n"
470
471   FPM_RESULTS=$("${COMMAND_ARR[@]}")
472   FPM_EXIT_CODE=$?
473   fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
474 fi
475
476 # Build the 'bare' package without vendor/bundle.
477 declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward@curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados API server - Arvados is a free and open source platform for big data science.'" "--license='GNU Affero General Public License, version 3.0'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}" "-v" "$API_VERSION" "-x" "var/www/arvados-api/current/tmp" "-x" "var/www/arvados-api/current/log" "-x" "var/www/arvados-api/current/vendor/bundle" "-x" "var/www/arvados-api/current/vendor/cache/*" "-x" "var/www/arvados-api/current/coverage" "-x" "var/www/arvados-api/current/Capfile*" "-x" "var/www/arvados-api/current/config/deploy*" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-api-server-extras/postinst.sh" "$WORKSPACE/services/api/=/var/www/arvados-api/current" "$RUN_BUILD_PACKAGES_PATH/arvados-api-server-extras/arvados-api-server-upgrade.sh=/usr/local/bin/arvados-api-server-upgrade.sh")
478
479 debug_echo -e "\n${COMMAND_ARR[@]}\n"
480
481 FPM_RESULTS=$("${COMMAND_ARR[@]}")
482 FPM_EXIT_CODE=$?
483 fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
484
485 # API server package build done
486
487 # Build the workbench server package
488
489 cd "$WORKSPACE/apps/workbench"
490
491 WORKBENCH_VERSION=$(version_from_git)
492 PACKAGE_NAME=arvados-workbench
493
494 if [[ ! -d "$WORKSPACE/apps/workbench/tmp" ]]; then
495   mkdir $WORKSPACE/apps/workbench/tmp
496 fi
497
498 # We need to bundle to be ready even when we build a package without vendor directory
499 # because asset compilation requires it.
500 bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
501
502 /usr/bin/git rev-parse HEAD > git-commit.version
503
504 # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
505 # and we want that in the package, so it's easier to not exclude the tmp directory
506 # from the package - empty it instead.
507 rm -rf $WORKSPACE/apps/workbench/tmp/*
508
509 # Set up application.yml and production.rb so that asset precompilation works
510 \cp config/application.yml.example config/application.yml -f
511 \cp config/environments/production.rb.example config/environments/production.rb -f
512 sed -i 's/secret_token: ~/secret_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/' config/application.yml
513
514 RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile >/dev/null
515
516 if [[ "$?" != "0" ]]; then
517   echo "ERROR: Asset precompilation failed"
518   EXITCODE=1
519 fi
520
521 cd $WORKSPACE/packages/$TARGET
522
523 # This is the complete package with vendor/bundle included.
524 # It's big, so we do not build it by default.
525 if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
526
527   declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward@curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados Workbench - Arvados is a free and open source platform for big data science.'" "--license='GNU Affero General Public License, version 3.0'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}-with-bundle" "-v" "$WORKBENCH_VERSION" "-x" "var/www/arvados-workbench/current/log" "-x" "var/www/arvados-workbench/current/vendor/cache/*" "-x" "var/www/arvados-workbench/current/coverage" "-x" "var/www/arvados-workbench/current/Capfile*" "-x" "var/www/arvados-workbench/current/config/deploy*" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-workbench-extras/postinst.sh" "$WORKSPACE/apps/workbench/=/var/www/arvados-workbench/current" "$RUN_BUILD_PACKAGES_PATH/arvados-workbench-extras/arvados-workbench-upgrade.sh=/usr/local/bin/arvados-workbench-upgrade.sh")
528
529   debug_echo -e "\n${COMMAND_ARR[@]}\n"
530
531   FPM_RESULTS=$("${COMMAND_ARR[@]}")
532   FPM_EXIT_CODE=$?
533   fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
534 fi
535
536 # Build the 'bare' package without vendor/bundle.
537
538 declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward@curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados Workbench - Arvados is a free and open source platform for big data science.'" "--license='GNU Affero General Public License, version 3.0'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}" "-v" "$WORKBENCH_VERSION" "-x" "var/www/arvados-workbench/current/log" "-x" "var/www/arvados-workbench/current/vendor/bundle" "-x" "var/www/arvados-workbench/current/vendor/cache/*" "-x" "var/www/arvados-workbench/current/coverage" "-x" "var/www/arvados-workbench/current/Capfile*" "-x" "var/www/arvados-workbench/current/config/deploy*" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-workbench-extras/postinst.sh" "$WORKSPACE/apps/workbench/=/var/www/arvados-workbench/current" "$RUN_BUILD_PACKAGES_PATH/arvados-workbench-extras/arvados-workbench-upgrade.sh=/usr/local/bin/arvados-workbench-upgrade.sh")
539
540 debug_echo -e "\n${COMMAND_ARR[@]}\n"
541
542 FPM_RESULTS=$("${COMMAND_ARR[@]}")
543 FPM_EXIT_CODE=$?
544 fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
545
546 # Workbench package build done
547 # clean up temporary GOPATH
548 rm -rf "$GOPATH"
549
550 exit $EXITCODE