Downloads:

54,000

Downloads of v 3.0.0.0:

6,103

Last Update:

29 Aug 2019

Package Maintainer(s):

Software Author(s):

  • Cabal Team

Tags:

cabal ghc haskell

Cabal

3.0.0.0 | Updated: 29 Aug 2019

Downloads:

54,000

Downloads of v 3.0.0.0:

6,103

Maintainer(s):

Software Author(s):

  • Cabal Team

Tags:

cabal ghc haskell

Cabal 3.0.0.0

All Checks are Passing

2 Passing Test


Validation Testing Passed


Verification Testing Passed

Details

To install Cabal, run the following command from the command line or from PowerShell:

>

To upgrade Cabal, run the following command from the command line or from PowerShell:

>

To uninstall Cabal, run the following command from the command line or from PowerShell:

>

NOTE: This applies to both open source and commercial editions of Chocolatey.

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://chocolatey.org/api/v2. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Enter your internal repository url

(this should look similar to https://chocolatey.org/api/v2)

4. Choose your deployment method:


choco upgrade cabal -y --source="'STEP 3 URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade cabal -y --source="'STEP 3 URL'" 
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Ensure cabal installed
  win_chocolatey:
    name: cabal
    state: present
    version: 3.0.0.0
    source: STEP 3 URL

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.

Coming early 2020! Central Managment Reporting available now! More information...


chocolatey_package 'cabal' do
  action    :install
  version  '3.0.0.0'
  source   'STEP 3 URL'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


Chocolatey::Ensure-Package
(
    Name: cabal,
    Version: 3.0.0.0,
    Source: STEP 3 URL
);

Requires Otter Chocolatey Extension. See docs at https://inedo.com/den/otter/chocolatey.


cChocoPackageInstaller cabal
{
   Name     = 'cabal'
   Ensure   = 'Present'
   Version  = '3.0.0.0'
   Source   = 'STEP 3 URL'
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'cabal':
  provider => 'chocolatey',
  ensure   => '3.0.0.0',
  source   => 'STEP 3 URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


salt '*' chocolatey.install cabal version="3.0.0.0" source="STEP 3 URL"

See docs at https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.chocolatey.html.

5. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Private CDN cached downloads available for licensed customers. Never experience 404 breakages again! Learn more...

This package was approved as a trusted package on 10 Nov 2019.

Description

The 'cabal.exe' command-line program simplifies the process of managing Haskell software by automating the fetching, configuration, compilation and installation of Haskell libraries and programs.

    Cabal is a system for building and packaging Haskell libraries and programs. It defines a common interface for package authors and distributors to easily build their applications in a portable way. Cabal is part of a larger infrastructure for distributing, organizing, and cataloging Haskell libraries and programs.

Specifically, the Cabal describes what a Haskell package is, how these packages interact with the language, and what Haskell implementations must to do to support packages. The Cabal also specifies some infrastructure (code) that makes it easy for tool authors to build and distribute conforming packages.

The Cabal is only one contribution to the larger goal. In particular, the Cabal says nothing about more global issues such as how authors decide where in the module name space their library should live; how users can find a package they want; how orphan packages find new owners; and so on.


LICENSE.txt
Copyright (c) 2003-2008, Isaac Jones, Simon Marlow, Martin Sjögren,
                         Bjorn Bringert, Krasimir Angelov,
                         Malcolm Wallace, Ross Patterson,
                         Lemmih, Paolo Martini, Don Stewart,
                         Duncan Coutts
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 Isaac Jones nor the names of other
      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
OWNER 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.
tools\chocolateyBeforeModify.ps1
$version     = '3.0.0.0'
$packageName = 'cabal'

$binRoot         = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
$packageFullName = Join-Path $binRoot ($packageName + '-' + $version)
$is64 = (Get-OSArchitectureWidth 64)  -and $env:chocolateyForceX86 -ne 'true'

$cabal = Join-Path $packageFullName "cabal.exe"
function Find-Entry {
    param( [string] $app )
    Get-Command -ErrorAction SilentlyContinue $app `
      | Select-Object -first 1 `
      | ForEach-Object { Split-Path $_.Path -Parent }
}

Function Execute-Command {
  param( [string] $commandTitle
       , [string] $commandPath
       , [string] $commandArguments
       )
  Try {
    $pinfo = New-Object System.Diagnostics.ProcessStartInfo
    $pinfo.FileName = $commandPath
    $pinfo.RedirectStandardError = $true
    $pinfo.RedirectStandardOutput = $true
    $pinfo.UseShellExecute = $false
    $pinfo.Arguments = $commandArguments
    $pinfo.WindowStyle = [Diagnostics.ProcessWindowStyle]::Hidden
    $pinfo.CreateNoWindow = $true
    $p = New-Object System.Diagnostics.Process
    $p.StartInfo = $pinfo
    $p.Start() | Out-Null
    [pscustomobject]@{
        commandTitle = $commandTitle
        stdout = $p.StandardOutput.ReadToEnd()
        stderr = $p.StandardError.ReadToEnd()
        ExitCode = $p.ExitCode
    }
    $p.WaitForExit()
  }
  Catch {
     exit
  }
}

function Find-MSYS2 {
  param()

  # See if the user has msys2 already installed.
  $msys2 = Find-Entry "msys2_shell.cmd"
  if (($null -eq $msys2) -or ($msys2 -eq "")) {
    $msys2 = Find-Entry "mingw*_shell.bat"
  }

  $dir_name = if ($is64) { 'msys64' } else { 'msys32' }

  # Check for standalone msys2 installs
  if (($null -eq $msys2) -or ($msys2 -eq "")) {
    $tmp = Join-Path $Env:SystemDrive $dir_name
    if (Test-Path $tmp -PathType Container) {
      Write-Information "Standalone msys2 detected. Using default paths."
      $msys2 = $tmp
    }
  }

  if (($null -eq $msys2) -or ($msys2 -eq "")) {
    # msys2 was not found already installed, assume user will install
    # it in the default directory, so create the expected default msys2
    # installation path.
    $msys2    = "{0}\\{1}" -f (Get-ToolsLocation), $dir_name
  }

  Write-Debug "Msys2 directory: ${msys2}"
  return $msys2
}

function ReadCabal-Config {
  param( [string] $key )

  $prog = "$cabal"
  $cmd  = "user-config diff -a ${key}:"

  $proc = Execute-Command "Reading cabal config key '${key}'." $prog $cmd

  if ($proc.ExitCode -ne 0) {
    Write-Error $proc.stdout
    Write-Error $proc.stderr
    throw ("Could not read cabal configuration key '${key}'.")
  }

  $option = [System.StringSplitOptions]::RemoveEmptyEntries
  $procout = $proc.stdout.Split([Environment]::NewLine) | Select-String "- ${key}" | Select-Object -First 1
  if (!$procout) {
    Write-Debug "No Cabal config for ${key}"
    return {@()}.Invoke()
  } else {
    $value = $procout.ToString().Split(@(':'), 2, $option)[1].ToString()
    $value = $value.Split([Environment]::NewLine)[0].Trim()
    Write-Debug "Read Cabal config ${key}: ${value}"
    return {$value.Split(@(';'), $option)}.Invoke()
  }
}

function UpdateCabal-Config {
  param( [string] $key
       , [string[]] $values
       )

  if ((!$values) -or ($values.Count -eq 0)) {
    $values = ""
  }
  $prog = "$cabal"
  $value = [String]::Join(";", $values)
  $cmd  = "user-config update -a `"${key}: $value`""

  $proc = Execute-Command "Update cabal config key '${key}'." $prog $cmd

  if ($proc.ExitCode -ne 0) {
    Write-Error $proc.stdout
    Write-Error $proc.stderr
    throw ("Could not update cabal configuration key '${key}'.")
  }

  Write-Debug "Wrote Cabal config ${key}: ${value}"
}

function Restore-Config-Cabal {
  param()

  $ErrorActionPreference = 'Stop'
  $msys2_path   = Find-MSYS2
  $prog_path    = ReadCabal-Config "extra-prog-path"
  $lib_dirs     = ReadCabal-Config "extra-lib-dirs"
  $include_dirs = ReadCabal-Config "extra-include-dirs"

  $native_path = if ($is64) { 'mingw64' } else { 'mingw32' }
  $native_path = Join-Path $msys2_path $native_path

  # Build new binary paths
  $native_bin     = Join-Path $native_path "bin"
  $new_prog_paths = {$prog_path}.Invoke()
  $new_prog_paths.Remove((Join-Path (Join-Path $msys2_path "usr") "bin")) | Out-Null
  $new_prog_paths.Remove(($native_bin)) | Out-Null
  $new_prog_paths = $new_prog_paths | Select-Object -Unique

  # Build new library paths
  $new_lib_dirs = {$lib_dirs}.Invoke()
  $new_lib_dirs.Remove((Join-Path $native_path "lib")) | Out-Null
  $new_lib_dirs = $new_lib_dirs | Select-Object -Unique

  # Build new include paths
  $new_include_dirs = {$include_dirs}.Invoke()
  $new_include_dirs.Remove((Join-Path $native_path "include")) | Out-Null
  $new_include_dirs = $new_include_dirs | Select-Object -Unique

  UpdateCabal-Config "extra-prog-path"    $new_prog_paths
  UpdateCabal-Config "extra-lib-dirs"     $new_lib_dirs
  UpdateCabal-Config "extra-include-dirs" $new_include_dirs

  Write-Host "Restored cabal configuration."
}

# Now execute cabal configuration updates
Restore-Config-Cabal
Uninstall-ChocolateyEnvironmentVariable -VariableName '_MSYS2_BASH'
Uninstall-ChocolateyEnvironmentVariable -VariableName '_MSYS2_PREFIX'
# Cleanup the batch file we created
Get-Command "mingw64-pkg.bat" -ErrorAction SilentlyContinue `
  | ForEach-Object { Remove-Item -Force $_ -ErrorAction SilentlyContinue }
tools\chocolateyInstall.ps1
$version     = '3.0.0.0'
$packageName = 'cabal'
$url         = 'https://downloads.haskell.org/cabal/cabal-install-3.0.0.0/cabal-install-3.0.0.0-i386-unknown-mingw32.zip'
$url64       = 'https://downloads.haskell.org/cabal/cabal-install-3.0.0.0/cabal-install-3.0.0.0-x86_64-unknown-mingw32.zip'

$binRoot         = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
$packageFullName = Join-Path $binRoot ($packageName + '-' + $version)
$is64 = (Get-OSArchitectureWidth 64)  -and $env:chocolateyForceX86 -ne 'true'

Install-ChocolateyZipPackage `
  -PackageName $packageName `
  -UnzipLocation $packageFullName `
  -Url $url -ChecksumType sha256 -Checksum 36ae21454a40726de8a39d269c0a96f62967c4364b2ce8777834385474c8e3ec `
  -Url64bit $url64 -ChecksumType64 sha256 -Checksum64 8889963ebef5e829d86329fdb59832c107efd117cf7862a605f2fe2d2360de1f

$cabal = Join-Path $packageFullName "cabal.exe"

# Simplified version of Install-ChocolateyPath that prepends instead of
# Appends to a path.  We use this in certain cases when we need to Override an
# existing path entry.  Such as on AppVeyor which adds both cygwin and msys2
# on PATH.
function Install-AppVeyorPath {
param(
  [parameter(Mandatory=$true, Position=0)][string] $pathToInstall
)

  Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters
  ## Called from chocolateysetup.psm1 - wrap any Write-Host in try/catch

  $originalPathToInstall = $pathToInstall
  $pathType = [System.EnvironmentVariableTarget]::Machine

  #get the PATH variable
  Update-SessionEnvironment
  $envPath = $env:PATH
  if (!$envPath.ToLower().Contains($pathToInstall.ToLower()))
  {
    try {
      Write-Host "PATH environment variable does not have $pathToInstall in it. Adding..."
    } catch {
      Write-Verbose "PATH environment variable does not have $pathToInstall in it. Adding..."
    }

    $actualPath = Get-EnvironmentVariable -Name 'Path' -Scope $pathType -PreserveVariables

    $statementTerminator = ";"
    if (!$pathToInstall.EndsWith($statementTerminator)) {$pathToInstall = $pathToInstall + $statementTerminator}
    $actualPath = $pathToInstall + $actualPath

    Set-EnvironmentVariable -Name 'Path' -Value $actualPath -Scope $pathType

    #add it to the local path as well so users will be off and running
    $envPSPath = $env:PATH
    $env:Path = $pathToInstall + $envPSPath
  }
}

function Find-Entry {
    param( [string] $app )
    Get-Command -ErrorAction SilentlyContinue $app `
      | Select-Object -first 1 `
      | ForEach-Object { Split-Path $_.Path -Parent }
}

Function Execute-Command {
  param( [string] $commandTitle
       , [string] $commandPath
       , [string] $commandArguments
       )
  Try {
    $pinfo = New-Object System.Diagnostics.ProcessStartInfo
    $pinfo.FileName = $commandPath
    $pinfo.RedirectStandardError = $true
    $pinfo.RedirectStandardOutput = $true
    $pinfo.UseShellExecute = $false
    $pinfo.Arguments = $commandArguments
    $pinfo.WindowStyle = [Diagnostics.ProcessWindowStyle]::Hidden
    $pinfo.CreateNoWindow = $true
    $p = New-Object System.Diagnostics.Process
    $p.StartInfo = $pinfo
    $p.Start() | Out-Null
    [pscustomobject]@{
        commandTitle = $commandTitle
        stdout = $p.StandardOutput.ReadToEnd()
        stderr = $p.StandardError.ReadToEnd()
        ExitCode = $p.ExitCode
    }
    $p.WaitForExit()
  }
  Catch {
     exit
  }
}

function Detect-GHC-Versions {
  return Get-ChildItem "C:\ghc\ghc-*\bin" -ErrorAction SilentlyContinue `
    | Sort-Object CreationTime -Descending `
    | ForEach-Object { $_.ToString() }
}

function Find-MSYS2 {
  param()

  # See if the user has msys2 already installed.
  $msys2 = Find-Entry "msys2_shell.cmd"
  if (($null -eq $msys2) -or ($msys2 -eq "")) {
    $msys2 = Find-Entry "mingw*_shell.bat"
  }

  $dir_name = if ($is64) { 'msys64' } else { 'msys32' }
  # Detect AppVeyor installs
  if (($null -ne $Env:APPVEYOR) -and ("" -ne $Env:APPVEYOR)) {
    Write-Host "AppVeyor detected. Using AppVeyor default paths."
    $msys2 = Join-Path $Env:SystemDrive $dir_name
  }

  # Check for standalone msys2 installs
  if (($null -eq $msys2) -or ($msys2 -eq "")) {
    $tmp = Join-Path $Env:SystemDrive $dir_name
    if (Test-Path $tmp -PathType Container) {
      Write-Information "Standalone msys2 detected. Using default paths."
      $msys2 = $tmp
    }
  }

  if (($null -eq $msys2) -or ($msys2 -eq "")) {
    # msys2 was not found already installed, assume user will install
    # it in the default directory, so create the expected default msys2
    # installation path.
    $msys2    = "{0}\{1}" -f (Get-ToolsLocation), $dir_name
  }

  Write-Debug "Msys2 directory: ${msys2}"
  return $msys2
}

function ReadCabal-Config {
  param( [string] $key )

  $prog = "$cabal"
  $cmd  = "user-config diff -a ${key}:"

  $proc = Execute-Command "Reading cabal config key '${key}'." $prog $cmd

  if ($proc.ExitCode -ne 0) {
    Write-Debug $proc.stdout
    Write-Debug $proc.stderr
    Write-Host "Could not read cabal configuration key '${key}'."
  }

  $option = [System.StringSplitOptions]::RemoveEmptyEntries
  $procout = $proc.stdout.Split([Environment]::NewLine) | Select-String "- ${key}" | Select-Object -First 1
  if (!$procout) {
    Write-Debug "No Cabal config for ${key}"
    return {@()}.Invoke()
  } else {
    $value = $procout.ToString().Split(@(':'), 2, $option)[1].ToString()
    $value = $value.Split([Environment]::NewLine)[0].Trim()
    Write-Debug "Read Cabal config ${key}: ${value}"
    return {$value.Split(@(','), $option)}.Invoke()
  }
}

function UpdateCabal-Config {
  param( [string] $key
       , [string[]] $values
       )

  if ((!$values) -or ($values.Count -eq 0)) {
    $values = ""
  }
  $prog = "$cabal"
  $value = [String]::Join(",", $values)
  $cmd  = "user-config update -a `"${key}: $value`""

  $proc = Execute-Command "Update cabal config key '${key}'." $prog $cmd

  if ($proc.ExitCode -ne 0) {
    Write-Error $proc.stdout
    Write-Error $proc.stderr
    throw ("Could not update cabal configuration key '${key}'.")
  }

  Write-Debug "Wrote Cabal config ${key}: ${value}"
}

function Configure-Cabal {
  param()

  $ErrorActionPreference = 'Stop'
  $msys2_path   = Find-MSYS2

  # Initialize cabal
  $prog_path    = ReadCabal-Config "extra-prog-path"
  $lib_dirs     = ReadCabal-Config "extra-lib-dirs"
  $include_dirs = ReadCabal-Config "extra-include-dirs"
  $method       = ReadCabal-Config "install-method"
  $native_path = if ($is64) { 'mingw64' } else { 'mingw32' }
  $native_path = Join-Path $msys2_path $native_path

  # Build new binary paths
  $native_bin     = Join-Path $native_path "bin"
  $new_prog_paths = @()
  $new_prog_paths += Join-Path (Join-Path $msys2_path "usr") "bin"
  $new_prog_paths += $native_bin
  $new_prog_paths += $prog_path
  $new_prog_paths = $new_prog_paths | Select-Object -Unique

  # Build new library paths
  $new_lib_dirs = @(Join-Path $native_path "lib")
  $new_lib_dirs += $lib_dirs
  $new_lib_dirs = $new_lib_dirs | Select-Object -Unique

  # Build new include paths
  $new_include_dirs = @(Join-Path $native_path "include")
  $new_include_dirs += $include_dirs
  $new_include_dirs = $new_include_dirs | Select-Object -Unique

  # Set install method if no default is set
  if ($method -ne "copy" -and $method -ne "symlink" -and $method -ne "auto")
    {
      UpdateCabal-Config "install-method"     "copy"
    }

  UpdateCabal-Config "extra-prog-path"    $new_prog_paths
  UpdateCabal-Config "extra-lib-dirs"     $new_lib_dirs
  UpdateCabal-Config "extra-include-dirs" $new_include_dirs

  Write-Host "Updated cabal configuration."

  Install-ChocolateyPath (Join-Path (Join-Path "$Env:APPDATA" "cabal") "bin")

  if (($null -ne $Env:APPVEYOR) -and ("" -ne $Env:APPVEYOR)) {
    Write-Host "Configuring AppVeyor PATH."
    # We need to fix up some paths for AppVeyor
    $ghcpaths = Detect-GHC-Versions
    ForEach ($path in $ghcpaths) { Install-ChocolateyPath $path }

    # I'm not a fan of doing this, but we need auto-reconf available.
    Install-AppVeyorPath (Join-Path (Join-Path "${msys2_path}" "mingw64") "bin")
    Install-AppVeyorPath (Join-Path (Join-Path "${msys2_path}" "usr") "bin")
    # Override msys2 git with git for Windows
    Install-AppVeyorPath "$($env:SystemDrive)\Program Files\Git\cmd"
    Install-AppVeyorPath "$($env:SystemDrive)\Program Files\Git\mingw64\bin"
  }
}

function Find-Bash {
  param()
  $ErrorActionPreference = 'Stop'
  $msys2_path = Find-MSYS2
  $bin        = Join-Path (Join-Path $msys2_path "usr") "bin"
  $bash       = Join-Path $bin "bash.exe"
  return $bash
}

# Now execute cabal configuration updates
Configure-Cabal
$bash = Find-Bash
$prefix = if ($is64) { 'x86_64' } else { 'i686' }
Install-ChocolateyEnvironmentVariable "_MSYS2_BASH" "$bash"
Install-ChocolateyEnvironmentVariable "_MSYS2_PREFIX" "$prefix"
$psFile = Join-Path $(Split-Path -Parent $MyInvocation.MyCommand.Definition) "mingw64-pkg.ps1"
Install-ChocolateyPowershellCommand -PackageName '${packageName}.powershell' -PSFileFullPath $psFile
tools\mingw64-pkg.ps1
<#
.SYNOPSIS
    Install a Mingw-w64 native package such that cabal and ghc will recognize them.
.DESCRIPTION
    This CmdLet makes it easier to install native Mingw-w64 packages into MSYS2 such
    that cabal-install and GHC can use them without any other configuration required.

    This will not allow installation of MSYS2 packages.  Your global namespace will
    not be poluted by the use of this CmdLet.
.PARAMETER Action
    The action to perform. Must be one of install, uninstall, update or shell.

    - install: install a new native package
    - uninstall: remove native package
    - update: sync the repositories, will not upgrade any packages.
    - shell: open a bash shell
.PARAMETER Package
    The name of the Mingw64 package to install into the msys2 environment.
.PARAMETER NoConfirm
    Indicates whether or not an interactive prompt should be used to confirm before
    action is carried out.
.EXAMPLE
    C:\PS> mingw-pkg install gtk2
.NOTES
    Author: Tamar Christina
    Date:   February 16, 2019
#>

Param(
  [ValidateSet("install","uninstall", "update", "shell")]
  [String] $Action
, [string] $Package
, [switch] $NoConfirm = $false
)

$bash = $Env:_MSYS2_BASH
$prefix = $Env:_MSYS2_PREFIX
if ((!$bash) -or ($bash -eq "") -or (!$prefix) -or ($prefix -eq "")) {
  throw ("Bash environment variable found, are you sure you installed cabal and msys2 via chocolatey?")
}

if(![System.IO.File]::Exists($bash)){
  throw ("Bash not found, try `choco install msys2' first.")
}

$package = "mingw-w64-${prefix}-${Package}"
$shell = $false

switch ($Action){
  "install" {
    $cmd = "-S"
    if((!$Package) -or ($Package -eq "")){
      throw ("Package name required when installing package.")
    }
    break
  }
  "uninstall" {
    $cmd = "-R"
    if((!$Package) -or ($Package -eq "")){
      throw ("Package name required when removing package.")
    }
    break
  }
  "update" {
    $cmd = "-Sy"
    $package = ""
    break
  }
  "shell" {
    $shell = $true
    break
  }
  default {
    Write-Host ".SYNOPSIS
  Install a Mingw-w64 native package such that cabal and ghc will recognize them.
.DESCRIPTION
  This CmdLet makes it easier to install native Mingw-w64 packages into MSYS2 such
  that cabal-install and GHC can use them without any other configuration required.

  This will not allow installation of MSYS2 packages.  Your global namespace will
  not be poluted by the use of this CmdLet.
.PARAMETER Action
  The action to perform. Must be one of install, uninstall, update or shell.

  - install: install a new native package
  - uninstall: remove native package
  - update: sync the repositories, will not upgrade any packages.
  - shell: open a bash shell
.PARAMETER Package
  The name of the Mingw64 package to install into the msys2 environment.
.PARAMETER NoConfirm
  Indicates whether or not an interactive prompt should be used to confirm before
  action is carried out.
.EXAMPLE
  C:\PS> mingw-pkg install gtk2
.NOTES
  Author: Tamar Christina
  Date:   February 16, 2019"
    return
  }
}

switch ($NoConfirm){
  $true {
    $arg = "--noconfirm"
    break
  }
  $false {
    $arg = "--confirm"
    break
  }
}


$osBitness = "64"
if ($prefix -eq "i686") {
  $osBitness = "32"
}

# Set the APPDATA path which does not get inherited during these invokes
# and set MSYSTEM to make sure we're using the right system
$envdata = "export APPDATA=""" + $Env:AppData + """ && export MSYSTEM=MINGW" + $osBitness + " && "

if ($false -eq $shell) {
  $proc = Start-Process -NoNewWindow -UseNewEnvironment -Wait $bash `
                        -ArgumentList '--login', '-c', "'$envdata pacman $cmd $arg $package'" `
                        -PassThru

  if ((-not $ignoreExitCode) -and ($proc.ExitCode -ne 0)) {
      throw ("`'${bash}`' did not complete successfully. ExitCode: " + $proc.ExitCode)
  }
} else {
  $proc = Start-Process -NoNewWindow -UseNewEnvironment -Wait $bash `
                        -ArgumentList '--login' `
                        -PassThru
}

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Version Downloads Last Updated Status
Cabal 2.4.1.0 17251 Monday, November 26, 2018 Approved
Cabal 2.4.0.20180922 2391 Sunday, September 23, 2018 Approved
Cabal 2.4.0.0 1048 Saturday, September 22, 2018 Approved
Cabal 2.2.0.0 6203 Thursday, March 29, 2018 Approved
Cabal 2.0.0.1 2592 Tuesday, February 6, 2018 Approved
Cabal 2.0.0.0 5521 Thursday, August 17, 2017 Approved
Cabal 1.24.0.2 4473 Saturday, January 14, 2017 Approved
Cabal 1.24.0.0 4851 Saturday, May 14, 2016 Approved
Cabal 1.22.0.0 230 Saturday, May 14, 2016 Approved

This package has no dependencies.

Discussion for the Cabal Package

Ground Rules:

  • This discussion is only about Cabal and the Cabal package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or Cabal, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus