%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/openbsdpkg.pyc

�
���^c@@sdZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlmZm
Z
eje�Zejd�ZdZd�Zed�Zd	�Zd
�Zdddd�Zdded�Zddd
�Zd�Zddd�ZdS(u�
Package support for OpenBSD

.. note::

    The package repository is configured on each host using ``/etc/installurl``
    from OpenBSD 6.1 onwards. Earlier releases relied on ``/etc/pkg.conf``.

.. versionchanged:: 2016.3.5

    Package versions on OpenBSD are not normally specified explicitly; instead
    packages may be available in multiple *flavors*, and *branches* which are
    specified by the format of the package name. This module allows you to use
    the same formatting as ``pkg_add(1)``, and will select the empty flavor and
    default branch by default. Examples:

    .. code-block:: yaml

      - rsync
      - vim--no_x11
      - ruby%2.3

i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortMinionErroru0^((?:[^-]+|-(?![0-9]))+)-([0-9][^-]*)(?:-(.*))?$upkgcC@stddkrtStdfS(u9
    Set the virtual pkg module if the os is OpenBSD
    uosuOpenBSDuTThe openbsdpkg execution module cannot be loaded: only available on OpenBSD systems.(t
__grains__t__virtualname__tFalse(((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pyt__virtual__/sc
K@sstjjj|�}tgd
D]$}tjjj|j|��^q�rPiSdtkr�|rjtdStjtd�}t	d|�|Sni}d}t	d|dd�}x�|j
�D]r}y"tj|�j
�\}}}	Wntk
r�q�nX||	rd	j|	�nd
7}t	d|||�q�Wt	d|�tj|�td<|sot	d|�n|S(u�
    List the packages currently installed as a dict::

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

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_pkgs
    uremovedu
purge_desiredu
pkg.list_pkgsupkg_resource.stringifyupkg_info -q -aucmd.run_stdouttoutput_loglevelutraceu--{0}uupkg_resource.add_pkgupkg_resource.sort_pkglist(uremovedu
purge_desired(tsalttutilstdatatis_truetanytgett__context__tcopytdeepcopyt__salt__t
splitlinest__PKG_REtmatchtgroupstAttributeErrortformat(
tversions_as_listtkwargstxtrettcmdtouttlinetpkgnametpkgvertflavor((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pyt	list_pkgs9s21"
c

O@s}|jdt�t�}i}x9|D]1}d||<dj|�}td|dtdd�}x�|j�D]�}y"tj|�j	�\}}	}
Wnt
k
r�qnnXtjd|	�}|r�Pnd	j||
�|kr�|d
j|
�7}n||krnnqn|j|d�}|sFt
jjjd|dd
d|	�rn|	||<qnqnWq&Wt|�dkry||dS|S(u�
    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 '*' pkg.latest_version <package name>
    urefreshuupkg_info -Q {0}ucmd.run_stdouttpython_shellR	utraceu.*\(installed\)$u{0}--{1}u--{0}tver1toperu<tver2ii(tpoptTrueR$RRRRRRRRtreRR
Rtversionstcomparetlen(
tnamesRtpkgsRtnameRRR R!R"R#Rtcur((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pytlatest_versiones:	

"
	cO@std||�S(uY
    Returns a string representing the package version or an empty string if not
    installed. If more than one package name is specified, a dict of
    name/version pairs is returned.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.version <package name>
        salt '*' pkg.version <package1> <package2> <package3> ...
    upkg_resource.version(R(R/R((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pytversion�s
cK@s�y#td||||�\}}Wntk
rD}t|��nX|dksct|�dkrgiSt�}g}x�|D]�}	|dkr�|	jd�dgd \}
}|
jd�dgd \}}
dj||
|�}	nd	j|	�}td
|dtdd
�}|ddkr}|dr}|j	|d�q}q}Wt
jdd�t�}tj
jj||�}|r�tddi|d6|d6��n|S(u�
    Install the passed package

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

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

    CLI Example, Install one package:

    .. code-block:: bash

        salt '*' pkg.install <package name>

    CLI Example, Install more than one package:

    .. code-block:: bash

        salt '*' pkg.install pkgs='["<package name>", "<package name>"]'

    CLI Example, Install more than one package from a alternate source (e.g.
    salt file-server, HTTP, FTP, local filesystem):

    .. code-block:: bash

        salt '*' pkg.install sources='[{"<pkg name>": "salt://pkgs/<pkg filename>"}]'
    upkg_resource.parse_targetsiu
repositoryu%uiu--u{0}--{1}%{2}upkg_add -x -I {0}ucmd.run_allR%R	utraceuretcodeustderru
pkg.list_pkgsu)Problem encountered installing package(s)tinfouerrorsuchangesN(RRRtNoneR.R$tsplitRRtappendRR)R
RRt
compare_dicts(R1R0tsourcesRt
pkg_paramstpkg_typetexctoldterrorstpkgtstemtbranchtbaseR#RRtnewR((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pytinstall�s:	
  		cK@sqy;gtd||�dD]}|jd�d^q}Wntk
r\}t|��nXt�}g|D]}||krm|^qm}|s�iSdddg}	|r�|	jd�n|	j|�td|	d	td
d�}
|
ddkr
|
d
r
|
d
g}ng}tj	dd�t�}tjj
j||�}
|rmtddi|d6|
d6��n|
S(u�
    Remove a single package with pkg_delete

    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"]'
    upkg_resource.parse_targetsiu--u
pkg_deleteu-Ixu-Ddependenciesu-cqqucmd.run_allR%R	utraceuretcodeustderru
pkg.list_pkgsu'Problem encountered removing package(s)R5uerrorsuchangesN(RR7RRR$R8textendRRR)R6R
RRR9(R1R0tpurgeRRR;R=R>ttargetsRRR?RDR((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pytremove�s88	%
		cK@std|d|dt�S(u;
    Remove a package and extra configuration files.

    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"]'
    R1R0RG(RIR*(R1R0R((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pyRG=scC@st|�dkS(u�
    Check whether or not an upgrade is available for a given package

    .. versionadded:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade_available <package name>
    u(R3(R1((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pytupgrade_available[scK@s�t�}dddg}|jdt�r:|jd�n|rP|j|�n|rf|j|�ntd|ddd	t�}tjd
d�t�}t	j
jj||�}|ddkr�t
d
di|d6|d6��n|S(u�
    Run a full package upgrade (``pkg_add -u``), or upgrade a specific package
    if ``name`` or ``pkgs`` is provided.
    ``name`` is ignored when ``pkgs`` is specified.

    Returns a dictionary containing the changes:

    .. versionadded:: 2019.2.0

    .. code-block:: python

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

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade
        salt '*' pkg.upgrade python%2.7
    upkg_addu-Ixu-uunoopu-nucmd.run_allR	utraceR%u
pkg.list_pkgsuretcodeiu&Problem encountered upgrading packagesR5uchangesuresultN(R$RRR8RFRRR)R6R
RRR9R(R1R0RR>RtresultRDR((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pytupgradejs$			(t__doc__t
__future__RRRRR+tloggingtsalt.utils.dataR
tsalt.utils.versionstsalt.exceptionsRRt	getLoggert__name__tlogtcompileRRRRR$R3R4R6RERIRGRJRL(((s;/usr/lib/python2.7/site-packages/salt/modules/openbsdpkg.pyt<module>s(	
,	C	E@	

Zerion Mini Shell 1.0