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 WORKSPACE=path Path to the Arvados source tree to build packages from
18 if ! [[ -n "$WORKSPACE" ]]; then
19 echo >&2 "$helpmessage"
21 echo >&2 "Error: WORKSPACE environment variable not set"
26 if ! [[ -d "$WORKSPACE" ]]; then
27 echo >&2 "$helpmessage"
29 echo >&2 "Error: $WORKSPACE is not a directory"
34 PARSEDOPTS=$(getopt --name "$0" --longoptions \
35 help,target:,command: \
44 eval set -- "$PARSEDOPTS"
45 while [ $# -gt 0 ]; do
48 echo >&2 "$helpmessage"
60 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
70 if [[ "$COMMAND" != "" ]]; then
71 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET"
75 JENKINS_DIR=$(dirname "$(readlink -e "$0")")
79 if docker run -v "$JENKINS_DIR:/jenkins" -v "$WORKSPACE:/arvados" \
80 --env ARVADOS_DEBUG=1 "arvados/build:$tag" $COMMAND; then
81 # Success - nothing more to do.
85 echo "ERROR: $tag build failed with exit status $FINAL_EXITCODE." >&2
89 # In case it's needed, build the container. This costs just a few
90 # seconds when the container already exist, so it's not a big deal to
92 cd "$JENKINS_DIR/dockerfiles"
95 time docker build -t arvados/build:$TARGET .