Created
June 2, 2020 07:24
-
-
Save stinos/cbc2593adda04da0e9c05a41af515d78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Install-Msys2 () { | |
param ( | |
[Parameter()] [String] $Dir = 'c:\tools\msys2' | |
) | |
if (Test-Path $Dir -PathType Any) { | |
$reply = Read-Host -Prompt "MSys2 destination $Dir exists. Delete and continue? [y/n]" | |
if ($reply -eq 'y') { | |
Remove-Item -Recurse -Force $Dir | |
} else { | |
return | |
} | |
} | |
$archive = Join-Path $env:TEMP 'msys2.tar.xz' | |
Invoke-WebRequest -Uri 'http://repo.msys2.org/distrib/msys2-x86_64-latest.tar.xz' -OutFile $archive -UseBasicParsing | |
& 7z 'e' '-y' "-o$Dir" $archive | |
& 7z 'x' '-y' "-o$Dir" (Join-Path $Dir 'msys2.tar') | |
$bash = Join-Path $Dir 'msys64\usr\bin\bash.exe' | |
$msysShell = Join-Path $Dir 'msys64\msys2_shell.cmd' | |
# Run initial command so bash configures itself. | |
& $msysShell '-msys2' '-no-start' '-shell' 'bash' '-l' '-c' '"echo"' | |
# Update; couple of times since this might need restarts. | |
& $msysShell '-msys2' '-no-start' '-shell' 'bash' '-l' '-c' '"pacman -Syuu --noconfirm"' | |
& $msysShell '-msys2' '-no-start' '-shell' 'bash' '-l' '-c' '"pacman -Syuu --noconfirm"' | |
& $msysShell '-msys2' '-no-start' '-shell' 'bash' '-l' '-c' '"pacman -Syuu --noconfirm"' | |
# Install gcc etc. | |
& $msysShell '-msys2' '-no-start' '-shell' 'bash' '-l' '-c' '"pacman -S --noconfirm make mingw-w64-x86_64-gcc pkg-config"' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment