Stop building broken debs for our gems. We don't use them and they have
[arvados-dev.git] / jenkins / run-build-packages.sh
1 #!/bin/bash
2
3
4 read -rd "\000" helpmessage <<EOF
5 $(basename $0): Build Arvados packages
6
7 Syntax:
8         WORKSPACE=/path/to/arvados $(basename $0) [options]
9
10 Options:
11
12 --build-bundle-packages  (default: false)
13     Build api server and workbench packages with vendor/bundle included
14 --debug
15     Output debug information (default: false)
16 --target
17     Distribution to build packages for (default: debian7)
18
19 WORKSPACE=path         Path to the Arvados source tree to build packages from
20
21 EOF
22
23 EXITCODE=0
24 DEBUG=${ARVADOS_DEBUG:-0}
25 BUILD_BUNDLE_PACKAGES=0
26 TARGET=debian7
27
28 PARSEDOPTS=$(getopt --name "$0" --longoptions \
29     help,build-bundle-packages,debug,target: \
30     -- "" "$@")
31 if [ $? -ne 0 ]; then
32     exit 1
33 fi
34
35 eval set -- "$PARSEDOPTS"
36 while [ $# -gt 0 ]; do
37     case "$1" in
38         --help)
39             echo >&2 "$helpmessage"
40             echo >&2
41             exit 1
42             ;;
43         --target)
44             TARGET="$2"; shift
45             ;;
46         --debug)
47             DEBUG=1
48             ;;
49         --build-bundle-packages)
50             BUILD_BUNDLE_PACKAGES=1
51             ;;
52         --)
53             if [ $# -gt 1 ]; then
54                 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
55                 exit 1
56             fi
57             ;;
58     esac
59     shift
60 done
61
62 STDOUT_IF_DEBUG=/dev/null
63 STDERR_IF_DEBUG=/dev/null
64 DASHQ_UNLESS_DEBUG=-q
65 if [[ "$DEBUG" != 0 ]]; then
66     STDOUT_IF_DEBUG=/dev/stdout
67     STDERR_IF_DEBUG=/dev/stderr
68     DASHQ_UNLESS_DEBUG=
69 fi
70
71 debug_echo () {
72     echo "$@" >"$STDOUT_IF_DEBUG"
73 }
74
75 declare -a PYTHON_BACKPORTS PYTHON3_BACKPORTS
76
77 PYTHON2_VERSION=2.7
78 PYTHON3_VERSION=$(python3 -c 'import sys; print("{v.major}.{v.minor}".format(v=sys.version_info))')
79
80 case "$TARGET" in
81     debian7)
82         FORMAT=deb
83         PYTHON2_PACKAGE=python$PYTHON2_VERSION
84         PYTHON2_PKG_PREFIX=python
85         PYTHON3_PACKAGE=python$PYTHON3_VERSION
86         PYTHON3_PKG_PREFIX=python3
87         PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
88             oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
89             rsa uritemplate httplib2 ws4py \
90             virtualenv pykka apache-libcloud requests six pyexecjs jsonschema \
91             ciso8601 pycrypto backports.ssl_match_hostname pycurl llfuse)
92         PYTHON3_BACKPORTS=(docker-py six requests websocket-client)
93         ;;
94     debian8)
95         FORMAT=deb
96         PYTHON2_PACKAGE=python$PYTHON2_VERSION
97         PYTHON2_PKG_PREFIX=python
98         PYTHON3_PACKAGE=python$PYTHON3_VERSION
99         PYTHON3_PKG_PREFIX=python3
100         PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
101             oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
102             rsa uritemplate httplib2 ws4py \
103             virtualenv pykka apache-libcloud requests six pyexecjs jsonschema \
104             ciso8601 pycrypto backports.ssl_match_hostname pycurl llfuse)
105         PYTHON3_BACKPORTS=(docker-py six requests websocket-client)
106         ;;
107     ubuntu1204)
108         FORMAT=deb
109         PYTHON2_PACKAGE=python$PYTHON2_VERSION
110         PYTHON2_PKG_PREFIX=python
111         PYTHON3_PACKAGE=python$PYTHON3_VERSION
112         PYTHON3_PKG_PREFIX=python3
113         PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
114             oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
115             rsa uritemplate httplib2 ws4py \
116             virtualenv pykka apache-libcloud requests six pyexecjs jsonschema \
117             ciso8601 pycrypto backports.ssl_match_hostname pycurl llfuse)
118         PYTHON3_BACKPORTS=(docker-py six requests websocket-client)
119         ;;
120     ubuntu1404)
121         FORMAT=deb
122         PYTHON2_PACKAGE=python$PYTHON2_VERSION
123         PYTHON2_PKG_PREFIX=python
124         PYTHON3_PACKAGE=python$PYTHON3_VERSION
125         PYTHON3_PKG_PREFIX=python3
126         PYTHON_BACKPORTS=(pyasn1==0.1.7 pyvcf pyasn1-modules==0.0.5 llfuse ciso8601 \
127             google-api-python-client six uritemplate oauth2client httplib2 \
128             rsa apache-libcloud pycurl backports.ssl_match_hostname)
129         PYTHON3_BACKPORTS=(docker-py requests websocket-client)
130         ;;
131     centos6)
132         FORMAT=rpm
133         PYTHON2_PACKAGE=$(rpm -qf "$(which python$PYTHON2_VERSION)" --queryformat '%{NAME}\n')
134         PYTHON2_PKG_PREFIX=$PYTHON2_PACKAGE
135         PYTHON3_PACKAGE=$(rpm -qf "$(which python$PYTHON3_VERSION)" --queryformat '%{NAME}\n')
136         PYTHON3_PKG_PREFIX=$PYTHON3_PACKAGE
137         PYTHON_BACKPORTS=(python-gflags pyvcf google-api-python-client \
138             oauth2client pyasn1==0.1.7 pyasn1-modules==0.0.5 \
139             rsa uritemplate httplib2 ws4py \
140             pykka apache-libcloud requests six pyexecjs jsonschema \
141             ciso8601 pycrypto backports.ssl_match_hostname pycurl
142             python-daemon lockfile llfuse)
143         PYTHON3_BACKPORTS=(docker-py six requests)
144         export PYCURL_SSL_LIBRARY=nss
145         ;;
146     *)
147         echo -e "$0: Unknown target '$TARGET'.\n" >&2
148         exit 1
149         ;;
150 esac
151
152
153 if ! [[ -n "$WORKSPACE" ]]; then
154   echo >&2 "$helpmessage"
155   echo >&2
156   echo >&2 "Error: WORKSPACE environment variable not set"
157   echo >&2
158   exit 1
159 fi
160
161 # Test for fpm
162 fpm --version >/dev/null 2>&1
163
164 if [[ "$?" != 0 ]]; then
165   echo >&2 "$helpmessage"
166   echo >&2
167   echo >&2 "Error: fpm not found"
168   echo >&2
169   exit 1
170 fi
171
172 find_easy_install() {
173     for version_suffix in "$@"; do
174         if "easy_install$version_suffix" --version >/dev/null 2>&1; then
175             echo "easy_install$version_suffix"
176             return 0
177         fi
178     done
179     cat >&2 <<EOF
180 $helpmessage
181
182 Error: easy_install$1 (from Python setuptools module) not found
183
184 EOF
185     exit 1
186 }
187
188 EASY_INSTALL2=$(find_easy_install -$PYTHON2_VERSION "")
189 EASY_INSTALL3=$(find_easy_install -$PYTHON3_VERSION 3)
190
191 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
192 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`"  # absolutized and normalized
193 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
194   # error; for some reason, the path is not accessible
195   # to the script (e.g. permissions re-evaled after suid)
196   exit 1  # fail
197 fi
198
199 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
200 debug_echo "Workspace is $WORKSPACE"
201
202 format_last_commit_here() {
203     local format=$1; shift
204     TZ=UTC git log -n1 --first-parent "--format=format:$format" .
205 }
206
207 version_from_git() {
208   # Generates a version number from the git log for the current working
209   # directory, and writes it to stdout.
210   local git_ts git_hash
211   declare $(format_last_commit_here "git_ts=%ct git_hash=%h")
212   echo "0.1.$(date -ud "@$git_ts" +%Y%m%d%H%M%S).$git_hash"
213 }
214
215 nohash_version_from_git() {
216     version_from_git | cut -d. -f1-3
217 }
218
219 timestamp_from_git() {
220     format_last_commit_here "%ct"
221 }
222
223 handle_python_package () {
224   # This function assumes the current working directory is the python package directory
225   if [ -n "$(find dist -name "*-$(nohash_version_from_git).tar.gz" -print -quit)" ]; then
226     # This package doesn't need rebuilding.
227     return
228   fi
229   # Make sure only to use sdist - that's the only format pip can deal with (sigh)
230   python setup.py $DASHQ_UNLESS_DEBUG sdist
231 }
232
233 handle_ruby_gem() {
234     local gem_name=$1; shift
235     local gem_version=$(nohash_version_from_git)
236     local gem_src_dir="$(pwd)"
237
238     if ! [[ -e "${gem_name}-${gem_version}.gem" ]]; then
239         find -maxdepth 1 -name "${gem_name}-*.gem" -delete
240
241         # -q appears to be broken in gem version 2.2.2
242         $GEM build "$gem_name.gemspec" $DASHQ_UNLESS_DEBUG >"$STDOUT_IF_DEBUG" 2>"$STDERR_IF_DEBUG"
243     fi
244 }
245
246 # Build packages for everything
247 fpm_build () {
248   # The package source.  Depending on the source type, this can be a
249   # path, or the name of the package in an upstream repository (e.g.,
250   # pip).
251   PACKAGE=$1
252   shift
253   # The name of the package to build.  Defaults to $PACKAGE.
254   PACKAGE_NAME=${1:-$PACKAGE}
255   shift
256   # Optional: the vendor of the package.  Should be "Curoverse, Inc." for
257   # packages of our own software.  Passed to fpm --vendor.
258   VENDOR=$1
259   shift
260   # The type of source package.  Passed to fpm -s.  Default "python".
261   PACKAGE_TYPE=${1:-python}
262   shift
263   # Optional: the package version number.  Passed to fpm -v.
264   VERSION=$1
265   shift
266
267   case "$PACKAGE_TYPE" in
268       python)
269           # All Arvados Python2 packages depend on Python 2.7.
270           # Make sure we build with that for consistency.
271           set -- "$@" --python-bin python2.7 \
272               --python-easyinstall "$EASY_INSTALL2" \
273               --python-package-name-prefix "$PYTHON2_PKG_PREFIX" \
274               --depends "$PYTHON2_PACKAGE"
275           ;;
276       python3)
277           # fpm does not actually support a python3 package type.  Instead
278           # we recognize it as a convenience shortcut to add several
279           # necessary arguments to fpm's command line later, after we're
280           # done handling positional arguments.
281           PACKAGE_TYPE=python
282           set -- "$@" --python-bin python3 \
283               --python-easyinstall "$EASY_INSTALL3" \
284               --python-package-name-prefix "$PYTHON3_PKG_PREFIX" \
285               --depends "$PYTHON3_PACKAGE"
286           ;;
287   esac
288
289   declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward@curoverse.com>" "-s" "$PACKAGE_TYPE" "-t" "$FORMAT")
290   if [ python = "$PACKAGE_TYPE" ]; then
291     COMMAND_ARR+=(--exclude=\*/{dist,site}-packages/tests/\*)
292   fi
293
294   if [[ "$PACKAGE_NAME" != "$PACKAGE" ]]; then
295     COMMAND_ARR+=('-n' "$PACKAGE_NAME")
296   fi
297
298   if [[ "$VENDOR" != "" ]]; then
299     COMMAND_ARR+=('--vendor' "$VENDOR")
300   fi
301
302   if [[ "$VERSION" != "" ]]; then
303     COMMAND_ARR+=('-v' "$VERSION")
304   fi
305
306   # Append remaining function arguments directly to fpm's command line.
307   for i; do
308     COMMAND_ARR+=("$i")
309   done
310
311   # Append --depends X and other arguments specified by fpm-info.sh in
312   # the package source dir. These are added last so they can override
313   # the arguments added by this script.
314   declare -a fpm_args=()
315   declare -a fpm_depends=()
316   if [[ -d "$PACKAGE" ]]; then
317       FPM_INFO="$PACKAGE/fpm-info.sh"
318   else
319       FPM_INFO="${WORKSPACE}/backports/${PACKAGE_TYPE}-${PACKAGE}/fpm-info.sh"
320   fi
321   if [[ -e "$FPM_INFO" ]]; then
322       debug_echo "Loading fpm overrides from $FPM_INFO"
323       source "$FPM_INFO"
324   fi
325   for i in "${fpm_depends[@]}"; do
326     COMMAND_ARR+=('--depends' "$i")
327   done
328   COMMAND_ARR+=("${fpm_args[@]}")
329
330   COMMAND_ARR+=("$PACKAGE")
331
332   debug_echo -e "\n${COMMAND_ARR[@]}\n"
333
334   FPM_RESULTS=$("${COMMAND_ARR[@]}")
335   FPM_EXIT_CODE=$?
336
337   fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
338 }
339
340 # verify build results
341 fpm_verify () {
342   FPM_EXIT_CODE=$1
343   shift
344   FPM_RESULTS=$@
345
346   FPM_PACKAGE_NAME=''
347   if [[ $FPM_RESULTS =~ ([A-Za-z0-9_\.-]*\.)(deb|rpm) ]]; then
348     FPM_PACKAGE_NAME=${BASH_REMATCH[1]}${BASH_REMATCH[2]}
349   fi
350
351   if [[ "$FPM_PACKAGE_NAME" == "" ]]; then
352     EXITCODE=1
353     echo "Error: $PACKAGE: Unable to figure out package name from fpm results:"
354     echo
355     echo $FPM_RESULTS
356     echo
357   elif [[ "$FPM_RESULTS" =~ "File already exists" ]]; then
358     echo "Package $FPM_PACKAGE_NAME exists, not rebuilding"
359   elif [[ 0 -ne "$FPM_EXIT_CODE" ]]; then
360     echo "Error building package for $1:\n $FPM_RESULTS"
361   fi
362 }
363
364 if [[ -f /etc/profile.d/rvm.sh ]]; then
365     source /etc/profile.d/rvm.sh
366     GEM="rvm-exec default gem"
367 else
368     GEM=gem
369 fi
370
371 # Make all files world-readable -- jenkins runs with umask 027, and has checked
372 # out our git tree here
373 chmod o+r "$WORKSPACE" -R
374
375 # More cleanup - make sure all executables that we'll package are 755
376 find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
377
378 # Now fix our umask to something better suited to building and publishing
379 # gems and packages
380 umask 0022
381
382 debug_echo "umask is" `umask`
383
384 if [[ ! -d "$WORKSPACE/packages/$TARGET" ]]; then
385   mkdir -p $WORKSPACE/packages/$TARGET
386 fi
387
388 # Perl packages
389 debug_echo -e "\nPerl packages\n"
390
391 cd "$WORKSPACE/sdk/perl"
392
393 if [[ -e Makefile ]]; then
394   make realclean >"$STDOUT_IF_DEBUG"
395 fi
396 find -maxdepth 1 \( -name 'MANIFEST*' -or -name "libarvados-perl*.$FORMAT" \) \
397     -delete
398 rm -rf install
399
400 perl Makefile.PL INSTALL_BASE=install >"$STDOUT_IF_DEBUG" && \
401     make install INSTALLDIRS=perl >"$STDOUT_IF_DEBUG" && \
402     fpm_build install/lib/=/usr/share libarvados-perl \
403     "Curoverse, Inc." dir "$(version_from_git)" install/man/=/usr/share/man && \
404     mv libarvados-perl*.$FORMAT "$WORKSPACE/packages/$TARGET/"
405
406 # Ruby gems
407 debug_echo -e "\nRuby gems\n"
408
409 FPM_GEM_PREFIX=$($GEM environment gemdir)
410
411 cd "$WORKSPACE/sdk/ruby"
412 handle_ruby_gem arvados
413
414 cd "$WORKSPACE/sdk/cli"
415 handle_ruby_gem arvados-cli
416
417 cd "$WORKSPACE/services/login-sync"
418 handle_ruby_gem arvados-login-sync
419
420 # Python packages
421 debug_echo -e "\nPython packages\n"
422
423 cd "$WORKSPACE/sdk/pam"
424 handle_python_package
425
426 cd "$WORKSPACE/sdk/python"
427 handle_python_package
428
429 cd "$WORKSPACE/services/fuse"
430 handle_python_package
431
432 cd "$WORKSPACE/services/nodemanager"
433 handle_python_package
434
435 # arvados-src
436 (
437     set -e
438
439     cd "$WORKSPACE"
440     COMMIT_HASH=$(format_last_commit_here "%H")
441
442     SRC_BUILD_DIR=$(mktemp -d)
443     git clone $DASHQ_UNLESS_DEBUG "$WORKSPACE/.git" "$SRC_BUILD_DIR"
444     cd "$SRC_BUILD_DIR"
445
446     # go into detached-head state
447     git checkout $DASHQ_UNLESS_DEBUG "$COMMIT_HASH"
448     echo "$COMMIT_HASH" >git-commit.version
449
450     cd "$SRC_BUILD_DIR"
451     PKG_VERSION=$(version_from_git)
452     cd $WORKSPACE/packages/$TARGET
453     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"
454
455     rm -r "$SRC_BUILD_DIR"
456 )
457
458 # Keep
459 export GOPATH=$(mktemp -d)
460 mkdir -p "$GOPATH/src/git.curoverse.com"
461 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git"
462
463 # keepstore
464 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/keepstore"
465 PKG_VERSION=$(version_from_git)
466 go get "git.curoverse.com/arvados.git/services/keepstore"
467 cd $WORKSPACE/packages/$TARGET
468 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"
469
470 # Get GO SDK version
471 cd "$GOPATH/src/git.curoverse.com/arvados.git/sdk/go"
472 GO_SDK_VERSION=$(version_from_git)
473 GO_SDK_TIMESTAMP=$(timestamp_from_git)
474
475 # keepproxy
476 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/keepproxy"
477 KEEPPROXY_VERSION=$(version_from_git)
478 KEEPPROXY_TIMESTAMP=$(timestamp_from_git)
479
480 if [[ "$GO_SDK_TIMESTAMP" -gt "$KEEPPROXY_TIMESTAMP" ]]; then
481   PKG_VERSION=$GO_SDK_VERSION
482 else
483   PKG_VERSION=$KEEPPROXY_VERSION
484 fi
485
486 go get "git.curoverse.com/arvados.git/services/keepproxy"
487 cd $WORKSPACE/packages/$TARGET
488 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"
489
490 # datamanager
491 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/datamanager"
492 DATAMANAGER_VERSION=$(version_from_git)
493 DATAMANAGER_TIMESTAMP=$(timestamp_from_git)
494
495 if [[ "$GO_SDK_TIMESTAMP" -gt "$DATAMANAGER_TIMESTAMP" ]]; then
496   PKG_VERSION=$GO_SDK_VERSION
497 else
498   PKG_VERSION=$DATAMANAGER_VERSION
499 fi
500
501 go get "git.curoverse.com/arvados.git/services/datamanager"
502 cd $WORKSPACE/packages/$TARGET
503 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."
504
505 # arv-git-httpd
506 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/arv-git-httpd"
507 ARVGITHTTPD_VERSION=$(version_from_git)
508 ARVGITHTTPD_TIMESTAMP=$(timestamp_from_git)
509
510 if [[ "$GO_SDK_TIMESTAMP" -gt "$ARVGITHTTPD_TIMESTAMP" ]]; then
511   PKG_VERSION=$GO_SDK_VERSION
512 else
513   PKG_VERSION=$ARVGITHTTPD_VERSION
514 fi
515
516 go get "git.curoverse.com/arvados.git/services/arv-git-httpd"
517 cd $WORKSPACE/packages/$TARGET
518 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."
519
520 # crunchstat
521 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/crunchstat"
522 PKG_VERSION=$(version_from_git)
523 go get "git.curoverse.com/arvados.git/services/crunchstat"
524 cd $WORKSPACE/packages/$TARGET
525 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"
526
527 # The Python SDK
528 # Please resist the temptation to add --no-python-fix-name to the fpm call here
529 # (which would remove the python- prefix from the package name), because this
530 # package is a dependency of arvados-fuse, and fpm can not omit the python-
531 # prefix from only one of the dependencies of a package...  Maybe I could
532 # whip up a patch and send it upstream, but that will be for another day. Ward,
533 # 2014-05-15
534 cd $WORKSPACE/packages/$TARGET
535 rm -rf "$WORKSPACE/sdk/python/build"
536 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
537
538 # The PAM module
539 if [[ $TARGET =~ debian|ubuntu ]]; then
540     cd $WORKSPACE/packages/$TARGET
541     rm -rf "$WORKSPACE/sdk/pam/build"
542     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
543 fi
544
545 # The FUSE driver
546 # Please see comment about --no-python-fix-name above; we stay consistent and do
547 # not omit the python- prefix first.
548 cd $WORKSPACE/packages/$TARGET
549 rm -rf "$WORKSPACE/services/fuse/build"
550 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"
551
552 # The node manager
553 cd $WORKSPACE/packages/$TARGET
554 rm -rf "$WORKSPACE/services/nodemanager/build"
555 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"
556
557 # The Docker image cleaner
558 cd $WORKSPACE/packages/$TARGET
559 rm -rf "$WORKSPACE/services/dockercleaner/build"
560 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"
561
562 # A few dependencies
563 for deppkg in "${PYTHON_BACKPORTS[@]}"; do
564     outname=$(echo "$deppkg" | sed -e 's/^python-//' -e 's/[<=>].*//' -e 's/_/-/g' -e "s/^/${PYTHON2_PKG_PREFIX}-/")
565     fpm_build "$deppkg" "$outname"
566 done
567
568 # Python 3 dependencies
569 for deppkg in "${PYTHON3_BACKPORTS[@]}"; do
570     outname=$(echo "$deppkg" | sed -e 's/^python-//' -e 's/[<=>].*//' -e 's/_/-/g' -e "s/^/${PYTHON3_PKG_PREFIX}-/")
571     # The empty string is the vendor argument: these aren't Curoverse software.
572     fpm_build "$deppkg" "$outname" "" python3
573 done
574
575 # Build the API server package
576
577 cd "$WORKSPACE/services/api"
578
579 API_VERSION=$(version_from_git)
580 PACKAGE_NAME=arvados-api-server
581
582 if [[ ! -d "$WORKSPACE/services/api/tmp" ]]; then
583   mkdir $WORKSPACE/services/api/tmp
584 fi
585
586
587 bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
588
589 /usr/bin/git rev-parse HEAD > git-commit.version
590
591 cd $WORKSPACE/packages/$TARGET
592
593 # Annoyingly, we require a database.yml file for rake assets:precompile to work. So for now,
594 # we do that in the upgrade script.
595 # TODO: add bogus database.yml file so we can precompile the assets and put them in the
596 # package. Then remove that database.yml file again. It has to be a valid file though.
597 #RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile
598
599 # This is the complete package with vendor/bundle included.
600 # It's big, so we do not build it by default.
601 if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
602   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")
603
604   debug_echo -e "\n${COMMAND_ARR[@]}\n"
605
606   FPM_RESULTS=$("${COMMAND_ARR[@]}")
607   FPM_EXIT_CODE=$?
608   fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
609 fi
610
611 # Build the 'bare' package without vendor/bundle.
612 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")
613
614 debug_echo -e "\n${COMMAND_ARR[@]}\n"
615
616 FPM_RESULTS=$("${COMMAND_ARR[@]}")
617 FPM_EXIT_CODE=$?
618 fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
619
620 # API server package build done
621
622 # Build the workbench server package
623
624 cd "$WORKSPACE/apps/workbench"
625
626 WORKBENCH_VERSION=$(version_from_git)
627 PACKAGE_NAME=arvados-workbench
628
629 if [[ ! -d "$WORKSPACE/apps/workbench/tmp" ]]; then
630   mkdir $WORKSPACE/apps/workbench/tmp
631 fi
632
633 bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
634
635 /usr/bin/git rev-parse HEAD > git-commit.version
636
637 # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
638 # and we want that in the package, so it's easier to not exclude the tmp directory
639 # from the package - empty it instead.
640 rm -rf $WORKSPACE/apps/workbench/tmp/*
641
642 # Set up application.yml and production.rb so that asset precompilation works
643 \cp config/application.yml.example config/application.yml -f
644 \cp config/environments/production.rb.example config/environments/production.rb -f
645 sed -i 's/secret_token: ~/secret_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/' config/application.yml
646
647 RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile >/dev/null
648
649 if [[ "$?" != "0" ]]; then
650   echo "ERROR: Asset precompilation failed"
651   EXITCODE=1
652 fi
653
654 cd $WORKSPACE/packages/$TARGET
655
656 # This is the complete package with vendor/bundle included.
657 # It's big, so we do not build it by default.
658 if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
659
660   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")
661
662   debug_echo -e "\n${COMMAND_ARR[@]}\n"
663
664   FPM_RESULTS=$("${COMMAND_ARR[@]}")
665   FPM_EXIT_CODE=$?
666   fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
667 fi
668
669 # Build the 'bare' package without vendor/bundle.
670
671 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")
672
673 debug_echo -e "\n${COMMAND_ARR[@]}\n"
674
675 FPM_RESULTS=$("${COMMAND_ARR[@]}")
676 FPM_EXIT_CODE=$?
677 fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
678
679 # Workbench package build done
680 # clean up temporary GOPATH
681 rm -rf "$GOPATH"
682
683 exit $EXITCODE