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 WORKSPACE=path Path to the Arvados source tree to build packages from
39 if ! [[ -n "$WORKSPACE" ]]; then
40 echo >&2 "$helpmessage"
42 echo >&2 "Error: WORKSPACE environment variable not set"
47 if ! [[ -d "$WORKSPACE" ]]; then
48 echo >&2 "$helpmessage"
50 echo >&2 "Error: $WORKSPACE is not a directory"
55 PARSEDOPTS=$(getopt --name "$0" --longoptions \
56 help,debug,upload,rc,target:,force-test,only-build:,force-build,arch:,build-version: \
67 declare -a build_args=()
69 eval set -- "$PARSEDOPTS"
70 while [ $# -gt 0 ]; do
73 echo >&2 "$helpmessage"
87 ONLY_BUILD="$2"; shift
102 build_args+=("$1" "$2")
106 if [ $# -gt 1 ]; then
107 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
115 build_args+=(--target "$TARGET")
117 if [[ -n "$ONLY_BUILD" ]]; then
118 build_args+=(--only-build "$ONLY_BUILD")
121 if [[ -n "$FORCE_BUILD" ]]; then
122 build_args+=(--force-build)
125 if [[ -n "$FORCE_TEST" ]]; then
126 build_args+=(--force-test)
129 if [[ -n "$ARCH" ]]; then
130 build_args+=(--arch "$ARCH")
140 . $WORKSPACE/build/run-library.sh
142 title "Start build packages"
145 $WORKSPACE/build/run-build-packages-one-target.sh "${build_args[@]}"$DEBUG
147 checkexit $? "build packages"
148 title "End of build packages (`timer`)"
150 title "Start test packages"
153 if [ ${#failures[@]} -eq 0 ]; then
154 $WORKSPACE/build/run-build-packages-one-target.sh "${build_args[@]}" --test-packages$DEBUG
156 echo "Skipping package upload, there were errors building the packages"
159 checkexit $? "test packages"
160 title "End of test packages (`timer`)"
162 if [[ "$UPLOAD" != 0 ]]; then
163 title "Start upload packages"
166 if [ ${#failures[@]} -eq 0 ]; then
167 if [[ "$RC" != 0 ]]; then
168 echo "/usr/local/arvados-dev/jenkins/run_upload_packages.py --repo testing -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET"
169 /usr/local/arvados-dev/jenkins/run_upload_packages.py --repo testing -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET
171 echo "/usr/local/arvados-dev/jenkins/run_upload_packages.py --repo dev -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET"
172 /usr/local/arvados-dev/jenkins/run_upload_packages.py --repo dev -H jenkinsapt@apt.arvados.org -o Port=2222 --workspace $WORKSPACE $TARGET
175 echo "Skipping package upload, there were errors building and/or testing the packages"
177 checkexit $? "upload packages"
178 title "End of upload packages (`timer`)"