WIndows - update Install-Msys2.ps1 (#906)

1. Use Invoke-RestMethod to retrieve most recent msys2 base
2. Git tar  - change paths to full nix style
3. Git tar - requires exe's from Git/mingw64/bin, set ENV

2 & 3 may not be needed, but if anything changes...
This commit is contained in:
MSP-Greg
2020-05-21 01:36:33 -05:00
committed by GitHub
parent 521b0c5e28
commit db702848ce

View File

@@ -10,8 +10,11 @@
$origPath = $env:PATH $origPath = $env:PATH
$gitPath = "$env:ProgramFiles\Git" $gitPath = "$env:ProgramFiles\Git"
# get info from https://sourceforge.net/projects/msys2/files/Base/x86_64/ $msys2_release = "https://api.github.com/repos/msys2/msys2-installer/releases/latest"
$msys2Uri = "http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20190524.tar.xz"
$msys2Uri = ((Invoke-RestMethod $msys2_release).assets | Where-Object {
$_.name -match "x86_64" -and $_.name.EndsWith("tar.xz") }).browser_download_url
$msys2File = "$env:TEMP\msys2.tar.xz" $msys2File = "$env:TEMP\msys2.tar.xz"
# Download the latest msys2 x86_64 # Download the latest msys2 x86_64
@@ -19,13 +22,17 @@ Write-Host "Starting msys2 download"
(New-Object System.Net.WebClient).DownloadFile($msys2Uri, $msys2File) (New-Object System.Net.WebClient).DownloadFile($msys2Uri, $msys2File)
Write-Host "Finished download" Write-Host "Finished download"
$msys2FileU = "/$msys2File".replace(':', '') # nix style path for tar
$msys2FileU = "/$msys2File".replace(':', '').replace('\', '/')
# Git tar needs exe's from mingw64\bin
$env:PATH = "$gitPath\usr\bin;$gitPath\mingw64\bin;$origPath"
$tar = "$gitPath\usr\bin\tar.exe" $tar = "$gitPath\usr\bin\tar.exe"
# extract tar.xz to C:\ # extract tar.xz to C:\
Write-Host "Starting msys2 extraction" Write-Host "Starting msys2 extraction from $msys2FileU"
&$tar -Jxf $msys2FileU -C /c/ &$tar -xJf $msys2FileU -C /c/
Remove-Item $msys2File Remove-Item $msys2File
Write-Host "Finished extraction" Write-Host "Finished extraction"