4 read -rd "\000" helpmessage <<EOF
5 $(basename $0): Build Arvados packages and (optionally) upload them.
8 WORKSPACE=/path/to/arvados $(basename $0) [options]
13 Upload packages (default: false)
15 scp user for repository server (only required when --upload is specified)
17 scp host for repository server (only required when --upload is specified)
18 --build-bundle-packages (default: false)
19 Build api server and workbench packages with vendor/bundle included
21 Output debug information (default: false)
23 Distribution to build packages for (default: debian7)
25 WORKSPACE=path Path to the Arvados source tree to build packages from
34 BUILD_BUNDLE_PACKAGES=0
37 PARSEDOPTS=$(getopt --name "$0" --longoptions \
38 help,upload,scp-user:,scp-host:,build-bundle-packages,debug,target: \
44 eval set -- "$PARSEDOPTS"
45 while [ $# -gt 0 ]; do
48 echo >&2 "$helpmessage"
67 --build-bundle-packages)
68 BUILD_BUNDLE_PACKAGES=1
72 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
81 if [[ "$UPLOAD" != '0' && ("$SCPUSER" == '' || "$SCPHOST" == '') ]]; then
82 echo >&2 "$helpmessage"
84 echo >&2 "Error: please specify --scp-user and --scp-host if --upload is set"
89 declare -a PYTHON_BACKPORTS PYTHON3_BACKPORTS
92 PYTHON3_VERSION=$(python3 -c 'import sys; print("{v.major}.{v.minor}".format(v=sys.version_info))')
98 REPO_UPDATE_CMD='freight add *deb apt/wheezy && freight cache && rm -f *deb'
100 PYTHON2_PACKAGE=python$PYTHON2_VERSION
101 PYTHON2_PKG_PREFIX=python
102 PYTHON3_PACKAGE=python$PYTHON3_VERSION
103 PYTHON3_PKG_PREFIX=python3
104 PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
105 oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
106 rsa uritemplate httplib2 ws4py \
107 virtualenv pykka apache-libcloud requests six pyexecjs jsonschema \
108 ciso8601 pycrypto backports.ssl_match_hostname pycurl)
109 PYTHON3_BACKPORTS=(docker-py six requests)
114 REPO_UPDATE_CMD='mv *rpm /var/www/rpm.arvados.org/CentOS/6/os/x86_64/ && createrepo /var/www/rpm.arvados.org/CentOS/6/os/x86_64/'
116 PYTHON2_PACKAGE=$(rpm -qf "$(which python$PYTHON2_VERSION)" --queryformat '%{NAME}\n')
117 PYTHON2_PKG_PREFIX=$PYTHON2_PACKAGE
118 PYTHON3_PACKAGE=$(rpm -qf "$(which python$PYTHON3_VERSION)" --queryformat '%{NAME}\n')
119 PYTHON3_PKG_PREFIX=$PYTHON3_PACKAGE
120 PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
121 oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
122 rsa uritemplate httplib2 ws4py \
123 pykka apache-libcloud requests six pyexecjs jsonschema \
124 ciso8601 pycrypto backports.ssl_match_hostname pycurl
126 PYTHON3_BACKPORTS=(docker-py six requests)
127 export PYCURL_SSL_LIBRARY=nss
130 echo -e "$0: Unknown target '$TARGET'.\n" >&2
136 if ! [[ -n "$WORKSPACE" ]]; then
137 echo >&2 "$helpmessage"
139 echo >&2 "Error: WORKSPACE environment variable not set"
145 fpm --version >/dev/null 2>&1
147 if [[ "$?" != 0 ]]; then
148 echo >&2 "$helpmessage"
150 echo >&2 "Error: fpm not found"
155 find_easy_install() {
156 for version_suffix in "$@"; do
157 if "easy_install$version_suffix" --version >/dev/null 2>&1; then
158 echo "easy_install$version_suffix"
165 Error: easy_install$1 (from Python setuptools module) not found
171 EASY_INSTALL2=$(find_easy_install -$PYTHON2_VERSION "")
172 EASY_INSTALL3=$(find_easy_install -$PYTHON3_VERSION 3)
174 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
175 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`" # absolutized and normalized
176 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
177 # error; for some reason, the path is not accessible
178 # to the script (e.g. permissions re-evaled after suid)
182 if [[ "$DEBUG" != 0 ]]; then
183 echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
184 echo "Workspace is $WORKSPACE"
188 # Generates a version number from the git log for the current working
189 # directory, and writes it to stdout.
190 local git_ts git_hash
191 declare $(TZ=UTC git log -n1 --first-parent --max-count=1 \
192 --format=format:"git_ts=%ct git_hash=%h" .)
193 echo "0.1.$(date -ud "@$git_ts" +%Y%m%d%H%M%S).$git_hash"
196 timestamp_from_git() {
197 # Generates a version number from the git log for the current working
198 # directory, and writes it to stdout.
199 local git_ts git_hash
200 declare $(TZ=UTC git log -n1 --first-parent --max-count=1 \
201 --format=format:"git_ts=%ct git_hash=%h" .)
205 handle_python_package () {
206 # This function assumes the current working directory is the python package directory
207 if [[ "$UPLOAD" != 0 ]]; then
208 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
209 if [[ "$DEBUG" != 0 ]]; then
210 python setup.py sdist upload
212 python setup.py -q sdist upload
215 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
216 if [[ "$DEBUG" != 0 ]]; then
217 python setup.py sdist
219 python setup.py -q sdist
224 # Build debs for everything
225 fpm_build_and_scp () {
226 # The package source. Depending on the source type, this can be a
227 # path, or the name of the package in an upstream repository (e.g.,
231 # The name of the package to build. Defaults to $PACKAGE.
232 PACKAGE_NAME=${1:-$PACKAGE}
234 # Optional: the vendor of the package. Should be "Curoverse, Inc." for
235 # packages of our own software. Passed to fpm --vendor.
238 # The type of source package. Passed to fpm -s. Default "python".
239 PACKAGE_TYPE=${1:-python}
241 # Optional: the package version number. Passed to fpm -v.
245 case "$PACKAGE_TYPE" in
247 # All Arvados Python2 packages depend on Python 2.7.
248 # Make sure we build with that for consistency.
249 set -- "$@" --python-bin python2.7 \
250 --python-easyinstall "$EASY_INSTALL2" \
251 --python-package-name-prefix "$PYTHON2_PKG_PREFIX" \
252 --depends "$PYTHON2_PACKAGE"
255 # fpm does not actually support a python3 package type. Instead
256 # we recognize it as a convenience shortcut to add several
257 # necessary arguments to fpm's command line later, after we're
258 # done handling positional arguments.
260 set -- "$@" --python-bin python3 \
261 --python-easyinstall "$EASY_INSTALL3" \
262 --python-package-name-prefix "$PYTHON3_PKG_PREFIX" \
263 --depends "$PYTHON3_PACKAGE"
267 declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward@curoverse.com>" "-s" "$PACKAGE_TYPE" "-t" "$FORMAT")
268 if [ python = "$PACKAGE_TYPE" ]; then
269 COMMAND_ARR+=(--exclude=\*/{dist,site}-packages/tests/\*)
272 if [[ "$PACKAGE_NAME" != "$PACKAGE" ]]; then
273 COMMAND_ARR+=('-n' "$PACKAGE_NAME")
276 if [[ "$VENDOR" != "" ]]; then
277 COMMAND_ARR+=('--vendor' "$VENDOR")
280 if [[ "$VERSION" != "" ]]; then
281 COMMAND_ARR+=('-v' "$VERSION")
284 # Append remaining function arguments directly to fpm's command line.
289 COMMAND_ARR+=("$PACKAGE")
291 if [[ "$DEBUG" != 0 ]]; then
293 echo "${COMMAND_ARR[@]}"
297 FPM_RESULTS=$("${COMMAND_ARR[@]}")
300 fpm_verify_and_scp $FPM_EXIT_CODE $FPM_RESULTS
303 # verify build results and scp debs, if needed
304 fpm_verify_and_scp () {
310 if [[ $FPM_RESULTS =~ ([A-Za-z0-9_\-.]*\.)(deb|rpm) ]]; then
311 FPM_PACKAGE_NAME=${BASH_REMATCH[1]}${BASH_REMATCH[2]}
314 if [[ "$FPM_PACKAGE_NAME" == "" ]]; then
316 echo "Error: $PACKAGE: Unable to figure out package name from fpm results:"
321 if [[ ! $FPM_RESULTS =~ "File already exists" ]]; then
322 if [[ "$FPM_EXIT_CODE" != "0" ]]; then
323 echo "Error building package for $1:\n $FPM_RESULTS"
325 if [[ "$UPLOAD" != 0 ]]; then
326 scp -P2222 $FPM_PACKAGE_NAME $SCPUSER@$SCPHOST:$FPM_OUTDIR/
331 echo "Package $FPM_PACKAGE_NAME exists, not rebuilding"
336 if [[ -f /etc/profile.d/rvm.sh ]]; then
337 source /etc/profile.d/rvm.sh
340 # Make all files world-readable -- jenkins runs with umask 027, and has checked
341 # out our git tree here
342 chmod o+r "$WORKSPACE" -R
344 # More cleanup - make sure all executables that we'll package are 755
345 find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
347 # Now fix our umask to something better suited to building and publishing
351 if [[ "$DEBUG" != 0 ]]; then
352 echo "umask is" `umask`
355 if [[ ! -d "$WORKSPACE/debs" ]]; then
356 mkdir -p $WORKSPACE/debs
360 if [[ "$DEBUG" != 0 ]]; then
361 echo -e "\nPerl packages\n"
364 if [[ "$DEBUG" != 0 ]]; then
370 cd "$WORKSPACE/sdk/perl"
372 if [[ -e Makefile ]]; then
373 make realclean >"$PERL_OUT"
375 find -maxdepth 1 \( -name 'MANIFEST*' -or -name "libarvados-perl*.$FORMAT" \) \
379 perl Makefile.PL INSTALL_BASE=install >"$PERL_OUT" && \
380 make install INSTALLDIRS=perl >"$PERL_OUT" && \
381 fpm_build_and_scp install/lib/=/usr/share libarvados-perl \
382 "Curoverse, Inc." dir "$(version_from_git)" install/man/=/usr/share/man && \
383 mv libarvados-perl*.$FORMAT "$WORKSPACE/debs/"
386 if [[ "$DEBUG" != 0 ]]; then
392 if type rvm-exec >/dev/null 2>&1; then
393 FPM_GEM_PREFIX=$(rvm-exec system gem environment gemdir)
395 FPM_GEM_PREFIX=$(gem environment gemdir)
401 ARVADOS_GEM_EPOCH=`git log -n1 --first-parent --format=%ct`
402 ARVADOS_GEM_DATE=`date --utc --date="@${ARVADOS_GEM_EPOCH}" +%Y%m%d%H%M%S`
403 ARVADOS_GEM_VERSION="0.1.${ARVADOS_GEM_DATE}"
405 # see if this gem needs building/uploading
406 gem search arvados -r -a |grep -q $ARVADOS_GEM_VERSION
408 if [[ "$?" != "0" ]]; then
409 # clean up old packages
410 find -maxdepth 1 \( -name 'arvados-*.gem' -or -name 'rubygem-arvados_*.deb' -or -name 'rubygem-arvados_*.rpm' \) \
413 if [[ "$DEBUG" != 0 ]]; then
414 gem build arvados.gemspec
416 # -q appears to be broken in gem version 2.2.2
417 gem build arvados.gemspec -q >/dev/null 2>&1
420 if [[ "$UPLOAD" != 0 ]]; then
422 gem push arvados-*gem
425 fpm_build_and_scp arvados-*.gem "" "Curoverse, Inc." gem "" \
426 --prefix "$FPM_GEM_PREFIX"
429 # Build arvados-cli GEM
433 ARVADOS_CLI_GEM_EPOCH=`git log -n1 --first-parent --format=%ct`
434 ARVADOS_CLI_GEM_DATE=`date --utc --date="@${ARVADOS_CLI_GEM_EPOCH}" +%Y%m%d%H%M%S`
435 ARVADOS_CLI_GEM_VERSION="0.1.${ARVADOS_CLI_GEM_DATE}"
437 # see if this gem needs building/uploading
438 gem search arvados-cli -r -a |grep -q $ARVADOS_GEM_VERSION
440 if [[ "$?" != "0" ]]; then
442 rm -f arvados-cli*gem
444 if [[ "$DEBUG" != 0 ]]; then
445 gem build arvados-cli.gemspec
447 # -q appears to be broken in gem version 2.2.2
448 gem build arvados-cli.gemspec -q >/dev/null
451 if [[ "$UPLOAD" != 0 ]]; then
453 gem push arvados-cli*gem
458 if [[ "$DEBUG" != 0 ]]; then
460 echo "Python packages"
467 handle_python_package
469 cd ../../services/fuse
470 handle_python_package
472 cd ../../services/nodemanager
473 handle_python_package
476 # We use $WORKSPACE/src-build-dir as the clean directory from which to build the src package
477 if [[ ! -d "$WORKSPACE/src-build-dir" ]]; then
478 mkdir "$WORKSPACE/src-build-dir"
480 if [[ "$DEBUG" != 0 ]]; then
481 git clone https://github.com/curoverse/arvados.git src-build-dir
483 git clone -q https://github.com/curoverse/arvados.git src-build-dir
487 cd "$WORKSPACE/src-build-dir"
488 # just in case, check out master
489 if [[ "$DEBUG" != 0 ]]; then
492 # go into detached-head state
493 git checkout `git log --format=format:%h -n1 .`
495 git checkout -q master
497 # go into detached-head state
498 git checkout -q `git log --format=format:%h -n1 .`
501 git log --format=format:%H -n1 . > git-commit.version
503 # Build arvados src deb package
505 PKG_VERSION=$(version_from_git)
507 fpm_build_and_scp $WORKSPACE/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"
509 # clean up, check out master and step away from detached-head state
510 cd "$WORKSPACE/src-build-dir"
511 if [[ "$DEBUG" != 0 ]]; then
514 git checkout -q master
518 export GOPATH=$(mktemp -d)
519 mkdir -p "$GOPATH/src/git.curoverse.com"
520 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git"
523 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/keepstore"
524 PKG_VERSION=$(version_from_git)
525 go get "git.curoverse.com/arvados.git/services/keepstore"
527 fpm_build_and_scp $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"
530 cd "$GOPATH/src/git.curoverse.com/arvados.git/sdk/go"
531 GO_SDK_VERSION=$(version_from_git)
532 GO_SDK_TIMESTAMP=$(timestamp_from_git)
535 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/keepproxy"
536 KEEPPROXY_VERSION=$(version_from_git)
537 KEEPPROXY_TIMESTAMP=$(timestamp_from_git)
539 if [[ "$GO_SDK_TIMESTAMP" -gt "$KEEPPROXY_TIMESTAMP" ]]; then
540 PKG_VERSION=$GO_SDK_VERSION
542 PKG_VERSION=$KEEPPROXY_VERSION
545 go get "git.curoverse.com/arvados.git/services/keepproxy"
547 fpm_build_and_scp $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"
550 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/datamanager"
551 DATAMANAGER_VERSION=$(version_from_git)
552 DATAMANAGER_TIMESTAMP=$(timestamp_from_git)
554 if [[ "$GO_SDK_TIMESTAMP" -gt "$DATAMANAGER_TIMESTAMP" ]]; then
555 PKG_VERSION=$GO_SDK_VERSION
557 PKG_VERSION=$DATAMANAGER_VERSION
560 go get "git.curoverse.com/arvados.git/services/datamanager"
562 fpm_build_and_scp $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."
565 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/arv-git-httpd"
566 ARVGITHTTPD_VERSION=$(version_from_git)
567 ARVGITHTTPD_TIMESTAMP=$(timestamp_from_git)
569 if [[ "$GO_SDK_TIMESTAMP" -gt "$ARVGITHTTPD_TIMESTAMP" ]]; then
570 PKG_VERSION=$GO_SDK_VERSION
572 PKG_VERSION=$ARVGITHTTPD_VERSION
575 go get "git.curoverse.com/arvados.git/services/arv-git-httpd"
577 fpm_build_and_scp $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."
580 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/crunchstat"
581 PKG_VERSION=$(version_from_git)
582 go get "git.curoverse.com/arvados.git/services/crunchstat"
584 fpm_build_and_scp $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"
587 # Please resist the temptation to add --no-python-fix-name to the fpm call here
588 # (which would remove the python- prefix from the package name), because this
589 # package is a dependency of arvados-fuse, and fpm can not omit the python-
590 # prefix from only one of the dependencies of a package... Maybe I could
591 # whip up a patch and send it upstream, but that will be for another day. Ward,
594 fpm_build_and_scp $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"
597 # Please see comment about --no-python-fix-name above; we stay consistent and do
598 # not omit the python- prefix first.
600 fpm_build_and_scp $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"
604 fpm_build_and_scp $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"
606 # The Docker image cleaner
608 fpm_build_and_scp $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"
611 for deppkg in "${PYTHON_BACKPORTS[@]}"; do
612 outname=$(echo "$deppkg" | sed -e 's/^python-//' -e 's/[<=>].*//' -e 's/_/-/g' -e "s/^/${PYTHON2_PKG_PREFIX}-/")
613 fpm_build_and_scp "$deppkg" "$outname"
616 # Python 3 dependencies
617 for deppkg in "${PYTHON3_BACKPORTS[@]}"; do
618 outname=$(echo "$deppkg" | sed -e 's/^python-//' -e 's/[<=>].*//' -e 's/_/-/g' -e "s/^/${PYTHON3_PKG_PREFIX}-/")
619 # The empty string is the vendor argument: these aren't Curoverse software.
620 fpm_build_and_scp "$deppkg" "$outname" "" python3
623 # Build the API server package
625 cd "$WORKSPACE/services/api"
627 API_VERSION=$(version_from_git)
628 PACKAGE_NAME=arvados-api-server
630 if [[ ! -d "$WORKSPACE/services/api/tmp" ]]; then
631 mkdir $WORKSPACE/services/api/tmp
634 BUNDLE_OUTPUT=`bundle install --path vendor/bundle`
636 if [[ "$DEBUG" != 0 ]]; then
640 /usr/bin/git rev-parse HEAD > git-commit.version
644 # Annoyingly, we require a database.yml file for rake assets:precompile to work. So for now,
645 # we do that in the upgrade script.
646 # TODO: add bogus database.yml file so we can precompile the assets and put them in the
647 # package. Then remove that database.yml file again. It has to be a valid file though.
648 #RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile
650 # This is the complete package with vendor/bundle included.
651 # It's big, so we do not build it by default.
652 if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
653 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")
655 if [[ "$DEBUG" != 0 ]]; then
657 echo "${COMMAND_ARR[@]}"
661 FPM_RESULTS=$("${COMMAND_ARR[@]}")
663 fpm_verify_and_scp $FPM_EXIT_CODE $FPM_RESULTS
666 # Build the 'bare' package without vendor/bundle.
667 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")
669 if [[ "$DEBUG" != 0 ]]; then
671 echo "${COMMAND_ARR[@]}"
675 FPM_RESULTS=$("${COMMAND_ARR[@]}")
677 fpm_verify_and_scp $FPM_EXIT_CODE $FPM_RESULTS
679 # API server package build done
681 # Build the workbench server package
683 cd "$WORKSPACE/apps/workbench"
685 WORKBENCH_VERSION=$(version_from_git)
686 PACKAGE_NAME=arvados-workbench
688 if [[ ! -d "$WORKSPACE/apps/workbench/tmp" ]]; then
689 mkdir $WORKSPACE/apps/workbench/tmp
692 BUNDLE_OUTPUT=`bundle install --path vendor/bundle`
694 if [[ "$DEBUG" != 0 ]]; then
698 /usr/bin/git rev-parse HEAD > git-commit.version
700 # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
701 # and we want that in the package, so it's easier to not exclude the tmp directory
702 # from the package - empty it instead.
703 rm -rf $WORKSPACE/apps/workbench/tmp/*
705 # Set up application.yml so that asset precompilation works
706 \cp config/application.yml.example config/application.yml -f
707 sed -i 's/secret_token: ~/secret_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/' config/application.yml
709 RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile >/dev/null
711 if [[ "$?" != "0" ]]; then
712 echo "ERROR: Asset precompilation failed"
718 # This is the complete package with vendor/bundle included.
719 # It's big, so we do not build it by default.
720 if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
722 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")
724 if [[ "$DEBUG" != 0 ]]; then
726 echo "${COMMAND_ARR[@]}"
730 FPM_RESULTS=$("${COMMAND_ARR[@]}")
732 fpm_verify_and_scp $FPM_EXIT_CODE $FPM_RESULTS
735 # Build the 'bare' package without vendor/bundle.
737 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")
739 if [[ "$DEBUG" != 0 ]]; then
741 echo "${COMMAND_ARR[@]}"
745 FPM_RESULTS=$("${COMMAND_ARR[@]}")
747 fpm_verify_and_scp $FPM_EXIT_CODE $FPM_RESULTS
749 # Workbench package build done
751 # Finally, publish the packages, if necessary
752 if [[ "$UPLOAD" != 0 && "$CALL_FREIGHT" != 0 ]]; then
753 ssh -p2222 $SCPUSER@$SCPHOST -t bash - <<EOF
754 if [ -n "\$(find -name "$FPM_OUTDIR/*.$FORMAT" -print -quit)" ]; then
755 cd "$FPM_OUTDIR" && $REPO_UPDATE_CMD
759 if [[ "$UPLOAD" != 0 ]]; then
760 echo "No new packages generated. No freight run necessary."
764 # clean up temporary GOPATH