Document environment variables of linux images (#2498)

* Document environment variables of linux images

* Change adnroid variables

* Apply reviews

* Remove some variables, fix headers

* Show link targets

* rename helper

* remove symlinks

* More links

* Dynamic GO variables

* Architecture for  GO variables

* remove GOROOT
This commit is contained in:
Sergey Dolin
2021-02-12 12:30:36 +05:00
committed by GitHub
parent d49a011d9c
commit 77b21e0c24
6 changed files with 169 additions and 4 deletions

View File

@@ -20,4 +20,94 @@ function New-MDNewLine {
function Restore-UserOwner {
sudo chown -R ${env:USER}: $env:HOME
}
}
function Get-LinkTarget {
param (
[string] $inputPath
)
$link = Get-Item $inputPath | Select-Object -ExpandProperty Target
if ($link) {
return " -> $link"
}
return ""
}
function Get-PathWithLink {
param (
[string] $inputPath
)
$link = Get-LinkTarget($inputPath)
return "${inputPath}${link}"
}
function Get-CachedToolInstances
{
<#
.SYNOPSIS
Returns hastable of installed cached tools.
.DESCRIPTION
Return hastable that contains versions and architectures for selected cached tool.
.PARAMETER Name
Name of cached tool.
.PARAMETER VersionCommand
Optional parameter. Command to return version of system default tool.
.EXAMPLE
Get-CachedToolInstances -Name "Python" -VersionCommand "--version"
#>
param
(
[String] $Name,
[String] $VersionCommand
)
$toolInstances = @()
$toolPath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $Name
# Get all installed versions from TOOLSDIRECTORY folder
$versions = Get-ChildItem $toolPath | Sort-Object { [System.Version]$_.Name }
foreach ($version in $versions)
{
$instanceInfo = @{}
# Create instance hashtable
[string]$instanceInfo.Path = Join-Path -Path $toolPath -ChildPath $version.Name
[string]$instanceInfo.Version = $version.Name
### Temporary workaround. Currently Boost instances don't have architecture subfolders.
if ($Name -eq "Boost")
{
[string]$instanceInfo.Architecture = "x64, x86"
$toolInstances += $instanceInfo
continue
}
# Get all architectures for current version
[array]$instanceInfo.Architecture_Array = Get-ChildItem $version.FullName -Name -Directory | Where-Object { $_ -match "^x[0-9]{2}$" }
[string]$instanceInfo.Architecture = $instanceInfo.Architecture_Array -Join ", "
# Add (default) postfix to version name, in case if current version is in environment path
if (-not ([string]::IsNullOrEmpty($VersionCommand)))
{
$defaultVersion = $(& ($Name.ToLower()) $VersionCommand 2>&1)
$defaultToolVersion = $defaultVersion | Select-String -Pattern "\d+\.\d+\.\d+" -AllMatches `
| ForEach-Object { $_.Matches.Value }
if ([version]$version.Name -eq [version]$defaultToolVersion)
{
$instanceInfo.Version += " (Default)"
}
}
$toolInstances += $instanceInfo
}
return $toolInstances
}