HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/cabal.cpython-310.pyc
o

�N�g��@sDdZddlZddlmZmZdd�Zdd�Zd
d	d
�Zddd�Z	dS)a-
Installation of Cabal Packages
==============================

.. versionadded:: 2015.8.0

These states manage the installed packages for Haskell using
cabal. Note that cabal-install must be installed for these states to
be available, so cabal states should include a requisite to a
pkg.installed state for the package which provides cabal
(``cabal-install`` in case of Debian based distributions). Example::

.. code-block:: yaml

   cabal-install:
     pkg.installed

   ShellCheck:
     cabal.installed:
       - require:
         - pkg: cabal-install

�N)�CommandExecutionError�CommandNotFoundErrorcCs,tjj�d�durtjj�d�durdSdS)z4
    Only work when cabal-install is installed.
    ZcabalNzghc-pkgT)Fz#cabal or ghc-pkg commands not found)�salt�utils�path�which�rr�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/cabal.py�__virtual__sr
cCs"|�d�\}}}|��||��fS)a=
    Parse pkg string and return a tuple of package name, separator, and
    package version.

    Cabal support install package with following format:

    * foo-1.0
    * foo < 1.2
    * foo > 1.3

    For the sake of simplicity only the first form is supported,
    support for other forms can be added later.
    �-)�	partition�strip)�pkg�pkg_name�	separator�pkg_verrrr	�_parse_pkg_string(srFc
Cs�|ddid�}z
td||d�}Wn!ttfy2}zd|d<d|��|d	<|WYd}~Sd}~ww|dur:|}n|g}ztd
|d|d�}	Wn$ttfyl}zd|d<d
|�d|��|d	<|WYd}~Sd}~wwg}
g}|D],}t|�\}
}}|
|	vr�|�|�qs|r�|	|
|kr�|�|�qs|
�|�qs|
�|�qstdr�d|d<g}|r�|�d�d�|���|
r�|�d�d�|�d�|
���d�|�|d	<|S|s�d|d<d�d�|�d�|
��|d	<|Sztd||||d�}Wn&ttf�y}zd|d<d�d�|�|�|d	<|WYd}~Sd}~ww|�r:t|t	��r:d|d<g|d�|d<d�d�|��|d	<|Sd|d<d�d�|��|d	<|S)a
    Verify that the given package is installed and is at the correct version
    (if specified).

    .. code-block:: yaml

        ShellCheck-0.3.5:
          cabal:
            - installed:

    name
        The package to install
    user
        The user to run cabal install with
    install_global
        Install package globally instead of locally
    env
        A list of environment variables to be set prior to execution. The
        format is the same as the :py:func:`cmd.run <salt.states.cmd.run>`.
        state function.
    N���name�result�comment�changeszcabal.update)�user�envFrzCould not run cabal update r�
cabal.listT�r�	installedr�Error looking up '�': �testz(Packages(s) '{}' are set to be installedz, z Packages(s) '{}' satisfied by {}z. z
cabal.install)�pkgsr�install_globalrzError installing '{}': {})�old�newrz'Packages(s) '{}' successfully installedz"Could not install packages(s) '{}')
�__salt__rrr�append�__opts__�format�join�
isinstance�dict)rr!rr"r�ret�call�errZpkg_list�installed_pkgsZpkgs_satisfiedZpkgs_to_installrr�_rZcomment_msgrrr	r:s����������
����	��rc
Cs|ddid�}ztd|d|d�}Wn"ttfy4}zd|d<d	|�d
|��|d<WYd}~nd}~ww||vrGd|d<d|�d
�|d<|StdrYd|d<d|�d�|d<|Std|||d�rvd|d<d|d|<d|�d�|d<|Sd|d<d|�d�|d<|S)z5
    Verify that given package is not installed.
    NrrrTrFrrrrz	Package 'z' is not installedr z' is set to be removedzcabal.uninstall)rrrZRemovedrz' was successfully removedzError removing package '�')r%rrr')rrrr,r/r.rrr	�removed�s0 ���r2)NNFN)NN)
�__doc__Zsalt.utils.pathrZsalt.exceptionsrrr
rrr2rrrr	�<module>s
r