%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl
Z
ddljjZddlmZmZddlmZejd�Zeje�ZdZejd��Zejd	��Zejd
��Zejd��Z d�Z!d
�Z"d�Z#d�Z$e
jj%j&e$d�Z'd�Z(e)d�Z*e)d�Z+e,d�Z-de)dddd�Z/e,dd�Z0ddd�Z1ddd�Z2d�Z3d�Z4d�Z5dS(uL
Package support for pkgin based systems, inspired from freebsdpkg module

.. 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>`.
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortMinionError(tsixu%pkgin(?:[\s]+)([\d.]+)(?:[\s]+)(?:.*)upkgcC@s�tjjjd�}|dkr�yNtdddd�}|dk	rndj|�}tjj|�sndSnWq�t	k
r�dSXn|S(uJ
    Looks to see if pkgin is present on the system, return full path
    upkginucmd.runupkg_info -Q LOCALBASE pkgintoutput_loglevelutraceu
{0}/bin/pkginN(
tsalttutilstpathtwhichtNonet__salt__tformattostexistsR(tppatht	localbase((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt_check_pkgin%s	
cC@s^tdt�dgdd�}|dkr/tStj|�}|sHtS|jd�jd�S(u
    Get the pkgin version
    ucmd.runu-vRutraceiu.N(RRRtFalset
VERSION_MATCHtsearchtgrouptsplit(tversion_stringt
version_match((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt_get_version;s	cC@s,tgt�D]}t|�^q
�dkS(u!
    Check support of regexp
    ii(ii(ttupleRtint(ti((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt_supports_regexNscC@s,tgt�D]}t|�^q
�dkS(u"
    Check support of parsing
    ii(ii(RRR(R((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt_supports_parsingVscC@sQddddddg}td|kr5t�r5tStdjd	j|��fS(
uD
    Set the virtual pkg module if the os is supported by pkgin
    uNetBSDuSunOSu	DragonFlyuMinixuDarwinuSmartOSuosuKThe pkgin execution module cannot be loaded: only available on {0} systems.u, (t
__grains__Rt__virtualname__RR
tjoin(t	supported((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt__virtual__^s
	cC@s@|dj�r<|dkr<|jdd�djdd�SdS(u2
    Split package name from versioned string
    iuNou;iu-N(tisalnumRtrsplit(tname((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt	_splitpkgjscC@s�i}t�}|s|St�r4dj|�}ntd|d|gdd�}xN|j�D]@}|r`t|j�d�}|r�|d||d<q�q`q`W|S(u�
    Searches for an exact match using pkgin ^package$

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.search 'mysql-server'
    u^{0}$ucmd.runuseRutraceii(RRR
Rt
splitlinesR(R(tpkg_nametpkglisttpkgintouttlinetmatch((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyRss			cO@s�tjjj|jdt��}i}t�}|s:|S|rJt�n|dg}t�rr|j	dd�nx6|D].}t
j|�}|jt
�r�dj|�n|�td|dd�}x�|j�D]�}	|	jd	�r�|S|	jt�rd
nd�}
|
r)|
ddkr)q�q�|
r�t|
d�}|r�|d|kr�t|
�dkr�|
ddkr�|d||d<q�d||d<q�q�q�q�WqyW|r�t|�dkr�|d|kr�||dSn|SdS(u�
    .. versionchanged: 2016.3.0

    Return the latest version of the named package available for upgrade or
    installation.

    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>
        salt '*' pkg.latest_version <package1> <package2> ...
    urefreshuseiu-pu^{0}$ucmd.runRutraceuNo results found foru;iu=:u<:u>:uu<u=N(u=:u<:u>:u(u<uu=(RRtdatatis_truetpoptTrueRt
refresh_dbRtinserttcopytdeepcopytappendRR
RR)t
startswithRRR(tlen(tnamestkwargstrefreshR+R,t
cmd_prefixR'tcmdR-R.tpts((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pytlatest_version�s>!	
	
%"uavailable_versioncO@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<((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pytversion�s
cC@s�tjjjt�t�}|r�|dg}|rG|jdd�ntd|dd�}|ddkr�d	}d
|kr�||d
7}nt|��q�nt	S(u�
    Use pkg update to get latest pkg_summary

    force
        Pass -f so that the cache is always refreshed.

        .. versionadded:: 2018.3.0


    CLI Example:

    .. code-block:: bash

        salt '*' pkg.refresh_db
    uupiu-fucmd.run_allRutraceuretcodeiuustderr(
RRtpkgt
clear_rtagt__opts__RR5RRR3(tforceR,R?tcalltcomment((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyR4�s	c	K@sytjjj|�}tgdD]$}tjjj|j|��^q�rPiSdtkr�|rjtdStjtd�}t	d|�|Snt
�}i}t	d|r�|dgndgdd	�}xn|j�D]`}y/tj
d
|d�djd
d�\}}Wntk
r$q�nXt	d|||�q�Wt	d|�tj|�td<|sut	d|�n|S(u�
    .. versionchanged: 2016.3.0

    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.stringifyucmd.runulsupkg_infoRutraceu[; ]iiu-upkg_resource.add_pkgupkg_resource.sort_pkglist(uremovedu
purge_desired(RRR0R1tanytgett__context__R6R7RRR)treRR&t
ValueError(	tversions_as_listR<txtretR,R-R.RDtver((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt	list_pkgss41		/
cK@sUi}xHttd|�j��D]+}t|dt�}|r"|||<q"q"W|S(u�
    List all available package upgrades.

    .. versionadded:: 2018.3.0

    refresh
        Whether or not to refresh the package database before installing.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_upgrades
    R=(tsortedRStkeysRBR(R=R<tpkgsRDtpkg_upgrade((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt
list_upgrades;s"cK@s y#td||||�\}}Wntk
rD}t|��nX|jdd�}	|rm|	rm|	}n|swiSg}
g}t�}|r�|}
|r�tjd|�|
jd|f�q�n2d}
|r�tjd|�|
jd|f�n|d	krd}
n;|d
krI|rI|r6|jd�n|jd�qIn|j	d|
�|j|�t
�}td|d|
dd�}|ddkr�|dr�|dg}ng}tjdd�t
�}tjjj||�}|rtddi|d6|d6��nt�|S(ue
    Install the passed package

    name
        The name of the package to be installed.

    refresh
        Whether or not to refresh the package database before installing.

    fromrepo
        Specify a package repository to install from.


    Multiple Package Installation Options:

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

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install pkgs='["foo","bar"]'

    sources
        A list of packages to install. Must be passed as a list of dicts,
        with the keys being package names, and the values being the source URI
        or local path to the package.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install sources='[{"foo": "salt://foo.deb"},{"bar": "salt://bar.deb"}]'

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

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

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.install <package name>
    upkg_resource.parse_targetsurepouuSetting PKG_REPOS=%su	PKG_REPOSupkg_adduSetting PKG_PATH=%suPKG_PATHufileu
repositoryu-fu-yuiniucmd.run_alltenvRutraceuretcodeustderru
pkg.list_pkgsu)Problem encountered installing package(s)tinfouerrorsuchanges(u-yuinN(RRRRKRtlogRZR8textendR5RSRLR2RRRR0t
compare_dictst_rehash(R'R=tfromrepoRVtsourcesR<t
pkg_paramstpkg_typetexctrepoRYtargsR,R?toldR-terrorstnewRQ((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pytinstallSsZ1
			
		cK@spt�}|siStjjj|�r2t�nt�}g}|s`|j|ddg�ngtjjj|�r�xO|D]}|j|dd|g�q|Wn%idd6dd6}t	j
|d�x>|D]6}td|d	d
dt�}|ddkr�Pq�q�Wt
jd
d�t�}	tjjj||	�}
|ddkrltddi|
d6|d6��n|
S(u�
    Run pkg upgrade, if pkgin used. Otherwise do nothing

    refresh
        Whether or not to refresh the package database before installing.

    Multiple Package Upgrade Options:

    pkgs
        A list of packages to upgrade from a software repository. Must be
        passed as a python list.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.upgrade pkgs='["foo","bar"]'

    Returns a dictionary containing the changes:

    .. code-block:: python

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


    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade
    u-yufull-upgradeuinstalliuretcodeu7Ignoring the parameter `pkgs` because it is not a list!ureasonucmd.run_allRutracetpython_shelliu
pkg.list_pkgsu&Problem encountered upgrading packagesRZuchangesuresultN(RRRR0R1R4RSR8tis_listR[terrorRRRLR2RR]R(R=RVR<R,RftcmdsRDtresultR?RhRQ((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pytupgrade�s8!	
	
 

		cK@s�ytd||�\}}Wntk
r>}t|��nX|sIiSt�}g}x�|D]{}|j|g�}	|	s�q_nt|	t�r�|jg|	D]}
dj||
�^q��q_|j	dj||	��q_W|s�iSt
�}|r|ddgndg}|j|�td|dd�}
|
d	d
kr\|
dr\|
dg}ng}tjdd�t�}tjjj||�}|r�td
di|d6|d6��n|S(u
    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 list containing the removed packages.

    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_targetsu{0}-{1}u-yuremoveu
pkg_removeucmd.run_allRutraceuretcodeiustderru
pkg.list_pkgsu'Problem encountered removing package(s)RZuerrorsuchangesN(RRRRSRKt
isinstancetlistR\R
R8RRLR2RRRR0R](R'RVR<RaRbRcRfRetparamRRtvR,R?R-RgRhRQ((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pytremovesB	
/	
	cK@std|d|�S(u]
    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"]'
    R'RV(Rt(R'RVR<((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pytpurgeVscC@sDtdd�}|jd�ddkr@tddd	d
�ndS(
u�
    Recomputes internal hash table for the PATH variable.
    Use whenever a new command is created during the current
    session.
    uenviron.getuSHELLu/i����ucshutcshucmd.runurehashRutraceN(ucshutcsh(RR(tshell((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyR^uscC@sKt|�}g}x(tj|d�D]}|j|�q&W||d<|S(u�
    List the files that belong to a package.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.file_list nginx
    ufiles(t	file_dictRt
itervaluesR\(tpackageRQtfilest	pkg_files((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt	file_list�s

cG@s	g}i}x�|D]�}dd|g}td|dd�}g||<x%|dj�D]}|j|�qYWx>|dj�D],}|jd�r�||j|�q�q�q�WqWi|d	6|d
6}x9t|�D]+}||s�||dkr�||=q�q�W|S(u�
    .. versionchanged: 2016.3.0

    List the files that belong to a package.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.file_dict nginx
        salt '*' pkg.file_dict nginx varnish
    upkg_infou-qLucmd.run_allRutraceustderrustdoutu/uerrorsufilesu(RR)R8R9Rq(tpackagesRgRzRyR?RQR.tfield((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyRw�s"


(6t__doc__t
__future__RRRR6tloggingRRMtsalt.utils.dataRtsalt.utils.functoolstsalt.utils.pathtsalt.utils.pkgtsalt.utils.decoratorsRt
decoratorstsalt.exceptionsRRtsalt.extRtcompileRt	getLoggert__name__R[R!tmemoizeRRRRR$R(RRBt	functoolstalias_functiontavailable_versionRCRR4RSR3RXRRiRoRtRuR^R|Rw(((s6/usr/lib/python2.7/site-packages/salt/modules/pkgin.pyt<module>
sH				 	>	$3	oIJ		

Zerion Mini Shell 1.0