2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
8 . `dirname "$(readlink -f "$0")"`/run-library.sh
9 #. `dirname "$(readlink -f "$0")"`/libcloud-pin.sh
11 read -rd "\000" helpmessage <<EOF
12 $(basename $0): Build Arvados Python packages and Ruby gems
15 WORKSPACE=/path/to/arvados $(basename $0) [options]
20 Output debug information (default: false)
22 If the build and test steps are successful, upload the python
23 packages to pypi and the gems to rubygems (default: false)
25 Build ruby gems (default: true)
27 Build python packages (default: true)
29 WORKSPACE=path Path to the Arvados source tree to build packages from
40 local gem_name="$1"; shift
41 local gem_directory="$1"; shift
43 title "Start $gem_name gem build"
47 handle_ruby_gem $gem_name
49 checkexit $? "$gem_name gem build"
50 title "End of $gem_name gem build (`timer`)"
54 local package_name="$1"; shift
55 local package_directory="$1"; shift
57 title "Start $package_name python package build"
60 cd "$package_directory"
61 if [[ $DEBUG > 0 ]]; then
66 checkexit $? "$package_name python package build"
67 title "End of $package_name python package build (`timer`)"
74 DEBUG=${ARVADOS_DEBUG:-0}
76 PARSEDOPTS=$(getopt --name "$0" --longoptions \
77 help,debug,ruby:,python:,upload,target: \
83 eval set -- "$PARSEDOPTS"
84 while [ $# -gt 0 ]; do
87 echo >&2 "$helpmessage"
96 if [ "$RUBY" != "true" ] && [ "$RUBY" != "1" ]; then
104 if [ "$PYTHON" != "true" ] && [ "$PYTHON" != "1" ]; then
117 if [ $# -gt 1 ]; then
118 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
126 if ! [[ -n "$WORKSPACE" ]]; then
127 echo >&2 "$helpmessage"
129 echo >&2 "Error: WORKSPACE environment variable not set"
134 STDOUT_IF_DEBUG=/dev/null
135 STDERR_IF_DEBUG=/dev/null
136 DASHQ_UNLESS_DEBUG=-q
137 if [[ "$DEBUG" != 0 ]]; then
138 STDOUT_IF_DEBUG=/dev/stdout
139 STDERR_IF_DEBUG=/dev/stderr
143 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
144 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`" # absolutized and normalized
145 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
146 # error; for some reason, the path is not accessible
147 # to the script (e.g. permissions re-evaled after suid)
151 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
152 debug_echo "Workspace is $WORKSPACE"
154 if [ $RUBY -eq 0 ] && [ $PYTHON -eq 0 ]; then
155 echo "Nothing to do!"
159 if [[ -f /etc/profile.d/rvm.sh ]]; then
160 source /etc/profile.d/rvm.sh
161 GEM="rvm-exec default gem"
166 # Make all files world-readable -- jenkins runs with umask 027, and has checked
167 # out our git tree here
168 chmod o+r "$WORKSPACE" -R
170 # More cleanup - make sure all executables that we'll package are 755
172 find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
174 # Now fix our umask to something better suited to building and publishing
178 debug_echo "umask is" `umask`
181 if [ $RUBY -eq 1 ]; then
182 debug_echo "Building Ruby gems"
183 gem_wrapper arvados "$WORKSPACE/sdk/ruby"
184 gem_wrapper arvados-cli "$WORKSPACE/sdk/cli"
185 gem_wrapper arvados-login-sync "$WORKSPACE/services/login-sync"
186 if [ ${#failures[@]} -ne 0 ]; then
187 GEM_BUILD_FAILURES=${#failures[@]}
191 PYTHON_BUILD_FAILURES=0
192 if [ $PYTHON -eq 1 ]; then
193 debug_echo "Building Python packages"
194 python_wrapper arvados-python-client "$WORKSPACE/sdk/python"
195 python_wrapper arvados-cwl-runner "$WORKSPACE/sdk/cwl"
196 python_wrapper arvados_fuse "$WORKSPACE/services/fuse"
198 if [ $((${#failures[@]} - $GEM_BUILD_FAILURES)) -ne 0 ]; then
199 PYTHON_BUILD_FAILURES=$((${#failures[@]} - $GEM_BUILD_FAILURES))
203 if [ $UPLOAD -ne 0 ]; then
206 if [ $DEBUG > 0 ]; then
207 EXTRA_UPLOAD_FLAGS=" --verbose"
209 EXTRA_UPLOAD_FLAGS=""
212 if [ ! -e "$WORKSPACE/packages" ]; then
213 mkdir -p "$WORKSPACE/packages"
216 if [ $PYTHON -eq 1 ]; then
217 title "Start upload python packages"
220 if [ $PYTHON_BUILD_FAILURES -eq 0 ]; then
221 /usr/local/arvados-dev/jenkins/run_upload_packages.py $EXTRA_UPLOAD_FLAGS --workspace $WORKSPACE python
223 echo "Skipping python packages upload, there were errors building the packages"
225 checkexit $? "upload python packages"
226 title "End of upload python packages (`timer`)"
229 if [ $RUBY -eq 1 ]; then
230 title "Start upload ruby gems"
233 if [ $GEM_BUILD_FAILURES -eq 0 ]; then
234 /usr/local/arvados-dev/jenkins/run_upload_packages.py $EXTRA_UPLOAD_FLAGS --workspace $WORKSPACE gems
236 echo "Skipping ruby gem upload, there were errors building the packages"
238 checkexit $? "upload ruby gems"
239 title "End of upload ruby gems (`timer`)"