Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Msys2 #891

Merged
merged 16 commits into from
Nov 6, 2017
Merged

Msys2 #891

Show file tree
Hide file tree
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
34 changes: 34 additions & 0 deletions automatic/msys2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# <img src="" width="48" height="48"/> [msys2](https://chocolatey.org/packages/msys2)

MSYS2 is a software distro and building platform for Windows.

At its core is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. It provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains.

It features a package management system to provide easy installation of packages, Pacman. It brings many powerful features such as dependency resolution and simple complete system upgrades, as well as straight-forward package building.

## Package parameters

- `/InstallDir` - Path to installation directory, by default msys will be installed in `Get-ToolsLocation`.
- `/NoPath` - Do not add msys installation directory to system PATH.
- `/NoUpdate` - Do not automatically update with Pacman according to the [official instructions](https://msys2.github.io).

## Notes

- MSYS2 itself will not be installed again on updating or reinstalling the Chocolatey package. Instead, the existing MSYS2 will be updated with Pacman. Manually delete the installation folder to force complete reinstallation.

### Ruby integration

This package can be used with [ruby](https://chocolatey.org/packages/ruby) package to provide native building environment for gems.

- The ruby installer comes with `ridk` function which offers interactive GUI installation wizard of msys2 and hence [can't be used unattended](https://github.com/oneclick/rubyinstaller2/issues/79) (`ridk install 1`).
- Its system update is the same as initialization done with this package (`ridk install 2`).
- Ruby installer offers unattended setup of MSYS2 and MINGW development toolchain (`ridk install 3`).

You can also just install the msys2 package without system update and use `ridk` afterwards:

```powershell
cinst ruby # install ruby
cinst msys2 --params "/NoUpdate" # install msys2 without system update
Update-SessionEnvironment # refresh environment vars
ridk install 2 3 # use ruby's ridk to update the system and install development toolchain
```
339 changes: 339 additions & 0 deletions automatic/msys2/legal/COPYING.txt

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions automatic/msys2/legal/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2013, Алексей
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 changes: 26 additions & 0 deletions automatic/msys2/legal/VERIFICATION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
VERIFICATION

Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.

Package can be verified like this:

1. Go to

x32: http://repo.msys2.org/distrib/i686/msys2-base-i686-20161025.tar.xz
x64: http://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-20161025.tar.xz

to download the installer.

2. You can use one of the following methods to obtain the SHA256 checksum:
- Use powershell function 'Get-FileHash'
- Use Chocolatey utility 'checksum.exe'

checksum32: 8BAFD3D52F5A51528A8671C1CAE5591B36086D6EA5B1E76E17E390965CF6768F
checksum64: BB1F1A0B35B3D96BF9C15092DA8CE969A84A134F7B08811292FBC9D84D48C65D

File 'LICENSE.txt' is obtained from:
https://raw.githubusercontent.com/Alexpux/MSYS2-packages/master/LICENSE

File 'COPYING' is obtained from:
https://github.com/Alexpux/MSYS2-pacman/blob/master/COPYING
62 changes: 62 additions & 0 deletions automatic/msys2/msys2.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>msys2</id>
<version>0.0</version>
<title>MSYS2</title>
<authors>Alexpux, martell, mingwandroid, elieux, renatosilva, niXman</authors>
<owners>chocolatey, userzimmermann, petemounce</owners>
<licenseUrl>https://github.com/userzimmermann/choco-packages/blob/master/msys2/NOTICE</licenseUrl>
<projectUrl>http://msys2.github.io</projectUrl>
<iconUrl>https://github.com/chocolatey/chocolatey-coreteampackages/tree/master/icons/msys2.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description><![CDATA[MSYS2 is a software distro and building platform for Windows.

At its core is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. It provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains.

It features a package management system to provide easy installation of packages, Pacman. It brings many powerful features such as dependency resolution and simple complete system upgrades, as well as straight-forward package building.

## Package parameters

- `/InstallDir` - Path to installation directory, by default msys will be installed in `Get-ToolsLocation`.
- `/NoPath` - Do not add msys installation directory to system PATH.
- `/NoUpdate` - Do not automatically update with Pacman according to the [official instructions](https://msys2.github.io).

## Notes

- MSYS2 itself will not be installed again on updating or reinstalling the Chocolatey package. Instead, the existing MSYS2 will be updated with Pacman. Manually delete the installation folder to force complete reinstallation.

### Ruby integration

This package can be used with [ruby](https://chocolatey.org/packages/ruby) package to provide native building environment for gems.

- The ruby installer comes with `ridk` function which offers interactive GUI installation wizard of msys2 and hence [can't be used unattended](https://github.com/oneclick/rubyinstaller2/issues/79) (`ridk install 1`).
- Its system update is the same as initialization done with this package (`ridk install 2`).
- Ruby installer offers unattended setup of MSYS2 and MINGW development toolchain (`ridk install 3`).

You can also just install the msys2 package without system update and use `ridk` afterwards:

```powershell
cinst ruby # install ruby
cinst msys2 --params "/NoUpdate" # install msys2 without system update
Update-SessionEnvironment # refresh environment vars
ridk install 2 3 # use ruby's ridk to update the system and install development toolchain
```
]]></description>
<summary>A Cygwin-derived software distro for Windows using Arch Linux's Pacman</summary>
<releaseNotes>https://github.com/userzimmermann/choco-packages/blob/master/msys2/CHANGES.md</releaseNotes>
<copyright>MSYS2 Copyright (c) 2013, Алексей</copyright>
<tags>msys2 msys cygwin mingw gnu linux unix posix arch pacman bash makepkg gcc shell cli foss development</tags>
<projectSourceUrl>https://github.com/Alexpux/MSYS2-packages</projectSourceUrl>
<packageSourceUrl>https://github.com/chocolatey/chocolatey-coreteampackages/tree/master/automatic/msys2</packageSourceUrl>
<docsUrl>https://github.com/msys2/msys2/wiki</docsUrl>
<dependencies>
<dependency id="chocolatey" version="0.10.8" />
<dependency id="chocolatey-core.extension" version="1.3.3" />
</dependencies>
</metadata>
<files>
<file src="tools\**" target="tools" />
<file src="legal\**" target="legal" />
</files>
</package>
16 changes: 16 additions & 0 deletions automatic/msys2/tools/chocolateyUninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$ErrorActionPreference = 'Stop'

$toolsDir = Split-Path $MyInvocation.MyCommand.Definition

$pp = Import-Clixml $toolsDir\pp.xml
if (!$pp.NoPath) {
$user_path = [System.Environment]::GetEnvironmentVariable('PATH', 'User')
$newPath = $user_path.Replace(";" + $pp.InstallDir, '')
if ($newPath -ne $user_path) {
Write-Host "Removing from user PATH"
[System.Environment]::SetEnvironmentVariable('PATH', $newPath, 'User')
}
}

Write-Host "Please remove install dir manually when you don't need it anymore."
Write-Host "Install dir: " $pp.InstallDir
52 changes: 52 additions & 0 deletions automatic/msys2/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
$ErrorActionPreference = 'Stop'

$toolsDir = Split-Path $MyInvocation.MyCommand.Definition
$is64 = (Get-ProcessorBits 64) -and $env:chocolateyForceX86 -ne 'true'
$dir_name = if ($is64) { 'msys64' } else { 'msys32' }

$pp = Get-PackageParameters
if (!$pp.InstallDir) { $pp.InstallDir = "{0}\{1}" -f (Get-ToolsLocation), $dir_name }
$install_dir = $pp.InstallDir
Copy link
Member

Choose a reason for hiding this comment

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

Since allowing custom installation directory, an uninstall script is needed to remove the path on uninstall.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original package was not removing the directory. I added a message as was there before as I also think its safer to not delete it. Perhaps there is no harm in removing it but its a minor issue anyway so I opted for the safe side.

$pp | Export-Clixml $toolsDir\pp.xml

if (!(Test-Path $install_dir)) {
Write-Host "Installing to:" $install_dir
$packageArgs = @{
PackageName = $Env:ChocolateyPackageName
FileFullPath = gi $toolsDir\*-i686*
FileFullPath64 = gi $toolsDir\*-x86_64*
Destination = $install_dir
}
Get-ChocolateyUnzip @packageArgs
rm $toolsPath\*.xz -ea 0

$tarFile = gi "$install_dir\*.tar"
Get-ChocolateyUnzip $tarFile $install_dir
rm "$install_dir\*.tar" -ea 0
$tardir = gi "$install_dir\msys*"
mv $tardir\* $install_dir; rm $tardir
} else { Write-Host "'$install_dir' already exists and will only be updated." }

if ($proxy = Get-EffectiveProxy) {
Write-Host "Using CLI proxy:" $proxy
$Env:http_proxy = $Env:https_proxy = $proxy
}

#https://github.com/msys2/msys2/wiki/MSYS2-installation
Write-Host "Starting initialization via msys2_shell.cmd"
Start-Process "$install_dir\msys2_shell.cmd" -Wait -ArgumentList '-c', exit

if (!$pp.NoPath) { Install-ChocolateyPath $pp.InstallDir }
Copy link
Member

Choose a reason for hiding this comment

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

The path will need to be removed in an uninstall script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


if (!$pp.NoUpdate) {
Write-Host "Repeating system update until there are no more updates or max 5 iterations"
$ErrorActionPreference = 'Continue' #otherwise bash warnings will exit
sal bash "$install_dir\usr\bin\bash.exe"
while (!$done) {
Write-Host "`n================= SYSTEM UPDATE $((++$i)) =================`n"
bash -lc 'pacman --noconfirm -Syuu | tee /update.log'
$done = (gc $install_dir\update.log) -match 'there is nothing to do' | Measure | % { $_.Count -eq 2 }
$done = $done -or ($i -ge 5)
}
rm $install_dir\update.log -ea 0
}
38 changes: 38 additions & 0 deletions automatic/msys2/update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import-module au

$releases = 'http://repo.msys2.org/distrib'

function global:au_SearchReplace {
@{
".\legal\VERIFICATION.txt" = @{
"(?i)(\s+x32:).*" = "`${1} $($Latest.URL32)"
"(?i)(\s+x64:).*" = "`${1} $($Latest.URL64)"
"(?i)(checksum32:).*" = "`${1} $($Latest.Checksum32)"
"(?i)(checksum64:).*" = "`${1} $($Latest.Checksum64)"
}
}
}

function global:au_BeforeUpdate { Get-RemoteFiles -Purge -NoSuffix }

function global:au_GetLatest {
$re = '\.xz$'

$download_page = Invoke-WebRequest -Uri "$releases/i686" -UseBasicParsing
$url32 = $download_page.Links | ? href -match $re | select -Last 1 | % { "$releases/i686/" + $_.href }
$version32 = $url32 -split '/|-|\.' | select -Last 1 -Skip 2

$download_page = Invoke-WebRequest -Uri "$releases/x86_64" -UseBasicParsing
$url64 = $download_page.Links | ? href -match $re | select -Last 1 | % { "$releases/x86_64/" + $_.href }
$version64 = $url64 -split '/|-|\.' | select -Last 1 -Skip 2

if ($version32 -ne $version64) { throw "x32 and x64 versions are not the same" }

@{
Version = "$version32.0.0"
URL32 = $url32
URL64 = $url64
}
}

update -ChecksumFor none
4 changes: 4 additions & 0 deletions automatic/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ This package provides a self-contained [Windows-based installer](https://rubyins
- `/InstallDir` - Ruby installation directory, by default `c:\tools\RubyXY` where XY are major and minor version parts.
- `/NoPath` - Do not add ruby bin folder to machine PATH.

## Notes

- To install ruby development kit ruby installer provides `ridk` command. It provides easy way to install msys2 via `ridk install 1`, however, the installation is interactive. To accomplish unattended install, use [msys2](https://chocolatey.org/packages/msys2) package.

Binary file added icons/msys2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.