mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
Merge branch 'master' into v-mapetr/linux/update-az
This commit is contained in:
95
images/linux/scripts/installers/Configure-Toolset.ps1
Normal file
95
images/linux/scripts/installers/Configure-Toolset.ps1
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
################################################################################
|
||||||
|
## File: Configure-Toolset.ps1
|
||||||
|
## Team: CI-Build
|
||||||
|
## Desc: Configure toolset
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
function Get-ToolsetToolFullPath
|
||||||
|
{
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory)] [string] $ToolName,
|
||||||
|
[Parameter(Mandatory)] [string] $ToolVersion,
|
||||||
|
[Parameter(Mandatory)] [string] $ToolArchitecture
|
||||||
|
)
|
||||||
|
|
||||||
|
$toolPath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $toolName
|
||||||
|
$toolPathVersion = Join-Path -Path $toolPath -ChildPath $toolVersion
|
||||||
|
$foundVersion = Get-Item $toolPathVersion | Sort-Object -Property {[version]$_.name} -Descending | Select-Object -First 1
|
||||||
|
$installationDir = Join-Path -Path $foundVersion -ChildPath $toolArchitecture
|
||||||
|
return $installationDir
|
||||||
|
}
|
||||||
|
|
||||||
|
function Add-EnvironmentVariable
|
||||||
|
{
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory)] [string] $Name,
|
||||||
|
[Parameter(Mandatory)] [string] $Value,
|
||||||
|
[string] $FilePath = "/etc/environment"
|
||||||
|
)
|
||||||
|
|
||||||
|
$envVar = "{0}={1}" -f $name, $value
|
||||||
|
Tee-Object -InputObject $envVar -FilePath $filePath -Append
|
||||||
|
}
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
Write-Host "Configure toolset tools environment..."
|
||||||
|
$toolsEnvironment = @{
|
||||||
|
boost = @{
|
||||||
|
variableTemplate = "BOOST_ROOT_{0}_{1}_{2}"
|
||||||
|
}
|
||||||
|
go = @{
|
||||||
|
command = "ln -s {0}/bin/* /usr/bin/"
|
||||||
|
defaultVariable = "GOROOT"
|
||||||
|
variableTemplate = "GOROOT_{0}_{1}_X64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$toolset = Get-Content -Path "$env:INSTALLER_SCRIPT_FOLDER/toolset.json" -Raw | ConvertFrom-Json
|
||||||
|
|
||||||
|
foreach ($tool in $toolset.toolcache)
|
||||||
|
{
|
||||||
|
$toolName = $tool.name
|
||||||
|
$toolArch = $tool.arch
|
||||||
|
$toolEnvironment = $toolsEnvironment[$toolName]
|
||||||
|
|
||||||
|
if (-not $toolEnvironment)
|
||||||
|
{
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($toolVersion in $tool.versions)
|
||||||
|
{
|
||||||
|
Write-Host "Set $toolName $toolVersion environment variable..."
|
||||||
|
$toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolVersion -ToolArchitecture $toolArch
|
||||||
|
$envName = $toolEnvironment.variableTemplate -f $toolVersion.split(".")
|
||||||
|
|
||||||
|
# Add environment variable name=value
|
||||||
|
Add-EnvironmentVariable -Name $envName -Value $toolPath
|
||||||
|
}
|
||||||
|
|
||||||
|
# Invoke command and add env variable for the default tool version
|
||||||
|
$toolDefVersion = $tool.default
|
||||||
|
if (-not $toolDefVersion)
|
||||||
|
{
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
$envDefName = $toolEnvironment.defaultVariable
|
||||||
|
$toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolDefVersion -ToolArchitecture $toolArch
|
||||||
|
|
||||||
|
if ($envDefName)
|
||||||
|
{
|
||||||
|
Write-Host "Set default $envDefName for $toolName $toolDefVersion environment variable..."
|
||||||
|
Add-EnvironmentVariable -Name $envDefName -Value $toolPath
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($toolEnvironment.command)
|
||||||
|
{
|
||||||
|
$command = $toolEnvironment.command -f $toolPath
|
||||||
|
Write-Host "Invoke $command command for default $toolName $toolDefVersion..."
|
||||||
|
Invoke-Expression -Command $command
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,7 +30,7 @@ $ErrorActionPreference = "Stop"
|
|||||||
$toolsetJson = Get-Content -Path "$env:INSTALLER_SCRIPT_FOLDER/toolset.json" -Raw
|
$toolsetJson = Get-Content -Path "$env:INSTALLER_SCRIPT_FOLDER/toolset.json" -Raw
|
||||||
$toolsToInstall = @("Python", "Node", "Boost", "Go")
|
$toolsToInstall = @("Python", "Node", "Boost", "Go")
|
||||||
|
|
||||||
$tools = ConvertFrom-Json -InputObject $toolsetJson | Select-Object -ExpandProperty toolcache | Where {$ToolsToInstall -contains $_.Name}
|
$tools = ConvertFrom-Json -InputObject $toolsetJson | Select-Object -ExpandProperty toolcache | Where-Object {$ToolsToInstall -contains $_.Name}
|
||||||
|
|
||||||
foreach ($tool in $tools) {
|
foreach ($tool in $tools) {
|
||||||
# Get versions manifest for current tool
|
# Get versions manifest for current tool
|
||||||
@@ -44,10 +44,9 @@ foreach ($tool in $tools) {
|
|||||||
| Select-Object -First 1
|
| Select-Object -First 1
|
||||||
|
|
||||||
Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..."
|
Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..."
|
||||||
if ($asset -ne $null) {
|
if ($null -ne $asset) {
|
||||||
Install-Asset -ReleaseAsset $asset
|
Install-Asset -ReleaseAsset $asset
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Write-Host "Asset was not found in versions manifest"
|
Write-Host "Asset was not found in versions manifest"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
################################################################################
|
|
||||||
## File: boost.sh
|
|
||||||
## Desc: Installs Boost C++ Libraries
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
TOOLSET_PATH="$INSTALLER_SCRIPT_FOLDER/toolset.json"
|
|
||||||
BOOST_LIB="$AGENT_TOOLSDIRECTORY/boost"
|
|
||||||
BOOST_VERSIONS=$(cat $TOOLSET_PATH | jq -r '.toolcache[] | select(.name | contains("boost")) | .versions[]')
|
|
||||||
BOOST_ARCH=$(cat $TOOLSET_PATH | jq -r '.toolcache[] | select(.name | contains("boost")) | .arch')
|
|
||||||
|
|
||||||
# Install Boost
|
|
||||||
for BOOST_VERSION in ${BOOST_VERSIONS}
|
|
||||||
do
|
|
||||||
BOOST_SYMLINK_VER=$(echo "${BOOST_VERSION//[.]/_}")
|
|
||||||
BOOST_ROOT_VERSION="BOOST_ROOT_$BOOST_SYMLINK_VER"
|
|
||||||
|
|
||||||
echo "$BOOST_ROOT_VERSION=$BOOST_LIB/$BOOST_VERSION/$BOOST_ARCH" | tee -a /etc/environment
|
|
||||||
done
|
|
||||||
@@ -27,6 +27,10 @@ else
|
|||||||
echo "Docker ($docker_package) is already installed"
|
echo "Docker ($docker_package) is already installed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Enable docker.service
|
||||||
|
systemctl is-active --quiet docker.service || systemctl start docker.service
|
||||||
|
systemctl is-enabled --quiet docker.service || systemctl enable docker.service
|
||||||
|
|
||||||
# Run tests to determine that the software installed as expected
|
# Run tests to determine that the software installed as expected
|
||||||
echo "Testing to make sure that script performed as expected, and basic scenarios work"
|
echo "Testing to make sure that script performed as expected, and basic scenarios work"
|
||||||
echo "Checking the docker-moby and moby-buildx"
|
echo "Checking the docker-moby and moby-buildx"
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
################################################################################
|
|
||||||
## File: go.sh
|
|
||||||
## Desc: Installs go, configures GOROOT, and adds go to the path
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# Fail out if any setups fail
|
|
||||||
set -e
|
|
||||||
|
|
||||||
toolsetJson="$INSTALLER_SCRIPT_FOLDER/toolset.json"
|
|
||||||
toolsetVersions=(`ls $AGENT_TOOLSDIRECTORY/go`)
|
|
||||||
defaultVersion=$(jq -r '.toolcache[] | select(.name | contains("go")) | .default' $toolsetJson)
|
|
||||||
|
|
||||||
for toolsetVersion in ${toolsetVersions[@]}
|
|
||||||
do
|
|
||||||
major="$(cut -d'.' -f1 <<< "$toolsetVersion")"
|
|
||||||
minor="$(cut -d'.' -f2 <<< "$toolsetVersion")"
|
|
||||||
goFolder="$AGENT_TOOLSDIRECTORY/go/$toolsetVersion/x64"
|
|
||||||
|
|
||||||
echo "GOROOT_${major}_${minor}_X64=$goFolder" | tee -a /etc/environment
|
|
||||||
|
|
||||||
if [[ "$toolsetVersion" =~ $defaultVersion ]]; then
|
|
||||||
ln -s $goFolder/bin/* /usr/bin/
|
|
||||||
echo "GOROOT=$goFolder" | tee -a /etc/environment
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
@@ -247,12 +247,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolcache-1604.json",
|
"source": "{{template_dir}}/toolsets/toolcache-1604.json",
|
||||||
"destination": "{{user `installer_script_folder`}}/toolcache.json"
|
"destination": "{{user `installer_script_folder`}}/toolcache.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolset-1604.json",
|
"source": "{{template_dir}}/toolsets/toolset-1604.json",
|
||||||
"destination": "{{user `installer_script_folder`}}/toolset.json"
|
"destination": "{{user `installer_script_folder`}}/toolset.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -278,6 +278,7 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{template_dir}}/scripts/installers/Install-Toolset.ps1",
|
"{{template_dir}}/scripts/installers/Install-Toolset.ps1",
|
||||||
|
"{{template_dir}}/scripts/installers/Configure-Toolset.ps1",
|
||||||
"{{template_dir}}/scripts/installers/Validate-Toolset.ps1"
|
"{{template_dir}}/scripts/installers/Validate-Toolset.ps1"
|
||||||
],
|
],
|
||||||
"environment_vars": [
|
"environment_vars": [
|
||||||
@@ -287,28 +288,6 @@
|
|||||||
],
|
],
|
||||||
"execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'"
|
"execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "shell",
|
|
||||||
"scripts": [
|
|
||||||
"{{template_dir}}/scripts/installers/go.sh"
|
|
||||||
],
|
|
||||||
"environment_vars": [
|
|
||||||
"INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}"
|
|
||||||
],
|
|
||||||
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "shell",
|
|
||||||
"scripts":[
|
|
||||||
"{{template_dir}}/scripts/installers/boost.sh"
|
|
||||||
],
|
|
||||||
"environment_vars": [
|
|
||||||
"METADATA_FILE={{user `metadata_file`}}",
|
|
||||||
"HELPER_SCRIPTS={{user `helper_script_folder`}}",
|
|
||||||
"INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}"
|
|
||||||
],
|
|
||||||
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"scripts":[
|
"scripts":[
|
||||||
|
|||||||
@@ -251,12 +251,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolcache-1804.json",
|
"source": "{{template_dir}}/toolsets/toolcache-1804.json",
|
||||||
"destination": "{{user `installer_script_folder`}}/toolcache.json"
|
"destination": "{{user `installer_script_folder`}}/toolcache.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolset-1804.json",
|
"source": "{{template_dir}}/toolsets/toolset-1804.json",
|
||||||
"destination": "{{user `installer_script_folder`}}/toolset.json"
|
"destination": "{{user `installer_script_folder`}}/toolset.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -282,6 +282,7 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{template_dir}}/scripts/installers/Install-Toolset.ps1",
|
"{{template_dir}}/scripts/installers/Install-Toolset.ps1",
|
||||||
|
"{{template_dir}}/scripts/installers/Configure-Toolset.ps1",
|
||||||
"{{template_dir}}/scripts/installers/Validate-Toolset.ps1"
|
"{{template_dir}}/scripts/installers/Validate-Toolset.ps1"
|
||||||
],
|
],
|
||||||
"environment_vars": [
|
"environment_vars": [
|
||||||
@@ -291,28 +292,6 @@
|
|||||||
],
|
],
|
||||||
"execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'"
|
"execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "shell",
|
|
||||||
"scripts": [
|
|
||||||
"{{template_dir}}/scripts/installers/go.sh"
|
|
||||||
],
|
|
||||||
"environment_vars": [
|
|
||||||
"INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}"
|
|
||||||
],
|
|
||||||
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "shell",
|
|
||||||
"scripts":[
|
|
||||||
"{{template_dir}}/scripts/installers/boost.sh"
|
|
||||||
],
|
|
||||||
"environment_vars": [
|
|
||||||
"METADATA_FILE={{user `metadata_file`}}",
|
|
||||||
"HELPER_SCRIPTS={{user `helper_script_folder`}}",
|
|
||||||
"INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}"
|
|
||||||
],
|
|
||||||
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"scripts":[
|
"scripts":[
|
||||||
|
|||||||
@@ -252,12 +252,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolcache-2004.json",
|
"source": "{{template_dir}}/toolsets/toolcache-2004.json",
|
||||||
"destination": "{{user `installer_script_folder`}}/toolcache.json"
|
"destination": "{{user `installer_script_folder`}}/toolcache.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolset-2004.json",
|
"source": "{{template_dir}}/toolsets/toolset-2004.json",
|
||||||
"destination": "{{user `installer_script_folder`}}/toolset.json"
|
"destination": "{{user `installer_script_folder`}}/toolset.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -283,6 +283,7 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{template_dir}}/scripts/installers/Install-Toolset.ps1",
|
"{{template_dir}}/scripts/installers/Install-Toolset.ps1",
|
||||||
|
"{{template_dir}}/scripts/installers/Configure-Toolset.ps1",
|
||||||
"{{template_dir}}/scripts/installers/Validate-Toolset.ps1"
|
"{{template_dir}}/scripts/installers/Validate-Toolset.ps1"
|
||||||
],
|
],
|
||||||
"environment_vars": [
|
"environment_vars": [
|
||||||
@@ -292,16 +293,6 @@
|
|||||||
],
|
],
|
||||||
"execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'"
|
"execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "shell",
|
|
||||||
"scripts": [
|
|
||||||
"{{template_dir}}/scripts/installers/go.sh"
|
|
||||||
],
|
|
||||||
"environment_vars": [
|
|
||||||
"INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}"
|
|
||||||
],
|
|
||||||
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"scripts":[
|
"scripts":[
|
||||||
|
|||||||
@@ -337,12 +337,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolcache-2016.json",
|
"source": "{{template_dir}}/toolsets/toolcache-2016.json",
|
||||||
"destination": "{{user `root_folder`}}/toolcache.json"
|
"destination": "{{user `root_folder`}}/toolcache.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolset-2016.json",
|
"source": "{{template_dir}}/toolsets/toolset-2016.json",
|
||||||
"destination": "{{user `toolset_json_path`}}"
|
"destination": "{{user `toolset_json_path`}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -370,16 +370,8 @@
|
|||||||
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
||||||
],
|
],
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{ template_dir }}/scripts/Installers/Install-Toolset.ps1"
|
"{{ template_dir }}/scripts/Installers/Install-Toolset.ps1",
|
||||||
]
|
"{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "powershell",
|
|
||||||
"environment_vars":[
|
|
||||||
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
|
||||||
],
|
|
||||||
"scripts":[
|
|
||||||
"{{ template_dir }}/scripts/Installers/Install-Go.ps1"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -606,16 +598,6 @@
|
|||||||
"{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1"
|
"{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "powershell",
|
|
||||||
"environment_vars": [
|
|
||||||
"ROOT_FOLDER={{user `root_folder`}}",
|
|
||||||
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
|
||||||
],
|
|
||||||
"scripts":[
|
|
||||||
"{{ template_dir }}/scripts/Installers/Install-Boost.ps1"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "powershell",
|
"type": "powershell",
|
||||||
"scripts":[
|
"scripts":[
|
||||||
|
|||||||
@@ -304,12 +304,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolcache-2019.json",
|
"source": "{{template_dir}}/toolsets/toolcache-2019.json",
|
||||||
"destination": "{{user `root_folder`}}/toolcache.json"
|
"destination": "{{user `root_folder`}}/toolcache.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"source": "{{template_dir}}/toolset-2019.json",
|
"source": "{{template_dir}}/toolsets/toolset-2019.json",
|
||||||
"destination": "{{user `toolset_json_path`}}"
|
"destination": "{{user `toolset_json_path`}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -337,16 +337,8 @@
|
|||||||
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
||||||
],
|
],
|
||||||
"scripts":[
|
"scripts":[
|
||||||
"{{ template_dir }}/scripts/Installers/Install-Toolset.ps1"
|
"{{ template_dir }}/scripts/Installers/Install-Toolset.ps1",
|
||||||
]
|
"{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "powershell",
|
|
||||||
"environment_vars":[
|
|
||||||
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
|
||||||
],
|
|
||||||
"scripts":[
|
|
||||||
"{{ template_dir }}/scripts/Installers/Install-Go.ps1"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -567,16 +559,6 @@
|
|||||||
"{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1"
|
"{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "powershell",
|
|
||||||
"environment_vars": [
|
|
||||||
"ROOT_FOLDER={{user `root_folder`}}",
|
|
||||||
"TOOLSET_JSON_PATH={{user `toolset_json_path`}}"
|
|
||||||
],
|
|
||||||
"scripts":[
|
|
||||||
"{{ template_dir }}/scripts/Installers/Install-Boost.ps1"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "powershell",
|
"type": "powershell",
|
||||||
"scripts":[
|
"scripts":[
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ Export-ModuleMember -Function @(
|
|||||||
'Install-VisualStudio'
|
'Install-VisualStudio'
|
||||||
'Get-ToolcachePackages'
|
'Get-ToolcachePackages'
|
||||||
'Get-ToolsetContent'
|
'Get-ToolsetContent'
|
||||||
|
'Get-ToolsetToolFullPath'
|
||||||
'Get-ToolsByName'
|
'Get-ToolsByName'
|
||||||
'Stop-SvcWithErrHandling'
|
'Stop-SvcWithErrHandling'
|
||||||
'Set-SvcWithErrHandling'
|
'Set-SvcWithErrHandling'
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ function Stop-SvcWithErrHandling
|
|||||||
.PARAMETER StopOnError
|
.PARAMETER StopOnError
|
||||||
Switch for stopping the script and exit from PowerShell if one service is absent
|
Switch for stopping the script and exit from PowerShell if one service is absent
|
||||||
#>
|
#>
|
||||||
param
|
Param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
||||||
[string] $ServiceName,
|
[string] $ServiceName,
|
||||||
@@ -187,7 +187,7 @@ function Set-SvcWithErrHandling
|
|||||||
Hashtable for service arguments
|
Hashtable for service arguments
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param
|
Param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
[Parameter(Mandatory, ValueFromPipeLine = $true)]
|
||||||
[string] $ServiceName,
|
[string] $ServiceName,
|
||||||
@@ -217,7 +217,7 @@ function Set-SvcWithErrHandling
|
|||||||
|
|
||||||
function Start-DownloadWithRetry
|
function Start-DownloadWithRetry
|
||||||
{
|
{
|
||||||
param
|
Param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[string] $Url,
|
[string] $Url,
|
||||||
@@ -348,17 +348,74 @@ function Get-VSExtensionVersion
|
|||||||
return $packageVersion
|
return $packageVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-ToolcachePackages {
|
function Get-ToolcachePackages
|
||||||
|
{
|
||||||
$toolcachePath = Join-Path $env:ROOT_FOLDER "toolcache.json"
|
$toolcachePath = Join-Path $env:ROOT_FOLDER "toolcache.json"
|
||||||
Get-Content -Raw $toolcachePath | ConvertFrom-Json
|
Get-Content -Raw $toolcachePath | ConvertFrom-Json
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-ToolsetContent {
|
function Get-ToolsetContent
|
||||||
|
{
|
||||||
$toolsetJson = Get-Content -Path $env:TOOLSET_JSON_PATH -Raw
|
$toolsetJson = Get-Content -Path $env:TOOLSET_JSON_PATH -Raw
|
||||||
ConvertFrom-Json -InputObject $toolsetJson
|
ConvertFrom-Json -InputObject $toolsetJson
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-ToolsByName {
|
function Get-ToolsetToolFullPath
|
||||||
|
{
|
||||||
|
<#
|
||||||
|
.DESCRIPTION
|
||||||
|
Function that return full path to specified toolset tool.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of required tool.
|
||||||
|
|
||||||
|
.PARAMETER Version
|
||||||
|
The version of required tool.
|
||||||
|
|
||||||
|
.PARAMETER Arch
|
||||||
|
The architecture of required tool.
|
||||||
|
#>
|
||||||
|
|
||||||
|
Param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string] $Name,
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string] $Version,
|
||||||
|
[string] $Arch = "x64"
|
||||||
|
)
|
||||||
|
|
||||||
|
$ToolPath = Join-Path $env:AGENT_TOOLSDIRECTORY $Name
|
||||||
|
|
||||||
|
# Add wildcard if missing
|
||||||
|
if ($Version.Split(".").Length -lt 3) {
|
||||||
|
$Version += ".*"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if version folder exists
|
||||||
|
$expectedVersionPath = Join-Path $ToolPath $Version
|
||||||
|
if (-not (Test-Path $expectedVersionPath)) {
|
||||||
|
Write-Host "Expected ${Name} ${Version} folder is not found!"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Take latest installed version in case if toolset version contains wildcards
|
||||||
|
$foundVersion = Get-Item $expectedVersionPath `
|
||||||
|
| Sort-Object -Property {[version]$_.name} -Descending `
|
||||||
|
| Select-Object -First 1
|
||||||
|
|
||||||
|
# Check for required architecture folder
|
||||||
|
$foundVersionArchPath = Join-Path $foundVersion $Arch
|
||||||
|
if (-not (Test-Path $foundVersionArchPath)) {
|
||||||
|
Write-Host "Expected ${Name}(${Arch}) $($foundVersion.name) architecture folder is not found!"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return $foundVersionArchPath
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-ToolsByName
|
||||||
|
{
|
||||||
Param
|
Param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $True)]
|
[Parameter(Mandatory = $True)]
|
||||||
@@ -391,7 +448,7 @@ function Test-IsWin16
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Extract-7Zip {
|
function Extract-7Zip {
|
||||||
param
|
Param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$Path,
|
[string]$Path,
|
||||||
|
|||||||
84
images/win/scripts/Installers/Configure-Toolset.ps1
Normal file
84
images/win/scripts/Installers/Configure-Toolset.ps1
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
################################################################################
|
||||||
|
## File: Configure-Toolset.ps1
|
||||||
|
## Team: CI-Build
|
||||||
|
## Desc: Configure Toolset
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
Function Set-DefaultVariables
|
||||||
|
{
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[object] $EnvVars,
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string] $ToolVersionPath
|
||||||
|
)
|
||||||
|
|
||||||
|
$templates = $EnvVars.pathTemplates
|
||||||
|
foreach ($template in $templates)
|
||||||
|
{
|
||||||
|
$toolSystemPath = $template -f $ToolVersionPath
|
||||||
|
Add-MachinePathItem -PathItem $toolSystemPath | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not ([string]::IsNullOrEmpty($EnvVars.defaultVariable)))
|
||||||
|
{
|
||||||
|
setx $toolEnvVars.defaultVariable $ToolVersionPath /M | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
Import-Module -Name ImageHelpers -Force -DisableNameChecking
|
||||||
|
|
||||||
|
# Define executables for cached tools
|
||||||
|
$toolsEnvironmentVariables = @{
|
||||||
|
Python = @{
|
||||||
|
pathTemplates = @(
|
||||||
|
"{0}",
|
||||||
|
"{0}\Scripts"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Boost = @{
|
||||||
|
variableTemplate = "BOOST_ROOT_{0}_{1}_{2}"
|
||||||
|
}
|
||||||
|
go = @{
|
||||||
|
pathTemplates = @(
|
||||||
|
"{0}\bin"
|
||||||
|
)
|
||||||
|
defaultVariable = "GOROOT"
|
||||||
|
variableTemplate = "GOROOT_{0}_{1}_X64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$toolsToConfigure = @("Python", "Boost", "Go")
|
||||||
|
$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache `
|
||||||
|
| Where-Object { $toolsToConfigure -contains $_.name }
|
||||||
|
|
||||||
|
Write-Host "Configure toolset tools environment..."
|
||||||
|
foreach ($tool in $tools)
|
||||||
|
{
|
||||||
|
$toolEnvVars = $toolsEnvironmentVariables[$tool.name]
|
||||||
|
|
||||||
|
if (-not ([string]::IsNullOrEmpty($toolEnvVars.variableTemplate)))
|
||||||
|
{
|
||||||
|
foreach ($version in $tool.versions)
|
||||||
|
{
|
||||||
|
Write-Host "Set $($tool.name) $version environment variable..."
|
||||||
|
|
||||||
|
$foundVersionArchPath = Get-ToolsetToolFullPath -Name $tool.name -Version $version -Arch $tool.arch
|
||||||
|
$envName = $toolEnvVars.variableTemplate -f $version.Split(".")
|
||||||
|
|
||||||
|
setx $envName $foundVersionArchPath /M | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not ([string]::IsNullOrEmpty($tool.default)))
|
||||||
|
{
|
||||||
|
Write-Host "Use $($tool.name) $($tool.default) as a system $($tool.name)..."
|
||||||
|
|
||||||
|
$toolVersionPath = Get-ToolsetToolFullPath -Name $tool.name -Version $tool.default -Arch $tool.arch
|
||||||
|
|
||||||
|
Set-DefaultVariables -ToolVersionPath $toolVersionPath -EnvVars $toolEnvVars
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
## File: Set-BoostRoot.ps1
|
|
||||||
## Team: CI-Build
|
|
||||||
## Desc: Install boost using tool cache
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
Import-Module -Name ImageHelpers
|
|
||||||
|
|
||||||
$SoftwareName = "Boost"
|
|
||||||
$BoostDirectory = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $SoftwareName
|
|
||||||
$BoostVersions = (Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object { $_.Name -eq "Boost"}).Versions
|
|
||||||
|
|
||||||
foreach($BoostVersion in $BoostVersions)
|
|
||||||
{
|
|
||||||
$BoostInstallationDir = Join-Path -Path $BoostDirectory -ChildPath "$BoostVersion\X86_64"
|
|
||||||
|
|
||||||
$EnvBoostPath = "BOOST_ROOT_{0}" -f ($BoostVersion.Replace('.', '_'))
|
|
||||||
setx $EnvBoostPath $BoostInstallationDir /M | Out-Null
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
## File: Install-Go.ps1
|
|
||||||
## Desc: Install Go
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
Import-Module -Name ImageHelpers -Force -DisableNameChecking
|
|
||||||
|
|
||||||
# Get Go content from toolset
|
|
||||||
$goTool = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object Name -eq "go"
|
|
||||||
|
|
||||||
$toolPath = Join-Path $env:AGENT_TOOLSDIRECTORY $goTool.name
|
|
||||||
foreach($goVersion in $goTool.versions)
|
|
||||||
{
|
|
||||||
if ($goVersion.Split(".").Length -lt 3) {
|
|
||||||
$goVersion += ".*"
|
|
||||||
}
|
|
||||||
$expectedVersionPath = Join-Path $toolPath $goVersion
|
|
||||||
$foundVersion = Get-Item $expectedVersionPath `
|
|
||||||
| Sort-Object -Property {[version]$_.name} -Descending `
|
|
||||||
| Select-Object -First 1
|
|
||||||
# Check for required architecture folder
|
|
||||||
$foundVersionArchPath = Join-Path $foundVersion $goTool.arch
|
|
||||||
$envName = "GOROOT_{0}_{1}_X64" -f $goVersion.split(".")
|
|
||||||
setx $envName "$foundVersionArchPath" /M
|
|
||||||
}
|
|
||||||
@@ -29,47 +29,6 @@ Function Install-Asset {
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Set-DefaultPythonVersion {
|
|
||||||
param(
|
|
||||||
[Parameter(Mandatory=$true)]
|
|
||||||
[object[]] $Toolset
|
|
||||||
)
|
|
||||||
|
|
||||||
$python = $Toolset | Where-Object { ($_.name -eq "Python") -and ($_.default -ne "") } `
|
|
||||||
| Select-Object default, arch -First 1
|
|
||||||
|
|
||||||
if ($python.default -ne $null) {
|
|
||||||
$pythonPath = Join-Path $Env:AGENT_TOOLSDIRECTORY "/Python/$($python.default)/$($python.arch)" -Resolve
|
|
||||||
|
|
||||||
Write-Host "Use Python $($python.default) as a system Python"
|
|
||||||
Add-MachinePathItem -PathItem $pythonPath
|
|
||||||
Add-MachinePathItem -PathItem "$pythonPath\Scripts"
|
|
||||||
} else {
|
|
||||||
Write-Host "Default Python version not found in toolset file!"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Set-DefaultGoVersion {
|
|
||||||
param(
|
|
||||||
[Parameter(Mandatory=$true)]
|
|
||||||
[object[]] $Toolset
|
|
||||||
)
|
|
||||||
|
|
||||||
$goToolset = $Toolset | Where-Object { ($_.name -eq "go") -and ($_.default -ne "") } `
|
|
||||||
| Select-Object default, arch -First 1
|
|
||||||
|
|
||||||
if ($goToolset.default -ne $null) {
|
|
||||||
$goPath = Join-Path $Env:AGENT_TOOLSDIRECTORY "/go/$($goToolset.default)/$($goToolset.arch)" -Resolve
|
|
||||||
|
|
||||||
Write-Host "Use Go $($goToolset.default) as a system Go"
|
|
||||||
Add-MachinePathItem -PathItem "$goPath\bin" | Out-Null
|
|
||||||
# Set the GOROOT environment variable.
|
|
||||||
setx GOROOT "$goPath" /M | Out-Null
|
|
||||||
} else {
|
|
||||||
Write-Host "Default Go version not found in toolset file!"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
Import-Module -Name ImageHelpers -Force
|
Import-Module -Name ImageHelpers -Force
|
||||||
@@ -92,7 +51,7 @@ foreach ($tool in $tools) {
|
|||||||
| Select-Object -First 1
|
| Select-Object -First 1
|
||||||
|
|
||||||
Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..."
|
Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..."
|
||||||
if ($asset -ne $null) {
|
if ($null -ne $asset) {
|
||||||
Install-Asset -ReleaseAsset $asset
|
Install-Asset -ReleaseAsset $asset
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Asset was not found in versions manifest"
|
Write-Host "Asset was not found in versions manifest"
|
||||||
@@ -100,7 +59,3 @@ foreach ($tool in $tools) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install default python version
|
|
||||||
Set-DefaultPythonVersion -Toolset $tools
|
|
||||||
Set-DefaultGoVersion -Toolset $tools
|
|
||||||
@@ -75,34 +75,11 @@ $toolsExecutables = @{
|
|||||||
$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache
|
$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache
|
||||||
|
|
||||||
foreach($tool in $tools) {
|
foreach($tool in $tools) {
|
||||||
$toolPath = Join-Path $env:AGENT_TOOLSDIRECTORY $tool.name
|
|
||||||
# Get executables for current tool
|
# Get executables for current tool
|
||||||
$toolExecs = $toolsExecutables[$tool.name]
|
$toolExecs = $toolsExecutables[$tool.name]
|
||||||
|
|
||||||
foreach ($version in $tool.versions) {
|
foreach ($version in $tool.versions) {
|
||||||
# Add wildcard if missing
|
$foundVersionArchPath = Get-ToolsetToolFullPath -Name $tool.name -Version $version -Arch $tool.arch
|
||||||
if ($version.Split(".").Length -lt 3) {
|
|
||||||
$version += ".*"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if version folder exists
|
|
||||||
$expectedVersionPath = Join-Path $toolPath $version
|
|
||||||
if (-not (Test-Path $expectedVersionPath)) {
|
|
||||||
Write-Host "Expected $($tool.name) $version folder is not found!"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Take latest installed version in case if toolset version contains wildcards
|
|
||||||
$foundVersion = Get-Item $expectedVersionPath `
|
|
||||||
| Sort-Object -Property {[version]$_.name} -Descending `
|
|
||||||
| Select-Object -First 1
|
|
||||||
|
|
||||||
# Check for required architecture folder
|
|
||||||
$foundVersionArchPath = Join-Path $foundVersion $tool.arch
|
|
||||||
if (-not (Test-Path $foundVersionArchPath)) {
|
|
||||||
Write-Host "Expected $($tool.name)($($tool.arch)) $($foundVersion.name) architecture folder is not found!"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($toolExecs) {
|
if ($toolExecs) {
|
||||||
Write-Host "Run validation test for $($tool.name)($($tool.arch)) $($foundVersion.name) executables..."
|
Write-Host "Run validation test for $($tool.name)($($tool.arch)) $($foundVersion.name) executables..."
|
||||||
|
|||||||
@@ -156,7 +156,6 @@ $markdown += New-MDHeader ".NET Core Runtime" -Level 3
|
|||||||
Get-DotnetRuntimes | Foreach-Object {
|
Get-DotnetRuntimes | Foreach-Object {
|
||||||
$path = $_.Path
|
$path = $_.Path
|
||||||
$versions = $_.Versions
|
$versions = $_.Versions
|
||||||
$markdown += "``Type: Developer Pack``"
|
|
||||||
$markdown += "``Location: $path``"
|
$markdown += "``Location: $path``"
|
||||||
$markdown += New-MDNewLine
|
$markdown += New-MDNewLine
|
||||||
$markdown += New-MDList -Lines $versions -Style Unordered
|
$markdown += New-MDList -Lines $versions -Style Unordered
|
||||||
@@ -164,6 +163,8 @@ Get-DotnetRuntimes | Foreach-Object {
|
|||||||
|
|
||||||
$markdown += New-MDHeader ".NET Framework" -Level 3
|
$markdown += New-MDHeader ".NET Framework" -Level 3
|
||||||
$frameworks = Get-DotnetFrameworkTools
|
$frameworks = Get-DotnetFrameworkTools
|
||||||
|
$markdown += "``Type: Developer Pack``"
|
||||||
|
$markdown += New-MDNewLine
|
||||||
$markdown += "``Location $($frameworks.Path)``"
|
$markdown += "``Location $($frameworks.Path)``"
|
||||||
$markdown += New-MDNewLine
|
$markdown += New-MDNewLine
|
||||||
$markdown += New-MDList -Lines $frameworks.Versions -Style Unordered
|
$markdown += New-MDList -Lines $frameworks.Versions -Style Unordered
|
||||||
|
|||||||
Reference in New Issue
Block a user