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:
26 \$ARVADOS_BUILDING_VERSION-\$ARVADOS_BUILDING_ITERATION or
27 0.1.timestamp.commithash)
29 WORKSPACE=path Path to the Arvados source tree to build packages from
35 if ! [[ -n "$WORKSPACE" ]]; then
36 echo >&2 "$helpmessage"
38 echo >&2 "Error: WORKSPACE environment variable not set"
43 if ! [[ -d "$WORKSPACE" ]]; then
44 echo >&2 "$helpmessage"
46 echo >&2 "Error: $WORKSPACE is not a directory"
51 PARSEDOPTS=$(getopt --name "$0" --longoptions \
52 help,debug,test-packages,target:,command:,only-test:,only-build:,build-version: \
62 eval set -- "$PARSEDOPTS"
63 while [ $# -gt 0 ]; do
66 echo >&2 "$helpmessage"
78 ONLY_BUILD="$2"; shift
91 if [[ -z "$2" ]]; then
93 elif ! [[ "$2" =~ (.*)-(.*) ]]; then
94 echo >&2 "FATAL: --build-version '$2' does not include an iteration. Try '${2}-1'?"
97 ARVADOS_BUILDING_VERSION="${BASH_REMATCH[1]}"
98 ARVADOS_BUILDING_ITERATION="${BASH_REMATCH[2]}"
103 if [ $# -gt 1 ]; then
104 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
114 if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
115 echo "build version='$ARVADOS_BUILDING_VERSION', package iteration='$ARVADOS_BUILDING_ITERATION'"
118 if [[ -n "$test_packages" ]]; then
119 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.rpm')" ]] ; then
121 /usr/bin/which createrepo >/dev/null
122 if [[ "$?" != "0" ]]; then
124 echo >&2 "Error: please install createrepo. E.g. sudo apt-get install createrepo"
129 createrepo $WORKSPACE/packages/$TARGET
132 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.deb')" ]] ; then
133 (cd $WORKSPACE/packages/$TARGET
134 dpkg-scanpackages . 2> >(grep -v 'warning' 1>&2) | tee Packages | gzip -c > Packages.gz
135 apt-ftparchive -o APT::FTPArchive::Release::Origin=Arvados release . > Release
139 COMMAND="/jenkins/package-testing/test-packages-$TARGET.sh"
140 IMAGE="arvados/package-test:$TARGET"
142 IMAGE="arvados/build:$TARGET"
143 if [[ "$COMMAND" != "" ]]; then
144 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET$DEBUG"
148 JENKINS_DIR=$(dirname "$(readlink -e "$0")")
150 if [[ -n "$test_packages" ]]; then
151 pushd "$JENKINS_DIR/package-test-dockerfiles"
153 pushd "$JENKINS_DIR/package-build-dockerfiles"
154 make "$TARGET/generated"
159 time docker build --tag=$IMAGE .
162 if test -z "$packages" ; then
163 packages="arvados-api-server
165 arvados-docker-cleaner
170 crunch-dispatch-local
171 crunch-dispatch-slurm
182 python-arvados-python-client
183 python-arvados-cwl-runner"
190 mkdir -p "$WORKSPACE/apps/workbench/vendor/cache-$TARGET"
191 mkdir -p "$WORKSPACE/services/api/vendor/cache-$TARGET"
194 -v "$JENKINS_DIR:/jenkins"
195 -v "$WORKSPACE:/arvados"
196 -v /arvados/services/api/vendor/bundle
197 -v /arvados/apps/workbench/vendor/bundle
198 -v "$WORKSPACE/services/api/vendor/cache-$TARGET:/arvados/services/api/vendor/cache"
199 -v "$WORKSPACE/apps/workbench/vendor/cache-$TARGET:/arvados/apps/workbench/vendor/cache"
202 if [[ -n "$test_packages" ]]; then
203 for p in $packages ; do
204 if [[ -n "$ONLY_BUILD" ]] && [[ "$p" != "$ONLY_BUILD" ]]; then
208 echo "START: $p test on $IMAGE" >&2
210 "${docker_volume_args[@]}" \
211 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
212 --env "TARGET=$TARGET" \
213 --env "WORKSPACE=/arvados" \
216 echo "OK: $p test on $IMAGE succeeded" >&2
219 package_fails="$package_fails $p"
220 echo "ERROR: $p test on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
225 echo "START: build packages on $IMAGE" >&2
226 # Move existing packages and other files into the processed/ subdirectory
227 if [[ ! -e "${WORKSPACE}/packages/${TARGET}/processed" ]]; then
228 mkdir -p "${WORKSPACE}/packages/${TARGET}/processed"
231 mv -f ${WORKSPACE}/packages/${TARGET}/* ${WORKSPACE}/packages/${TARGET}/processed/ 2>/dev/null
235 "${docker_volume_args[@]}" \
236 --env ARVADOS_BUILDING_VERSION="$ARVADOS_BUILDING_VERSION" \
237 --env ARVADOS_BUILDING_ITERATION="$ARVADOS_BUILDING_ITERATION" \
238 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
239 --env "ONLY_BUILD=$ONLY_BUILD" \
243 echo "OK: build packages on $IMAGE succeeded" >&2
246 echo "ERROR: build packages on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
250 if test -n "$package_fails" ; then
251 echo "Failed package tests:$package_fails" >&2