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) --target <target> [options]
13 Distribution to build packages for
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 if [[ -z "$TARGET" ]]; then
121 echo "FATAL: --target must be specified" >&2
123 elif [[ ! -d "$WORKSPACE/build/package-build-dockerfiles/$TARGET" ]]; then
124 echo "FATAL: unknown build target '$TARGET'" >&2
128 build_args+=(--target "$TARGET")
130 if [[ -n "$ONLY_BUILD" ]]; then
131 build_args+=(--only-build "$ONLY_BUILD")
134 if [[ -n "$FORCE_BUILD" ]]; then
135 build_args+=(--force-build)
138 if [[ -n "$FORCE_TEST" ]]; then
139 build_args+=(--force-test)
142 if [[ "$SKIP_DOCKER_BUILD" = 1 ]]; then
143 build_args+=(--skip-docker-build)
146 if [[ -n "$ARCH" ]]; then
147 build_args+=(--arch "$ARCH")
157 . $WORKSPACE/build/run-library.sh
159 title "Start build packages"
162 $WORKSPACE/build/run-build-packages-one-target.sh "${build_args[@]}"$DEBUG
164 checkexit $? "build packages"
165 title "End of build packages (`timer`)"
167 title "Start test packages"
170 if [ ${#failures[@]} -eq 0 ]; then
171 $WORKSPACE/build/run-build-packages-one-target.sh "${build_args[@]}" --test-packages$DEBUG
173 echo "Skipping package upload, there were errors building the packages"
176 checkexit $? "test packages"
177 title "End of test packages (`timer`)"
179 if [[ "$UPLOAD" != 0 ]]; then
180 title "Start upload packages"
183 if [ ${#failures[@]} -eq 0 ]; then
184 if [[ "$RC" != 0 ]]; then
185 echo "/usr/local/arvados-dev/jenkins/run_upload_packages.py --repo testing -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET"
186 /usr/local/arvados-dev/jenkins/run_upload_packages.py --repo testing -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET
188 echo "/usr/local/arvados-dev/jenkins/run_upload_packages.py --repo dev -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET"
189 /usr/local/arvados-dev/jenkins/run_upload_packages.py --repo dev -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET
192 echo "Skipping package upload, there were errors building and/or testing the packages"
194 checkexit $? "upload packages"
195 title "End of upload packages (`timer`)"