You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Temporary disable exit on error to retry on non-zero exit code
24
-
set +e
32
+
test"$ERR_EXIT_ENABLED" = true&&set +e
25
33
http_code=$(eval $COMMAND)
26
34
exit_code=$?
35
+
test"$ERR_EXIT_ENABLED" = true&&set -e
27
36
if [ $http_code-eq 200 ] && [ $exit_code-eq 0 ];then
28
37
echo"Download completed"
29
38
return 0
30
39
else
31
40
echo"Error — Either HTTP response code for '$URL' is wrong - '$http_code' or exit code is not 0 - '$exit_code'. Waiting $interval seconds before the next attempt, $retries attempts left"
32
41
sleep 30
33
42
fi
34
-
# Enable exit on error back
35
-
set -e
36
43
done
37
44
38
45
echo"Could not download $URL"
@@ -120,98 +127,50 @@ get_brew_os_keyword() {
120
127
fi
121
128
}
122
129
123
-
should_build_from_source() {
124
-
local tool_name=$1
125
-
local os_name=$2
126
-
# If one of the parsers aborts with an error,
127
-
# we will get an empty variable notification in the logs
128
-
set -u
129
-
130
-
# Geting tool info from brew to find available install methods except build from source
131
-
local tool_info=$(brew info --json=v1 $tool_name)
132
-
133
-
# No need to build from source if a bottle is disabled
134
-
local bottle_disabled=$(echo -E $tool_info| jq ".[0].bottle_disabled")
135
-
if [[ $bottle_disabled=="true" ]];then
136
-
echo"false"
137
-
return
138
-
fi
139
-
140
-
# No need to build from source if a universal bottle is available
141
-
local all_bottle=$(echo -E $tool_info| jq ".[0].bottle.stable.files.all")
142
-
if [[ "$all_bottle"!="null" ]];then
143
-
echo"false"
144
-
return
145
-
fi
146
-
147
-
# No need to build from source if a bottle for current OS is available
148
-
local os_bottle=$(echo -E $tool_info| jq ".[0].bottle.stable.files.$os_name")
149
-
if [[ "$os_bottle"!="null" ]];then
150
-
echo"false"
151
-
return
152
-
fi
153
-
154
-
# Available method wasn't found - should build from source
155
-
echo"true"
156
-
}
157
-
158
130
# brew provides package bottles for different macOS versions
159
131
# The 'brew install' command will fail if a package bottle does not exist
160
132
# Use the '--build-from-source' option to build from source in this case
161
133
brew_smart_install() {
162
134
local tool_name=$1
163
135
164
-
local os_name=$(get_brew_os_keyword)
165
-
if [[ "$os_name"=="null" ]];then
166
-
echo"$OSTYPE is unknown operating system"
167
-
exit 1
168
-
fi
136
+
echo"Downloading $tool_name..."
169
137
170
-
local build_from_source=$(should_build_from_source "$tool_name""$os_name")
171
-
if$build_from_source;then
172
-
echo"Bottle of the $tool_name for the $os_name was not found. Building $tool_name from source..."
0 commit comments