Skip to content

Commit

Permalink
Add MSYS2 dev toolchain onto path
Browse files Browse the repository at this point in the history
Also tidies up the install of MSYS2 more generally
  • Loading branch information
chadlwilson committed Dec 2, 2023
1 parent 7d37454 commit b7a27ea
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions provision/provision-install-packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ Copy-Item "$PSScriptroot\init.gradle" "${env:USERPROFILE}\.gradle\init.g
Copy-Item "$PSScriptroot\npmrc" "${env:USERPROFILE}\.npmrc"
Copy-Item "$PSScriptroot\settings.xml" "${env:USERPROFILE}\.m2\settings.xml"

function PrefixToSystemAndCurrentPath {
param (
[Parameter(Mandatory=$true)]
[string]$PathPrefix
)
$newSystemPath = "$PathPrefix;" + [System.Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
$env:Path = $newSystemPath + ";" + [System.Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable("Path", $newSystemPath, [EnvironmentVariableTarget]::Machine)
}

# install chocolatey
$chocolateyUseWindowsCompression = 'true'
$env:chocolateyUseWindowsCompression = 'true'
Expand All @@ -31,7 +41,6 @@ iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/in

$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).path)\..\.."
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"

RefreshEnv

# install packages
Expand All @@ -48,28 +57,25 @@ choco install --no-progress -y windows-sdk-11-version-22h2-all --install-argumen
choco install --no-progress -y --ignore-checksums googlechrome # Ignore checksums due to package not using repeatable build links to Google downloads

choco install --no-progress -y ruby --version="${RUBY_VERSION}"
choco install --no-progress -y msys2 --params "/NoUpdate" # For compiling certain native Ruby extensions, introduced for google-protobuf 3.25.0+
# Install MSYS2 and dev toolchain for compiling certain native Ruby extensions, introduced for google-protobuf 3.25.0+
# Following pattern at https://community.chocolatey.org/packages/msys2#description but disabling the auto-update of
# msys2-runtime due to mysterious hangs on docker. See https://github.com/msys2/msys2-installer/issues/59#issuecomment-1835720068
$msysInstallDir = "C:\tools\msys64"
choco install --no-progress -y msys2 --params "/NoUpdate /InstallDir:${msysInstallDir}"
RefreshEnv
C:\\tools\\msys64\\\usr\\bin\bash -c "echo '[options]' >> /etc/pacman.conf"
C:\\tools\\msys64\\\usr\\bin\bash -c "echo 'IgnorePkg = msys2-runtime' >> /etc/pacman.conf"
C:\\tools\\msys64\\\usr\\bin\bash -c "echo 'IgnorePkg = pacman' >> /etc/pacman.conf"
ridk install 2 3 # Install only MSYS2 and MINGW development toolchain (MSYS2 and system update already done by Chocolatey package)
ridk enable
cc --version
PrefixToSystemAndCurrentPath("${msysInstallDir}\ucrt64\bin;${msysInstallDir}\usr\bin") # Manually add MSYS2 and tools to path to avoid having to do shell-specific "ridk enable" in builds.
ridk exec bash.exe -c "echo -e '[options]\nIgnorePkg = msys2-runtime\nIgnorePkg = pacman' >> /etc/pacman.conf"
ridk install 2 3 # use ruby's ridk to update the system and install development toolchain

# Remove chocolatey from temp location
Remove-Item C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\chocolatey -Force -Recurse | Out-Null

# install p4d / helix-core-server
New-Item "${env:ProgramFiles}\\Perforce\\bin\\" -ItemType Directory | Out-Null
Invoke-WebRequest https://cdist2.perforce.com/perforce/r$P4D_VERSION/bin.ntx64/p4d.exe -Outfile "${env:ProgramFiles}\\Perforce\\bin\\p4d.exe"
PrefixToSystemAndCurrentPath("${env:ProgramFiles}\\Perforce\\bin")

# install gocd bootstrapper
Invoke-WebRequest https://github.com/gocd-contrib/gocd-golang-bootstrapper/releases/download/${GOLANG_BOOTSTRAPPER_VERSION}/go-bootstrapper-${GOLANG_BOOTSTRAPPER_VERSION}.windows.amd64.exe -Outfile C:\\go-agent.exe

$newSystemPath = [System.Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
$newSystemPath = "${newSystemPath};${env:ProgramFiles}\\Perforce\\bin"
$env:Path = $newSystemPath + ";" + [System.Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable("Path", $newSystemPath, [EnvironmentVariableTarget]::Machine)

Add-LocalGroupMember -Group "Administrators" -Member "ContainerAdministrator"

0 comments on commit b7a27ea

Please sign in to comment.