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