forked from fullstaq-ruby/server-edition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-all-packages
executable file
·92 lines (82 loc) · 2.23 KB
/
build-all-packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
set -e
SELFDIR=$(dirname "$0")
SELFDIR=$(cd "$SELFDIR" && pwd)
# shellcheck source=lib/library.sh
source "$SELFDIR/lib/library.sh"
TASKS=()
ONLY_SHOW_TASKS=false
CONFIG="$SELFDIR/config.yml"
DOWNLOAD_PACKAGES_FROM_REPO=false
SHOW_BACKTRACES=false
BUILD_CONCURRENCY=1
function usage()
{
echo "Usage: ./build-all-packages [OPTIONS] [TASK NAME...]"
echo "Build some or all Fullstaq Ruby packages per the settings in config.yml."
echo "Which packages are built depends on the specified task names. If no task names"
echo "are given, then a list of tasks is shown."
echo
echo "Examples:"
echo "- To build all packages: ./build-all-packages build"
echo "- To test all packages: ./build-all-packages test"
echo
echo "Optional options:"
echo " -T Only show tasks, then exit. Any specified task names are used"
echo " to filter the list"
echo " -c PATH Use given config file instead of config.yml"
echo " -d Download packages from APT/YUM repo if they exist, instead of"
echo " building them"
echo " -j NUM Build concurrency (default: $BUILD_CONCURRENCY)"
echo
echo " -t Show Rake backtraces"
echo
echo " -h Show usage"
}
function parse_options()
{
local OPTIND=1
local opt
while getopts "Tc:dj:th" opt; do
case "$opt" in
T)
ONLY_SHOW_TASKS=true
;;
c)
CONFIG=$(absolute_path "$OPTARG")
;;
d)
DOWNLOAD_PACKAGES_FROM_REPO=true
;;
j)
BUILD_CONCURRENCY="$OPTARG"
;;
t)
SHOW_BACKTRACES=true
;;
h)
usage
exit
;;
*)
return 1
;;
esac
done
(( OPTIND -= 1 )) || true
shift $OPTIND || true
TASKS=("$@")
}
parse_options "$@"
ARGS=(-j "$BUILD_CONCURRENCY")
if $SHOW_BACKTRACES; then
ARGS+=(--trace)
fi
export CONFIG
export DOWNLOAD_PACKAGES_FROM_REPO
cd "$SELFDIR"
if [[ ${#TASKS} -eq 0 ]] || $ONLY_SHOW_TASKS; then
verbose_exec bundle exec drake -f internal-scripts/build-all-packages.rb "${ARGS[@]}" -T "${TASKS[@]}"
else
verbose_exec bundle exec drake -f internal-scripts/build-all-packages.rb "${ARGS[@]}" _start "${TASKS[@]}"
fi