2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
8 . `dirname "$(readlink -f "$0")"`/run-library.sh
10 read -rd "\000" helpmessage <<EOF
11 $(basename $0): Build Arvados Python packages and Ruby gems
14 WORKSPACE=/path/to/arvados $(basename $0) [options]
19 Output debug information (default: false)
21 If the build and test steps are successful, upload the python
22 packages to pypi and the gems to rubygems (default: false)
24 Build ruby gems (default: true)
26 Build python packages (default: true)
28 WORKSPACE=path Path to the Arvados source tree to build packages from
39 local gem_name="$1"; shift
40 local gem_directory="$1"; shift
42 title "Start $gem_name gem build"
46 handle_ruby_gem $gem_name
48 checkexit $? "$gem_name gem build"
49 title "End of $gem_name gem build (`timer`)"
52 handle_python_package () {
53 # This function assumes the current working directory is the python package directory
54 if [ -n "$(find dist -name "*-$(nohash_version_from_git).tar.gz" -print -quit)" ]; then
55 echo "This package doesn't need rebuilding."
58 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
59 python3 setup.py $DASHQ_UNLESS_DEBUG sdist
63 local package_name="$1"; shift
64 local package_directory="$1"; shift
66 title "Start $package_name python package build"
69 cd "$package_directory"
70 if [[ $DEBUG > 0 ]]; then
75 checkexit $? "$package_name python package build"
76 title "End of $package_name python package build (`timer`)"
83 DEBUG=${ARVADOS_DEBUG:-0}
85 PARSEDOPTS=$(getopt --name "$0" --longoptions \
86 help,debug,ruby:,python:,upload,target: \
92 eval set -- "$PARSEDOPTS"
93 while [ $# -gt 0 ]; do
96 echo >&2 "$helpmessage"
105 if [ "$RUBY" != "true" ] && [ "$RUBY" != "1" ]; then
113 if [ "$PYTHON" != "true" ] && [ "$PYTHON" != "1" ]; then
126 if [ $# -gt 1 ]; then
127 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
135 if ! [[ -n "$WORKSPACE" ]]; then
136 echo >&2 "$helpmessage"
138 echo >&2 "Error: WORKSPACE environment variable not set"
143 STDOUT_IF_DEBUG=/dev/null
144 STDERR_IF_DEBUG=/dev/null
145 DASHQ_UNLESS_DEBUG=-q
146 if [[ "$DEBUG" != 0 ]]; then
147 STDOUT_IF_DEBUG=/dev/stdout
148 STDERR_IF_DEBUG=/dev/stderr
152 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
153 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`" # absolutized and normalized
154 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
155 # error; for some reason, the path is not accessible
156 # to the script (e.g. permissions re-evaled after suid)
160 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
161 debug_echo "Workspace is $WORKSPACE"
163 if [ $RUBY -eq 0 ] && [ $PYTHON -eq 0 ]; then
164 echo "Nothing to do!"
168 if [[ -f /etc/profile.d/rvm.sh ]]; then
169 source /etc/profile.d/rvm.sh
170 GEM="rvm-exec default gem"
175 # Make all files world-readable -- jenkins runs with umask 027, and has checked
176 # out our git tree here
177 chmod o+r "$WORKSPACE" -R
179 # More cleanup - make sure all executables that we'll package are 755
181 find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
183 # Now fix our umask to something better suited to building and publishing
187 debug_echo "umask is" `umask`
190 if [ $RUBY -eq 1 ]; then
191 debug_echo "Building Ruby gems"
192 gem_wrapper arvados "$WORKSPACE/sdk/ruby"
193 gem_wrapper arvados-cli "$WORKSPACE/sdk/cli"
194 gem_wrapper arvados-login-sync "$WORKSPACE/services/login-sync"
195 if [ ${#failures[@]} -ne 0 ]; then
196 GEM_BUILD_FAILURES=${#failures[@]}
200 PYTHON_BUILD_FAILURES=0
201 if [ $PYTHON -eq 1 ]; then
202 debug_echo "Building Python packages"
203 python_wrapper arvados-python-client "$WORKSPACE/sdk/python"
204 python_wrapper arvados-cwl-runner "$WORKSPACE/sdk/cwl"
205 python_wrapper arvados_fuse "$WORKSPACE/services/fuse"
206 python_wrapper crunchstat_summary "$WORKSPACE/tools/crunchstat-summary"
207 python_wrapper arvados-user-activity "$WORKSPACE/tools/user-activity"
209 if [ $((${#failures[@]} - $GEM_BUILD_FAILURES)) -ne 0 ]; then
210 PYTHON_BUILD_FAILURES=$((${#failures[@]} - $GEM_BUILD_FAILURES))
214 if [ $UPLOAD -ne 0 ]; then
217 if [ $DEBUG > 0 ]; then
218 EXTRA_UPLOAD_FLAGS=" --verbose"
220 EXTRA_UPLOAD_FLAGS=""
223 if [ ! -e "$WORKSPACE/packages" ]; then
224 mkdir -p "$WORKSPACE/packages"
227 if [ $PYTHON -eq 1 ]; then
228 title "Start upload python packages"
231 if [ $PYTHON_BUILD_FAILURES -eq 0 ]; then
232 /usr/local/arvados-dev/jenkins/run_upload_packages.py $EXTRA_UPLOAD_FLAGS --workspace $WORKSPACE python
234 echo "Skipping python packages upload, there were errors building the packages"
236 checkexit $? "upload python packages"
237 title "End of upload python packages (`timer`)"
240 if [ $RUBY -eq 1 ]; then
241 title "Start upload ruby gems"
244 if [ $GEM_BUILD_FAILURES -eq 0 ]; then
245 /usr/local/arvados-dev/jenkins/run_upload_packages.py $EXTRA_UPLOAD_FLAGS --workspace $WORKSPACE gems
247 echo "Skipping ruby gem upload, there were errors building the packages"
249 checkexit $? "upload ruby gems"
250 title "End of upload ruby gems (`timer`)"