2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 read -rd "\000" helpmessage <<EOF
7 $(basename $0): Orchestrate run-build-packages.sh for one target
10 WORKSPACE=/path/to/arvados $(basename $0) [options]
13 Distribution to build packages for (default: debian8)
15 Build command to execute (default: use built-in Docker image command)
17 Run package install test script "test-packages-[target].sh"
19 Output debug information (default: false)
20 --only-build <package>
21 Build only a specific package
23 Test only a specific package
24 --build-version <string>
25 Version to build (default: \$ARVADOS_BUILDING_VERSION or 0.1.timestamp.commithash)
27 WORKSPACE=path Path to the Arvados source tree to build packages from
33 if ! [[ -n "$WORKSPACE" ]]; then
34 echo >&2 "$helpmessage"
36 echo >&2 "Error: WORKSPACE environment variable not set"
41 if ! [[ -d "$WORKSPACE" ]]; then
42 echo >&2 "$helpmessage"
44 echo >&2 "Error: $WORKSPACE is not a directory"
49 PARSEDOPTS=$(getopt --name "$0" --longoptions \
50 help,debug,test-packages,target:,command:,only-test:,only-build:,build-version: \
60 eval set -- "$PARSEDOPTS"
61 while [ $# -gt 0 ]; do
64 echo >&2 "$helpmessage"
76 ONLY_BUILD="$2"; shift
89 if ! [[ "$2" =~ (.*)-(.*) ]]; then
90 echo >&2 "FATAL: --build-version '$2' does not include an iteration. Try '${2}-1'?"
93 ARVADOS_BUILDING_VERSION="${BASH_REMATCH[1]}"
94 ARVADOS_BUILDING_ITERATION="${BASH_REMATCH[2]}"
99 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
109 echo "build version='$ARVADOS_BUILDING_VERSION', package iteration='$ARVADOS_BUILDING_ITERATION'"
111 if [[ -n "$test_packages" ]]; then
112 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.rpm')" ]] ; then
113 createrepo $WORKSPACE/packages/$TARGET
116 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.deb')" ]] ; then
117 (cd $WORKSPACE/packages/$TARGET
118 dpkg-scanpackages . 2> >(grep -v 'warning' 1>&2) | tee Packages | gzip -c > Packages.gz
119 apt-ftparchive -o APT::FTPArchive::Release::Origin=Arvados release . > Release
123 COMMAND="/jenkins/package-testing/test-packages-$TARGET.sh"
124 IMAGE="arvados/package-test:$TARGET"
126 IMAGE="arvados/build:$TARGET"
127 if [[ "$COMMAND" != "" ]]; then
128 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET$DEBUG"
132 JENKINS_DIR=$(dirname "$(readlink -e "$0")")
134 if [[ -n "$test_packages" ]]; then
135 pushd "$JENKINS_DIR/package-test-dockerfiles"
137 pushd "$JENKINS_DIR/package-build-dockerfiles"
138 make "$TARGET/generated"
143 time docker build --tag=$IMAGE .
146 if test -z "$packages" ; then
147 packages="arvados-api-server
148 arvados-docker-cleaner
153 crunch-dispatch-local
154 crunch-dispatch-slurm
167 packages="$packages python-arvados-fuse
168 python-arvados-python-client python-arvados-cwl-runner"
177 mkdir -p "$WORKSPACE/apps/workbench/vendor/cache-$TARGET"
178 mkdir -p "$WORKSPACE/services/api/vendor/cache-$TARGET"
181 -v "$JENKINS_DIR:/jenkins"
182 -v "$WORKSPACE:/arvados"
183 -v /arvados/services/api/vendor/bundle
184 -v /arvados/apps/workbench/vendor/bundle
185 -v "$WORKSPACE/services/api/vendor/cache-$TARGET:/arvados/services/api/vendor/cache"
186 -v "$WORKSPACE/apps/workbench/vendor/cache-$TARGET:/arvados/apps/workbench/vendor/cache"
189 if [[ -n "$test_packages" ]]; then
190 for p in $packages ; do
191 if [[ -n "$ONLY_BUILD" ]] && [[ "$p" != "$ONLY_BUILD" ]]; then
195 echo "START: $p test on $IMAGE" >&2
197 "${docker_volume_args[@]}" \
198 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
199 --env "TARGET=$TARGET" \
200 --env "WORKSPACE=/arvados" \
203 echo "OK: $p test on $IMAGE succeeded" >&2
206 package_fails="$package_fails $p"
207 echo "ERROR: $p test on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
212 echo "START: build packages on $IMAGE" >&2
213 # Move existing packages and other files into the processed/ subdirectory
214 if [[ ! -e "${WORKSPACE}/packages/${TARGET}/processed" ]]; then
215 mkdir -p "${WORKSPACE}/packages/${TARGET}/processed"
218 mv -f ${WORKSPACE}/packages/${TARGET}/* ${WORKSPACE}/packages/${TARGET}/processed/ 2>/dev/null
222 "${docker_volume_args[@]}" \
223 --env ARVADOS_BUILDING_VERSION="$ARVADOS_BUILDING_VERSION" \
224 --env ARVADOS_BUILDING_ITERATION="$ARVADOS_BUILDING_ITERATION" \
225 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
226 --env "ONLY_BUILD=$ONLY_BUILD" \
230 echo "OK: build packages on $IMAGE succeeded" >&2
233 echo "ERROR: build packages on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
237 if test -n "$package_fails" ; then
238 echo "Failed package tests:$package_fails" >&2