Avoid copying mutex after first use.
[arvados.git] / build / build-dev-docker-jobs-image.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 read -rd "\000" helpmessage <<EOF
7 Build an arvados/jobs Docker image from local git tree.
8
9 Intended for use by developers working on arvados-python-client or
10 arvados-cwl-runner and need to run a crunch job with a custom package
11 version.  Also supports building custom cwltool if CWLTOOL is set.
12
13 Syntax:
14         WORKSPACE=/path/to/arvados $(basename $0)
15
16 WORKSPACE=path         Path to the Arvados source tree to build packages from
17 CWLTOOL=path           (optional) Path to cwltool git repository.
18 SALAD=path             (optional) Path to schema_salad git repository.
19
20 EOF
21
22 set -e
23
24 if [[ -z "$WORKSPACE" ]] ; then
25     export WORKSPACE=$(readlink -f $(dirname $0)/..)
26     echo "Using WORKSPACE $WORKSPACE"
27 fi
28
29 if [[ -z "$ARVADOS_API_HOST" || -z "$ARVADOS_API_TOKEN" ]] ; then
30     echo "$helpmessage"
31     echo
32     echo "Must set ARVADOS_API_HOST and ARVADOS_API_TOKEN"
33     exit 1
34 fi
35
36 cd "$WORKSPACE"
37
38 (cd sdk/python && python setup.py sdist)
39 sdk=$(cd sdk/python/dist && ls -t arvados-python-client-*.tar.gz | head -n1)
40
41 (cd sdk/cwl && python setup.py sdist)
42 runner=$(cd sdk/cwl/dist && ls -t arvados-cwl-runner-*.tar.gz | head -n1)
43
44 rm -rf sdk/cwl/salad_dist
45 mkdir -p sdk/cwl/salad_dist
46 if [[ -n "$SALAD" ]] ; then
47     (cd "$SALAD" && python setup.py sdist)
48     salad=$(cd "$SALAD/dist" && ls -t schema-salad-*.tar.gz | head -n1)
49     cp "$SALAD/dist/$salad" $WORKSPACE/sdk/cwl/salad_dist
50 fi
51
52 rm -rf sdk/cwl/cwltool_dist
53 mkdir -p sdk/cwl/cwltool_dist
54 if [[ -n "$CWLTOOL" ]] ; then
55     (cd "$CWLTOOL" && python setup.py sdist)
56     cwltool=$(cd "$CWLTOOL/dist" && ls -t cwltool-*.tar.gz | head -n1)
57     cp "$CWLTOOL/dist/$cwltool" $WORKSPACE/sdk/cwl/cwltool_dist
58 fi
59
60 . build/run-library.sh
61
62 python_sdk_ts=$(cd sdk/python && timestamp_from_git)
63 cwl_runner_ts=$(cd sdk/cwl && timestamp_from_git)
64
65 python_sdk_version=$(cd sdk/python && nohash_version_from_git 0.1)
66 cwl_runner_version=$(cd sdk/cwl && nohash_version_from_git 1.0)
67
68 if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then
69     cwl_runner_version=$(cd sdk/python && nohash_version_from_git 1.0)
70 fi
71
72 docker build --build-arg sdk=$sdk --build-arg runner=$runner --build-arg salad=$salad --build-arg cwltool=$cwltool -f "$WORKSPACE/sdk/dev-jobs.dockerfile" -t arvados/jobs:$cwl_runner_version "$WORKSPACE/sdk"
73 echo arv-keepdocker arvados/jobs $cwl_runner_version
74 arv-keepdocker arvados/jobs $cwl_runner_version