Merge branch 'master' into 10081-cwl-run-same-job
[arvados.git] / build / 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 TARGET=debian7
31 COMMAND=
32
33 PARSEDOPTS=$(getopt --name "$0" --longoptions \
34     help,build-bundle-packages,debug,target: \
35     -- "" "$@")
36 if [ $? -ne 0 ]; then
37     exit 1
38 fi
39
40 eval set -- "$PARSEDOPTS"
41 while [ $# -gt 0 ]; do
42     case "$1" in
43         --help)
44             echo >&2 "$helpmessage"
45             echo >&2
46             exit 1
47             ;;
48         --target)
49             TARGET="$2"; shift
50             ;;
51         --debug)
52             DEBUG=1
53             ;;
54         --command)
55             COMMAND="$2"; shift
56             ;;
57         --)
58             if [ $# -gt 1 ]; then
59                 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
60                 exit 1
61             fi
62             ;;
63     esac
64     shift
65 done
66
67 if [[ "$COMMAND" != "" ]]; then
68   COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET"
69 fi
70
71 STDOUT_IF_DEBUG=/dev/null
72 STDERR_IF_DEBUG=/dev/null
73 DASHQ_UNLESS_DEBUG=-q
74 if [[ "$DEBUG" != 0 ]]; then
75     STDOUT_IF_DEBUG=/dev/stdout
76     STDERR_IF_DEBUG=/dev/stderr
77     DASHQ_UNLESS_DEBUG=
78 fi
79
80 declare -a PYTHON_BACKPORTS PYTHON3_BACKPORTS
81
82 PYTHON2_VERSION=2.7
83 PYTHON3_VERSION=$(python3 -c 'import sys; print("{v.major}.{v.minor}".format(v=sys.version_info))')
84
85 ## These defaults are suitable for any Debian-based distribution.
86 # You can customize them as needed in distro sections below.
87 PYTHON2_PACKAGE=python$PYTHON2_VERSION
88 PYTHON2_PKG_PREFIX=python
89 PYTHON2_PREFIX=/usr
90 PYTHON2_INSTALL_LIB=lib/python$PYTHON2_VERSION/dist-packages
91
92 PYTHON3_PACKAGE=python$PYTHON3_VERSION
93 PYTHON3_PKG_PREFIX=python3
94 PYTHON3_PREFIX=/usr
95 PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/dist-packages
96 ## End Debian Python defaults.
97
98 case "$TARGET" in
99     debian7)
100         FORMAT=deb
101         PYTHON_BACKPORTS=(python-gflags==2.0 google-api-python-client==1.4.2 \
102             oauth2client==1.5.2 pyasn1==0.1.7 pyasn1-modules==0.0.5 \
103             rsa uritemplate httplib2 ws4py pykka six  \
104             ciso8601 pycrypto backports.ssl_match_hostname llfuse==0.41.1 \
105             'pycurl<7.21.5' contextlib2 pyyaml 'rdflib>=4.2.0' \
106             shellescape mistune typing avro ruamel.ordereddict
107             cachecontrol)
108         PYTHON3_BACKPORTS=(docker-py==1.7.2 six requests websocket-client)
109         ;;
110     debian8)
111         FORMAT=deb
112         PYTHON_BACKPORTS=(python-gflags==2.0 google-api-python-client==1.4.2 \
113             oauth2client==1.5.2 pyasn1==0.1.7 pyasn1-modules==0.0.5 \
114             rsa uritemplate httplib2 ws4py pykka six  \
115             ciso8601 pycrypto backports.ssl_match_hostname llfuse==0.41.1 \
116             'pycurl<7.21.5' pyyaml 'rdflib>=4.2.0' \
117             shellescape mistune typing avro ruamel.ordereddict
118             cachecontrol)
119         PYTHON3_BACKPORTS=(docker-py==1.7.2 six requests websocket-client)
120         ;;
121     ubuntu1204)
122         FORMAT=deb
123         PYTHON_BACKPORTS=(python-gflags==2.0 google-api-python-client==1.4.2 \
124             oauth2client==1.5.2 pyasn1==0.1.7 pyasn1-modules==0.0.5 \
125             rsa uritemplate httplib2 ws4py pykka six  \
126             ciso8601 pycrypto backports.ssl_match_hostname llfuse==0.41.1 \
127             contextlib2 'pycurl<7.21.5' pyyaml 'rdflib>=4.2.0' \
128             shellescape mistune typing avro isodate ruamel.ordereddict
129             cachecontrol)
130         PYTHON3_BACKPORTS=(docker-py==1.7.2 six requests websocket-client)
131         ;;
132     ubuntu1404)
133         FORMAT=deb
134         PYTHON_BACKPORTS=(pyasn1==0.1.7 pyasn1-modules==0.0.5 llfuse==0.41.1 ciso8601 \
135             google-api-python-client==1.4.2 six uritemplate oauth2client==1.5.2 httplib2 \
136             rsa 'pycurl<7.21.5' backports.ssl_match_hostname pyyaml 'rdflib>=4.2.0' \
137             shellescape mistune typing avro ruamel.ordereddict
138             cachecontrol)
139         PYTHON3_BACKPORTS=(docker-py==1.7.2 requests websocket-client)
140         ;;
141     centos6)
142         FORMAT=rpm
143         PYTHON2_PACKAGE=$(rpm -qf "$(which python$PYTHON2_VERSION)" --queryformat '%{NAME}\n')
144         PYTHON2_PKG_PREFIX=$PYTHON2_PACKAGE
145         PYTHON2_PREFIX=/opt/rh/python27/root/usr
146         PYTHON2_INSTALL_LIB=lib/python$PYTHON2_VERSION/site-packages
147         PYTHON3_PACKAGE=$(rpm -qf "$(which python$PYTHON3_VERSION)" --queryformat '%{NAME}\n')
148         PYTHON3_PKG_PREFIX=$PYTHON3_PACKAGE
149         PYTHON3_PREFIX=/opt/rh/python33/root/usr
150         PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/site-packages
151         PYTHON_BACKPORTS=(python-gflags==2.0 google-api-python-client==1.4.2 \
152             oauth2client==1.5.2 pyasn1==0.1.7 pyasn1-modules==0.0.5 \
153             rsa uritemplate httplib2 ws4py pykka six  \
154             ciso8601 pycrypto backports.ssl_match_hostname 'pycurl<7.21.5' \
155             python-daemon llfuse==0.41.1 'pbr<1.0' pyyaml \
156             'rdflib>=4.2.0' shellescape mistune typing avro requests \
157             isodate pyparsing sparqlwrapper html5lib==0.9999999 keepalive \
158             ruamel.ordereddict cachecontrol)
159         PYTHON3_BACKPORTS=(docker-py==1.7.2 six requests websocket-client)
160         export PYCURL_SSL_LIBRARY=nss
161         ;;
162     centos7)
163         FORMAT=rpm
164         PYTHON2_PACKAGE=$(rpm -qf "$(which python$PYTHON2_VERSION)" --queryformat '%{NAME}\n')
165         PYTHON2_PKG_PREFIX=$PYTHON2_PACKAGE
166         PYTHON2_INSTALL_LIB=lib/python$PYTHON2_VERSION/site-packages
167         PYTHON3_PACKAGE=$(rpm -qf "$(which python$PYTHON3_VERSION)" --queryformat '%{NAME}\n')
168         PYTHON3_PKG_PREFIX=$PYTHON3_PACKAGE
169         PYTHON3_PREFIX=/opt/rh/python33/root/usr
170         PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/site-packages
171         PYTHON_BACKPORTS=(python-gflags==2.0 google-api-python-client==1.4.2 \
172             oauth2client==1.5.2 pyasn1==0.1.7 pyasn1-modules==0.0.5 \
173             rsa uritemplate httplib2 ws4py pykka  \
174             ciso8601 pycrypto 'pycurl<7.21.5' \
175             python-daemon llfuse==0.41.1 'pbr<1.0' pyyaml \
176             'rdflib>=4.2.0' shellescape mistune typing avro \
177             isodate pyparsing sparqlwrapper html5lib==0.9999999 keepalive \
178             ruamel.ordereddict cachecontrol)
179         PYTHON3_BACKPORTS=(docker-py==1.7.2 six requests websocket-client)
180         export PYCURL_SSL_LIBRARY=nss
181         ;;
182     *)
183         echo -e "$0: Unknown target '$TARGET'.\n" >&2
184         exit 1
185         ;;
186 esac
187
188
189 if ! [[ -n "$WORKSPACE" ]]; then
190   echo >&2 "$helpmessage"
191   echo >&2
192   echo >&2 "Error: WORKSPACE environment variable not set"
193   echo >&2
194   exit 1
195 fi
196
197 # Test for fpm
198 fpm --version >/dev/null 2>&1
199
200 if [[ "$?" != 0 ]]; then
201   echo >&2 "$helpmessage"
202   echo >&2
203   echo >&2 "Error: fpm not found"
204   echo >&2
205   exit 1
206 fi
207
208 EASY_INSTALL2=$(find_easy_install -$PYTHON2_VERSION "")
209 EASY_INSTALL3=$(find_easy_install -$PYTHON3_VERSION 3)
210
211 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
212 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`"  # absolutized and normalized
213 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
214   # error; for some reason, the path is not accessible
215   # to the script (e.g. permissions re-evaled after suid)
216   exit 1  # fail
217 fi
218
219 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
220 debug_echo "Workspace is $WORKSPACE"
221
222 if [[ -f /etc/profile.d/rvm.sh ]]; then
223     source /etc/profile.d/rvm.sh
224     GEM="rvm-exec default gem"
225 else
226     GEM=gem
227 fi
228
229 # Make all files world-readable -- jenkins runs with umask 027, and has checked
230 # out our git tree here
231 chmod o+r "$WORKSPACE" -R
232
233 # More cleanup - make sure all executables that we'll package are 755
234 cd "$WORKSPACE"
235 find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
236
237 # Now fix our umask to something better suited to building and publishing
238 # gems and packages
239 umask 0022
240
241 debug_echo "umask is" `umask`
242
243 if [[ ! -d "$WORKSPACE/packages/$TARGET" ]]; then
244   mkdir -p $WORKSPACE/packages/$TARGET
245   chown --reference="$WORKSPACE" "$WORKSPACE/packages/$TARGET"
246 fi
247
248 # Perl packages
249 debug_echo -e "\nPerl packages\n"
250
251 cd "$WORKSPACE/sdk/perl"
252
253 if [[ -e Makefile ]]; then
254   make realclean >"$STDOUT_IF_DEBUG"
255 fi
256 find -maxdepth 1 \( -name 'MANIFEST*' -or -name "libarvados-perl*.$FORMAT" \) \
257     -delete
258 rm -rf install
259
260 perl Makefile.PL INSTALL_BASE=install >"$STDOUT_IF_DEBUG" && \
261     make install INSTALLDIRS=perl >"$STDOUT_IF_DEBUG" && \
262     fpm_build install/lib/=/usr/share libarvados-perl \
263     "Curoverse, Inc." dir "$(version_from_git)" install/man/=/usr/share/man \
264     "$WORKSPACE/LICENSE-2.0.txt=/usr/share/doc/libarvados-perl/LICENSE-2.0.txt" && \
265     mv --no-clobber libarvados-perl*.$FORMAT "$WORKSPACE/packages/$TARGET/"
266
267 # Ruby gems
268 debug_echo -e "\nRuby gems\n"
269
270 FPM_GEM_PREFIX=$($GEM environment gemdir)
271
272 cd "$WORKSPACE/sdk/ruby"
273 handle_ruby_gem arvados
274
275 cd "$WORKSPACE/sdk/cli"
276 handle_ruby_gem arvados-cli
277
278 cd "$WORKSPACE/services/login-sync"
279 handle_ruby_gem arvados-login-sync
280
281 # Python packages
282 debug_echo -e "\nPython packages\n"
283
284 cd "$WORKSPACE/sdk/pam"
285 handle_python_package
286
287 cd "$WORKSPACE/sdk/python"
288 handle_python_package
289
290 cd "$WORKSPACE/sdk/cwl"
291 handle_python_package
292
293 cd "$WORKSPACE/services/fuse"
294 handle_python_package
295
296 cd "$WORKSPACE/services/nodemanager"
297 handle_python_package
298
299 # arvados-src
300 (
301     set -e
302
303     cd "$WORKSPACE"
304     COMMIT_HASH=$(format_last_commit_here "%H")
305
306     SRC_BUILD_DIR=$(mktemp -d)
307     # mktemp creates the directory with 0700 permissions by default
308     chmod 755 $SRC_BUILD_DIR
309     git clone $DASHQ_UNLESS_DEBUG "$WORKSPACE/.git" "$SRC_BUILD_DIR"
310     cd "$SRC_BUILD_DIR"
311
312     # go into detached-head state
313     git checkout $DASHQ_UNLESS_DEBUG "$COMMIT_HASH"
314     echo "$COMMIT_HASH" >git-commit.version
315
316     cd "$SRC_BUILD_DIR"
317     PKG_VERSION=$(version_from_git)
318     cd $WORKSPACE/packages/$TARGET
319     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"
320
321     rm -rf "$SRC_BUILD_DIR"
322 )
323
324 # On older platforms we need to publish a backport of libfuse >=2.9.2,
325 # and we need to build and install it here in order to even build an
326 # llfuse package.
327 cd $WORKSPACE/packages/$TARGET
328 if [[ $TARGET =~ ubuntu1204 ]]; then
329     # port libfuse 2.9.2 to Ubuntu 12.04
330     LIBFUSE_DIR=$(mktemp -d)
331     (
332         cd $LIBFUSE_DIR
333         # download fuse 2.9.2 ubuntu 14.04 source package
334         file="fuse_2.9.2.orig.tar.xz" && curl -L -o "${file}" "http://archive.ubuntu.com/ubuntu/pool/main/f/fuse/${file}"
335         file="fuse_2.9.2-4ubuntu4.14.04.1.debian.tar.xz" && curl -L -o "${file}" "http://archive.ubuntu.com/ubuntu/pool/main/f/fuse/${file}"
336         file="fuse_2.9.2-4ubuntu4.14.04.1.dsc" && curl -L -o "${file}" "http://archive.ubuntu.com/ubuntu/pool/main/f/fuse/${file}"
337
338         # install dpkg-source and dpkg-buildpackage commands
339         apt-get install -y --no-install-recommends dpkg-dev
340
341         # extract source and apply patches
342         dpkg-source -x fuse_2.9.2-4ubuntu4.14.04.1.dsc
343         rm -f fuse_2.9.2.orig.tar.xz fuse_2.9.2-4ubuntu4.14.04.1.debian.tar.xz fuse_2.9.2-4ubuntu4.14.04.1.dsc
344
345         # add new version to changelog
346         cd fuse-2.9.2
347         (
348             echo "fuse (2.9.2-5) precise; urgency=low"
349             echo
350             echo "  * Backported from trusty-security to precise"
351             echo
352             echo " -- Joshua Randall <jcrandall@alum.mit.edu>  Thu, 4 Feb 2016 11:31:00 -0000"
353             echo
354             cat debian/changelog
355         ) > debian/changelog.new
356         mv debian/changelog.new debian/changelog
357
358         # install build-deps and build
359         apt-get install -y --no-install-recommends debhelper dh-autoreconf libselinux-dev
360         dpkg-buildpackage -rfakeroot -b
361     )
362     fpm_build "$LIBFUSE_DIR/fuse_2.9.2-5_amd64.deb" fuse "Ubuntu Developers" deb "2.9.2" --iteration 5
363     fpm_build "$LIBFUSE_DIR/libfuse2_2.9.2-5_amd64.deb" libfuse2 "Ubuntu Developers" deb "2.9.2" --iteration 5
364     fpm_build "$LIBFUSE_DIR/libfuse-dev_2.9.2-5_amd64.deb" libfuse-dev "Ubuntu Developers" deb "2.9.2" --iteration 5
365     dpkg -i \
366         "$WORKSPACE/packages/$TARGET/fuse_2.9.2-5_amd64.deb" \
367         "$WORKSPACE/packages/$TARGET/libfuse2_2.9.2-5_amd64.deb" \
368         "$WORKSPACE/packages/$TARGET/libfuse-dev_2.9.2-5_amd64.deb"
369     apt-get -y --no-install-recommends -f install
370     rm -rf $LIBFUSE_DIR
371 elif [[ $TARGET =~ centos6 ]]; then
372     # port fuse 2.9.2 to centos 6
373     # install tools to build rpm from source
374     yum install -y rpm-build redhat-rpm-config
375     LIBFUSE_DIR=$(mktemp -d)
376     (
377         cd "$LIBFUSE_DIR"
378         # download fuse 2.9.2 centos 7 source rpm
379         file="fuse-2.9.2-6.el7.src.rpm" && curl -L -o "${file}" "http://vault.centos.org/7.2.1511/os/Source/SPackages/${file}"
380         (
381             # modify source rpm spec to remove conflict on filesystem version
382             mkdir -p /root/rpmbuild/SOURCES
383             cd /root/rpmbuild/SOURCES
384             rpm2cpio ${LIBFUSE_DIR}/fuse-2.9.2-6.el7.src.rpm | cpio -i
385             perl -pi -e 's/Conflicts:\s*filesystem.*//g' fuse.spec
386         )
387         # build rpms from source
388         rpmbuild -bb /root/rpmbuild/SOURCES/fuse.spec
389         rm -f fuse-2.9.2-6.el7.src.rpm
390         # move built RPMs to LIBFUSE_DIR
391         mv "/root/rpmbuild/RPMS/x86_64/fuse-2.9.2-6.el6.x86_64.rpm" ${LIBFUSE_DIR}/
392         mv "/root/rpmbuild/RPMS/x86_64/fuse-libs-2.9.2-6.el6.x86_64.rpm" ${LIBFUSE_DIR}/
393         mv "/root/rpmbuild/RPMS/x86_64/fuse-devel-2.9.2-6.el6.x86_64.rpm" ${LIBFUSE_DIR}/
394         rm -rf /root/rpmbuild
395     )
396     fpm_build "$LIBFUSE_DIR/fuse-libs-2.9.2-6.el6.x86_64.rpm" fuse-libs "Centos Developers" rpm "2.9.2" --iteration 5
397     fpm_build "$LIBFUSE_DIR/fuse-2.9.2-6.el6.x86_64.rpm" fuse "Centos Developers" rpm "2.9.2" --iteration 5 --no-auto-depends
398     fpm_build "$LIBFUSE_DIR/fuse-devel-2.9.2-6.el6.x86_64.rpm" fuse-devel "Centos Developers" rpm "2.9.2" --iteration 5 --no-auto-depends
399     yum install -y \
400         "$WORKSPACE/packages/$TARGET/fuse-libs-2.9.2-5.x86_64.rpm" \
401         "$WORKSPACE/packages/$TARGET/fuse-2.9.2-5.x86_64.rpm" \
402         "$WORKSPACE/packages/$TARGET/fuse-devel-2.9.2-5.x86_64.rpm"
403 fi
404
405 # Go binaries
406 cd $WORKSPACE/packages/$TARGET
407 export GOPATH=$(mktemp -d)
408 package_go_binary sdk/go/crunchrunner crunchrunner \
409     "Crunchrunner executes a command inside a container and uploads the output"
410 package_go_binary services/arv-git-httpd arvados-git-httpd \
411     "Provide authenticated http access to Arvados-hosted git repositories"
412 package_go_binary services/crunch-dispatch-local crunch-dispatch-local \
413     "Dispatch Crunch containers on the local system"
414 package_go_binary services/crunch-dispatch-slurm crunch-dispatch-slurm \
415     "Dispatch Crunch containers to a SLURM cluster"
416 package_go_binary services/crunch-run crunch-run \
417     "Supervise a single Crunch container"
418 package_go_binary services/crunchstat crunchstat \
419     "Gather cpu/memory/network statistics of running Crunch jobs"
420 package_go_binary services/datamanager arvados-data-manager \
421     "Ensure block replication levels, report disk usage, and determine which blocks should be deleted when space is needed"
422 package_go_binary services/keep-balance keep-balance \
423     "Rebalance and garbage-collect data blocks stored in Arvados Keep"
424 package_go_binary services/keepproxy keepproxy \
425     "Make a Keep cluster accessible to clients that are not on the LAN"
426 package_go_binary services/keepstore keepstore \
427     "Keep storage daemon, accessible to clients on the LAN"
428 package_go_binary services/keep-web keep-web \
429     "Static web hosting service for user data stored in Arvados Keep"
430 package_go_binary tools/keep-block-check keep-block-check \
431     "Verify that all data from one set of Keep servers to another was copied"
432 package_go_binary tools/keep-rsync keep-rsync \
433     "Copy all data from one set of Keep servers to another"
434
435 # The Python SDK
436 # Please resist the temptation to add --no-python-fix-name to the fpm call here
437 # (which would remove the python- prefix from the package name), because this
438 # package is a dependency of arvados-fuse, and fpm can not omit the python-
439 # prefix from only one of the dependencies of a package...  Maybe I could
440 # whip up a patch and send it upstream, but that will be for another day. Ward,
441 # 2014-05-15
442 cd $WORKSPACE/packages/$TARGET
443 rm -rf "$WORKSPACE/sdk/python/build"
444 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
445
446 # cwl-runner
447 cd $WORKSPACE/packages/$TARGET
448 rm -rf "$WORKSPACE/sdk/cwl/build"
449 fpm_build $WORKSPACE/sdk/cwl "${PYTHON2_PKG_PREFIX}-arvados-cwl-runner" 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/sdk/cwl/arvados_cwl_runner.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados CWL runner" --iteration 3
450
451 fpm_build lockfile "" "" python 0.12.2 --epoch 1
452
453 # schema_salad. This is a python dependency of arvados-cwl-runner,
454 # but we can't use the usual PYTHONPACKAGES way to build this package due to the
455 # intricacies of how version numbers get generated in setup.py: we need version
456 # 1.7.20160316203940. If we don't explicitly list that version with the -v
457 # argument to fpm, and instead specify it as schema_salad==1.7.20160316203940, we get
458 # a package with version 1.7. That's because our gittagger hack is not being
459 # picked up by self.distribution.get_version(), which is called from
460 # https://github.com/jordansissel/fpm/blob/master/lib/fpm/package/pyfpm/get_metadata.py
461 # by means of this command:
462 #
463 # python2.7 setup.py --command-packages=pyfpm get_metadata --output=metadata.json
464 #
465 # So we build this thing separately.
466 #
467 # Ward, 2016-03-17
468 fpm_build schema_salad "" "" python 1.18.20160907135919 --depends "${PYTHON2_PKG_PREFIX}-lockfile >= 1:0.12.2-2"
469
470 # And schema_salad now depends on ruamel-yaml, which apparently has a braindead setup.py that requires special arguments to build (otherwise, it aborts with 'error: you have to install with "pip install ."'). Sigh.
471 # Ward, 2016-05-26
472 fpm_build ruamel.yaml "" "" python 0.12.4 --python-setup-py-arguments "--single-version-externally-managed"
473
474 # Dependency of cwltool.  Fpm doesn't produce a package with the correct version
475 # number unless we build it explicitly
476 fpm_build cwltest "" "" python 1.0.20160907111242
477
478 # And for cwltool we have the same problem as for schema_salad. Ward, 2016-03-17
479 fpm_build cwltool "" "" python 1.0.20160922135240
480
481 # FPM eats the trailing .0 in the python-rdflib-jsonld package when built with 'rdflib-jsonld>=0.3.0'. Force the version. Ward, 2016-03-25
482 fpm_build rdflib-jsonld "" "" python 0.3.0
483
484 # The PAM module
485 if [[ $TARGET =~ debian|ubuntu ]]; then
486     cd $WORKSPACE/packages/$TARGET
487     rm -rf "$WORKSPACE/sdk/pam/build"
488     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
489 fi
490
491 # The FUSE driver
492 # Please see comment about --no-python-fix-name above; we stay consistent and do
493 # not omit the python- prefix first.
494 cd $WORKSPACE/packages/$TARGET
495 rm -rf "$WORKSPACE/services/fuse/build"
496 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"
497
498 # The node manager
499 cd $WORKSPACE/packages/$TARGET
500 rm -rf "$WORKSPACE/services/nodemanager/build"
501 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"
502
503 # The Docker image cleaner
504 cd $WORKSPACE/packages/$TARGET
505 rm -rf "$WORKSPACE/services/dockercleaner/build"
506 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"
507
508 # The Arvados crunchstat-summary tool
509 cd $WORKSPACE/packages/$TARGET
510 rm -rf "$WORKSPACE/tools/crunchstat-summary/build"
511 fpm_build $WORKSPACE/tools/crunchstat-summary ${PYTHON2_PKG_PREFIX}-crunchstat-summary 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/tools/crunchstat-summary/crunchstat_summary.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=Crunchstat-summary reads Arvados Crunch log files and summarize resource usage"
512
513 # Forked libcloud
514 LIBCLOUD_DIR=$(mktemp -d)
515 (
516     cd $LIBCLOUD_DIR
517     git clone $DASHQ_UNLESS_DEBUG https://github.com/curoverse/libcloud.git .
518     git checkout apache-libcloud-$LIBCLOUD_PIN
519     # libcloud is absurdly noisy without -q, so force -q here
520     OLD_DASHQ_UNLESS_DEBUG=$DASHQ_UNLESS_DEBUG
521     DASHQ_UNLESS_DEBUG=-q
522     handle_python_package
523     DASHQ_UNLESS_DEBUG=$OLD_DASHQ_UNLESS_DEBUG
524 )
525 fpm_build $LIBCLOUD_DIR "$PYTHON2_PKG_PREFIX"-apache-libcloud
526 rm -rf $LIBCLOUD_DIR
527
528 # Python 2 dependencies
529 declare -a PIP_DOWNLOAD_SWITCHES=(--no-deps)
530 # Add --no-use-wheel if this pip knows it.
531 pip wheel --help >/dev/null 2>&1
532 case "$?" in
533     0) PIP_DOWNLOAD_SWITCHES+=(--no-use-wheel) ;;
534     2) ;;
535     *) echo "WARNING: `pip wheel` test returned unknown exit code $?" ;;
536 esac
537
538 for deppkg in "${PYTHON_BACKPORTS[@]}"; do
539     outname=$(echo "$deppkg" | sed -e 's/^python-//' -e 's/[<=>].*//' -e 's/_/-/g' -e "s/^/${PYTHON2_PKG_PREFIX}-/")
540     case "$deppkg" in
541         httplib2|google-api-python-client)
542             # Work around 0640 permissions on some package files.
543             # See #7591 and #7991.
544             pyfpm_workdir=$(mktemp --tmpdir -d pyfpm-XXXXXX) && (
545                 set -e
546                 cd "$pyfpm_workdir"
547                 pip install "${PIP_DOWNLOAD_SWITCHES[@]}" --download . "$deppkg"
548                 # Sometimes pip gives us a tarball, sometimes a zip file...
549                 DOWNLOADED=`ls $deppkg-*`
550                 [[ "$DOWNLOADED" =~ ".tar" ]] && tar -xf $DOWNLOADED
551                 [[ "$DOWNLOADED" =~ ".zip" ]] && unzip $DOWNLOADED
552                 cd "$deppkg"-*/
553                 "python$PYTHON2_VERSION" setup.py $DASHQ_UNLESS_DEBUG egg_info build
554                 chmod -R go+rX .
555                 set +e
556                 fpm_build . "$outname" "" python "" --iteration 3
557                 # The upload step uses the package timestamp to determine
558                 # whether it's new.  --no-clobber plays nice with that.
559                 mv --no-clobber "$outname"*.$FORMAT "$WORKSPACE/packages/$TARGET"
560             )
561             if [ 0 != "$?" ]; then
562                 echo "ERROR: $deppkg build process failed"
563                 EXITCODE=1
564             fi
565             if [ -n "$pyfpm_workdir" ]; then
566                 rm -rf "$pyfpm_workdir"
567             fi
568             ;;
569         *)
570             fpm_build "$deppkg" "$outname"
571             ;;
572     esac
573 done
574
575 # Python 3 dependencies
576 for deppkg in "${PYTHON3_BACKPORTS[@]}"; do
577     outname=$(echo "$deppkg" | sed -e 's/^python-//' -e 's/[<=>].*//' -e 's/_/-/g' -e "s/^/${PYTHON3_PKG_PREFIX}-/")
578     # The empty string is the vendor argument: these aren't Curoverse software.
579     fpm_build "$deppkg" "$outname" "" python3
580 done
581
582 # Build the API server package
583 handle_rails_package arvados-api-server "$WORKSPACE/services/api" \
584     "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
585     --description="Arvados API server - Arvados is a free and open source platform for big data science." \
586     --license="GNU Affero General Public License, version 3.0"
587
588 # Build the workbench server package
589 (
590     set -e
591     cd "$WORKSPACE/apps/workbench"
592
593     # We need to bundle to be ready even when we build a package without vendor directory
594     # because asset compilation requires it.
595     bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
596
597     # clear the tmp directory; the asset generation step will recreate tmp/cache/assets,
598     # and we want that in the package, so it's easier to not exclude the tmp directory
599     # from the package - empty it instead.
600     rm -rf tmp
601     mkdir tmp
602
603     # Set up application.yml and production.rb so that asset precompilation works
604     \cp config/application.yml.example config/application.yml -f
605     \cp config/environments/production.rb.example config/environments/production.rb -f
606     sed -i 's/secret_token: ~/secret_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/' config/application.yml
607
608     RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile >/dev/null
609
610     # Remove generated configuration files so they don't go in the package.
611     rm config/application.yml config/environments/production.rb
612 )
613
614 if [[ "$?" != "0" ]]; then
615   echo "ERROR: Asset precompilation failed"
616   EXITCODE=1
617 else
618   handle_rails_package arvados-workbench "$WORKSPACE/apps/workbench" \
619       "$WORKSPACE/agpl-3.0.txt" --url="https://arvados.org" \
620       --description="Arvados Workbench - Arvados is a free and open source platform for big data science." \
621       --license="GNU Affero General Public License, version 3.0"
622 fi
623
624 # clean up temporary GOPATH
625 rm -rf "$GOPATH"
626
627 exit $EXITCODE