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

�
���^c	@@sdZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
ZddlZddl
ZddlZddlZddlZddlZddlZddlmZmZddlmZeZyddlZeZWn{ek
r}ddlZddlZejjd�r~y)ejj dd�ddlZeZWqzek
rvqzXq~nXej!e"�Z#dZ$d�Z%d	�Z&d
�Z'd�Z(d�Z)d
�Z*d�Z+d�Z,d�Z-d�Z.d�Z/ej0j1j2e/d�Z3dd�Z4edd�Z5d�Z6d�Z7d�Z8ed�Z9d�Z:d�Z;deddddddd�Z=ddedd�Z>eddd�Z?ddddd �Z@ddddd!�ZAddddd"�ZBd#�ZCd$�ZDd%�ZEdS(&u�
Support for Portage

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

:optdepends:    - portage Python adapter

For now all package names *MUST* include the package category,
i.e. ``'vim'`` will not work, ``'app-editors/vim'`` will.
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortMinionError(tsixu/usr/lib/portage/pymupkgcC@s$trtddkrtStdfS(u9
    Confirm this module is on a Gentoo based system
    uosuGentoou}The ebuild execution module cannot be loaded: either the system is not Gentoo or the portage python library is not available.(tHAS_PORTAGEt
__grains__t__virtualname__tFalse(((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt__virtual__=scC@s3ddl}tjjj|�}|j|jdS(Niuvartree(tportagetsalttutilstcompattreloadtdbtroot(R((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt_vartreeFscC@s3ddl}tjjj|�}|j|jdS(Niuporttree(RRR
RRRR(R((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt	_porttreeLscC@s�ytj|�}|r|SWntjjk
r6nXy/t�jjd|�}|retj|�SWntjjk
rnXy3t�jjd|�}|r�tj|d�SWntjjk
r�nXdS(Nubestmatch-visibleu	match-alli(	Rt
dep_getkeyt	exceptiontInvalidAtomRtdbapitxmatcht
cpv_getkeytNone(tptret((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt_p_to_cpRs&cC@s5dtkrtdSt�j�}|td<|SdS(Nuportage._allnodes(t__context__Rtgetallnodes(R((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt	_allnodesks

cC@srytj|�}|r|SWntjjk
r6nXytj|�}|rS|SWntjjk
rmnX|S(N(RRRRR(tcpvR((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt
_cpv_to_cptscC@stjj|�S(N(Rtversionstcpv_getversion(R!((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt_cpv_to_version�sc	C@sDi}tjdtj�}tjdtj�j|�}|rL||d<ntjd�j|�}tjd�j|�}|r�|r�||d<ntjd|�}x�|D]�}d|kr�|j|�|d	<q�d
|kr�|j|�|d<q�d|kr|j|�|d
<q�d|kr�|j|�|d<q�q�W|S(uT
    Used to parse emerge output to provide meaningful output when emerge fails
    u^[<>=][^ ]+/[^ ]+ [^\n]+u^[^ \n]+/[^ ]+:[^ ]uslot conflictsu/(?m)^\[blocks .+\] ([^ ]+/[^ ]+-[0-9]+[^ ]+).*$u&Error: The above package list containsublockedu

uThe following keyword changesukeywordsuThe following license changesulicenseuThe following USE changesuuseuThe following mask changesumask(tretcompiletMtfindalltsplit(	tstdouttstderrRtrexptslot_conflictstblockedtunsatisfiedtsectionstsection((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt_process_emerge_err�s,
	

cO@s�i}x�|D]�}||kr;tjdj|��q
nd|krtt|j|i�d<t|�||d<q
|t�k|j|i�d<||dtkr
g||d<q
q
W|S(u�
    .. versionadded:: 0.17.0

    Returns a dict containing the following information for each specified
    package:

    1. A key ``found``, which will be a boolean value denoting if a match was
       found in the package database.
    2. If ``found`` is ``False``, then a second key called ``suggestions`` will
       be present, which will contain a list of possible matches. This list
       will be empty if the package name was specified in ``category/pkgname``
       format, since the suggestions are only intended to disambiguate
       ambiguous package names (ones submitted without a category).

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.check_db <package1> <package2> <package3>
    u4pkg.check_db: Duplicate package name '{0}' submittedu/ufoundusuggestions(tlogtwarningtformatR	t
setdefaulttporttree_matchesR (tnamestkwargsRtname((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pytcheck_db�s

cC@s%tddt�r!td�ntS(uJ
    If the config option ``ebuild.enforce_nice_config`` is set to True, this
    module will enforce a nice tree structure for /etc/portage/package.*
    configuration files.

    .. versionadded:: 0.17.0
       Initial automatic enforcement added when pkg is used on a Gentoo system.

    .. versionchanged:: 2014.1.0-Hydrogen
       Configure option added to make this behaviour optional, defaulting to
       off.

    .. seealso::
       ``ebuild.ex_mod_init`` is called automatically when a state invokes a
       pkg state on a Gentoo system.
       :py:func:`salt.states.pkg.mod_init`

       ``ebuild.ex_mod_init`` uses ``portage_config.enforce_nice_config`` to do
       the lifting.
       :py:func:`salt.modules.portage_config.enforce_nice_config`

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.ex_mod_init
    u
config.getuebuild.enforce_nice_configu"portage_config.enforce_nice_config(t__salt__R	tTrue(tlow((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pytex_mod_init�scO@s�tjjj|jdt��}t|�dkr7dS|rGt�ni}x�|D]�}d||<tt	�j
|��}tt�j
|��}|rT|s�tjjj
d|ddd|dt�rT|||<qTqTWt|�d	kr�||dS|S(
uf
    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.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.latest_version <package name>
        salt '*' pkg.latest_version <package1> <package2> <package3> ...
    urefreshiutver1toperu<tver2tcmp_funci(RR
tdatatis_truetpopR>tlent
refresh_dbR%Rt
dep_bestmatchRR#tcomparetversion_cmp(R9R:trefreshRR;t	installedtavail((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pytlatest_version�s
!


7uavailable_versionic

@s%dddddj|�dddd	d
g
}td|dd
dt�}|ddkr�d}x.dD]&}||rf|d||7}PqfqfWt|��n
|d}tjd�}ddg��fd�}|j|�}i}	x6|D].}
||
d�}||
d�}||	|<q�W|	S(uq
    Utility function to get upgradable packages

    Sample return data:
    { 'pkgname': '1.2.3-45', ... }
    uemergeu--askunu--backtracku{0}u	--pretendu--updateu--newuseu--deepu@worlducmd.run_alltoutput_loglevelutracetpython_shelluretcodeiuFailed to get upgradesustderrustdoutu: u*(?m)^\[.+\] ([^ ]+/[^ ]+)-([0-9]+[^ ]+).*$unameuversionc@s|�j|�S(N(tindex(tltk(tkeys(s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt<lambda>Cs(ustderrustdout(R6R=R	RR&R'R)(
t	backtracktcmdtcalltmsgtkeytoutR-t_gettupgradesRtlineR;tversion_num((RVs:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt_get_upgradables:	
	



cK@s)tjjj|�rt�nt|�S(u�
    List all available package upgrades.

    refresh
        Whether or not to sync the portage tree before checking for upgrades.

    backtrack
        Specifies an integer number of times to backtrack if dependency
        calculation fails due to a conflict or an unsatisfied dependency
        (default: ´3´).

        .. versionadded: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_upgrades
    (RR
RERFRIRb(RMRXR:((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt
list_upgradesPs
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(RP(R;((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pytupgrade_availableis
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=(R9R:((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pytversionvs
cC@sYg}xLt�jjD];}t�jj|d|�r|j|d|�qqW|S(u,
    Returns a list containing the matches for a given package name from the
    portage tree. Note that the specific version of the package will not be
    provided for packages that have several versions in the portage tree, but
    rather the name of the package (i.e. "dev-python/paramiko").
    u/(RRt
categoriestcp_listtappend(R;tmatchestcategory((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyR8�s
cK@stjjj|�}tgdD]$}tjjj|j|��^q�rPiSdtkr�|rjtdStjtd�}t	d|�|Sni}t
�jj�}x.|D]&}t	d|t
|�t|��q�Wt	d|�tj|�td<|st	d|�n|S(u�
    List the packages currently installed in a dict::

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

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_pkgs
    uremovedu
purge_desiredu
pkg.list_pkgsupkg_resource.stringifyupkg_resource.add_pkgupkg_resource.sort_pkglist(uremovedu
purge_desired(RR
RERFtanytgetRtcopytdeepcopyR=RRtcpv_allR"R%(tversions_as_listR:txRtpkgsR!((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt	list_pkgs�s*1

	cC@sitjjd�}dtkr$tnt}tdd�r@tnt}tjjj	t
�tddt�r�tdd�}tjd	d
�}tjj
�}tjjtjj|��}|||kr�tjdj|��tSn|rtdd
�dkS|rtd�S|rQd}tjjjd�r=d}ntd|�dkStdd�dkSdS(u�
    Update the portage tree using the first available method from the following
    list:

    - emaint sync
    - eix-sync
    - emerge-webrsync
    - emerge --sync

    To prevent the portage tree from being synced within one day of the
    previous sync, add the following pillar data for this minion:

    .. code-block:: yaml

        portage:
          sync_wait_one_day: True

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.refresh_db
    u/etc/portage/repos.confueix.syncumakeconf.features_containsuwebrsync-gpgu
pillar.getuportage:sync_wait_one_dayucmd.runuportageq get_repo_path / gentootdaysiuNDid not sync package tree since last sync was done at {0}, less than 1 day agoucmd.retcodeuemaint sync -aiuemerge-webrsync -quemerge-delta-webrsyncuemerge-delta-webrsync -quemerge --ask n --quiet --syncN(tostpathtisdirR=R>R	RR
tpkgt
clear_rtagt__opts__tdatetimet	timedeltatnowt
fromtimestamptgetmtimeR4tinfoR6twhich(t
has_emaintthas_eixthas_webrsynctmain_repo_roottdayR}t	timestampRY((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyRI�s.
	cC@sL|}x4|D],}y|j|�Wqtk
r9tSXqW|rHtStS(u
    @type inst_flags: list
    @param inst_flags: list of use flags which were used
        when package was installed
    @type conf_flags: list
    @param conf_flags: list of use flags form portage/package.use
    @rtype: bool
    @return: True, if lists have changes
    (tremovet
ValueErrorR>R	(t
inst_flagst
conf_flagsti((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt_flags_changed�s


	c!K@s�tjdji|d6|d6|d6|d6|d6|d6��tjjj|�r_t�ny#td||||�\}	}
Wnt	k
r�}t
|��nX|d?krY|d?krY|jd	�}|sYd
}|d?k	r�|dj|�7}n|d?k	r|dj|�7}n|d?k	rF|d
jdj
|��7}ni||6}	qYn|	d?kswt|	�dkr{iS|
dkr�dg}
ng}
|dkr�dg}n|dkr�dg}ng}i}|
dkr|t�}x�tj|	�D]{\}}|}t|�}|d?kr9tjj|��n|d?krU|j|�q�d?}tjd|�}|r|j�\}}}}|p�d
}||p�d
7}t|�dkr�|ddkr�|ddkr�|p�d}dj|||�}q!dj||�}ndj|�}d|kr�tdd|�}td |�tdd|�}||kr�i|d!6|d"6||d#<n||jd� }n|d?k	r�td$d%|d&g�id
d!6d&d"6||d'<n|sht|�}t|d(t�|krhtd)|�}t|�rei|d	6i|dd6d!6i|d*d6d"6||<qeqhn|j|�q�Wn|	}g}tjjj t!�r�td+d,t"�r�|j#d-d.g�n|j#d/d0d1d2g�|j#|�|j#|
�|j#|�t$�}td3|d4d5d6t�}|d7dkrUt%|d8|d9�} ng} t!j&d:d?�t$�}|j'tjjj(||��| r�t
d;d<i| d=6|d>6��n|S(@u?
    .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
        On minions running systemd>=205, `systemd-run(1)`_ is now used to
        isolate commands which modify installed packages from the
        ``salt-minion`` daemon's control group. This is done to keep systemd
        from killing any emerge commands spawned by Salt when the
        ``salt-minion`` service is restarted. (see ``KillMode`` in the
        `systemd.kill(5)`_ manpage for more information). If desired, usage of
        `systemd-run(1)`_ can be suppressed by setting a :mod:`config option
        <salt.modules.config.get>` called ``systemd.scope``, with a value of
        ``False`` (no quotes).

    .. _`systemd-run(1)`: https://www.freedesktop.org/software/systemd/man/systemd-run.html
    .. _`systemd.kill(5)`: https://www.freedesktop.org/software/systemd/man/systemd.kill.html

    Install the passed package(s), add refresh=True to sync the portage tree
    before package is installed.

    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 emerge a package from the
        portage tree. To install a tbz2 package manually, use the "sources"
        option described below.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install <package name>

    refresh
        Whether or not to sync the portage tree before installing.

    version
        Install a specific version of the package, e.g. 1.0.9-r1. Ignored
        if "pkgs" or "sources" is passed.

    slot
        Similar to version, but specifies a valid slot to be installed. It
        will install the latest available version in the specified slot.
        Ignored if "pkgs" or "sources" or "version" is passed.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install sys-devel/gcc slot='4.4'

    fromrepo
        Similar to slot, but specifies the repository from the package will be
        installed. It will install the latest available version in the
        specified repository.
        Ignored if "pkgs" or "sources" or "version" is passed.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install salt fromrepo='gentoo'

    uses
        Similar to slot, but specifies a list of use flag.
        Ignored if "pkgs" or "sources" or "version" is passed.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install sys-devel/gcc uses='["nptl","-nossp"]'


    Multiple Package Installation Options:

    pkgs
        A list of packages to install from the portage tree. Must be passed as
        a python list.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install pkgs='["foo","bar","~category/package:slot::repository[use]"]'

    sources
        A list of tbz2 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.tbz2"},{"bar": "salt://bar.tbz2"}]'
    binhost
        has two options try and force.
        try - tells emerge to try and install the package from a configured binhost.
        force - forces emerge to install the package from a binhost otherwise it fails out.

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

        {'<package>': {'old': '<old-version>',
                       'new': '<new-version>'}}
    uCalled modules.pkg.install: {0}unameurefreshupkgsusourcesukwargsubinhostupkg_resource.parse_targetsuversionuu:{0}u::{0}u[{0}]u,iufileutbz2fileutryu-guforceu-Gu
repositoryu^(~)?([<>])?(=)?([^<>=]*)$u:u[u=u
{0}{1}-{2}u{0}{1}u{0}u*portage_config.get_flags_from_package_confuuseuportage_config.append_use_flagsuoldunewu-USEu%portage_config.append_to_package_confuaccept_keywordsu~ARCHu-ACCEPT_KEYWORDRMu portage_config.get_cleared_flagsiu
config.getu
systemd.scopeusystemd-runu--scopeuemergeu--askunu--quietucmd.run_allRQutraceRRuretcodeustdoutustderru
pkg.list_pkgsu$Error occurred installing package(s)R�uneeded changesuchangesN()R4tdebugR6RR
RERFRIR=RRRRltjoinRHtlistRt	iteritemsRRtdepRRhR&tmatchtgroupstrfindReRPR	R�tsystemdt	has_scopeRR>textendRsR3RGtupdatet
compare_dicts(!R;RMRrtsourcestslottfromrepotusestbinhostR:t
pkg_paramstpkg_typetexcRatemerge_optstbin_optstchangesttargetstparamtoriginal_paramtkeywordR�tgt_ltteqtverstrtprefixttargettoldtnewtinst_vtall_usesRYRZtneeded_changes((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pytinstalls�q
	2


"


	
		c
	C@s�tjjj|�rt�n|}|dk	rFdj||�}n|dk	rgdj||�}n|dkrdg}n|dkr�dg}ng}t�}g}tjjj	t
�r�tddt�r�|j
d	d
g�n|j
ddd
ddddg�|j
|�|j|�td|dddt�}	|	ddkrlt|	d|	d�}
ng}
t
jdd�t�}tjjj||�}|
r�tddi|
d6|d6��n|S( u|
    .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
        On minions running systemd>=205, `systemd-run(1)`_ is now used to
        isolate commands which modify installed packages from the
        ``salt-minion`` daemon's control group. This is done to keep systemd
        from killing any emerge commands spawned by Salt when the
        ``salt-minion`` service is restarted. (see ``KillMode`` in the
        `systemd.kill(5)`_ manpage for more information). If desired, usage of
        `systemd-run(1)`_ can be suppressed by setting a :mod:`config option
        <salt.modules.config.get>` called ``systemd.scope``, with a value of
        ``False`` (no quotes).

    .. _`systemd-run(1)`: https://www.freedesktop.org/software/systemd/man/systemd-run.html
    .. _`systemd.kill(5)`: https://www.freedesktop.org/software/systemd/man/systemd.kill.html

    Updates the passed package (emerge --update package)

    slot
        Restrict the update to a particular slot. It will update to the
        latest version within the slot.

    fromrepo
        Restrict the update to a particular repository. It will update to the
        latest version within the repository.
    binhost
        has two options try and force.
        try - tells emerge to try and install the package from a configured binhost.
        force - forces emerge to install the package from a binhost otherwise it fails out.

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

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

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.update <package name>
    u{0}:{1}u{0}::{1}utryu-guforceu-Gu
config.getu
systemd.scopeusystemd-runu--scopeuemergeu--askunu--quietu--updateu--newuseu	--oneshotucmd.run_allRQutraceRRuretcodeiustdoutustderru
pkg.list_pkgsu'Problem encountered updating package(s)R�uneeded_changesuchangesN(RR
RERFRIRR6RsR�R�RR=R>R�RhR	R3RGR�R(
RxR�R�RMR�t	full_atomR�R�RYRZR�R�R((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyR�sN)
		



		c	C@s�iid6td6dd6}tjjj|�r:t�n|dkrRdg}n|dkrjdg}ng}t�}g}tjjjt	�r�t
d	d
t�r�|jddg�n|jd
dddddj|�dddg	�|r|j|�n|j
d�t
d|dddt�}t	jdd �t�}tjjj||�}|ddkr�tddi|d6|d6��n|S(!uP
    .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
        On minions running systemd>=205, `systemd-run(1)`_ is now used to
        isolate commands which modify installed packages from the
        ``salt-minion`` daemon's control group. This is done to keep systemd
        from killing any emerge commands spawned by Salt when the
        ``salt-minion`` service is restarted. (see ``KillMode`` in the
        `systemd.kill(5)`_ manpage for more information). If desired, usage of
        `systemd-run(1)`_ can be suppressed by setting a :mod:`config option
        <salt.modules.config.get>` called ``systemd.scope``, with a value of
        ``False`` (no quotes).

    .. _`systemd-run(1)`: https://www.freedesktop.org/software/systemd/man/systemd-run.html
    .. _`systemd.kill(5)`: https://www.freedesktop.org/software/systemd/man/systemd.kill.html

    Run a full system upgrade (emerge -uDN @world)

    binhost
        has two options try and force.
        try - tells emerge to try and install the package from a configured binhost.
        force - forces emerge to install the package from a binhost otherwise it fails out.

    backtrack
        Specifies an integer number of times to backtrack if dependency
        calculation fails due to a conflict or an unsatisfied dependency
        (default: ´3´).

        .. versionadded: 2015.8.0

    Returns a dictionary containing the changes:

    .. code-block:: python

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


    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade
    uchangesuresultuucommentutryu--getbinpkguforceu--getbinpkgonlyu
config.getu
systemd.scopeusystemd-runu--scopeuemergeu--askunu--quietu--backtracku{0}u--updateu--newuseu--deepu@worlducmd.run_allRQutraceRRu
pkg.list_pkgsuretcodeiu&Problem encountered upgrading packagesR�N(R>RR
RERFRIRsR�R�RR=R�R6RhR	RGRR�R(	RMR�RXRR�R�RYtresultR�((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pytupgrade]sH,


		


		cK@s ytd||�d}Wntk
r<}t|��nXt�}|r�|r�|dk	sk|dk	r�t|�dkr�|}|dk	r�dj||�g}	n|dk	r�dj||�g}	n|g}	n%g|D]}
|
|kr�|
^q�}	|	siSg}tjj	j
t�rJtddt�rJ|j
dd	g�n|j
d
ddd
ddg�|j
|	�td|dddt�}|ddkr�|dr�|dg}
ng}
tjdd�t�}tjjj||�}|
rtddi|
d6|d6��n|S(u�
    .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
        On minions running systemd>=205, `systemd-run(1)`_ is now used to
        isolate commands which modify installed packages from the
        ``salt-minion`` daemon's control group. This is done to keep systemd
        from killing any emerge commands spawned by Salt when the
        ``salt-minion`` service is restarted. (see ``KillMode`` in the
        `systemd.kill(5)`_ manpage for more information). If desired, usage of
        `systemd-run(1)`_ can be suppressed by setting a :mod:`config option
        <salt.modules.config.get>` called ``systemd.scope``, with a value of
        ``False`` (no quotes).

    .. _`systemd-run(1)`: https://www.freedesktop.org/software/systemd/man/systemd-run.html
    .. _`systemd.kill(5)`: https://www.freedesktop.org/software/systemd/man/systemd.kill.html

    Remove packages via emerge --unmerge.

    name
        The name of the package to be deleted.

    slot
        Restrict the remove to a specific slot. Ignored if ``name`` is None.

    fromrepo
        Restrict the remove to a specific slot. Ignored if ``name`` is None.

    Multiple Package Options:

    pkgs
        Uninstall multiple packages. ``slot`` and ``fromrepo`` arguments are
        ignored if this argument is present. Must be passed as a python list.

    .. versionadded:: 0.16.0

    Returns a dict containing the changes.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.remove <package name>
        salt '*' pkg.remove <package name> slot=4.4 fromrepo=gentoo
        salt '*' pkg.remove <package1>,<package2>,<package3>
        salt '*' pkg.remove pkgs='["foo", "bar"]'
    upkg_resource.parse_targetsiiu{0}:{1}u{0}::{1}u
config.getu
systemd.scopeusystemd-runu--scopeuemergeu--askunu--quietu	--unmergeu--quiet-unmerge-warnucmd.run_allRQutraceRRuretcodeustderru
pkg.list_pkgsu'Problem encountered removing package(s)R�uerrorsuchangesN(R=RRRsRRHR6RR
R�R�RR>R�R	RGRER�(R;R�R�RrR:R�R�R�tfullatomR�RqRYR]terrorsR�R((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyR��sP.	7%	

		c
K@sMtd|d|d|d|�}|jtd|d|d|d|��|S(u�
    .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
        On minions running systemd>=205, `systemd-run(1)`_ is now used to
        isolate commands which modify installed packages from the
        ``salt-minion`` daemon's control group. This is done to keep systemd
        from killing any emerge commands spawned by Salt when the
        ``salt-minion`` service is restarted. (see ``KillMode`` in the
        `systemd.kill(5)`_ manpage for more information). If desired, usage of
        `systemd-run(1)`_ can be suppressed by setting a :mod:`config option
        <salt.modules.config.get>` called ``systemd.scope``, with a value of
        ``False`` (no quotes).

    .. _`systemd-run(1)`: https://www.freedesktop.org/software/systemd/man/systemd-run.html
    .. _`systemd.kill(5)`: https://www.freedesktop.org/software/systemd/man/systemd.kill.html

    Portage does not have a purge, this function calls remove followed
    by depclean to emulate a purge process

    name
        The name of the package to be deleted.

    slot
        Restrict the remove to a specific slot. Ignored if name is None.

    fromrepo
        Restrict the remove to a specific slot. Ignored if ``name`` is None.

    Multiple Package Options:

    pkgs
        Uninstall multiple packages. ``slot`` and ``fromrepo`` arguments are
        ignored if this argument is present. Must be passed as a python list.

    .. versionadded:: 0.16.0


    Returns a dict containing the changes.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.purge <package name>
        salt '*' pkg.purge <package name> slot=4.4
        salt '*' pkg.purge <package1>,<package2>,<package3>
        salt '*' pkg.purge pkgs='["foo", "bar"]'
    R;R�R�Rr(R�R�tdepclean(R;R�R�RrR:R((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pytpurges0!(c
C@s^ytd||�d}Wntk
r<}t|��nXt�}|r�|r�|dk	sk|dk	r�t|�dkr�|}|dk	r�dj||�g}n|dk	r�dj||�g}n|g}n%g|D]}	|	|kr�|	^q�}dddd	d
g|}
td|
dd
dt�tj	dd�t�}t
jjj
||�S(u�
    Portage has a function to remove unused dependencies. If a package
    is provided, it will only removed the package if no other package
    depends on it.

    name
        The name of the package to be cleaned.

    slot
        Restrict the remove to a specific slot. Ignored if ``name`` is None.

    fromrepo
        Restrict the remove to a specific slot. Ignored if ``name`` is None.

    pkgs
        Clean multiple packages. ``slot`` and ``fromrepo`` arguments are
        ignored if this argument is present. Must be passed as a python list.

    Return a list containing the removed packages:

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.depclean <package name>
    upkg_resource.parse_targetsiiu{0}:{1}u{0}::{1}uemergeu--askunu--quietu
--depcleanucmd.run_allRQutraceRRu
pkg.list_pkgsN(R=RRRsRRHR6R	RRGRR
RER�(R;R�R�RrR�R�R�R�R�RqRYR�((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyR�Os(	7%
	cK@s�tjjj|�}|jdd�|rAtjjj|�nd}tj||�}tj||�}|r�|r�t	j
j|jd�|jd��SdS(u
    Do a cmp-style comparison on two packages. Return -1 if pkg1 < pkg2, 0 if
    pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem
    making the comparison.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.version_cmp '0.2.4-0' '0.2.4.1-0'
    uignore_epochu^~?([^:\[]+):?[^\[]*\[?.*$iN(
RR
targstclean_kwargsRGRtinvalid_kwargsR&R�RR#tvercmptgroup(tpkg1tpkg2R:tregexRARC((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyRL�s%cC@stjd|�S(u�
    Clean the version string removing extra data.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.version_clean <version_string>
    u^~?[<>]?=?([^<>=:\[]+).*$(R&R�(Re((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt
version_clean�s
cC@s.d}tjd|�}|r�|j�\}}}}|p?d}||pNd7}|jdd�}|ddkr�|ddkr�|p�d}dj|||�}q�d	j||�}ntSyt�jj	d
|�}	Wn3t
jjk
r}
t
jdj||
��tSX|	dkr#tSy(t�jj|	dd
g�\}}Wntk
r_tSXtjd|�}
|
r�|
jd�|kr�tStt
jj|��}|j�}tg|j|�D],}|ddks�|d|kr�|^q��dkrtS|r*tdd|d�s*tSntS(u�
    Check if the installed package already has the given requirements.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.check_extra_requirements 'sys-devel/gcc' '~>4.1.2:4.1::gentoo[nls,fortran]'
    u^(~)?([<>])?(=)?([^<>=]*)$uu'iu:u[u=u
{0}{1}-{2}u{0}{1}ubestmatch-visibleu0Unable to find a matching package for {0}: ({1})u
repositoryuUSEu^.+::([^\[]+).*$iu-uportage_config.has_flaguaccept_keywordsu~ARCHN(RR&R�R�treplaceR6R>RRRRRRR4terrorR	Rtaux_gettKeyErrorR�tsetR�tdep_getusedepsR*RHt
differenceR=(tpkgnametpkgverR�R�R�R�R�R�tatomR!tiaetcur_repotcur_usetdes_repotdes_usesRq((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pytcheck_extra_requirements�sF
 (
5(Ft__doc__t
__future__RRRRuRmtloggingR&R{tsalt.utils.argsRtsalt.utils.compattsalt.utils.datatsalt.utils.functoolstsalt.utils.pathtsalt.utils.pkgtsalt.utils.systemdtsalt.utils.versionstsalt.exceptionsRRtsalt.extRR	RRR>tImportErrortsysRvRwtinsertt	getLoggert__name__R4RR
RRRR R"R%R3R<R@RPR
t	functoolstalias_functiontavailable_versionRbRcRdReR8RsRIR�RR�R�R�R�R�R�RLR�R�(((s:/usr/lib/python2.7/site-packages/salt/modules/ebuildpkg.pyt<module>s�



										#	'	!	&2	
		'	9	�]Zc54		

Zerion Mini Shell 1.0