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