Merge branch '7829-package-licenses-wip'
[arvados-dev.git] / jenkins / 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: \
42     -- "" "$@")
43 if [ $? -ne 0 ]; then
44     exit 1
45 fi
46
47 COMMAND=
48 DEBUG=
49 TEST_PACKAGES=
50
51 eval set -- "$PARSEDOPTS"
52 while [ $# -gt 0 ]; do
53     case "$1" in
54         --help)
55             echo >&2 "$helpmessage"
56             echo >&2
57             exit 1
58             ;;
59         --debug)
60             DEBUG="--debug"
61             ;;
62         --command)
63             COMMAND="$2"; shift
64             ;;
65         --test-packages)
66             TEST_PACKAGES="--test-packages"
67             ;;
68         --)
69             if [ $# -gt 1 ]; then
70                 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
71                 exit 1
72             fi
73             ;;
74     esac
75     shift
76 done
77
78 cd $(dirname $0)
79
80 for dockerfile_path in $(find -name Dockerfile); do
81     ./run-build-packages-one-target.sh --target "$(basename $(dirname "$dockerfile_path"))" --command "$COMMAND" $DEBUG $TEST_PACKAGES
82 done