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
25 WORKSPACE=path Path to the Arvados source tree to build packages from
31 if ! [[ -n "$WORKSPACE" ]]; then
32 echo >&2 "$helpmessage"
34 echo >&2 "Error: WORKSPACE environment variable not set"
39 if ! [[ -d "$WORKSPACE" ]]; then
40 echo >&2 "$helpmessage"
42 echo >&2 "Error: $WORKSPACE is not a directory"
47 PARSEDOPTS=$(getopt --name "$0" --longoptions \
48 help,debug,test-packages,target:,command:,only-test:,only-build: \
58 eval set -- "$PARSEDOPTS"
59 while [ $# -gt 0 ]; do
62 echo >&2 "$helpmessage"
74 ONLY_BUILD="$2"; shift
88 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
98 if [[ -n "$test_packages" ]]; then
99 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.rpm')" ]] ; then
100 createrepo $WORKSPACE/packages/$TARGET
103 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.deb')" ]] ; then
104 (cd $WORKSPACE/packages/$TARGET
105 dpkg-scanpackages . 2> >(grep -v 'warning' 1>&2) | tee Packages | gzip -c > Packages.gz
106 apt-ftparchive -o APT::FTPArchive::Release::Origin=Arvados release . > Release
110 COMMAND="/jenkins/package-testing/test-packages-$TARGET.sh"
111 IMAGE="arvados/package-test:$TARGET"
113 IMAGE="arvados/build:$TARGET"
114 if [[ "$COMMAND" != "" ]]; then
115 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET$DEBUG"
119 JENKINS_DIR=$(dirname "$(readlink -e "$0")")
121 if [[ -n "$test_packages" ]]; then
122 pushd "$JENKINS_DIR/package-test-dockerfiles"
124 pushd "$JENKINS_DIR/package-build-dockerfiles"
125 make "$TARGET/generated"
130 time docker build --tag=$IMAGE .
133 if test -z "$packages" ; then
134 packages="arvados-api-server
135 arvados-docker-cleaner
140 crunch-dispatch-local
141 crunch-dispatch-slurm
154 packages="$packages python-arvados-fuse
155 python-arvados-python-client python-arvados-cwl-runner"
164 mkdir -p "$WORKSPACE/apps/workbench/vendor/cache-$TARGET"
165 mkdir -p "$WORKSPACE/services/api/vendor/cache-$TARGET"
168 -v "$JENKINS_DIR:/jenkins"
169 -v "$WORKSPACE:/arvados"
170 -v /arvados/services/api/vendor/bundle
171 -v /arvados/apps/workbench/vendor/bundle
172 -v "$WORKSPACE/services/api/vendor/cache-$TARGET:/arvados/services/api/vendor/cache"
173 -v "$WORKSPACE/apps/workbench/vendor/cache-$TARGET:/arvados/apps/workbench/vendor/cache"
176 if [[ -n "$test_packages" ]]; then
177 for p in $packages ; do
178 if [[ -n "$ONLY_BUILD" ]] && [[ "$p" != "$ONLY_BUILD" ]]; then
182 echo "START: $p test on $IMAGE" >&2
184 "${docker_volume_args[@]}" \
185 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
186 --env "TARGET=$TARGET" \
187 --env "WORKSPACE=/arvados" \
190 echo "OK: $p test on $IMAGE succeeded" >&2
193 package_fails="$package_fails $p"
194 echo "ERROR: $p test on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
199 echo "START: build packages on $IMAGE" >&2
200 # Move existing packages and other files into the processed/ subdirectory
201 if [[ ! -e "${WORKSPACE}/packages/${TARGET}/processed" ]]; then
202 mkdir -p "${WORKSPACE}/packages/${TARGET}/processed"
205 mv -f ${WORKSPACE}/packages/${TARGET}/* ${WORKSPACE}/packages/${TARGET}/processed/ 2>/dev/null
209 "${docker_volume_args[@]}" \
210 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
211 --env "ONLY_BUILD=$ONLY_BUILD" \
215 echo "OK: build packages on $IMAGE succeeded" >&2
218 echo "ERROR: build packages on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
222 if test -n "$package_fails" ; then
223 echo "Failed package tests:$package_fails" >&2