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 [[ -z "$2" ]]; then
91 elif ! [[ "$2" =~ (.*)-(.*) ]]; then
92 echo >&2 "FATAL: --build-version '$2' does not include an iteration. Try '${2}-1'?"
95 ARVADOS_BUILDING_VERSION="${BASH_REMATCH[1]}"
96 ARVADOS_BUILDING_ITERATION="${BASH_REMATCH[2]}"
101 if [ $# -gt 1 ]; then
102 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
112 if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
113 echo "build version='$ARVADOS_BUILDING_VERSION', package iteration='$ARVADOS_BUILDING_ITERATION'"
116 if [[ -n "$test_packages" ]]; then
117 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.rpm')" ]] ; then
119 /usr/bin/which createrepo >/dev/null
120 if [[ "$?" != "0" ]]; then
122 echo >&2 "Error: please install createrepo. E.g. sudo apt-get install createrepo"
127 createrepo $WORKSPACE/packages/$TARGET
130 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.deb')" ]] ; then
131 (cd $WORKSPACE/packages/$TARGET
132 dpkg-scanpackages . 2> >(grep -v 'warning' 1>&2) | tee Packages | gzip -c > Packages.gz
133 apt-ftparchive -o APT::FTPArchive::Release::Origin=Arvados release . > Release
137 COMMAND="/jenkins/package-testing/test-packages-$TARGET.sh"
138 IMAGE="arvados/package-test:$TARGET"
140 IMAGE="arvados/build:$TARGET"
141 if [[ "$COMMAND" != "" ]]; then
142 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET$DEBUG"
146 JENKINS_DIR=$(dirname "$(readlink -e "$0")")
148 if [[ -n "$test_packages" ]]; then
149 pushd "$JENKINS_DIR/package-test-dockerfiles"
151 pushd "$JENKINS_DIR/package-build-dockerfiles"
152 make "$TARGET/generated"
157 time docker build --tag=$IMAGE .
160 if test -z "$packages" ; then
161 packages="arvados-api-server
162 arvados-docker-cleaner
167 crunch-dispatch-local
168 crunch-dispatch-slurm
181 packages="$packages python-arvados-fuse
182 python-arvados-python-client python-arvados-cwl-runner"
191 mkdir -p "$WORKSPACE/apps/workbench/vendor/cache-$TARGET"
192 mkdir -p "$WORKSPACE/services/api/vendor/cache-$TARGET"
195 -v "$JENKINS_DIR:/jenkins"
196 -v "$WORKSPACE:/arvados"
197 -v /arvados/services/api/vendor/bundle
198 -v /arvados/apps/workbench/vendor/bundle
199 -v "$WORKSPACE/services/api/vendor/cache-$TARGET:/arvados/services/api/vendor/cache"
200 -v "$WORKSPACE/apps/workbench/vendor/cache-$TARGET:/arvados/apps/workbench/vendor/cache"
203 if [[ -n "$test_packages" ]]; then
204 for p in $packages ; do
205 if [[ -n "$ONLY_BUILD" ]] && [[ "$p" != "$ONLY_BUILD" ]]; then
209 echo "START: $p test on $IMAGE" >&2
211 "${docker_volume_args[@]}" \
212 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
213 --env "TARGET=$TARGET" \
214 --env "WORKSPACE=/arvados" \
217 echo "OK: $p test on $IMAGE succeeded" >&2
220 package_fails="$package_fails $p"
221 echo "ERROR: $p test on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
226 echo "START: build packages on $IMAGE" >&2
227 # Move existing packages and other files into the processed/ subdirectory
228 if [[ ! -e "${WORKSPACE}/packages/${TARGET}/processed" ]]; then
229 mkdir -p "${WORKSPACE}/packages/${TARGET}/processed"
232 mv -f ${WORKSPACE}/packages/${TARGET}/* ${WORKSPACE}/packages/${TARGET}/processed/ 2>/dev/null
236 "${docker_volume_args[@]}" \
237 --env ARVADOS_BUILDING_VERSION="$ARVADOS_BUILDING_VERSION" \
238 --env ARVADOS_BUILDING_ITERATION="$ARVADOS_BUILDING_ITERATION" \
239 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
240 --env "ONLY_BUILD=$ONLY_BUILD" \
244 echo "OK: build packages on $IMAGE succeeded" >&2
247 echo "ERROR: build packages on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
251 if test -n "$package_fails" ; then
252 echo "Failed package tests:$package_fails" >&2