HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/pkgutil.cpython-310.pyc
o

�N�gW'�@s�dZddlZddlZddlZddlZddlZddlmZm	Z	dZ
dd�Zdd�Zd	d
�Z
d dd
�Zd dd�Zdd�Zd!dd�Zdd�Zdd�Zejj�ed�Zd"dd�Zd#dd�Zd#dd�ZdS)$a
Pkgutil support for Solaris

.. important::
    If you feel that Salt should be using this module to manage packages on a
    minion, and it is using a different module (or gives an error similar to
    *'pkg.install' is not available*), see :ref:`here
    <module-provider-override>`.
�N)�CommandExecutionError�MinionError�pkgutilcCstddkrtSdS)z9
    Set the virtual pkg module if the os is Solaris
    Z	os_family�Solaris)FzQThe pkgutil execution module cannot be loaded: only available on Solaris systems.)Z
__grains__�__virtualname__�rr�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/pkgutil.py�__virtual__sr	cCstjj�t�tdd�dkS)z�
    Updates the pkgutil repo database (pkgutil -U)

    CLI Example:

    .. code-block:: bash

        salt '*' pkgutil.refresh_db
    zcmd.retcodez/opt/csw/bin/pkgutil -Ur)�salt�utilsZpkgZ
clear_rtagZ__opts__�__salt__rrrr�
refresh_db$sr
cCsFd}d|��}td|�}|r|��d��}|r!|dkrdS|SdS)z�
    Check if there is an upgrade available for a certain package

    CLI Example:

    .. code-block:: bash

        salt '*' pkgutil.upgrade_available CSWpython
    Nz)/opt/csw/bin/pkgutil -c --parse --single �cmd.run_stdout��SAME�)r�split�strip)�name�version_num�cmd�outrrr�upgrade_available3s

rTcKsltjj�|�r
t�i}tdd���}|D]}|�d�}|ddkr$q|ddkr+q|d||d<q|S)	z�
    List all available package upgrades on this system

    CLI Example:

    .. code-block:: bash

        salt '*' pkgutil.list_upgrades
    rz/opt/csw/bin/pkgutil -A --parse�	rrz
not installed�r)r
r�data�is_truer
r�
splitlinesr)�refresh�kwargsZupgrades�lines�line�compsrrr�
list_upgradesJs

r#cCsLtjj�|�r
t�t�}d}td|�t�dd�t�}tjj�	||�S)a!
    Upgrade all of the packages to the latest available version.

    Returns a dict containing the changes::

        {'<package>': {'old': '<old-version>',
                       'new': '<new-version>'}}

    CLI Example:

    .. code-block:: bash

        salt '*' pkgutil.upgrade
    z/opt/csw/bin/pkgutil -yu�cmd.run_all�
pkg.list_pkgsN)
r
rrrr
�	list_pkgsr�__context__�pop�
compare_dicts)r�oldr�newrrr�upgradebsr,cCs*|rtdSt�td�}td|�|S)z'
    Use pkg list from __context__
    r%�pkg_resource.stringify)r'�copy�deepcopyr)�versions_as_list�retrrr�_list_pkgs_from_contexts
r2Fc	Ks�tjj�|�}tjj�|�d��riSdtvr!|�dd�r!t|�Si}d}td|���}t	|�D](\}}|ddkrC|�
�d��}|dd	krY|�
�d	��}td
|||�q1td|�t�
|�td<|sotd|�|S)
z�
    List the packages currently installed as a dict::

        {'<package_name>': '<version>'}

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_pkgs
        salt '*' pkg.list_pkgs versions_as_list=True
    Zremovedr%Zuse_contextTz/usr/bin/pkginfo -xzcmd.runrrrzpkg_resource.add_pkgzpkg_resource.sort_pkglistr-)r
rrr�getr'r2rr�	enumeraterrr.r/)	r0rr1rr �indexr!rrrrrr&�s(
�r&cOstd|i|��S)z�
    Returns a version if the package is installed, else returns an empty string

    CLI Example:

    .. code-block:: bash

        salt '*' pkgutil.version CSWpython
    zpkg_resource.version)r)�namesrrrr�version�s
r7c	Ostjj�|�dd��}|sdSi}|D]}d||<q|rt�t�}d�d�|��}t	d|��
dd���}|D]9}z|��dd	�\}}	Wn	t
yOYq8w||vrq|�
|d�}
|	�d
�d}|
rmtjjj|
d|d
�rq|	||<q8t|�dkr~||dS|S)a�
    Return the latest version of the named package available for upgrade or
    installation. If more than one package name is specified, a dict of
    name/version pairs is returned.

    If the latest version of a given package is already installed, an empty
    string will be returned for that package.

    CLI Example:

    .. code-block:: bash

        salt '*' pkgutil.latest_version CSWpython
        salt '*' pkgutil.latest_version <package1> <package2> <package3> ...
    rTrz"/opt/csw/bin/pkgutil -a --parse {}� r$�stdoutr��,r�<)Zver1ZoperZver2)r
rrrr(r
r&�format�joinrr3rr�
ValueErrorZversionsZcompare�len)r6rrr1r�pkgsr�outputr!Zversion_revZcverZnverrrr�latest_version�s4
��rC�available_versionc

Ks�|rt�ztd||fi|��d}Wnty$}zt|��d}~ww|s)iS|dur9|r9t|�dkr9||i}g}|��D]\}}	|	durM|�|�q?|�|�d|	���q?d�d�|��}
t	�}td|
�t
�d	d�t	�}tj
j�||�S)
a�
    Install packages using the pkgutil tool.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.install <package_name>
        salt '*' pkg.install SMClgcc346


    Multiple Package Installation Options:

    pkgs
        A list of packages to install from OpenCSW. Must be passed as a python
        list.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install pkgs='["foo", "bar"]'
            salt '*' pkg.install pkgs='["foo", {"bar": "1.2.3"}]'


    Returns a dict containing the new package names and versions::

        {'<package>': {'old': '<old-version>',
                       'new': '<new-version>'}}
    �pkg_resource.parse_targetsrNr�-z/opt/csw/bin/pkgutil -yu {}r8r$r%)r
rrrr@�items�appendr=r>r&r'r(r
rrr))
rrr7rAr�
pkg_params�exc�targets�paramZpkgverrr*r+rrr�install�s.��rMc
s�ztd||�d}Wnty}zt|��d}~wwt���fdd�|D�}|s,iSd�d�|��}td|�t�d	d�t�}tj	j
��|�S)
ad
    Remove a package and all its dependencies which are not in use by other
    packages.

    name
        The name of the package to be deleted.


    Multiple Package Options:

    pkgs
        A list of packages to delete. Must be passed as a python list. The
        ``name`` parameter will be ignored if this option is passed.

    .. versionadded:: 0.16.0


    Returns a dict containing the changes.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.remove <package name>
        salt '*' pkg.remove <package1>,<package2>,<package3>
        salt '*' pkg.remove pkgs='["foo", "bar"]'
    rErNcsg|]}|�vr|�qSrr)�.0�x�r*rr�
<listcomp>Yszremove.<locals>.<listcomp>z/opt/csw/bin/pkgutil -yr {}r8r$r%)rrrr&r=r>r'r(r
rrr))rrArrIrJrKrr+rrPr�remove7s��rRcKst||d�S)a]
    Package purges are not supported, this function is identical to
    ``remove()``.

    name
        The name of the package to be deleted.


    Multiple Package Options:

    pkgs
        A list of packages to delete. Must be passed as a python list. The
        ``name`` parameter will be ignored if this option is passed.

    .. versionadded:: 0.16.0


    Returns a dict containing the changes.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.purge <package name>
        salt '*' pkg.purge <package1>,<package2>,<package3>
        salt '*' pkg.purge pkgs='["foo", "bar"]'
    )rrA)rR)rrArrrr�purgecsrS)T)F)NFNN)NN)�__doc__r.Zsalt.utils.datar
Zsalt.utils.functoolsZsalt.utils.pkgZsalt.utils.versionsZsalt.exceptionsrrrr	r
rr#r,r2r&r7rCr�	functoolsZalias_functionrDrMrRrSrrrr�<module>s.




*
4�

<,