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
55 local version="$(nohash_version_from_git)"
56 if [[ -z "$(find dist -name "*-$version.tar.gz" -print -quit)" ]]; then
59 if [[ -z "$(find dist -name "*-$version-py*.whl" -print -quit)" ]]; then
60 pkg_fmts+=(bdist_wheel)
62 if [[ "${#pkg_fmts[@]}" -eq 0 ]]; then
63 echo "This package doesn't need rebuilding."
65 python3 setup.py $DASHQ_UNLESS_DEBUG "${pkg_fmts[@]}"
70 local package_name="$1"; shift
71 local package_directory="$1"; shift
73 title "Start $package_name python package build"
76 cd "$package_directory"
77 if [[ $DEBUG > 0 ]]; then
82 checkexit $? "$package_name python package build"
83 title "End of $package_name python package build (`timer`)"
90 DEBUG=${ARVADOS_DEBUG:-0}
92 PARSEDOPTS=$(getopt --name "$0" --longoptions \
93 help,debug,ruby:,python:,upload,target: \
99 eval set -- "$PARSEDOPTS"
100 while [ $# -gt 0 ]; do
103 echo >&2 "$helpmessage"
112 if [ "$RUBY" != "true" ] && [ "$RUBY" != "1" ]; then
120 if [ "$PYTHON" != "true" ] && [ "$PYTHON" != "1" ]; then
133 if [ $# -gt 1 ]; then
134 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
142 if ! [[ -n "$WORKSPACE" ]]; then
143 echo >&2 "$helpmessage"
145 echo >&2 "Error: WORKSPACE environment variable not set"
150 STDOUT_IF_DEBUG=/dev/null
151 STDERR_IF_DEBUG=/dev/null
152 DASHQ_UNLESS_DEBUG=-q
153 if [[ "$DEBUG" != 0 ]]; then
154 STDOUT_IF_DEBUG=/dev/stdout
155 STDERR_IF_DEBUG=/dev/stderr
159 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
160 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`" # absolutized and normalized
161 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
162 # error; for some reason, the path is not accessible
163 # to the script (e.g. permissions re-evaled after suid)
167 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
168 debug_echo "Workspace is $WORKSPACE"
170 if [ $RUBY -eq 0 ] && [ $PYTHON -eq 0 ]; then
171 echo "Nothing to do!"
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`)"