@@ -14,10 +14,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14
14
[ -z " ${DOTNET_HOME:- } " ] && DOTNET_HOME=" $HOME /.dotnet"
15
15
verbose=false
16
16
update=false
17
+ reinstall=false
17
18
repo_path=" $DIR "
18
19
channel=' '
19
20
tools_source=' '
20
21
tools_source_suffix=' '
22
+ ci=false
21
23
22
24
#
23
25
# Functions
@@ -38,6 +40,8 @@ __usage() {
38
40
echo " -s|--tools-source|-ToolsSource <URL> The base url where build tools can be downloaded. Overrides the value from the config file."
39
41
echo " --tools-source-suffix|-ToolsSourceSuffix <SUFFIX> The suffix to append to tools-source. Useful for query strings."
40
42
echo " -u|--update Update to the latest KoreBuild even if the lock file is present."
43
+ echo " --reinstall Reinstall KoreBuild."
44
+ echo " --ci Apply CI specific settings and environment variables."
41
45
echo " "
42
46
echo " Description:"
43
47
echo " This function will create a file \$ DIR/korebuild-lock.txt. This lock file can be committed to source, but does not have to be."
@@ -62,6 +66,10 @@ get_korebuild() {
62
66
version=" $( echo " ${version# version: } " | sed -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//' ) "
63
67
local korebuild_path=" $DOTNET_HOME /buildtools/korebuild/$version "
64
68
69
+ if [ " $reinstall " = true ] && [ -d " $korebuild_path " ]; then
70
+ rm -rf " $korebuild_path "
71
+ fi
72
+
65
73
{
66
74
if [ ! -d " $korebuild_path " ]; then
67
75
mkdir -p " $korebuild_path "
@@ -175,6 +183,12 @@ while [[ $# -gt 0 ]]; do
175
183
-u|--update|-Update)
176
184
update=true
177
185
;;
186
+ --reinstall|-[Rr]einstall)
187
+ reinstall=true
188
+ ;;
189
+ --ci|-[Cc][Ii])
190
+ ci=true
191
+ ;;
178
192
--verbose|-Verbose)
179
193
verbose=true
180
194
;;
@@ -206,17 +220,28 @@ if [ -f "$config_file" ]; then
206
220
config_channel=" $( jq -r ' select(.channel!=null) | .channel' " $config_file " ) "
207
221
config_tools_source=" $( jq -r ' select(.toolsSource!=null) | .toolsSource' " $config_file " ) "
208
222
else
209
- __warn " $config_file is invalid JSON. Its settings will be ignored."
223
+ _error " $config_file contains invalid JSON."
224
+ exit 1
210
225
fi
211
226
elif __machine_has python ; then
212
227
if python -c " import json,codecs;obj=json.load(codecs.open('$config_file ', 'r', 'utf-8-sig'))" > /dev/null ; then
213
228
config_channel=" $( python -c " import json,codecs;obj=json.load(codecs.open('$config_file ', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')" ) "
214
229
config_tools_source=" $( python -c " import json,codecs;obj=json.load(codecs.open('$config_file ', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')" ) "
215
230
else
216
- __warn " $config_file is invalid JSON. Its settings will be ignored."
231
+ _error " $config_file contains invalid JSON."
232
+ exit 1
233
+ fi
234
+ elif __machine_has python3 ; then
235
+ if python3 -c " import json,codecs;obj=json.load(codecs.open('$config_file ', 'r', 'utf-8-sig'))" > /dev/null ; then
236
+ config_channel=" $( python3 -c " import json,codecs;obj=json.load(codecs.open('$config_file ', 'r', 'utf-8-sig'));print(obj['channel'] if 'channel' in obj else '')" ) "
237
+ config_tools_source=" $( python3 -c " import json,codecs;obj=json.load(codecs.open('$config_file ', 'r', 'utf-8-sig'));print(obj['toolsSource'] if 'toolsSource' in obj else '')" ) "
238
+ else
239
+ _error " $config_file contains invalid JSON."
240
+ exit 1
217
241
fi
218
242
else
219
- __warn ' Missing required command: jq or pyton. Could not parse the JSON file. Its settings will be ignored.'
243
+ _error ' Missing required command: jq or python. Could not parse the JSON file.'
244
+ exit 1
220
245
fi
221
246
222
247
[ ! -z " ${config_channel:- } " ] && channel=" $config_channel "
227
252
[ -z " $tools_source " ] && tools_source=' https://aspnetcore.blob.core.windows.net/buildtools'
228
253
229
254
get_korebuild
230
- set_korebuildsettings " $tools_source " " $DOTNET_HOME " " $repo_path " " $config_file "
255
+ set_korebuildsettings " $tools_source " " $DOTNET_HOME " " $repo_path " " $config_file " " $ci "
231
256
invoke_korebuild_command " $command " " $@ "
0 commit comments