11925: Explicitly join actor thread after stopping.
[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
21 WORKSPACE=path         Path to the Arvados source tree to build packages from
22
23 EOF
24
25 if ! [[ -n "$WORKSPACE" ]]; then
26   echo >&2 "$helpmessage"
27   echo >&2
28   echo >&2 "Error: WORKSPACE environment variable not set"
29   echo >&2
30   exit 1
31 fi
32
33 if ! [[ -d "$WORKSPACE" ]]; then
34   echo >&2 "$helpmessage"
35   echo >&2
36   echo >&2 "Error: $WORKSPACE is not a directory"
37   echo >&2
38   exit 1
39 fi
40
41 set -e
42
43 PARSEDOPTS=$(getopt --name "$0" --longoptions \
44     help,test-packages,debug,command:,only-test: \
45     -- "" "$@")
46 if [ $? -ne 0 ]; then
47     exit 1
48 fi
49
50 COMMAND=
51 DEBUG=
52 TEST_PACKAGES=
53 ONLY_TEST=
54
55 eval set -- "$PARSEDOPTS"
56 while [ $# -gt 0 ]; do
57     case "$1" in
58         --help)
59             echo >&2 "$helpmessage"
60             echo >&2
61             exit 1
62             ;;
63         --debug)
64             DEBUG="--debug"
65             ;;
66         --command)
67             COMMAND="$2"; shift
68             ;;
69         --test-packages)
70             TEST_PACKAGES="--test-packages"
71             ;;
72         --only-test)
73             ONLY_TEST="$1 $2"; shift
74             ;;
75         --)
76             if [ $# -gt 1 ]; then
77                 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
78                 exit 1
79             fi
80             ;;
81     esac
82     shift
83 done
84
85 cd $(dirname $0)
86
87 FINAL_EXITCODE=0
88
89 for dockerfile_path in $(find -name Dockerfile | grep package-build-dockerfiles); do
90     if ./run-build-packages-one-target.sh --target "$(basename $(dirname "$dockerfile_path"))" --command "$COMMAND" $DEBUG $TEST_PACKAGES $ONLY_TEST ; then
91         true
92     else
93         FINAL_EXITCODE=$?
94     fi
95 done
96
97 if test $FINAL_EXITCODE != 0 ; then
98     echo "Build packages failed with code $FINAL_EXITCODE" >&2
99 fi
100
101 exit $FINAL_EXITCODE