%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/apkpkg.pyc

�
���^c@@sdZddlmZmZmZddlZddlZddlZddl	Zddl
mZeje
�ZdZd�Zd�Zd�Zed	�Zd
�Zdeddd�Zddd�Zdded
�Zdded�Zed�Zd�Zd�Zd�ZdS(u/
Support for apk

.. 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>`.

.. versionadded: 2017.7.0

i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrorupkgcC@s&tjdt�dkrtStdfS(uH
    Confirm this module is running on an Alpine Linux distribution
    u	os_familyuAlpineu3Module apk only works on Alpine Linux based systems(t
__grains__tgettFalset__virtualname__(((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pyt__virtual__ scO@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(t__salt__(tnamestkwargs((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pytversionFs
cC@s�i}ddg}td|dddt�}|ddkrMg}t}n|d	g}t}|r�td
di|d6|d
6��n|S(u�
    Updates the package list

    - ``True``: Database updated successfully
    - ``False``: Problem updating database

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.refresh_db
    uapkuupdateucmd.run_alltoutput_loglevelutracetpython_shelluretcodeiustdoutu)Problem encountered installing package(s)tinfouerrorsuchanges(R	RtTrueR(trettcmdtcallterrors((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pyt
refresh_dbVs

		
c	K@sntjjj|�}tgdD]$}tjjj|j|��^q�rPiSdtkr�|rjtdStjtd�}t	d|�|Sndddg}i}t	d|d	d
dt
�}xltjjj|d�D]R}d
j
|jd
�d�}d
j
|jd
�d �}t	d|||�q�Wt	d|�tj|�td<|sjt	d|�n|S(u�
    List the packages currently installed in a dict::

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

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_pkgs
        salt '*' pkg.list_pkgs versions_as_list=True
    uremovedu
purge_desiredu
pkg.list_pkgsupkg_resource.stringifyuapkuinfou-vucmd.runR
utraceRu
u-i����upkg_resource.add_pkgupkg_resource.sort_pkglist(uremovedu
purge_desired(tsalttutilstdatatis_truetanyRt__context__tcopytdeepcopyR	Rt	itertoolstsplittjoin(	tversions_as_listRtxRRtouttlinetpkg_versiontpkg_name((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pyt	list_pkgsxs,
1cO@s`tjjj|jdt��}t|�dkr7dSi}x|D]}d||<qDWt�}|rqt�ndddg}t	d|dd	d
t
�}x�tjjj|d�D]�}yh|jd�d
}|jd�dj
d�}	|jd�dj
d�}
||kr"|
||<nWq�ttfk
r<q�Xq�Wx�|D]�}||sH|j|�}dd|g}t	d|dd	d
t
�}x�tjjj|d�D]�}yndj|jd�d�}
dj|jd�d �}||kr||
krd||<q|
||<nWq�tk
r2q�Xq�WqHqHWt|�dkr\||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>
        salt '*' pkg.latest_version <package name>
        salt '*' pkg.latest_version <package1> <package2> <package3> ...
    urefreshiuuapkuupgradeu-sucmd.run_stdoutR
utraceRu
u iiu(iu)usearchu-i����i(RRRRtpopRtlenR'RR	RRRtstript
ValueErrort
IndexErrorRR (R
RtrefreshRtnametpkgsRR#R$t_oldversiont
newversiontpkgt	installedR%R&((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pytlatest_version�sT!
	

	


	

c	K@s�tjjj|�}g}t�}|ra|p3|rad|krU|jd�}qa|g}n|r�g|D]'}t|t�rntt	|��^qn}|j
|�n|s�iS|r�t�nddg}	x.|D]&}
|j|
�r�|	j
d�Pq�q�W|	j
|�td|	dddt�}|d	d
krU|drU|dg}ng}tjdd�t�}
tjjj||
�}|r�td
di|d6|d6��n|S(u/
    Install the passed package, add refresh=True to update the apk database.

    name
        The name of the package to be installed. Note that this parameter is
        ignored if either "pkgs" or "sources" is passed. Additionally, please
        note that this option can only be used to install packages from a
        software repository. To install a package file manually, use the
        "sources" option.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install <package name>

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


    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 IPK 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.  Dependencies are automatically resolved
        and marked as auto-installed.

        CLI Example:

        .. code-block:: bash

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

    install_recommends
        Whether to install the packages marked as recommended. Default is True.

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

        {'<package>': {'old': '<old-version>',
                       'new': '<new-version>'}}
    u,uapkuaddu-uucmd.run_allR
utraceRuretcodeiustderru
pkg.list_pkgsu)Problem encountered installing package(s)RuerrorsuchangesN(RRRRR'Rt
isinstancetdicttnexttitertextendRRtappendR	RRR(tNonet
compare_dictsR(R.R-R/tsourcesRt	refreshdbtpkg_to_installtoldtpRt_pkgR#RtnewR((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pytinstall�sH9	
'



		cK@std|d|dt�S(u
    Alias to remove
    R.R/tpurge(tremoveR(R.R/R((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pyRE`scK@s:t�}g}|r?d|kr3|jd�}q?|g}n|rU|j|�n|s_iS|rwdddg}nddg}|j|�td|dddt�}|d	d
kr�|dr�|dg}ng}tjdd�t�}	tj	j
j||	�}
|r6td
di|d6|
d6��n|
S(u
    Remove packages using ``apk del``.

    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.

    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"]'
    u,uapkudelu--purgeucmd.run_allR
utraceRuretcodeiustderru
pkg.list_pkgsu'Problem encountered removing package(s)RuerrorsuchangesN(
R'RR9R	RRR(R;RRRR<R(R.R/RERR@t
pkg_to_removeRR#RRCR((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pyRFgs:	
		c		C@sZiid6td6dd6}tjjj|�r:t�nt�}g}|r�|r�d|krt|jd�}q�|g}n|r�|j|�n|r�dddg}|j|�ndd	g}t	d
|ddd
t
dt�}|ddkr!t
|d<|dr!|d|d<q!ntjdd�t�}tjjj||�|d<|S(uh
    Upgrades all packages via ``apk upgrade`` or a specific package if name or
    pkgs is specified. Name is ignored if pkgs is specified

    Returns a dict containing the changes.

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

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade
    uchangesuresultuucommentu,uapkuaddu-uuupgradeucmd.run_allR
utraceRtredirect_stderruretcodeiustdoutu
pkg.list_pkgsN(RRRRRRR'RR9R	RRR(R;R<(	R.R/R-RR@tpkg_to_upgradeRRRC((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pytupgrade�s:


	

	

	c
C@s8i}tjjj|�r%t�ndddg}td|dddt�}|dd	kr�d
}d|kr�||d7}nd|kr�||d7}nt|��n
|d}xx|j�D]j}d
|kr�|j	d�d}|j	d�dj
d�}|j	d�dj
d�}	|	||<q�q�W|S(u~
    List all available package upgrades.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_upgrades
    uapkuupgradeu-sucmd.run_allR
utraceRuretcodeiuustderrustdoutu	Upgradingu iiu(iu)(RRRRRR	RRt
splitlinesRR*(
R-RRRtcommentR#R$R.R0R1((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pyt
list_upgrades�s,


	
cG@s
t|�S(uV
    List the files that belong to a package. Not specifying any packages will
    return a list of _every_ file on the system's package database (not
    generally recommended).

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.file_list httpd
        salt '*' pkg.file_list httpd postfix
        salt '*' pkg.file_list
    (t	file_dict(tpackages((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pyt	file_listsc	G@s�g}i}dddg}|s%dSx�|D]�}g}|}|j|�td|dddt�}x:|d	j�D](}|jd
�r�qyqy|j|�qyW|r,|||<q,q,Wi|d6|d6S(
uj
    List the files that belong to a package, grouped by package. Not
    specifying any packages will return a list of _every_ file on the system's
    package database (not generally recommended).

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.file_list httpd
        salt '*' pkg.file_list httpd postfix
        salt '*' pkg.file_list
    uapkuinfou-LuPackage name should be provideducmd.run_allR
utraceRustdoutu	contains:uerrorsupackages(R:R	RRKtendswith(	RORRt	cmd_filestpackagetfilesRR#R$((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pyRN s&


	cG@s�|s
dSi}dddg}x�|D]�}|}|j|�td|dddt�}|r�d	|kr{d
||<q�|jd�dj�||<q&d
j|�||<q&W|S(u6
    Return the name of the package that owns the file. Multiple file paths can
    be passed. Like :mod:`pkg.version <salt.modules.apk.version`, if a single
    path is passed, a string will be returned, and if multiple paths are passed,
    a dictionary of file/package name pairs will be returned.

    If the file is not owned by a package, or is not present on the minion,
    then an empty string will be returned for that path.

    CLI Example:

        salt '*' pkg.owns /usr/bin/apachectl
        salt '*' pkg.owns /usr/bin/apachectl /usr/bin/basename
    uYou must provide a pathuapkuinfou-Wucmd.run_stdoutR
utraceRuERROR:uCould not find owner packageuby iuError running {0}(R:R	RRR*tformat(tpathsRt
cmd_searchtpathRtoutput((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pytownerGs 


	
 ( t__doc__t
__future__RRRRtloggingtsalt.utils.dataRtsalt.utils.itertoolstsalt.exceptionsRt	getLoggert__name__tlogRRRRRR'R4R;RDRERFRRJRMRPRNRZ(((s7/usr/lib/python2.7/site-packages/salt/modules/apkpkg.pyt<module>
s0	&		"*	IrE<'		'

Zerion Mini Shell 1.0