git
[Ported from github.com/git/git] Sync with Git 2.56.1
Brought by drakestapleton
git / ci / install-dependencies.ps1
| 1 | param( |
| 2 | [string]$DownloadDirectory = '.dependencies', |
| 3 | [switch]$Mingw |
| 4 | ) |
| 5 | |
| 6 | $ErrorActionPreference = 'Stop' |
| 7 | $ProgressPreference = 'SilentlyContinue' |
| 8 | |
| 9 | $GitVersion = '2.54.0.windows.1' |
| 10 | $MesonVersion = '1.11.0' |
| 11 | $RustVersion = '1.96.0' |
| 12 | |
| 13 | New-Item -Path $DownloadDirectory -ItemType Directory -Force | Out-Null |
| 14 | New-Item -Path .git/info -ItemType Directory -Force | Out-Null |
| 15 | if (-not (Test-Path .git/info/exclude)) { |
| 16 | New-Item -Path .git/info/exclude -ItemType File | Out-Null |
| 17 | } |
| 18 | Add-Content -Path .git/info/exclude -Value "/$DownloadDirectory" |
| 19 | |
| 20 | function Get-Installer { |
| 21 | param( |
| 22 | [Parameter(Mandatory = $true)][string]$Name, |
| 23 | [Parameter(Mandatory = $true)][string]$Url |
| 24 | ) |
| 25 | |
| 26 | $path = Join-Path $DownloadDirectory $Name |
| 27 | if (-not (Test-Path $path)) { |
| 28 | Write-Host "Downloading $Url" |
| 29 | Invoke-WebRequest $Url -OutFile $path -TimeoutSec 300 |
| 30 | } |
| 31 | return $path |
| 32 | } |
| 33 | |
| 34 | function Invoke-Installer { |
| 35 | param( |
| 36 | [Parameter(Mandatory = $true)][string]$FilePath, |
| 37 | [Parameter(Mandatory = $true)][string[]]$ArgumentList |
| 38 | ) |
| 39 | |
| 40 | Write-Host "Running $FilePath $($ArgumentList -join ' ')" |
| 41 | $process = Start-Process -Wait -PassThru -FilePath $FilePath -ArgumentList $ArgumentList |
| 42 | if ($process.ExitCode -ne 0) { |
| 43 | throw "$FilePath failed with exit code $($process.ExitCode)" |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | $rustTarget = if ($Mingw) { 'gnu' } else { 'msvc' } |
| 48 | $rustMsi = Get-Installer "rust-$rustTarget.msi" ( |
| 49 | "https://static.rust-lang.org/dist/" + |
| 50 | "rust-$RustVersion-x86_64-pc-windows-$rustTarget.msi") |
| 51 | Invoke-Installer msiexec.exe @('/i', $rustMsi, 'INSTALLDIR=C:\Rust', |
| 52 | "ADDLOCAL=Rustc,Cargo,Std$(if ($Mingw) { ',Gcc' })", '/quiet', '/norestart') |
| 53 | |
| 54 | if ($Mingw) { |
| 55 | return |
| 56 | } |
| 57 | |
| 58 | $gitAssetVersion = $GitVersion -replace '\.windows\.\d+$', '' |
| 59 | $gitInstaller = Get-Installer "Git-Installer.exe" ` |
| 60 | "https://github.com/git-for-windows/git/releases/download/v$GitVersion/PortableGit-$gitAssetVersion-64-bit.7z.exe" |
| 61 | Invoke-Installer $gitInstaller @('-y', '-o"C:\Program Files\Git"') |
| 62 | |
| 63 | $mesonMsi = Get-Installer "meson.msi" ` |
| 64 | "https://github.com/mesonbuild/meson/releases/download/$MesonVersion/meson-$MesonVersion-64.msi" |
| 65 | Invoke-Installer msiexec.exe @('/i', $mesonMsi, 'INSTALLDIR=C:\Meson', '/quiet', '/norestart') |
| 66 | |
| 67 | # Disable Git Credential Manager, which is auto-configured by PortableGit. |
| 68 | # GitLab's runner picks up this Git in its cleanup stage and runs `git |
| 69 | # credential reject`, which hangs in GCM and makes the job time out. |
| 70 | & "C:\Program Files\Git\bin\git.exe" config unset --all --system credential.helper |
| 71 | if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne 5) { |
| 72 | throw "Failed to unset credential.helper with exit code $LASTEXITCODE" |
| 73 | } |