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
114 /usr/bin/which createrepo >/dev/null
115 if [[ "$?" != "0" ]]; then
117 echo >&2 "Error: please install createrepo. E.g. sudo apt-get install createrepo"
122 createrepo $WORKSPACE/packages/$TARGET
125 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.deb')" ]] ; then
126 (cd $WORKSPACE/packages/$TARGET
127 dpkg-scanpackages . 2> >(grep -v 'warning' 1>&2) | tee Packages | gzip -c > Packages.gz
128 apt-ftparchive -o APT::FTPArchive::Release::Origin=Arvados release . > Release
132 COMMAND="/jenkins/package-testing/test-packages-$TARGET.sh"
133 IMAGE="arvados/package-test:$TARGET"
135 IMAGE="arvados/build:$TARGET"
136 if [[ "$COMMAND" != "" ]]; then
137 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET$DEBUG"
141 JENKINS_DIR=$(dirname "$(readlink -e "$0")")
143 if [[ -n "$test_packages" ]]; then
144 pushd "$JENKINS_DIR/package-test-dockerfiles"
146 pushd "$JENKINS_DIR/package-build-dockerfiles"
147 make "$TARGET/generated"
152 time docker build --tag=$IMAGE .
155 if test -z "$packages" ; then
156 packages="arvados-api-server
157 arvados-docker-cleaner
162 crunch-dispatch-local
163 crunch-dispatch-slurm
176 packages="$packages python-arvados-fuse
177 python-arvados-python-client python-arvados-cwl-runner"
186 mkdir -p "$WORKSPACE/apps/workbench/vendor/cache-$TARGET"
187 mkdir -p "$WORKSPACE/services/api/vendor/cache-$TARGET"
190 -v "$JENKINS_DIR:/jenkins"
191 -v "$WORKSPACE:/arvados"
192 -v /arvados/services/api/vendor/bundle
193 -v /arvados/apps/workbench/vendor/bundle
194 -v "$WORKSPACE/services/api/vendor/cache-$TARGET:/arvados/services/api/vendor/cache"
195 -v "$WORKSPACE/apps/workbench/vendor/cache-$TARGET:/arvados/apps/workbench/vendor/cache"
198 if [[ -n "$test_packages" ]]; then
199 for p in $packages ; do
200 if [[ -n "$ONLY_BUILD" ]] && [[ "$p" != "$ONLY_BUILD" ]]; then
204 echo "START: $p test on $IMAGE" >&2
206 "${docker_volume_args[@]}" \
207 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
208 --env "TARGET=$TARGET" \
209 --env "WORKSPACE=/arvados" \
212 echo "OK: $p test on $IMAGE succeeded" >&2
215 package_fails="$package_fails $p"
216 echo "ERROR: $p test on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
221 echo "START: build packages on $IMAGE" >&2
222 # Move existing packages and other files into the processed/ subdirectory
223 if [[ ! -e "${WORKSPACE}/packages/${TARGET}/processed" ]]; then
224 mkdir -p "${WORKSPACE}/packages/${TARGET}/processed"
227 mv -f ${WORKSPACE}/packages/${TARGET}/* ${WORKSPACE}/packages/${TARGET}/processed/ 2>/dev/null
231 "${docker_volume_args[@]}" \
232 --env ARVADOS_BUILDING_VERSION="$ARVADOS_BUILDING_VERSION" \
233 --env ARVADOS_BUILDING_ITERATION="$ARVADOS_BUILDING_ITERATION" \
234 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
235 --env "ONLY_BUILD=$ONLY_BUILD" \
239 echo "OK: build packages on $IMAGE succeeded" >&2
242 echo "ERROR: build packages on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
246 if test -n "$package_fails" ; then
247 echo "Failed package tests:$package_fails" >&2