%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/xbpspkg.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl
Z
ddlZ
ddljjZddlmZmZeje�ZdZd�Zejd��Zejd��Zd	�Zed
�Ze d�Z!d�Z"e"Z#d
�Z$d�Z%d�Z&e d�Z'dedddd�Z)dde d�Z*d�Z+d�Z,ed�Z-dd�Z.d�Z/dS(u[
Package support for XBPS package manager (used by VoidLinux)

.. versionadded:: 2016.11.0
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortMinionErrorupkgcC@s!tddkrt�rtStS(uM
    Set the virtual pkg module if the os is Void and xbps-install found
    uosuVoid(t
__grains__t_check_xbpst__virtualname__tFalse(((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyt__virtual__!scC@stjjjd�S(uQ
    Looks to see if xbps-install is present on the system, return full path
    uxbps-install(tsalttutilstpathtwhich(((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyR*scC@smtdt�dgdd�}|dkr/tStjd�}|j|�}|sWtS|jd�jd�S(	u
    Get the xbps version
    ucmd.runu	--versiontoutput_loglevelutraceu!(?:XBPS:[\s]+)([\d.]+)(?:[\s]+.*)iu.N(	t__salt__RtNoneRtretcompiletsearchtgrouptsplit(tversion_stringt
VERSION_MATCHt
version_match((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyt_get_version2s	cC@sDtdd�}|jd�ddkr@tddd	d
�ndS(
u�
    Recomputes internal hash table for the PATH variable.
    Used whenever a new command is created during the current
    session.
    uenviron.getuSHELLu/i����ucshutcshucmd.runurehashRutraceN(ucshutcsh(RR(tshell((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyt_rehashFsc	K@stjjj|�}tgd
D]$}tjjj|j|��^q�rPiSd}i}td|dd�}x�|j�D]s}|s�qny)|jd�dj
dd�\}}Wn!tk
r�tj
d	|�nXtd
|||�qWtd|�|std|�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
xbps-query -lucmd.runRutraceiu-u/xbps-query: Unexpected formatting in line: "%s"upkg_resource.add_pkgupkg_resource.sort_pkglistupkg_resource.stringify(uremovedu
purge_desiredN(R
Rtdatatis_truetanytgetRt
splitlinesRRtrsplitt
ValueErrortlogterror(	tversions_as_listtkwargstxtcmdtrettouttlinetpkgtver((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyt	list_pkgsQs(7)
cC@s�tjjj|�}|r%t�ni}d}td|dd�}x�|j�D]�}|sfqTnd}d}y&|j�djdd	�\}}Wn*t	t
fk
r�tjd
|�qTnXtj
d||�|||<qTW|S(u�
    Check whether or not an upgrade is available for all packages

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_upgrades
    uxbps-install -unucmd.runRutraceubase-systemuNonNumericValueIsErroriu-iu/xbps-query: Unexpected formatting in line: "%s"upkg=%s version=%s(R
RRRt
refresh_dbRR RR!R"t
IndexErrorR#R$ttrace(trefreshR)R(R*R+R,R-((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyt
list_upgrades|s*
&c
O@s|tjjj|jdt��}t|�dkr7dS|rGt�ni}x|D]}d||<qTWddg}|j|�t	d|dtdd	�}x�|j
�D]�}|s�q�n|jd
�dkr�q�ny&|j�dj
dd
�\}}	Wn*ttfk
r)tjd|�q�nXtjd||	�||kr�|	||<q�q�Wt|�d
krx||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 <package1> <package2> <package3> ...
    urefreshiuuxbps-installu-unucmd.runtignore_retcodeRutraceu is up to date.i����u-iu/xbps-query: Unexpected formatting in line: "%s"upkg=%s version=%s(R
RRRtpoptTruetlenR/textendRR tfindRR!R"R0R#R$R1(
tnamesR&R2R)tnameR(R*R+R,R-((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pytlatest_version�s: !


&cC@st|�dkS(u�
    Check whether or not an upgrade is available for a given package

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade_available <package name>
    u(R<(R;((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pytupgrade_available�s
cC@sutjjjt�d}td|dd�}|ddkrqd}d|krb||d7}nt|��ntS(	u�
    Update list of available packages from installed repos

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.refresh_db
    uxbps-install -Syucmd.run_allRutraceuretcodeiuustderr(R
RR,t
clear_rtagt__opts__RRR6(R(tcalltcomment((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyR/s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&((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pytversions
cC@s�t�}ddj|rdnd�g}td|dddt�}tjd	d�t�}tjj	j
||�}|d
dkr�tdd
i|d6|d6��n|S(u�
    Run a full system upgrade

    refresh
        Whether or not to refresh the package database before installing.
        Default is `True`.

    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xbps-installu-{0}yuuSuucmd.run_allRutracetpython_shellu
pkg.list_pkgsuretcodeiu&Problem encountered upgrading packagestinfouchangesuresultN(R.tformatRRt__context__R5RR
RRt
compare_dictsR(R2toldR(tresulttnewR)((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pytupgrade/s	!
		cK@s2y#td||||�\}}Wntk
rD}t|��nX|d
ksct|�dkrgiS|dkr�tjd|�iSdg}	|r�|	jd�n|r�|	jdj|��n|	jd�|	j	|�t
�}
td	|	d
d�tjdd
�t
�}t
�tjjj|
|�S(uk
    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 (url) 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_targetsiu
repositoryu"xbps: pkg_type "%s" not supported.uxbps-installu-Su--repository={0}u-yucmd.runRutraceu
pkg.list_pkgsN(RRRRR7R#R$tappendRER8R.RFR5RR
RRRG(R;R2tfromrepotpkgstsourcesR&t
pkg_paramstpkg_typetexcR(RHRJ((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pytinstall]s.4	

		cK@s�ytd||�\}}Wntk
r>}t|��nX|sIiSt�}g|D]}||krY|^qY}	|	s�iSddg}
|r�|
jd�n|
j|	�td|
dd�tjdd	�t�}t	j
jj||�S(
u�
    name
        The name of the package to be deleted.

    recursive
        Also remove dependent packages (not required elsewhere).
        Default mode: enabled.

    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 list containing the removed packages.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.remove <package name> [recursive=False]
        salt '*' pkg.remove <package1>,<package2>,<package3> [recursive=False]
        salt '*' pkg.remove pkgs='["foo", "bar"]' [recursive=False]
    upkg_resource.parse_targetsuxbps-removeu-yu-Rucmd.runRutraceu
pkg.list_pkgsN(
RRRR.RLR8RFR5RR
RRRG(R;RNt	recursiveR&RPRQRRRHR'ttargetsR(RJ((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pytremove�s&	%
	cC@s�i}tdddd�}x�|j�D]�}i}|sAq)ny%|j�jdd�\}}}Wn!tk
r�tjd|�nX|j�r�t|�nd|d	<||d
<|dkr�t	nt
|d<|||d
<q)W|S(
ur
    List all repos known by XBPS

    CLI Example:

    .. code-block:: bash

       salt '*' pkg.list_repos
    ucmd.runu
xbps-query -LRutraceu iu?Problem parsing xbps-query: Unexpected formatting in line: "%s"iunbpkguurlu(RSA signed)u	rsasigned(RR tstripRR"R#R$tisdigittintR6R(treposR*R+trepotnbturltrsa((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyt
list_repos�s"
%
"
cK@s!t�}||kr||SiS(u�
    Display information about the repo.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.get_repo 'repo-url'
    (R_(R[R&RZ((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pytget_repos
	c
	C@sMg}g}ddg}d}tjd|d�}x(|D] }|jtj||��q<Wx�|D]�}g}	tjjj|d��S}
xI|
D]A}|jtjj	j
|��r�|j|�q�|	j|�q�WWdQX|rg||krgt|	�dkr5tjjj|d	��}|j
|	�WdQXqEtj|�qgqgW|S(
u
    Find what file a repo is called in.

    Helper function for add_repo() and del_repo()

    repo
        url of the repo to locate (persistent).

    rewrite
        Whether to remove matching repository settings during this process.

    Returns a list of absolute paths.
    u/etc/xbps.d/u/usr/share/xbps.d/u*.confu\s*repository\s*=\s*u/?\s*(#.*)?$urNiuw(RRR8tglobR
Rtfilestfopentmatchtstringutilst
to_unicodeRLR7t
writelinestosRV(
R[trewritetret_valRbt	conf_dirst	name_globtregextcur_dirtfilenamet
write_bufftcur_fileR+trewrite_file((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyt_locate_repo_filess(


u#/usr/share/xbps.d/15-saltstack.confcC@s~tt|��dkrzyJtjjj|d��,}|jtjjjdj	|���WdQXWqzt
k
rvtSXntS(uO
    Add an XBPS repository to the system.

    repo
        url of repo to add (persistent).

    conffile
        path to xbps conf file to add this repo
        default: /usr/share/xbps.d/15-saltstack.conf

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.add_repo <repo url> [conffile=/path/to/xbps/repo.conf]
    iua+urepository={0}
N(
R7RsR
RRbRctwriteRetto_strREtIOErrorRR6(R[tconffilet	conf_file((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pytadd_repoBs
cC@s1yt|dt�Wntk
r(tSXtSdS(u�
    Remove an XBPS repository from the system.

    repo
        url of repo to remove (persistent).

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.del_repo <repo url>
    RiN(RsR6RvR(R[((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pytdel_repobs

(0t__doc__t
__future__RRRRhRtloggingRatsalt.utils.dataR
tsalt.utils.filestsalt.utils.pathtsalt.utils.pkgtsalt.utils.stringutilstsalt.utils.decoratorsRt
decoratorstsalt.exceptionsRRt	getLoggert__name__R#RR	tmemoizeRRRRR.R6R3R<tavailable_versionR=R/RBRKRRSRVR_R`RsRyRz(((s8/usr/lib/python2.7/site-packages/salt/modules/xbpspkg.pyt<module>sD			+.	M	
		.	S6		- 

Zerion Mini Shell 1.0