@@ -14,10 +14,12 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1414[ -z " ${DOTNET_HOME:- } " ] && DOTNET_HOME=" $HOME /.dotnet"
1515verbose=false
1616update=false
17+ reinstall=false
1718repo_path=" $DIR "
1819channel=' '
1920tools_source=' '
2021tools_source_suffix=' '
22+ ci=false
2123
2224#
2325# Functions
@@ -38,6 +40,8 @@ __usage() {
3840 echo " -s|--tools-source|-ToolsSource <URL> The base url where build tools can be downloaded. Overrides the value from the config file."
3941 echo " --tools-source-suffix|-ToolsSourceSuffix <SUFFIX> The suffix to append to tools-source. Useful for query strings."
4042 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."
4145 echo " "
4246 echo " Description:"
4347 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() {
6266 version=" $( echo " ${version# version: } " | sed -e ' s/^[[:space:]]*//' -e ' s/[[:space:]]*$//' ) "
6367 local korebuild_path=" $DOTNET_HOME /buildtools/korebuild/$version "
6468
69+ if [ " $reinstall " = true ] && [ -d " $korebuild_path " ]; then
70+ rm -rf " $korebuild_path "
71+ fi
72+
6573 {
6674 if [ ! -d " $korebuild_path " ]; then
6775 mkdir -p " $korebuild_path "
@@ -175,6 +183,12 @@ while [[ $# -gt 0 ]]; do
175183 -u|--update|-Update)
176184 update=true
177185 ;;
186+ --reinstall|-[Rr]einstall)
187+ reinstall=true
188+ ;;
189+ --ci|-[Cc][Ii])
190+ ci=true
191+ ;;
178192 --verbose|-Verbose)
179193 verbose=true
180194 ;;
@@ -206,17 +220,28 @@ if [ -f "$config_file" ]; then
206220 config_channel=" $( jq -r ' select(.channel!=null) | .channel' " $config_file " ) "
207221 config_tools_source=" $( jq -r ' select(.toolsSource!=null) | .toolsSource' " $config_file " ) "
208222 else
209- __warn " $config_file is invalid JSON. Its settings will be ignored."
223+ _error " $config_file contains invalid JSON."
224+ exit 1
210225 fi
211226 elif __machine_has python ; then
212227 if python -c " import json,codecs;obj=json.load(codecs.open('$config_file ', 'r', 'utf-8-sig'))" > /dev/null ; then
213228 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 '')" ) "
214229 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 '')" ) "
215230 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
217241 fi
218242 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
220245 fi
221246
222247 [ ! -z " ${config_channel:- } " ] && channel=" $config_channel "
227252[ -z " $tools_source " ] && tools_source=' https://aspnetcore.blob.core.windows.net/buildtools'
228253
229254get_korebuild
230- set_korebuildsettings " $tools_source " " $DOTNET_HOME " " $repo_path " " $config_file "
255+ set_korebuildsettings " $tools_source " " $DOTNET_HOME " " $repo_path " " $config_file " " $ci "
231256invoke_korebuild_command " $command " " $@ "
0 commit comments