| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- commit 14aec22cda2c0c81b369b08c7d260afffae20c9d
- Author: Ryan Brandenburg <[email protected]>
- Date: Fri Dec 1 10:24:09 2017 -0800
- Update bootstrappers
- diff --git a/run.ps1 b/run.ps1
- index 49c28998564..27dcf848f84 100644
- --- a/run.ps1
- +++ b/run.ps1
- @@ -29,6 +29,9 @@ Updates KoreBuild to the latest version even if a lock file is present.
- .PARAMETER ConfigFile
- The path to the configuration file that stores values. Defaults to korebuild.json.
-
- +.PARAMETER ToolsSourceSuffix
- +The Suffix to append to the end of the ToolsSource. Useful for query strings in blob stores.
- +
- .PARAMETER Arguments
- Arguments to be passed to the command
-
- @@ -51,7 +54,7 @@ Example config file:
- #>
- [CmdletBinding(PositionalBinding = $false)]
- param(
- - [Parameter(Mandatory=$true, Position = 0)]
- + [Parameter(Mandatory = $true, Position = 0)]
- [string]$Command,
- [string]$Path = $PSScriptRoot,
- [Alias('c')]
- @@ -63,6 +66,7 @@ param(
- [Alias('u')]
- [switch]$Update,
- [string]$ConfigFile,
- + [string]$ToolsSourceSuffix,
- [Parameter(ValueFromRemainingArguments = $true)]
- [string[]]$Arguments
- )
- @@ -79,7 +83,7 @@ function Get-KoreBuild {
- $lockFile = Join-Path $Path 'korebuild-lock.txt'
-
- if (!(Test-Path $lockFile) -or $Update) {
- - Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile
- + Get-RemoteFile "$ToolsSource/korebuild/channels/$Channel/latest.txt" $lockFile $ToolsSourceSuffix
- }
-
- $version = Get-Content $lockFile | Where-Object { $_ -like 'version:*' } | Select-Object -first 1
- @@ -96,7 +100,7 @@ function Get-KoreBuild {
-
- try {
- $tmpfile = Join-Path ([IO.Path]::GetTempPath()) "KoreBuild-$([guid]::NewGuid()).zip"
- - Get-RemoteFile $remotePath $tmpfile
- + Get-RemoteFile $remotePath $tmpfile $ToolsSourceSuffix
- if (Get-Command -Name 'Expand-Archive' -ErrorAction Ignore) {
- # Use built-in commands where possible as they are cross-plat compatible
- Expand-Archive -Path $tmpfile -DestinationPath $korebuildPath
- @@ -124,7 +128,7 @@ function Join-Paths([string]$path, [string[]]$childPaths) {
- return $path
- }
-
- -function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) {
- +function Get-RemoteFile([string]$RemotePath, [string]$LocalPath, [string]$RemoteSuffix) {
- if ($RemotePath -notlike 'http*') {
- Copy-Item $RemotePath $LocalPath
- return
- @@ -134,7 +138,7 @@ function Get-RemoteFile([string]$RemotePath, [string]$LocalPath) {
- while ($retries -gt 0) {
- $retries -= 1
- try {
- - Invoke-WebRequest -UseBasicParsing -Uri $RemotePath -OutFile $LocalPath
- + Invoke-WebRequest -UseBasicParsing -Uri $($RemotePath + $RemoteSuffix) -OutFile $LocalPath
- return
- }
- catch {
- @@ -161,7 +165,8 @@ if (Test-Path $ConfigFile) {
- if (!($Channel) -and (Get-Member -Name 'channel' -InputObject $config)) { [string] $Channel = $config.channel }
- if (!($ToolsSource) -and (Get-Member -Name 'toolsSource' -InputObject $config)) { [string] $ToolsSource = $config.toolsSource}
- }
- - } catch {
- + }
- + catch {
- Write-Warning "$ConfigFile could not be read. Its settings will be ignored."
- Write-Warning $Error[0]
- }
- diff --git a/run.sh b/run.sh
- index c278423accb..834961fc3a5 100755
- --- a/run.sh
- +++ b/run.sh
- @@ -17,6 +17,7 @@ update=false
- repo_path="$DIR"
- channel=''
- tools_source=''
- +tools_source_suffix=''
-
- #
- # Functions
- @@ -29,13 +30,14 @@ __usage() {
- echo " <Arguments>... Arguments passed to the command. Variable number of arguments allowed."
- echo ""
- echo "Options:"
- - echo " --verbose Show verbose output."
- - echo " -c|--channel <CHANNEL> The channel of KoreBuild to download. Overrides the value from the config file.."
- - echo " --config-file <FILE> The path to the configuration file that stores values. Defaults to korebuild.json."
- - echo " -d|--dotnet-home <DIR> The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet."
- - echo " --path <PATH> The directory to build. Defaults to the directory containing the script."
- - echo " -s|--tools-source|-ToolsSource <URL> The base url where build tools can be downloaded. Overrides the value from the config file."
- - echo " -u|--update Update to the latest KoreBuild even if the lock file is present."
- + echo " --verbose Show verbose output."
- + echo " -c|--channel <CHANNEL> The channel of KoreBuild to download. Overrides the value from the config file.."
- + echo " --config-file <FILE> The path to the configuration file that stores values. Defaults to korebuild.json."
- + echo " -d|--dotnet-home <DIR> The directory where .NET Core tools will be stored. Defaults to '\$DOTNET_HOME' or '\$HOME/.dotnet."
- + echo " --path <PATH> The directory to build. Defaults to the directory containing the script."
- + echo " -s|--tools-source|-ToolsSource <URL> The base url where build tools can be downloaded. Overrides the value from the config file."
- + echo " --tools-source-suffix|-ToolsSourceSuffix <SUFFIX> The suffix to append to tools-source. Useful for query strings."
- + echo " -u|--update Update to the latest KoreBuild even if the lock file is present."
- echo ""
- echo "Description:"
- 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."
- @@ -50,7 +52,7 @@ get_korebuild() {
- local version
- local lock_file="$repo_path/korebuild-lock.txt"
- if [ ! -f "$lock_file" ] || [ "$update" = true ]; then
- - __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file"
- + __get_remote_file "$tools_source/korebuild/channels/$channel/latest.txt" "$lock_file" "$tools_source_suffix"
- fi
- version="$(grep 'version:*' -m 1 "$lock_file")"
- if [[ "$version" == '' ]]; then
- @@ -66,7 +68,7 @@ get_korebuild() {
- local remote_path="$tools_source/korebuild/artifacts/$version/korebuild.$version.zip"
- tmpfile="$(mktemp)"
- echo -e "${MAGENTA}Downloading KoreBuild ${version}${RESET}"
- - if __get_remote_file "$remote_path" "$tmpfile"; then
- + if __get_remote_file "$remote_path" "$tmpfile" "$tools_source_suffix"; then
- unzip -q -d "$korebuild_path" "$tmpfile"
- fi
- rm "$tmpfile" || true
- @@ -98,6 +100,7 @@ __machine_has() {
- __get_remote_file() {
- local remote_path=$1
- local local_path=$2
- + local remote_path_suffix=$3
-
- if [[ "$remote_path" != 'http'* ]]; then
- cp "$remote_path" "$local_path"
- @@ -106,14 +109,14 @@ __get_remote_file() {
-
- local failed=false
- if __machine_has wget; then
- - wget --tries 10 --quiet -O "$local_path" "$remote_path" || failed=true
- + wget --tries 10 --quiet -O "$local_path" "${remote_path}${remote_path_suffix}" || failed=true
- else
- failed=true
- fi
-
- if [ "$failed" = true ] && __machine_has curl; then
- failed=false
- - curl --retry 10 -sSL -f --create-dirs -o "$local_path" "$remote_path" || failed=true
- + curl --retry 10 -sSL -f --create-dirs -o "$local_path" "${remote_path}${remote_path_suffix}" || failed=true
- fi
-
- if [ "$failed" = true ]; then
- @@ -164,6 +167,11 @@ while [[ $# -gt 0 ]]; do
- tools_source="${1:-}"
- [ -z "$tools_source" ] && __usage
- ;;
- + --tools-source-suffix|-ToolsSourceSuffix)
- + shift
- + tools_source_suffix="${1:-}"
- + [ -z "$tools_source_suffix" ] && __usage
- + ;;
- -u|--update|-Update)
- update=true
- ;;
|