-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgreenbase.resolve_deps
53 lines (44 loc) · 1.02 KB
/
greenbase.resolve_deps
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
#!/bin/bash
# -- Check greenbase dependencies and export variables
# /
#
fail() {
echo -e "\033[1;31m!!! ${1}\033[0m"
exit 1
} >&2
export -f fail
warn() {
echo -e "\033[1;33mWarning: ${1}\033[0m"
} >&2
export -f warn
# Make sure we are in a Git repo
[[ ! -e .git ]] && { fail "Not a git repo"; }
# Make sure we can run Git commands
if ! type git > /dev/null 2>&1; then
fail "Cannot run git. Is it in your PATH?"
fi
export git=$(which git)
# Make sure curl exists
if ! type curl > /dev/null 2>&1; then
fail "curl is not installed."
fi
export curl=$(which curl)
get_os_arch() {
arch=$(getconf LONG_BIT)
jq="${LIB_DIR}/jq/jq"
if [[ $arch -eq 64 ]]; then
echo 64
elif [[ $arch -eq 32 ]]; then
echo 32
elif [[ ! $( "${jq}64" --version 2>&1 ) =~ error ]]; then
echo 64
elif [[ ! $( "${jq}32" --version 2>&1 ) =~ error ]]; then
echo 32
else
echo "Unable to determine OS architecture. Defaulting to x86_64" >&2
echo 64
fi
}
# Use 32 or 64 bit jq?
jq="${LIB_DIR}/jq/jq$(get_os_arch)"
export jq