-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgenerate-bootstrap-archive.sh
More file actions
executable file
·129 lines (104 loc) · 3.32 KB
/
generate-bootstrap-archive.sh
File metadata and controls
executable file
·129 lines (104 loc) · 3.32 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env bash
set -euo pipefail
script=$(realpath "$0")
script_dir=$(dirname "$script")
# shellcheck source=common.sh
. "$script_dir/common.sh"
COTG_RELEASE="false"
COTG_LOCAL="false"
usage() {
echo "Script to generate bootstrap archives for Code On the Go."
echo
echo "Usage: $0 [options]"
echo
echo "Options:"
echo " -g Generate bootstrap archive for release builds."
echo " Defaults to ${COTG_RELEASE}."
echo " -l Use local packages repository. Defaults to ${COTG_LOCAL}."
echo " This takes precendence over the repository provided using -r."
echo " -r The repository where the built packages will be published."
echo " Defaults to '${COTG_REPO}'."
echo
echo " -h Show this help message and exit."
}
build_boostrap() {
variant="$1"
arch="$2"
repo="$3"
shift 3
packages=("$@")
packages=$(IFS=,; echo "${packages[*]}")
if [[ -z "$variant" ]]; then
scribe_error_exit "Target variant must not be empty"
fi
if [[ -z "$arch" ]]; then
scribe_error_exit "Target arch must not be empty"
fi
if [[ -z "$repo" ]]; then
scribe_error_exit "Target repo must not be empty"
fi
bootstrap_name="bootstrap-${arch}.zip"
bootstrap_out="${COTG_OUTPUT_DIR}/bootstrap-${variant}-${arch}.zip"
echo
echo "==="
echo "Building bootstrap: $(realpath --relative-to="$(pwd)" ${bootstrap_out})"
echo "==="
echo
out_dir="$script_dir/output/$arch"
pushd "$out_dir" ||\
scribe_error_exit "Unable to switch to output dir: ${out_dir}"
if ! {
set -x
time "$TERMUX_PACKAGES_DIR/scripts/generate-bootstraps.sh" \
--architectures "$arch" \
--repository "$repo" \
--add "${packages}" |&\
tee "$out_dir/generate-bootstrap-${variant}.log"
}; then
scribe_error_exit "Failed to generate boostrap for ${arch} ${variant}."
fi
# Rename the built files
mv "${bootstrap_name}" "${bootstrap_out}"
mv "${bootstrap_name}.9" "${bootstrap_out}.9"
popd ||\
scribe_error_exit "Unable to switch from output dir: ${out_dir}"
}
while getopts "glr:h" opt; do
case "$opt" in
g) COTG_RELEASE="true";;
l) COTG_LOCAL="true";;
r) COTG_REPO="$OPTARG";;
h)
usage
exit 0
;;
*)
scribe_error "Invalid option" >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [[ "$COTG_LOCAL" == "true" ]]; then
COTG_REPO="file://${COTG_REPO_DIR}"
fi
if [[ -z "${COTG_REPO}" ]]; then
scribe_error_exit "A package repository URL must be specified."
fi
COTG_VARIANT="debug"
declare -a COTG_EXTRA_PACKAGES
COTG_EXTRA_PACKAGES=("${COTG_PACKAGES__BASE[@]}")
if [[ "$COTG_RELEASE" == "true" ]]; then
COTG_VARIANT="release"
COTG_EXTRA_PACKAGES+=("${COTG_PACKAGES__RELEASE[@]}")
else
COTG_EXTRA_PACKAGES+=("${COTG_PACKAGES__DEBUG[@]}")
fi
echo "Using configuration:"
echo " Variant : ${COTG_VARIANT}"
echo " Repository : ${COTG_REPO}"
echo " Extra packages : ${COTG_EXTRA_PACKAGES[@]}"
for arch in aarch64 arm; do
build_boostrap "$COTG_VARIANT" "$arch" "$COTG_REPO" "${COTG_EXTRA_PACKAGES[@]}" ||\
scribe_error_exit "Unable to build bootstrap for ${arch}"
done