Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions images/win/scripts/Installers/Install-Msys2.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,29 @@
$origPath = $env:PATH
$gitPath = "$env:ProgramFiles\Git"

# get info from https://sourceforge.net/projects/msys2/files/Base/x86_64/
$msys2Uri = "http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20190524.tar.xz"
$msys2_release = "https://api.github.com/repos/msys2/msys2-installer/releases/latest"

$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"

# Download the latest msys2 x86_64
Write-Host "Starting msys2 download"
(New-Object System.Net.WebClient).DownloadFile($msys2Uri, $msys2File)
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"
Comment on lines -22 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 7z available by this time? You can use 7z x to extract the tarball (although not at once like tar)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if one pipes to STDOUT, 7z will extract easily.

But, given that the tar was created by MSYS2 tar, and Git tar is MSYS2, might was well extract with GIT?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's up to you since both should result in the same output and the only reason why I mentioned 7z is that it supports windows style paths naturally without using msys2 style paths


$tar = "$gitPath\usr\bin\tar.exe"

# extract tar.xz to C:\
Write-Host "Starting msys2 extraction"
&$tar -Jxf $msys2FileU -C /c/
Write-Host "Starting msys2 extraction from $msys2FileU"
&$tar -xJf $msys2FileU -C /c/
Remove-Item $msys2File
Write-Host "Finished extraction"

Expand Down