-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·59 lines (55 loc) · 1.29 KB
/
build.sh
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
#!/usr/bin/env bash
set -o errexit -o errtrace -o functrace -o nounset -o pipefail
# shellcheck source=/dev/null
root="$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd)/../"
readonly root
# shellcheck source=/dev/null
BIN_LOCATION="${BIN_LOCATION:-$root/cache/bin}" source "$root/hack/helpers/install-tools.sh"
# Build the cue invocation
params=(cue)
case "${1:-}" in
# Provisional
"--version")
exit
;;
# Provisional
"--help")
exit
;;
*)
cd "$root"
target=image
files=("$root/hack/recipe.cue" "$root/hack/cue_tool.cue")
isparam=
for i in "$@"; do
if [ "${i:0:2}" == "--" ]; then
params+=("$i")
isparam=true
elif [ "$isparam" == true ]; then
params+=("$i")
isparam=
elif [ "${i##*.}" == "cue" ]; then
files+=("$i")
else
target="$i"
fi
done
com=("${params[@]}")
com+=("$target")
com+=("${files[@]}")
echo "------------------------------------------------------------------"
for i in "${com[@]}"; do
if [ "${i:0:2}" == -- ]; then
>&2 printf " %s" "$i"
else
>&2 printf " %s\n" "$i"
fi
done
"${com[@]}" || {
cd - > /dev/null
echo "Execution failure"
exit 1
}
cd - > /dev/null
;;
esac