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 WORKSPACE=path Path to the Arvados source tree to build packages from
36 local gem_name="$1"; shift
37 local gem_directory="$1"; shift
39 title "Start $gem_name gem build"
43 handle_ruby_gem $gem_name
45 checkexit $? "$gem_name gem build"
46 title "End of $gem_name gem build (`timer`)"
50 local package_name="$1"; shift
51 local package_directory="$1"; shift
53 title "Start $package_name python package build"
56 cd "$package_directory"
57 if [[ $DEBUG > 0 ]]; then
62 checkexit $? "$package_name python package build"
63 title "End of $package_name python package build (`timer`)"
68 DEBUG=${ARVADOS_DEBUG:-0}
70 PARSEDOPTS=$(getopt --name "$0" --longoptions \
71 help,debug,upload,target: \
77 eval set -- "$PARSEDOPTS"
78 while [ $# -gt 0 ]; do
81 echo >&2 "$helpmessage"
96 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
104 if ! [[ -n "$WORKSPACE" ]]; then
105 echo >&2 "$helpmessage"
107 echo >&2 "Error: WORKSPACE environment variable not set"
112 STDOUT_IF_DEBUG=/dev/null
113 STDERR_IF_DEBUG=/dev/null
114 DASHQ_UNLESS_DEBUG=-q
115 if [[ "$DEBUG" != 0 ]]; then
116 STDOUT_IF_DEBUG=/dev/stdout
117 STDERR_IF_DEBUG=/dev/stderr
121 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
122 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`" # absolutized and normalized
123 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
124 # error; for some reason, the path is not accessible
125 # to the script (e.g. permissions re-evaled after suid)
129 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
130 debug_echo "Workspace is $WORKSPACE"
132 if [[ -f /etc/profile.d/rvm.sh ]]; then
133 source /etc/profile.d/rvm.sh
134 GEM="rvm-exec default gem"
139 # Make all files world-readable -- jenkins runs with umask 027, and has checked
140 # out our git tree here
141 chmod o+r "$WORKSPACE" -R
143 # More cleanup - make sure all executables that we'll package are 755
145 find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
147 # Now fix our umask to something better suited to building and publishing
151 debug_echo "umask is" `umask`
153 gem_wrapper arvados "$WORKSPACE/sdk/ruby"
154 gem_wrapper arvados-cli "$WORKSPACE/sdk/cli"
155 gem_wrapper arvados-login-sync "$WORKSPACE/services/login-sync"
158 if [ ${#failures[@]} -ne 0 ]; then
159 GEM_BUILD_FAILURES=${#failures[@]}
162 python_wrapper arvados-python-client "$WORKSPACE/sdk/python"
163 python_wrapper arvados-pam "$WORKSPACE/sdk/pam"
164 python_wrapper arvados-cwl-runner "$WORKSPACE/sdk/cwl"
165 python_wrapper arvados_fuse "$WORKSPACE/services/fuse"
166 python_wrapper arvados-node-manager "$WORKSPACE/services/nodemanager"
168 PYTHON_BUILD_FAILURES=0
169 if [ $((${#failures[@]} - $GEM_BUILD_FAILURES)) -ne 0 ]; then
170 PYTHON_BUILD_FAILURES=${#failures[@]} - $GEM_BUILD_FAILURES
173 if [[ "$UPLOAD" != 0 ]]; then
175 if [[ $DEBUG > 0 ]]; then
176 EXTRA_UPLOAD_FLAGS=" --verbose"
178 EXTRA_UPLOAD_FLAGS=""
181 if [[ ! -e "$WORKSPACE/packages" ]]; then
182 mkdir -p "$WORKSPACE/packages"
185 title "Start upload python packages"
188 if [ "$PYTHON_BUILD_FAILURES" -eq 0 ]; then
189 /usr/local/arvados-dev/jenkins/run_upload_packages.py $EXTRA_UPLOAD_FLAGS --workspace $WORKSPACE python
191 echo "Skipping python packages upload, there were errors building the packages"
193 checkexit $? "upload python packages"
194 title "End of upload python packages (`timer`)"
196 title "Start upload ruby gems"
199 if [ "$GEM_BUILD_FAILURES" -eq 0 ]; then
200 /usr/local/arvados-dev/jenkins/run_upload_packages.py $EXTRA_UPLOAD_FLAGS --workspace $WORKSPACE gems
202 echo "Skipping ruby gem upload, there were errors building the packages"
204 checkexit $? "upload ruby gems"
205 title "End of upload ruby gems (`timer`)"