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): Build, test and (optionally) upload packages for one target
10 WORKSPACE=/path/to/arvados $(basename $0) [options]
13 Distribution to build packages for (default: debian10)
14 --only-build <package>
15 Build only a specific package (or ONLY_BUILD from environment)
17 Build a specific architecture (or ARCH from environment, defaults to native architecture)
19 Build even if the package exists upstream or if it has already been
22 Test even if there is no new untested package
24 If the build and test steps are successful, upload the packages
25 to a remote apt repository (default: false)
27 Output debug information (default: false)
29 Optional Parameter to build Release Candidate
30 --build-version <version>
31 Version to build (default:
32 \$ARVADOS_BUILDING_VERSION-\$ARVADOS_BUILDING_ITERATION or
33 0.1.timestamp.commithash)
35 Don't try to build Docker images
37 WORKSPACE=path Path to the Arvados source tree to build packages from
41 if ! [[ -n "$WORKSPACE" ]]; then
42 echo >&2 "$helpmessage"
44 echo >&2 "Error: WORKSPACE environment variable not set"
49 if ! [[ -d "$WORKSPACE" ]]; then
50 echo >&2 "$helpmessage"
52 echo >&2 "Error: $WORKSPACE is not a directory"
57 PARSEDOPTS=$(getopt --name "$0" --longoptions \
58 help,debug,upload,rc,target:,force-test,only-build:,force-build,arch:,build-version:,skip-docker-build \
69 declare -a build_args=()
71 eval set -- "$PARSEDOPTS"
72 while [ $# -gt 0 ]; do
75 echo >&2 "$helpmessage"
89 ONLY_BUILD="$2"; shift
104 build_args+=("$1" "$2")
111 if [ $# -gt 1 ]; then
112 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
120 build_args+=(--target "$TARGET")
122 if [[ -n "$ONLY_BUILD" ]]; then
123 build_args+=(--only-build "$ONLY_BUILD")
126 if [[ -n "$FORCE_BUILD" ]]; then
127 build_args+=(--force-build)
130 if [[ -n "$FORCE_TEST" ]]; then
131 build_args+=(--force-test)
134 if [[ "$SKIP_DOCKER_BUILD" = 1 ]]; then
135 build_args+=(--skip-docker-build)
138 if [[ -n "$ARCH" ]]; then
139 build_args+=(--arch "$ARCH")
149 . $WORKSPACE/build/run-library.sh
151 title "Start build packages"
154 $WORKSPACE/build/run-build-packages-one-target.sh "${build_args[@]}"$DEBUG
156 checkexit $? "build packages"
157 title "End of build packages (`timer`)"
159 title "Start test packages"
162 if [ ${#failures[@]} -eq 0 ]; then
163 $WORKSPACE/build/run-build-packages-one-target.sh "${build_args[@]}" --test-packages$DEBUG
165 echo "Skipping package upload, there were errors building the packages"
168 checkexit $? "test packages"
169 title "End of test packages (`timer`)"
171 if [[ "$UPLOAD" != 0 ]]; then
172 title "Start upload packages"
175 if [ ${#failures[@]} -eq 0 ]; then
176 if [[ "$RC" != 0 ]]; then
177 echo "/usr/local/arvados-dev/jenkins/run_upload_packages.py --repo testing -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET"
178 /usr/local/arvados-dev/jenkins/run_upload_packages.py --repo testing -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET
180 echo "/usr/local/arvados-dev/jenkins/run_upload_packages.py --repo dev -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET"
181 /usr/local/arvados-dev/jenkins/run_upload_packages.py --repo dev -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET
184 echo "Skipping package upload, there were errors building and/or testing the packages"
186 checkexit $? "upload packages"
187 title "End of upload packages (`timer`)"