3 read -rd "\000" helpmessage <<EOF
4 $(basename $0): Orchestrate run-build-packages.sh for one target
7 WORKSPACE=/path/to/arvados $(basename $0) [options]
10 Distribution to build packages for (default: debian7)
12 Build command to execute (default: use built-in Docker image command)
14 Output debug information (default: false)
16 WORKSPACE=path Path to the Arvados source tree to build packages from
20 if ! [[ -n "$WORKSPACE" ]]; then
21 echo >&2 "$helpmessage"
23 echo >&2 "Error: WORKSPACE environment variable not set"
28 if ! [[ -d "$WORKSPACE" ]]; then
29 echo >&2 "$helpmessage"
31 echo >&2 "Error: $WORKSPACE is not a directory"
36 PARSEDOPTS=$(getopt --name "$0" --longoptions \
37 help,debug,target:,command: \
47 eval set -- "$PARSEDOPTS"
48 while [ $# -gt 0 ]; do
51 echo >&2 "$helpmessage"
66 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
76 if [[ "$COMMAND" != "" ]]; then
77 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET$DEBUG"
81 JENKINS_DIR=$(dirname "$(readlink -e "$0")")
85 if docker run -v "$JENKINS_DIR:/jenkins" -v "$WORKSPACE:/arvados" \
86 --env ARVADOS_DEBUG=1 "arvados/build:$tag" $COMMAND; then
87 # Success - nothing more to do.
91 echo "ERROR: $tag build failed with exit status $FINAL_EXITCODE." >&2
95 # In case it's needed, build the container. This costs just a few
96 # seconds when the container already exist, so it's not a big deal to
98 cd "$JENKINS_DIR/dockerfiles"
101 time docker build -t arvados/build:$TARGET .