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
# Define endpoint
endpoint_url="https://kitcreator.rkeene.org/kitcreator"
# Set arguments
declare -A jsonArgs
jsonArgs["platform"]="$(uname -s)-$(uname -m)"
nextArg=''
kit_filename=''
for arg in "$@"; do
if [ -n "${nextArg}" ]; then
jsonArgs["${nextArg}"]="${arg}"
nextArg=''
continue
fi
case "${arg}" in
--platform|--tcl-version|--kitcreator-version)
nextArg="${arg:2}"
nextArg="${nextArg//-/_}"
;;
esac
done
# Convert arguments into a request
jqArgs=()
jqSettings=''
for jsonArg in "${!jsonArgs[@]}"; do
jqArgs+=(--arg "${jsonArg}" "${jsonArgs[${jsonArg}]}")
jqSettings="${jqSettings} | .${jsonArg} = \$${jsonArg}"
done
jqArgs+=("${jqSettings:3}")
jsonRequest="$(jq -crM "${jqArgs[@]}" <<<'{"action":"build"}')"
# Make the request
results="$(curl -sSL -d "json=${jsonRequest}" "${endpoint_url}")"
url="$(jq -crM .url <<<"${results}")"
while true; do
info="$(curl -sSL "${url}")"
terminal="$(jq -crM .terminal <<<"${info}")"
if [ "${terminal}" = 'true' ]; then
break
fi
sleep 30
done
status="$(jq -crM .status <<<"${info}")"
if [ "${status}" != "complete" ]; then
echo "failed: ${status}" >&2
exit 1
fi
kit_url="$(jq -crM .kit_url <<<"${info}")"
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
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
|
#! /usr/bin/env bash
# Define endpoint
endpoint_url="https://kitcreator.rkeene.org/kitcreator"
# Set arguments
declare -A jsonArgs
jsonArgs["platform"]="$(uname -s)-$(uname -m)"
nextArg=''
kit_filename=''
options=()
for arg in "$@"; do
if [ -n "${nextArg}" ]; then
jsonArgs["${nextArg}"]="${arg}"
nextArg=''
continue
fi
case "${arg}" in
--platform|--tcl-version|--kitcreator-version)
nextArg="${arg:2}"
nextArg="${nextArg//-/_}"
;;
--kitdll|--threaded)
options+=("${arg:2}")
;;
esac
done
if [ -n "${options[*]}" ]; then
jsonArgs["options"]="${options[@]}"
fi
# Convert arguments into a request
jqArgs=()
jqSettings=''
for jsonArg in "${!jsonArgs[@]}"; do
case "${jsonArg}" in
options)
requestArray='[]'
for value in ${jsonArgs[${jsonArg}]}; do
requestArray="$(jq -crM --arg value "${value}" '. + [ $value ]' <<<"${requestArray}")"
done
jqArgs+=(--argjson "${jsonArg}" "${requestArray}")
;;
*)
jqArgs+=(--arg "${jsonArg}" "${jsonArgs[${jsonArg}]}")
;;
esac
jqSettings="${jqSettings} | .${jsonArg} = \$${jsonArg}"
done
jqArgs+=("${jqSettings:3}")
jsonRequest="$(jq -crM "${jqArgs[@]}" <<<'{"action":"build"}')"
# Make the request
results="$(curl -sSL -d "json=${jsonRequest}" "${endpoint_url}")"
url="$(jq -crM .url <<<"${results}")"
while true; do
info="$(curl -sSL "${url}")"
terminal="$(jq -crM .terminal <<<"${info}")"
if [ "${terminal}" = 'true' ]; then
break
fi
if [ -z "${buildStatusWroteHeader}" ]; then
buildStatusWroteHeader='1'
echo -n 'Building...'
fi
sleep 30
echo -n '.'
done
status="$(jq -crM .status <<<"${info}")"
if [ -n "${buildStatusWroteHeader}" ]; then
echo " ${status}"
fi
if [ "${status}" != "complete" ]; then
echo "failed: ${status}" >&2
exit 1
fi
kit_url="$(jq -crM .kit_url <<<"${info}")"
|