Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Update init-tools.sh from corefx (#4166)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas authored Jul 15, 2017
1 parent ff7eba5 commit bad4b3e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
17 changes: 11 additions & 6 deletions init-tools.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ set DOTNET_LOCAL_PATH=%DOTNET_PATH%%DOTNET_ZIP_NAME%
echo Installing '%DOTNET_REMOTE_PATH%' to '%DOTNET_LOCAL_PATH%' >> "%INIT_TOOLS_LOG%"
powershell -NoProfile -ExecutionPolicy unrestricted -Command "$retryCount = 0; $success = $false; do { try { (New-Object Net.WebClient).DownloadFile('%DOTNET_REMOTE_PATH%', '%DOTNET_LOCAL_PATH%'); $success = $true; } catch { if ($retryCount -ge 6) { throw; } else { $retryCount++; Start-Sleep -Seconds (5 * $retryCount); } } } while ($success -eq $false); Add-Type -Assembly 'System.IO.Compression.FileSystem' -ErrorVariable AddTypeErrors; if ($AddTypeErrors.Count -eq 0) { [System.IO.Compression.ZipFile]::ExtractToDirectory('%DOTNET_LOCAL_PATH%', '%DOTNET_PATH%') } else { (New-Object -com shell.application).namespace('%DOTNET_PATH%').CopyHere((new-object -com shell.application).namespace('%DOTNET_LOCAL_PATH%').Items(),16) }" >> "%INIT_TOOLS_LOG%"
if NOT exist "%DOTNET_LOCAL_PATH%" (
echo ERROR: Could not install dotnet cli correctly. See '%INIT_TOOLS_LOG%' for more details. 1>&2
exit /b 1
echo ERROR: Could not install dotnet cli correctly. 1>&2
goto :error
)

:afterdotnetrestore
Expand All @@ -50,8 +50,8 @@ echo Restoring BuildTools version %BUILDTOOLS_VERSION%...
echo Running: "%DOTNET_CMD%" restore "%INIT_TOOLS_RESTORE_PROJECT%" --no-cache --packages %PACKAGES_DIR% --source "%BUILDTOOLS_SOURCE%" /p:BuildToolsPackageVersion=%BUILDTOOLS_VERSION% >> "%INIT_TOOLS_LOG%"
call "%DOTNET_CMD%" restore "%INIT_TOOLS_RESTORE_PROJECT%" --no-cache --packages %PACKAGES_DIR% --source "%BUILDTOOLS_SOURCE%" /p:BuildToolsPackageVersion=%BUILDTOOLS_VERSION% >> "%INIT_TOOLS_LOG%"
if NOT exist "%BUILD_TOOLS_PATH%init-tools.cmd" (
echo ERROR: Could not restore build tools correctly. See '%INIT_TOOLS_LOG%' for more details. 1>&2
exit /b 1
echo ERROR: Could not restore build tools correctly. 1>&2
goto :error
)

:afterbuildtoolsrestore
Expand All @@ -61,8 +61,8 @@ echo Running: "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRU
call "%BUILD_TOOLS_PATH%init-tools.cmd" "%~dp0" "%DOTNET_CMD%" "%TOOLRUNTIME_DIR%" >> "%INIT_TOOLS_LOG%"
set INIT_TOOLS_ERRORLEVEL=%ERRORLEVEL%
if not [%INIT_TOOLS_ERRORLEVEL%]==[0] (
echo ERROR: An error occured when trying to initialize the tools. Please check '%INIT_TOOLS_LOG%' for more details. 1>&2
exit /b %INIT_TOOLS_ERRORLEVEL%
echo ERROR: An error occured when trying to initialize the tools. 1>&2
goto :error
)

rem CoreRT does not use special copy of the shared runtime for testing
Expand All @@ -72,3 +72,8 @@ copy /Y %TOOLRUNTIME_DIR%\csc.runtimeconfig.json %TOOLRUNTIME_DIR%\xunit.console
echo Done initializing tools.
echo Init-Tools.cmd completed for BuildTools Version: %BUILDTOOLS_VERSION% > "%BUILD_TOOLS_SEMAPHORE%"
exit /b 0

:error
echo Please check the detailed log that follows. 1>&2
type "%INIT_TOOLS_LOG%" 1>&2
exit /b 1
29 changes: 22 additions & 7 deletions init-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ if [ -z "$__DOTNET_PKG" ]; then
if [ "$(uname -m | grep "i[3456]86")" = "i686" ]; then
echo "Warning: build not supported on 32 bit Unix"
fi
OSName=$(uname -s)
OSName=$(uname -s)
case $OSName in
Darwin)
OS=OSX
__DOTNET_PKG=dotnet-dev-osx-x64
ulimit -n 2048
# Format x.y.z as single integer with three digits for each part
VERSION=`sw_vers -productVersion| sed -e 's/\./ /g' | xargs printf "%03d%03d%03d"`
if [ "$VERSION" -lt 010012000 ]; then
echo error: macOS version `sw_vers -productVersion` is too old. 10.12 is needed as minimum.
exit 1
fi
;;

Linux)
Expand All @@ -40,6 +46,12 @@ OSName=$(uname -s)
esac
fi

display_error_message()
{
echo "Please check the detailed log that follows." 1>&2
cat "$__init_tools_log" 1>&2
}

if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then
__PATCH_CLI_NUGET_FRAMEWORKS=0

Expand All @@ -61,11 +73,10 @@ if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then
__DOTNET_LOCATION="https://dotnetcli.azureedge.net/dotnet/Sdk/${__DOTNET_TOOLS_VERSION}/${__DOTNET_PKG}.${__DOTNET_TOOLS_VERSION}.tar.gz"
# curl has HTTPS CA trust-issues less often than wget, so lets try that first.
echo "Installing '${__DOTNET_LOCATION}' to '$__DOTNET_PATH/dotnet.tar'" >> $__init_tools_log
which curl > /dev/null 2> /dev/null
if [ $? -ne 0 ]; then
wget -q -O $__DOTNET_PATH/dotnet.tar ${__DOTNET_LOCATION}
else
if command -v curl > /dev/null; then
curl --retry 10 -sSL --create-dirs -o $__DOTNET_PATH/dotnet.tar ${__DOTNET_LOCATION}
else
wget -q -O $__DOTNET_PATH/dotnet.tar ${__DOTNET_LOCATION}
fi
cd $__DOTNET_PATH
tar -xf $__DOTNET_PATH/dotnet.tar
Expand All @@ -88,7 +99,10 @@ if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then
echo "Restoring BuildTools version $__BUILD_TOOLS_PACKAGE_VERSION..."
echo "Running: $__DOTNET_CMD restore \"$__INIT_TOOLS_RESTORE_PROJECT\" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION" >> $__init_tools_log
$__DOTNET_CMD restore "$__INIT_TOOLS_RESTORE_PROJECT" --no-cache --packages $__PACKAGES_DIR --source $__BUILDTOOLS_SOURCE /p:BuildToolsPackageVersion=$__BUILD_TOOLS_PACKAGE_VERSION >> $__init_tools_log
if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then echo "ERROR: Could not restore build tools correctly. See '$__init_tools_log' for more details."1>&2; fi
if [ ! -e "$__BUILD_TOOLS_PATH/init-tools.sh" ]; then
echo "ERROR: Could not restore build tools correctly." 1>&2
display_error_message
fi
fi

echo "Initializing BuildTools..."
Expand All @@ -98,7 +112,8 @@ if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then
chmod +x $__BUILD_TOOLS_PATH/init-tools.sh
$__BUILD_TOOLS_PATH/init-tools.sh $__scriptpath $__DOTNET_CMD $__TOOLRUNTIME_DIR >> $__init_tools_log
if [ "$?" != "0" ]; then
echo "ERROR: An error occured when trying to initialize the tools. Please check '$__init_tools_log' for more details."1>&2
echo "ERROR: An error occurred when trying to initialize the tools." 1>&2
display_error_message
exit 1
fi
fi
Expand Down

0 comments on commit bad4b3e

Please sign in to comment.