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 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:,version: \
60 eval set -- "$PARSEDOPTS"
61 while [ $# -gt 0 ]; do
64 echo >&2 "$helpmessage"
76 ONLY_BUILD="$2"; shift
89 ARVADOS_BUILDING_VERSION="$2"
94 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
104 IFS=- read ARVADOS_BUILDING_VERSION ARVADOS_BUILDING_ITERATION <<EOF
105 $ARVADOS_BUILDING_VERSION
108 if [[ -n "$test_packages" ]]; then
109 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.rpm')" ]] ; then
110 createrepo $WORKSPACE/packages/$TARGET
113 if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.deb')" ]] ; then
114 (cd $WORKSPACE/packages/$TARGET
115 dpkg-scanpackages . 2> >(grep -v 'warning' 1>&2) | tee Packages | gzip -c > Packages.gz
116 apt-ftparchive -o APT::FTPArchive::Release::Origin=Arvados release . > Release
120 COMMAND="/jenkins/package-testing/test-packages-$TARGET.sh"
121 IMAGE="arvados/package-test:$TARGET"
123 IMAGE="arvados/build:$TARGET"
124 if [[ "$COMMAND" != "" ]]; then
125 COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET$DEBUG"
129 JENKINS_DIR=$(dirname "$(readlink -e "$0")")
131 if [[ -n "$test_packages" ]]; then
132 pushd "$JENKINS_DIR/package-test-dockerfiles"
134 pushd "$JENKINS_DIR/package-build-dockerfiles"
135 make "$TARGET/generated"
140 time docker build --tag=$IMAGE .
143 if test -z "$packages" ; then
144 packages="arvados-api-server
145 arvados-docker-cleaner
150 crunch-dispatch-local
151 crunch-dispatch-slurm
164 packages="$packages python-arvados-fuse
165 python-arvados-python-client python-arvados-cwl-runner"
174 mkdir -p "$WORKSPACE/apps/workbench/vendor/cache-$TARGET"
175 mkdir -p "$WORKSPACE/services/api/vendor/cache-$TARGET"
178 -v "$JENKINS_DIR:/jenkins"
179 -v "$WORKSPACE:/arvados"
180 -v /arvados/services/api/vendor/bundle
181 -v /arvados/apps/workbench/vendor/bundle
182 -v "$WORKSPACE/services/api/vendor/cache-$TARGET:/arvados/services/api/vendor/cache"
183 -v "$WORKSPACE/apps/workbench/vendor/cache-$TARGET:/arvados/apps/workbench/vendor/cache"
186 if [[ -n "$test_packages" ]]; then
187 for p in $packages ; do
188 if [[ -n "$ONLY_BUILD" ]] && [[ "$p" != "$ONLY_BUILD" ]]; then
192 echo "START: $p test on $IMAGE" >&2
194 "${docker_volume_args[@]}" \
195 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
196 --env "TARGET=$TARGET" \
197 --env "WORKSPACE=/arvados" \
200 echo "OK: $p test on $IMAGE succeeded" >&2
203 package_fails="$package_fails $p"
204 echo "ERROR: $p test on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
209 echo "START: build packages on $IMAGE" >&2
210 # Move existing packages and other files into the processed/ subdirectory
211 if [[ ! -e "${WORKSPACE}/packages/${TARGET}/processed" ]]; then
212 mkdir -p "${WORKSPACE}/packages/${TARGET}/processed"
215 mv -f ${WORKSPACE}/packages/${TARGET}/* ${WORKSPACE}/packages/${TARGET}/processed/ 2>/dev/null
219 "${docker_volume_args[@]}" \
220 --env ARVADOS_BUILDING_VERSION="$ARVADOS_BUILDING_VERSION" \
221 --env ARVADOS_BUILDING_ITERATION="$ARVADOS_BUILDING_ITERATION" \
222 --env ARVADOS_DEBUG=$ARVADOS_DEBUG \
223 --env "ONLY_BUILD=$ONLY_BUILD" \
227 echo "OK: build packages on $IMAGE succeeded" >&2
230 echo "ERROR: build packages on $IMAGE failed with exit status $FINAL_EXITCODE" >&2
234 if test -n "$package_fails" ; then
235 echo "Failed package tests:$package_fails" >&2