Set secrets.secret_key_base refs #13996
[arvados.git] / build / run-build-packages-all-targets.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 read -rd "\000" helpmessage <<EOF
7 $(basename $0): Orchestrate run-build-packages.sh for every target
8
9 Syntax:
10         WORKSPACE=/path/to/arvados $(basename $0) [options]
11
12 Options:
13
14 --command
15     Build command to execute (default: use built-in Docker image command)
16 --test-packages
17     Run package install tests
18 --debug
19     Output debug information (default: false)
20 --build-version <string>
21     Version to build (default:
22     \$ARVADOS_BUILDING_VERSION-\$ARVADOS_BUILDING_ITERATION or
23     0.1.timestamp.commithash)
24
25 WORKSPACE=path         Path to the Arvados source tree to build packages from
26
27 EOF
28
29 if ! [[ -n "$WORKSPACE" ]]; then
30   echo >&2 "$helpmessage"
31   echo >&2
32   echo >&2 "Error: WORKSPACE environment variable not set"
33   echo >&2
34   exit 1
35 fi
36
37 if ! [[ -d "$WORKSPACE" ]]; then
38   echo >&2 "$helpmessage"
39   echo >&2
40   echo >&2 "Error: $WORKSPACE is not a directory"
41   echo >&2
42   exit 1
43 fi
44
45 set -e
46
47 PARSEDOPTS=$(getopt --name "$0" --longoptions \
48     help,test-packages,debug,command:,only-test:,build-version: \
49     -- "" "$@")
50 if [ $? -ne 0 ]; then
51     exit 1
52 fi
53
54 COMMAND=
55 DEBUG=
56 TEST_PACKAGES=
57 ONLY_TEST=
58
59 eval set -- "$PARSEDOPTS"
60 while [ $# -gt 0 ]; do
61     case "$1" in
62         --help)
63             echo >&2 "$helpmessage"
64             echo >&2
65             exit 1
66             ;;
67         --debug)
68             DEBUG="--debug"
69             ;;
70         --command)
71             COMMAND="$2"; shift
72             ;;
73         --test-packages)
74             TEST_PACKAGES="--test-packages"
75             ;;
76         --only-test)
77             ONLY_TEST="$1 $2"; shift
78             ;;
79         --build-version)
80             ARVADOS_BUILDING_VERSION="$2"; shift
81             ;;
82         --)
83             if [ $# -gt 1 ]; then
84                 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
85                 exit 1
86             fi
87             ;;
88     esac
89     shift
90 done
91
92 cd $(dirname $0)
93
94 FINAL_EXITCODE=0
95
96 for dockerfile_path in $(find -name Dockerfile | grep package-build-dockerfiles); do
97     if ./run-build-packages-one-target.sh --target "$(basename $(dirname "$dockerfile_path"))" --command "$COMMAND" --build-version "$ARVADOS_BUILDING_VERSION" $DEBUG $TEST_PACKAGES $ONLY_TEST ; then
98         true
99     else
100         FINAL_EXITCODE=$?
101         echo
102         echo "Build packages failed for $(basename $(dirname "$dockerfile_path"))"
103         echo
104     fi
105 done
106
107 if test $FINAL_EXITCODE != 0 ; then
108     echo
109     echo "Build packages failed with code $FINAL_EXITCODE" >&2
110     echo
111 fi
112
113 exit $FINAL_EXITCODE