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

�
���^c
@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZmZddlZddlZddlmZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl!Zddl"Zddl#Zddl$Zddl%Zddl&m'Z'm(Z(m)Z)ej*e+�Z,y2ddl-Z.ddl/Z.dd	l0m1Z1e2Z3Wne4k
r�e5Z3nXyddl6Z6e2Z7Wne4k
r
e5Z7nXyddl8Z9e2Z:Wne4k
r:e5Z:nXd
Z;dZ<dZ=e>d
dddddg�Z?idd6dd6dd6dd6Z@ejAr�ejBjCjDe@�Z@ndZEd�ZFd�ZGd�ZHd�ZId�ZJe2d �ZKd!�ZLd"�ZMejBjNjOeMd#�ZPd$�ZQde5d%�ZReSe5eSe5eSeSeSe5e5d&�	ZTd'eSeSd(�ZUe5e5d)�ZVeSeSd*�ZWeSeSd+�ZXe2e5d,�ZYeSeSeSd-�ZZeSeSeSd.�Z[e5e5e5d/�Z\e2d0�Z]e2e2d1�Z^d2�Z_e5d3�Z`d4�Zad5�Zbd6�Zcd7�Zdd8�Zed9�Zfd:�Zgd;�ZheSeSeSeSd<d=�ZieSd>�Zjd<d?�Zkd@�ZldA�ZmdB�ZndC�ZoeSeSdD�ZpeSeSe5d<dE�ZqdF�ZrdG�ZsdH�ZtdI�ZudJ�ZvdS(Ku{
Support for APT (Advanced Packaging Tool)

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

    For repository management, the ``python-apt`` package must be installed.
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(t	HTTPError(tRequestturlopen(t
_parse_env(tCommandExecutionErrortMinionErrortSaltInvocationError(tsourceslistu/var/lib/apt/listsu4deb http://ppa.launchpad.net/{0}/{1}/ubuntu {2} mainu@deb https://{0}private-ppa.launchpad.net/{1}/{2}/ubuntu {3} mainuuriucompsu
architecturesudisabledufileudistunoneuAPT_LISTBUGS_FRONTENDuAPT_LISTCHANGES_FRONTENDunoninteractiveuDEBIAN_FRONTENDu1uUCF_FORCE_CONFFOLDupkgcC@s#tjd�dkrtStdfS(u9
    Confirm this module is on a Debian-based system
    u	os_familyuDebianu9The pkg module could not be loaded: unsupported OS family(t
__grains__tgett__virtualname__tFalse(((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt__virtual__cs
cC@s&t�tkr"tjjt�ndS(uv
    For Debian and derivative systems, set up
    a few env variables to keep apt happy and
    non-interactive.
    N(RRtostenvirontupdatet
DPKG_ENV_VARS(topts((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt__init__rscC@sJdj||�}t|didd6�}t|�}tjjj|�S(u�
    Idea from softwareproperties.ppa.
    Uses urllib2 which sacrifices server cert verification.

    This is used as fall-back code or for secure PPAs

    :param owner_name:
    :param ppa_name:
    :return:
    u/https://launchpad.net/api/1.0/~{0}/+archive/{1}theadersuapplication/jsonuAccept(tformatt_Requestt_urlopentsalttutilstjsontload(t
owner_nametppa_nametlp_urltrequesttlp_page((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt_get_ppa_info_from_launchpad}s
cC@sdj||�S(u'
    Stringify PPA name from args.
    uppa:{0}/{1}(R(RR ((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt_reconstruct_ppa_name�scC@ststd��ndS(u.
    Abort if python-apt is not installed
    u)Error: 'python-apt' package not installedN(tHAS_APTR(((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt
_check_apt�scK@s�g}|rJtjjjt�rJtddt�rJ|jddg�n|j|�idd6td6tjj	j
t��d6}|j|�td	||�S(
u
    Call apt* utilities.
    u
config.getu
systemd.scopeusystemd-runu--scopeutraceuoutput_loglevelupython_shelluenvucmd.run_all(
RRtsystemdt	has_scopet__context__t__salt__tTruetextendRtenvironmenttget_module_environmenttglobalsR(targstscopetkwargstcmdtparams((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt	_call_apt�s.


cC@s!tjd�tjd|�dS(u=
    Warn of missing python-software-properties package.
    u�The 'python-software-properties' package is not installed. For more accurate support of PPA repositories, you should install this package.uBest guess at ppa format: %sN(tlogtwarning(trepo((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt_warn_software_properties�s
c@satjjj|jdt��}tjjj|jdt��}d|kr]td��n|jdd�}|jdd�}t	|�dkr�dSi}x|D]}d||<q�Wt
d	t�}|r�d
dj|�gnd}	|r�t|�nxA|D]9}dd
d|g}
|	dk	r6|
j
|	�nt|
dt�}d�xztjjj|dd�D]\}d|krk|j�}
t	|
�dkr�|
d��j�dkr�d�q�nPqkqkW|j|g�}|s��||<q|r	|r	�||<q�rt�fd�|D��s;�||<q;qqWt	|�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.

    A specific repo can be requested using the ``fromrepo`` keyword argument.

    cache_valid_time

        .. versionadded:: 2016.11.0

        Skip refreshing the package database if refresh has already occurred within
        <value> seconds

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.latest_version <package name>
        salt '*' pkg.latest_version <package name> fromrepo=unstable
        salt '*' pkg.latest_version <package1> <package2> <package3> ...
    urefreshushow_installedurepou6The 'repo' argument is invalid, use 'fromrepo' insteadufromrepoucache_valid_timeiutversions_as_listu-ouAPT::Default-Release={0}u	apt-cacheu-qupolicyR2ustdoutu
u	Candidateii����u(none)c
3@s9|]/}tjjjd|ddd�dt�VqdS(tver1toperu>=tver2tcmp_funcN(RRtversionstcomparetversion_cmp(t.0tx(t	candidate(s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pys	<genexpr>siN(RRtdatatis_truetpopR,RR
tNonetlent	list_pkgsRt
refresh_dbR-R6t	itertoolstsplittlowerR
tany(tnamesR3trefreshtshow_installedtfromrepotcache_valid_timetrettnametpkgsR9R4touttlinetcompst	installed((REs7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytlatest_version�sV!!
!

#



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+(RQR3((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytversions
c
C@sDtjjjt�tjjj|�}i}t�}|r�yLtj	t
�j}tj�}t
jd|||�|||kr�|SWq�tk
r�}t
jd|�q�tk
r�}t
jd|�q�Xntdddgdt�}|dd	kr1d
}d|kr"||d7}nt|��n
|d}	x�|	j�D]�}
|
j�}|sfqHnd
j|d�}d|d	kr�tjdd
|�}t||<qHd|d	kr�t||<qHd|d	kr�d||<qHd|d	krHt||<|j|�qHqHW|r@|r@tdjdj|����n|S(uO
    Updates the APT database to latest packages based upon repositories

    Returns a dict, with the keys being package databases and the values being
    the result of the update attempt. Values can be one of the following:

    - ``True``: Database updated successfully
    - ``False``: Problem updating database
    - ``None``: Database already up-to-date

    cache_valid_time

        .. versionadded:: 2016.11.0

        Skip refreshing the package database if refresh has already occurred within
        <value> seconds

    failhard

        If False, return results of Err lines as ``False`` for the package database that
        encountered the error.
        If True, raise an error with a list of the package databases that encountered
        errors.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.refresh_db
    u7now: %s, last update time: %s, expire after: %s secondsu@expected integer for cache_valid_time parameter, failed with: %su)could not stat cache directory due to: %suapt-getu-quupdateR2uretcodeiuustderrustdoutu iuGetu	 \[.+B\]$uIgnuHituErruError getting repos: {0}u, N(RRtpkgt
clear_rtagt__opts__RFRGtlistRtstattAPT_LISTS_PATHtst_mtimettimeR7tdebugt	TypeErrorR8tIOErrorR6RRt
splitlinesRNtjointretsubR,RItappendR(
RUtfailhardRVterror_repost
latest_updatetnowtexptcalltcommentRYRZtcolstident((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyRL)sP 	




!c	3K@s
t}
tjjj|�rt}
d|	kr||	dr|t}
t|dtdt�}|	jd�}||ks|t}
q|n|rt}
xu|D]j}
t|
t	�r�t
tj|
��}t|dtdt�}|
|}||ks�t}
q�q�t}
q�Wqn|rt
d|�ny#t
d||||	�\}}Wntk
r^}t|��nX|	jdd�}|r�|r�|}n|dDks�t|�dkr�iSg}t�}g}g}i}g}|d	kr�ttj|��}g|D]<\}}|dDk	r�|jd
�s.|jd�r�|^q�}|rUtdt||	�ni}|jd
ddg�|	jdt�r�|jd�nd|	kr�|	dr�|jddg�n|jddg�|ddg7}d|	kr|	ds|jd�q|jd�nd|	kr>|	dr>|jd�n|rT|jd�n|rp|jd|g�n|jd�n�g}x�|D]x}dt
kr�t
d|�}ndD}|dDkr�tjd |�|j|g�q�|j|d!||dg�q�Wd|	kr8|	dr8|jd"d#d$g�n|jd"d#d%g�|rd|jd&�ntr}t|||	�nxd|D]\} |d	kr�| \}!}"|r"|dDkr"|	jd�r"t|�d'kr"|	d}"q"n=y| \}!}#}"Wn'tk
r!dD}!| d}#dD}"nX|"dDkry|d	kri|rY|!|krY|!||!<qv|j|!�q�|j|#�q�|d	kr7|"jd(�}"|!|kr"|j|!g�}$tjjj |"|$d)t!d*|�}%|%dDkr|jd+j"|!|"|$r	d,j#|$�ndD��q�q"|%}"nd-j"|!|"�}&n|#}&|j|!d�}'|r�|'r�tjj$j%d.|"d/d0d1|'d)t!�r�|&||!<q�|'s�tjj$j%d.|"d/d2d1|'d)t!�r�|j|&�q�|j|&�q�W|r|rtj&d3|�ng}(g})|rO|)j|�t'j(|�}*|*j|�|(j|*�n|r�t'j(|�}*|d	kr�d|*kr�|*j)d4d�n|*j|�|(j|*�n|r|)j|�t'j(|�}*|s�|*jd5�n|*jgtj*|�D]}|^q��|(j|*�n|(s,i}+n�|	j+d6d�},|
rQt,|,�nt-|	jd7��}-|-j.t/j'��t0d8d9�jd9g�}.g|)D]}|j1d(�d^q�}/g|.D]}||/kr�|^q�}0|0r�t2d:|0�nxH|(D]@}*t3|*�}1|1d;dkr�|1d<r�|j|1d<�q�q�Wt4j+d=dD�t�}2tjjj5||2�}+xc|D][}!|!|+ks�	|!|krx	|+j.ii|j|!d�d>6|2j|!d�d?6|!6�qx	qx	W|0r�	t6d:|0�n|r
td@dAi|dB6|+dC6��n|+S(EuI
    .. 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 apt-get/dpkg 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, add refresh=True to update the dpkg 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.

        32-bit packages can be installed on 64-bit systems by appending the
        architecture designation (``:i386``, etc.) to the end of the package
        name.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install <package name>

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

    cache_valid_time

        .. versionadded:: 2016.11.0

        Skip refreshing the package database if refresh has already occurred within
        <value> seconds

    fromrepo
        Specify a package repository to install from
        (e.g., ``apt-get -t unstable install somepackage``)

    skip_verify
        Skip the GPG verification check (e.g., ``--allow-unauthenticated``, or
        ``--force-bad-verify`` for install from package file).

    debconf
        Provide the path to a debconf answers file, processed before
        installation.

    version
        Install a specific version of the package, e.g. 1.2.3~0ubuntu0. Ignored
        if "pkgs" or "sources" is passed.

        .. versionchanged:: 2018.3.0
            version can now contain comparison operators (e.g. ``>1.2.3``,
            ``<=2.0``, etc.)

    reinstall : False
        Specifying reinstall=True will use ``apt-get install --reinstall``
        rather than simply ``apt-get install`` for requested packages that are
        already installed.

        If a version is specified with the requested package, then ``apt-get
        install --reinstall`` will only be used if the installed version
        matches the requested version.

        .. versionadded:: 2015.8.0

    ignore_epoch : False
        Only used when the version of a package is specified using a comparison
        operator (e.g. ``>4.1``). If set to ``True``, then the epoch will be
        ignored when comparing the currently-installed version to the desired
        version.

        .. versionadded:: 2018.3.0

    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"]'
            salt '*' pkg.install pkgs='["foo", {"bar": "1.2.3-0ubuntu0"}]'

    sources
        A list of DEB 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.

        32-bit packages can be installed on 64-bit systems by appending the
        architecture designation (``:i386``, etc.) to the end of the package
        name.

        .. versionchanged:: 2014.7.0

        CLI Example:

        .. code-block:: bash

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

    force_yes
        Passes ``--force-yes`` to the apt-get command.  Don't use this unless
        you know what you're doing.

        .. versionadded:: 0.17.4

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

        .. versionadded:: 2015.5.0

    only_upgrade
        Only upgrade the packages, if they are already installed. Default is False.

        .. versionadded:: 2015.5.0

    force_conf_new
        Always install the new version of any configuration files.

        .. versionadded:: 2015.8.0

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

        {'<package>': {'old': '<old-version>',
                       'new': '<new-version>'}}
    uversionRRRSudebconf.set_fileupkg_resource.parse_targetsurepouiu
repositoryu<u>tbyrepouapt-getu-qu-yu	force_yesu--force-yesuforce_conf_newu-ouDPkg::Options::=--force-confnewuDPkg::Options::=--force-confolduDPkg::Options::=--force-confdefuinstall_recommendsu--no-install-recommendsu--install-recommendsuonly_upgradeu--only-upgradeu--allow-unauthenticatedu-tuinstallulowpkg.bin_pkg_infou[pkg.install: Unable to get deb information for %s. Version comparisons will be unavailable.unameudpkgu-iu--force-confnewu--force-confoldu--force-bad-verifyiu=R?tignore_epochu<No version matching '{0}{1}' could be found (available: {2})u, u{0}={1}R<R=u==R>u>=uTargeting repo '%s'i����u--reinstallucache_valid_timeuenvtstateuholdRXuretcodeustderru
pkg.list_pkgsuoldunewu)Problem encountered installing package(s)tinfouerrorsuchangesN(7RRRRFRGR,R]R
t
isinstancetdicttnextRtiterkeysR+R	RRIRJRKRbt	iteritemst
startswithtlist_repo_pkgsR-RnR7terrorR&t
_resolve_depst
ValueErrortlstripR_t
match_versionRBRRkR@RAR{tcopytdeepcopytinsertt
itervaluesRHRLRRRtget_selectionsRNtunholdR6R*t
compare_dictsthold(3RWRRRTtskip_verifytdebconfRXtsourcest	reinstallRyR3t_refresh_dbt_latest_versiont_versionR_t_namet
pkg_paramstpkg_typetexcR9t
cmd_prefixtoldttargetst	downgradetto_reinstallterrorstpkg_params_itemsRDtythas_comparisont
_availablet
pkg_sourcetdeb_infot
pkg_item_listtpkgnametversion_numtpkgpatht
candidatesttargettpkgstrtcvertcmdstall_pkgsR4RVRUtenvt	hold_pkgsttargeted_namest	to_unholdRYtnew((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytinstall{sx�		
		

		*!






			
	




)	
&%
	
"uremovecK@s�ytd||�d}Wntk
r<}t|��nXt�}tdt�}g|D]}||kr\|^q\}	|dkr�|	jg|D]}||kr�|^q��n|	s�iSddd|g}
|
j|	�t|jd��}|jt	j
��t|
d	|�}|d
dkrB|drB|dg}
ng}
tj
dd�t�}tdt�}tjjj||�}|dkr�itjjj||�d
6|d6}n|}|
r�tddi|
d6|d6��n|S(u�
    remove and purge do identical things but with different apt-get commands,
    this function performs the common logic.
    upkg_resource.parse_targetsitremovedupurgeuapt-getu-qu-yuenvR�uretcodeustderru
pkg.list_pkgsuremovedu	installedu'Problem encountered removing package(s)R{uerrorsuchangesN(R+R	RRKR,R-RR
RRR�R6R*RHRIRRRFR�(tactionRWRXR3R�R�R�told_removedRDR�R4R�RYR�R�tnew_removedtchangesRV((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt
_uninstallsB	%/
	
c	C@sZg}|r�g}|jddg�|r;|jd�n|jd�t|dt�d}t}xc|j�D]U}|tkr�|jd�r�|j|j��q�t}qqd|krqt}qqqqW|j�|St	�}|jdd	g�|r
|jd�n|jd�t|dt�t
jd
d�t	�}t
jjj||�SdS(u%
    .. versionadded:: 2015.5.0

    Remove packages not required by another package using ``apt-get
    autoremove``.

    list_only : False
        Only retrieve the list of packages to be auto-removed, do not actually
        perform the auto-removal.

    purge : False
        Also remove package config data when autoremoving packages.

        .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.autoremove
        salt '*' pkg.autoremove list_only=True
        salt '*' pkg.autoremove purge=True
    uapt-getu--assume-nou--purgeu
autoremovetignore_retcodeustdoutu u'The following packages will be REMOVED:u--assume-yesu
pkg.list_pkgsN(R-RnR6R,RRjR�RNtsortRKR*RHRIRRRFR�(	t	list_onlytpurgeR4RVRYtfoundRZR�R�((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt
autoremoveEs6
	

	
	cK@stddd|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 apt-get/dpkg 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 using ``apt-get 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.remove <package name>
        salt '*' pkg.remove <package1>,<package2>,<package3>
        salt '*' pkg.remove pkgs='["foo", "bar"]'
    R�uremoveRWRX(R�(RWRXR3((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytremove|s)cK@stddd|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 apt-get/dpkg 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 ``apt-get purge`` along with all 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"]'
    R�upurgeRWRX(R�(RWRXR3((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyR��s)c
K@s�|jdd�}tjjj|�r4t|�nt�}d|kr\|dr\d}nd}dddd	d
j|�d	dg}|jdt	�r�|j
d
�n|jdt	�r�|j
d�n|jdt	�r�|j
d�n|j
|r�dnd�t|dtj
��}tjdd�t�}tjjj||�}	|ddkr�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 apt-get/dpkg 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

    Upgrades all packages via ``apt-get upgrade`` or ``apt-get dist-upgrade``
    if  ``dist_upgrade`` is ``True``.

    Returns a dictionary containing the changes:

    .. code-block:: python

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

    dist_upgrade
        Whether to perform the upgrade using dist-upgrade vs upgrade.  Default
        is to use upgrade.

        .. versionadded:: 2014.7.0

    cache_valid_time

        .. versionadded:: 2016.11.0

        Skip refreshing the package database if refresh has already occurred within
        <value> seconds

    download_only
        Only download the packages, don't unpack or install them

        .. versionadded:: 2018.3.0

    force_conf_new
        Always install the new version of any configuration files.

        .. versionadded:: 2015.8.0

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade
    ucache_valid_timeiuforce_conf_newu--force-confnewu--force-confolduapt-getu-qu-yu-ouDPkg::Options::={0}uDPkg::Options::=--force-confdefu	force_yesu--force-yesuskip_verifyu--allow-unauthenticatedu
download_onlyu--download-onlyudist-upgradeuupgradeR�u
pkg.list_pkgsuretcodeu&Problem encountered upgrading packagesR{uchangesuresultN(RHRRRFRGRLRKRR
RRnR6RR�R*RIR�R(
RRtdist_upgradeR3RUR�t
force_confR4tresultR�RV((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytupgrade�s27
			c

K@s|r$|r$|r$td��n|r?|r?td��ng}|r[|j|�n@|r�x7|D]}|jtt|���qhWn
|j|�i}xn|D]f}t|t�r�tt|��}ni|d6id6td6dd6||<td|d	d
�}|s-dj	|�||d<q�t
jjj
|jd
t��s�dtkr�tdr�||jd
d�dj	|�||d<qtdi|gd
6�}	||jd|	|d
t�dj	|�||d<q�||jd
t�dj	|�||d<q�W|S(u�
    .. versionadded:: 2014.7.0

    Set package in 'hold' state, meaning it will not be upgraded.

    name
        The name of the package, e.g., 'tmux'

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.hold <package name>

    pkgs
        A list of packages to hold. Must be passed as a python list.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.hold pkgs='["foo", "bar"]'
    u0One of name, pkgs, or sources must be specified.u-Only one of pkgs or sources can be specified.unameuchangesuresultuucommenttpatternRzuholduPackage {0} not currently held.utestR�uPackage {0} is set to be held.t	selectionR�uPackage {0} is now being held.u&Package {0} is already set to be held.N(R
R-RnR~titerR|R}RR�RRRRFRGR
RaRRItset_selectionsR,(
RWRXR�R3R�tsourceRVR�RzR�((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyR�-sL
 


!c

K@s|r$|r$|r$td��n|r?|r?td��ng}|r[|j|�n@|r�x7|D]}|jtt|���qhWn
|j|�i}xh|D]`}t|t�r�tt|��}ni|d6id6td6dd6||<td|�}|s'd	j	|�||d<q�t
jjj
|jd
t��r�dtkr�tdr�||jdd�d
j	|�||d<qtdi|gd6�}	||jd|	|dt�dj	|�||d<q�||jdt�dj	|�||d<q�W|S(u�
    .. versionadded:: 2014.7.0

    Set package current in 'hold' state to install state,
    meaning it will be upgraded.

    name
        The name of the package, e.g., 'tmux'

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.unhold <package name>

    pkgs
        A list of packages to hold. Must be passed as a python list.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.unhold pkgs='["foo", "bar"]'
    u0One of name, pkgs, or sources must be specified.u-Only one of pkgs or sources can be specified.unameuchangesuresultuucommentR�u"Package {0} does not have a state.uholdutestR�u"Package {0} is set not to be held.R�uinstallR�u$Package {0} is no longer being held.u*Package {0} is already set not to be held.N(R
R-RnR~R�R|R}RR�RRRRFRGR
RaRRIR�R,(
RWRXR�R3R�R�RVR�RzR�((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyR�vsL
 


!c
K@stjjj|�}tjjj|�}tjjj|�}dtkr�|rktjtdd�}n5tjtdd�}|s�|jtdd�n|s�td|�n|Siid6id6id6}dddd	g}td
|ddd
t	�}x||j
�D]n}|j�}y0gd D]}	||	^q-\}
}}}
}Wntt
fk
roqnXtjdd�dkr�tjdd�}|dkr�|dkr�||kr�|dj|�7}q�nt|�rd|
ks�d|
kr"d|kr"td|d||
�qd|
krItd|d||
�qd|
kr|dkrtd|d||
�qqqWx d!D]}td||�q�Wtj|�td<|r�|d}n5tjtdd�}|s|jtdd�n|std|�n|S("u�
    List the packages currently installed in a dict::

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

    removed
        If ``True``, then only packages which have been removed (but not
        purged) will be returned.

    purge_desired
        If ``True``, then only packages which have been marked to be purged,
        but can't be purged due to their status as dependencies for other
        installed packages, will be returned. Note that these packages will
        appear in installed

        .. versionchanged:: 2014.1.1

            Packages in this state now correctly show up in the output of this
            function.


    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_pkgs
        salt '*' pkg.list_pkgs versions_as_list=True
    u
pkg.list_pkgsuremovedu
purge_desiredu	installedupkg_resource.stringifyu
dpkg-queryu--showformatu0${Status} ${Package} ${Version} ${Architecture}
u-Wucmd.run_stdouttoutput_loglevelutracetpython_shelliiiiiucpuarchuux86_64uosarchualluamd64u:{0}uinstalluholdupkg_resource.add_pkgu	deinstallupurgeupkg_resource.sort_pkglist(iiiii(u	installeduremovedu
purge_desired(RRRFRGR*R�R�RR+RRjRNR�t
IndexErrorRR
RRJ(R;R�t
purge_desiredR3RVR4RYRZRvRDtlinetypetstatusRWR�tarchtosarchtpkglist_type((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyRK�sl 	0$



c@sOddg}|r"|jd�n
|jd�y$|jddj|d�g�Wntk
rfnXt|�}|dd	kr�d
}x.dD]&}||r�|d
||7}Pq�q�Wt|��n
|d}tjd�}ddg��fd�}|j|�}	i}
x6|	D].}||d�}||d�}
|
|
|<qW|
S(uq
    Utility function to get upgradable packages

    Sample return data:
    { 'pkgname': '1.2.3-45', ... }
    uapt-getu--just-printudist-upgradeuupgradeu-ouAPT::Default-Release={0}ufromrepouretcodeiuFailed to get upgradesustderrustdoutu: u(?m)^Conf ([^ ]+) \(([^ ]+)unameuversionc@s|�j|�S(N(tindex(tltk(tkeys(s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt<lambda>Gs(ustderrustdout(	RnR-RtKeyErrorR6RRltcompiletfindall(R�R3R4RttmsgtkeyRYtrexpt_gettupgradesRVRZRWR�((R�s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt_get_upgradable$s6
$




cK@sA|jdd�}tjjj|�r4t|�nt||�S(u
    List all available package upgrades.

    refresh
        Whether to refresh the package database before listing upgrades.
        Default: True.

    cache_valid_time

        .. versionadded:: 2016.11.0

        Skip refreshing the package database if refresh has already occurred within
        <value> seconds

    dist_upgrade
        Whether to list the upgrades using dist-upgrade vs upgrade.  Default is
        to use dist-upgrade.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_upgrades
    ucache_valid_timei(RHRRRFRGRLR�(RRR�R3RU((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt
list_upgradesTs
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](RW((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytupgrade_availabless
c		@sV�fd�}||�}||�}tr�y�tj�ytj||�}Wn5tk
r�tjtj|�tj|��}nX|dkr�dS|dkr�dSdSWq�tk
r�q�XnykxddddfD]S\}}dd	|||g}td
|ddd
t	dt
�}|dkr�|Sq�WWn tk
rQ}tj|�nXdS(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.

    ignore_epoch : False
        Set to ``True`` to ignore the epoch when comparing versions

        .. versionadded:: 2015.8.10,2016.3.2

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.version_cmp '0.2.4-0ubuntu1' '0.2.4.1-0ubuntu1'
    c@s0�r#tj|�jdd�dStj|�S(Nu:ii����(Rt	text_typeRN(RD(Ry(s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyR��siii����ultuequgtudpkgu--compare-versionsucmd.retcodeR�utraceR�R�(ulti����(ueqi(ugtiN(t
HAS_APTPKGtapt_pkgtinit_systemtversion_compareRhRR�t	ExceptionR+RR,R7R�RI(	tpkg1tpkg2Ryt	normalizeRVR=R4tretcodeR�((Rys7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyRB�s2

((

	cC@s1tj|�}|j|j|j|j|jfS(u-
    Return APT source entry as a tuple.
    (RtSourceEntryttypet
architecturesturitdistR[(R9RN((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt_split_repo_str�scC@s�t|tj�s6tdjt|�tj���ni}t�}tjd�j}g|j	D]}|j
sa|^qa}x�|D]�}|jjd�|_t
t|dg�|j|j|j|jf�}||kr||}t|j�jt|j��}	t	|	�||_n(tjtjjjj|j��||<|j|kr�|j|j�q�q�Wt	|j��|_	|j�x3|D]+}
ytj|
�Wq�tk
r�q�Xq�W|S(u"
    Consolidate APT sources.
    u'{0}' not a '{1}'uu/u
architectures(R|RtSourcesListRhRR�tsetR�tfileRbtinvalidR�trstriptstrtgetattrtdisabledR�R[tunionRRR_tdebt	strip_uriRZtaddtvaluestsaveRR�tOSError(R�tconsolidatedtdelete_filest	base_filetstreposR9R�tcombinedtcombined_compstfile_((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt_consolidate_repo_sources�s8		%
!
!(


cO@s>|r,ddgg|D]}|^q}nddg}t|dtdt�}i}d}t}tjd�}x�tjjj	|dd�D]�}	|	j
�s�q�ny|j|	�jd	�}
Wnt
k
r�nX|
|kr�|
}q�n|	j
�j	dd	�}|d
dkr�|j|g�j|d	�q�q�W|S(
uH
    .. versionadded:: 2017.7.0

    Returns all available packages. Optionally, package names (and name globs)
    can be passed and the results will be filtered to packages matching those
    names.

    This function can be helpful in discovering the version or repo to specify
    in a :mod:`pkg.installed <salt.states.pkg.installed>` state.

    The return data will be a dictionary mapping package names to a list of
    version numbers, ordered from newest to oldest. For example:

    .. code-block:: python

        {
            'bash': ['4.3-14ubuntu1.1',
                     '4.3-14ubuntu1'],
            'nginx': ['1.10.0-0ubuntu0.16.04.4',
                      '1.9.15-0ubuntu1']
        }

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.list_repo_pkgs
        salt '*' pkg.list_repo_pkgs foo bar baz
    u	apt-cacheushowudumpR2R�u^Package: (.+)ustdoutu
iiuVersion:N(R6RR,RIRlR�RRRMRNtstriptmatchtgrouptAttributeErrort
setdefaultRn(R1R3targR4RYRVtpkg_nametskip_pkgtnew_pkgRZtcur_pkgR[((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyR��s,&#
$cC@s�t�i}tj�}x�|jD]�}|jr8q#ni}|j|d<t|dg�|d<|j|d<|j|d<|j	|d<|j
jd�|d<tj
jjj|jj��|d<t|d	g�|d	<|j|j
g�j|�q#W|S(
u�
    Lists all repos in the sources.list (and sources.lists.d) files

    CLI Example:

    .. code-block:: bash

       salt '*' pkg.list_repos
       salt '*' pkg.list_repos disabled=True
    ufileucompsudisabledudistutypeu/uuriulineu
architectures(R'RR�RbR�R�R�R�R�R�R�R�RRR_R�RRZRRRn(R	R�R�R9((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt
list_repos)s"	



% c
K@s�t�|jdd�}|jd�r+tddkr+td}|djd	�\}}|r�d
j|�}tj||||�}q+tryQt	t
jd�r�t
jj|�j
|�d}nt
jj||�d}Wq(tk
r}td
j||���q(Xq+tj|||�}nt�}|r�y�t|�\}	}
}}}
|r�tjd|�}|r�|jd�j|�s�dj|jd�||jd��}q�q�nWn&tk
r�tdj|���nXx�tj|�D]�}x�|D]�}|d|	kr|djd	�|jd	�kr|d|kr|
sW|Sx-|
D]"}||jdg�kr^|Sq^WqqWq�WniS(u�
    Display a repo from the sources.list / sources.list.d

    The repo passed in needs to be a complete repo entry.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.get_repo "myrepo definition"
    uppa_authuppa:uosuUbuntuuMintuneonulsb_distrib_codenameiu/u{0}@uPPAShortcutHandleriuCould not find ppa {0}: {1}u(http[s]?://)(.+)iu
{0}{1}@{2}iu4Error: repo '{0}' is not a well formatted definitionutypeuuriudistucompsN(uUbuntuuMintuneon(R'R
RIR�RRNRtLP_PVT_SRC_FORMATtHAS_SOFTWAREPROPERTIESthasattrtsoftwarepropertiestppatPPAShortcutHandlertexpandtexpand_ppa_linet	NameErrorRt
LP_SRC_FORMATRR�RltsearchRtSyntaxErrorRR�R�(R9R3tppa_authR�RR t	auth_infot
name_errorR	t	repo_typetrepo_architecturestrepo_urit	repo_distt
repo_compst	uri_matchR�Rmtcomp((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytget_repoGs^
			

"
cK@s1t�t}|jd�rtddkrt}td}ts�t|�|djd�\}}d	|kr�d
j|d	�}t	j||||�}qt
j|||�}qttj
d�r�tj
j|�j|�d}qtj
j||�d}ntj�}g|jD]}|js|^q}	|	rt�}
yt|�\}}}
}}Wn&tk
r�td
j|���nXx�|	D]�}|j|kr^|j|kr^|j|
kr^|j|kr^t|j�}t|�}|j|�r^d|
|j <t|j!|��|_|js[y|j"|�WqXt#k
rTqXXq[q^n|r#|dkr#|jdkr#|j|
kr#|j|kr#t|j�}t|�}|j|�r#d|
|j <t|j!|��|_|js y|j"|�Wqt#k
rqXq q#n|j$�q�W|
rd}x3|D]+}|j |
krD|
|j cd7<qDqDWx�t%j&|
�D]�\}}d}|dkr�d|kr�t'j(j)|�r�d}yt'j"|�Wq�t*k
r�q�Xq�n||j||�7}q�Wt+�|Snt,dj|���dS(u�
    Delete a repo from the sources.list / sources.list.d

    If the .list file is in the sources.list.d directory
    and the file that the repo exists in does not contain any other
    repo configuration, the file itself will be deleted.

    The repo passed in must be a fully formed repository definition
    string.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.del_repo "myrepo definition"
    uppa:uosuUbuntuuMintuneonulsb_distrib_codenameiu/uppa_authu{0}@uPPAShortcutHandleriu1Error: repo '{0}' not a well formatted definitionudebudeb-srcuiu&Repo '{0}' has been removed from {1}.
usources.list.d/u0File {1} containing repo '{0}' has been removed.u-Repo {0} doesn't exist in the sources.list(s)N(uUbuntuuMintuneon(-R'RR�RR,RR:RNRRR"RRRRRR RR�RbR�R}R�R$R
R�R�R�R�R�R[tintersectionR�t
differenceR�R�RRR�RtpathtisfileRRLR(R9R3tis_ppaR�RR R&R�RR	tdeleted_fromR(R)R*R+R,R�ts_compstr_compsRVt	repo_filetcountR�((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytdel_repo�s�

"%	


	

!
	




cC@s.ytt|��}Wntk
r)nX|S(u�
    .. versionadded:: 2017.7.0

    Convert to an int if necessary.

    :param str value: The value to check/convert.

    :return: The converted or passed value.
    :rtype: bool|int|str
    (tintR�R�(tvalue((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt_convert_if_ints

c
C@sxt�}t�}ddddddddg}t|dt�}|d	d
krgtj|d�|Sg|dj�D]}|j�rx|^qx}x�|D]�}g|jd
�D]*}|j�r�t	|j��nd'^q�}t�}t|�dkrtjd|�q�n|d
d(kr�|j
i|dd6|dd6|dd6|dd6|dd6|dd6|dd6�|d
dkr�|j|�qQ||dd <q�|d
d!kr|djd t�r�|dd j
i|d"d#6�qQ|dj
i|d"d#6�q�|d
d$kr�|dj
i|d"d$6|d%d&6�q�q�Wx|D]}	|	||	d<q\W|S()u�
    .. versionadded:: 2017.7.0

    List known repo key details.

    :return: A dictionary containing the repo keys.
    :rtype: dict

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.get_repo_keys
    uapt-keyuadvu--batchu--list-public-keysu--with-fingerprintu
--with-colonsu--fixed-list-modeR2uretcodeiustderrustdoutu:iuSkipping line: %supubusubiu	algorithmubitsiu
capabilityiu
date_creationiudate_expirationiukeyidiuvalidityi����usubkeyufpri	ufingerprintuuidiuuid_hashN(upubusub(R}RbR6RR7R�RjRRNR=RIRJRgRRnR
(
RVt	repo_keysR4tcmd_retRZtlinestitemtitemst	key_propstrepo_key((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt
get_repo_keyssL		/
@		#

ubasecC@s�dg}i}t�}|ratd||�}|sKtjd|�tS|jd|g�n�|r�tjd|�|jddg�|ji|d6�n�|r�|s�dj|�}	t	|	��n|jd	d
d|d|g�n<|rd
j|�}	t	|	��nt
djtj���|rqx?|D]4}
|
t
|�|kr6tjd||
�tSq6Wnt||�}|ddkr�tStjd|d�tS(u�
    .. versionadded:: 2017.7.0

    Add a repo key using ``apt-key add``.

    :param str path: The path of the key file to import.
    :param str text: The key data to import, in string form.
    :param str keyserver: The server to download the repo key specified by the keyid.
    :param str keyid: The key id of the repo key to add.
    :param str saltenv: The environment the key file resides in.

    :return: A boolean representing whether the repo key was added.
    :rtype: bool

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.add_repo_key 'salt://apt/sources/test.key'

        salt '*' pkg.add_repo_key text="'$KEY1'"

        salt '*' pkg.add_repo_key keyserver='keyserver.example' keyid='0000AAAA'
    uapt-keyu
cp.cache_fileu%Unable to get cached copy of file: %suadduReceived value: %su-ustdinu.No keyid or keyid too short for keyserver: {0}uadvu--batchu--keyserveru--recvu%No keyserver specified for keyid: {0}u){0}() takes at least 1 argument (0 given)u"The keyid '%s' already present: %suretcodeiuUnable to add repo key: %sustderr(RER+R7R�RR-RgRRR
Rhtadd_repo_keyt__name__RJR,R6(R2ttextt	keyservertkeyidtsaltenvR4R3tcurrent_repo_keystcached_source_patht	error_msgt
current_keyidR?((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyRF]s@		"
cK@s
|jdt�r{t|tj�rl|jd�rl|djd�\}}t||�}|dd}q�td��n*d|kr�|jd�}ntd	��t	d
d|gdt�}|d
dkr	d}|dr�|dj
|d�7}nt|��n|S(u�
    .. versionadded:: 2015.8.0

    Remove a repo key using ``apt-key del``

    name
        Repo from which to remove the key. Unnecessary if ``keyid`` is passed.

    keyid
        The KeyID of the GPG key to remove

    keyid_ppa : False
        If set to ``True``, the repo's GPG key ID will be looked up from
        ppa.launchpad.net and removed.

        .. note::

            Setting this option to ``True`` requires that the ``name`` param
            also be passed.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.del_repo_key keyid=0123ABCD
        salt '*' pkg.del_repo_key name='ppa:foo/bar' keyid_ppa=True
    u	keyid_ppauppa:iu/usigning_key_fingerprinti����u'keyid_ppa requires that a PPA be passedukeyidu.keyid or keyid_ppa and PPA name must be passeduapt-keyudelR2uretcodeiuFailed to remove keyid {0}ustderru: {0}(R
RR|Rtstring_typesR�RNR$R
R6RR(RWR3RR tppa_infoRJR�R�((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytdel_repo_key�s&!	
c+K@s�	d|kr/tjjjdd�|d}n|jdt�}t�|jd�r�tddRkr�tjj	j
d
�rud|krut|�}|r�i||6SdS}t
�}|r�i|d6|d
6}nttd�dkr�d
|g}nd
d|g}t|d|dt|�}|drWtdj|d||d|d���n|rgt�ni||6Sq�ts�t|�n
tjd�y |djdd�\}	}
Wn*tk
r�tdj|d���nXtd}||d<d}d|kr*d}
|
j|	|
|�|d<ny]t|	|
�}d|krY|d |d!<n-d!|kr�d"}t|j|	|
���nWn[tk
r�}td#j|	|
|���n.tk
r�}td$j|	|
|���nXd%|kr�d&|d%<nd|kr/|d's/td(j|���q/nd|krid)j|d�}tj||	|
|�}q�tj|	|
|�}q�td*j|���ntj �}|jd+t�r�t!|�}ng|D]}|j"s�|^q�}dS}yt#|�\}}}}}Wn&t$k
r5t$d,j|���nXt%|�}t&d-d.�}d!|kr�|j'd!dS�}|j'd%dS�}|s�|r�d/}t(|��nt)|t*�s�|g}nx;|D]}t)|t+�r�t,|�}nd0d1|g}t&d2|d3t|�}|jd4�} |r�| s�t
�}|r|||kr|d0d5d6d7d8j|�d9|d:d;d<|g}n!d0d5d6d9|d:d;d<|g	}t|dt|�}!|!dd=kr�td>j|!d?���q�q�q�q�Wnd@|kr�|d@}"t&dA|"|�}#|#s2tdBj|"���nd0dC|#g}t&d2|d3t|�}|j-�jdD�s�tdEj|"���q�ntdF|kr�|dF}$d0dCdGg}t&d2|dH|$d3t|�}|j-�jdD�s�tdIj|$���q�ndJ|kr8|dJjdK�|dJ<|t%|dJ�O}nt*|�|dJ<dL|krn|dLjdK�|dL<n
||dL<dM|kr�tjj.j/|dM�|dM<n|jdN�}%|jd�}&x�|D]�}'|'j0|ko�|'j1|ko�|'j2|k}(|'j2|&ko|'j0|%k})|(s&|)r�x/|D]'}*|*t3|'dJg�kr-|'}q-q-W|'j4sj|'}n|dL|'j5kr�|'}n|r�Pq�q�q�WdO|kr�tjj6j7j8|dO�|dO<n|s
	tj9|�}dO|kr�|dO|_:n|j*j;|�ndO|kr&	|dO|_:nx@|D]8}|t<kr-	t=||�r-	t>||||�q-	q-	W|j?�|r�	t�niit3|dLg�dL6|j4dJ6|j@dM6|jAd6|j0dN6|j1dP6|jBdQ6|6S(Tu
    Modify one or more values for a repo.  If the repo does not exist, it will
    be created, so long as the definition is well formed.  For Ubuntu the
    ``ppa:<project>/repo`` format is acceptable. ``ppa:`` format can only be
    used to create a new repository.

    The following options are available to modify a repo definition:

    architectures
        A comma-separated list of supported architectures, e.g. ``amd64`` If
        this option is not set, all architectures (configured in the system)
        will be used.

    comps
        A comma separated list of components for the repo, e.g. ``main``

    file
        A file name to be used

    keyserver
        Keyserver to get gpg key from

    keyid
        Key ID or a list of key IDs to load with the ``keyserver`` argument

    key_url
        URL to a GPG key to add to the APT GPG keyring

    key_text
        GPG key in string form to add to the APT GPG keyring

        .. versionadded:: 2018.3.0

    consolidate : False
        If ``True``, will attempt to de-duplicate and consolidate sources

    comments
        Sometimes you want to supply additional information, but not as
        enabled configuration. All comments provided here will be joined
        into a single string and appended to the repo configuration with a
        comment marker (#) before it.

        .. versionadded:: 2015.8.9

    .. note::
        Due to the way keys are stored for APT, there is a known issue where
        the key won't be updated unless another change is made at the same
        time. Keys should be properly added on initial configuration.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.mod_repo 'myrepo definition' uri=http://new/uri
        salt '*' pkg.mod_repo 'myrepo definition' comps=main,universe
    u
refresh_dbuNeonu�The 'refresh_db' argument to 'pkg.mod_repo' has been renamed to 'refresh'. Support for using 'refresh_db' will be removed in the Neon release of Salt.urefreshuppa:uosuUbuntuuMintuneonuapt-add-repositoryuppa_authu
http_proxyuhttps_proxyu	osreleaseg�G�z(@u-yR�R2uretcodeu?Unable to add PPA '{0}'. '{1}' exited with status {2!s}: '{3}' iustderru-Falling back to urllib method for private PPAu/iu�Unable to get PPA info from argument. Expected format "<PPA_OWNER>/<PPA_NAME>" (e.g. saltstack/salt) not found.  Received '{0}' instead.ulsb_distrib_codenameudistuufileu(/etc/apt/sources.list.d/{0}-{1}-{2}.listusigning_key_fingerprintukeyidu5Private PPAs require a keyid to be specified: {0}/{1}u*Launchpad does not know about {0}/{1}: {2}u^Launchpad knows about {0}/{1} but did not return a fingerprint. Please set keyid manually: {2}u	keyserverukeyserver.ubuntu.comuprivateu3PPA is not private but auth credentials passed: {0}u{0}@u/cannot parse "ppa:" style repo definitions: {0}uconsolidateu1Error: repo '{0}' not a well formatted definitionu
config.optionuno_proxyu*both keyserver and keyid options required.uapt-keyuexportucmd.run_stdoutR�u-----BEGIN PGPuadvu--batchu--keyserver-optionsuhttp-proxy={0}u--keyserveru--logger-fdu1u--recv-keysiu Error: key retrieval failed: {0}ustdoutukey_urlu
cp.cache_fileuError: file not found: {0}uadduOKu!Error: failed to add key from {0}ukey_textu-tstdinuError: failed to add key:
{0}ucompsu,u
architecturesudisabledutypeucommentsuuriuline(uUbuntuuMintuneonN(CRRR@t
warn_untilR
R,R'R�RR2twhichR/RIt_get_http_proxy_urltfloatR6RRRRLRR:R7R{RNR�R$RR�RR"RR�R
R�R�R$R�R+RHR!R|RbR;thextupperRFRGR�R�R�R�R[R�R_R�tcombine_commentsR�RuRnt
_MODIFY_OKRtsetattrRR�R�RZ(+R9RKR3RRt	repo_infoR�thttp_proxy_urlR4RYRR R�R%tfilenametlaunchpad_ppa_infot	error_strR�R�RR	t
mod_sourceR(R)R*R+R,tfull_comp_listtno_proxyRJRIR�toutputtimportedRVtkey_urltfn_tkey_texttkw_typetkw_distR�trepo_matchest
kw_matchesR.((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytmod_repo�sv9
	





 




"

	&


 
-

			#







cG@std|�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
    ulowpkg.file_list(R+(tpackages((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt	file_list'	scG@std|�S(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_dict httpd
        salt '*' pkg.file_dict httpd postfix
        salt '*' pkg.file_dict
    ulowpkg.file_dict(R+(Ro((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt	file_dict8	scK@sfd|krtd��nt�i}tjjjj|d�}|jd�r_tddkr_td}|d	j	d
d�\}}d|kr�d
j
|d�}tj
||||�}nktrt
tjd�r�tjj|�j|�d}q.tjj||�d}ntj
|||�}d|kr_d}|j
|||�|d<q_ntj|�}x4dD],}	|	|kru||	j	d�||	<ququWx1tD])}
|
|kr�t||
||
�q�q�W|j|d<t|dg�|d<|j|d<|j|d<|j|d<|jjd
�|d<|jj �|d<t|dg�|d<|S(uV
    Take a repository definition and expand it to the full pkg repository dict
    that can be used for comparison.  This is a helper function to make
    the Debian/Ubuntu apt sources sane for comparison in the pkgrepo states.

    This is designed to be called from pkgrepo states and will have little use
    being called on the CLI.
    urepoumissing 'repo' argumentuppa:uosuUbuntuuMintuneonulsb_distrib_codenameiu/iuppa_authu{0}@uPPAShortcutHandleriufileu(/etc/apt/sources.list.d/{0}-{1}-{2}.listu
architecturesucompsu,udisabledudistutypeuuriuline(uUbuntuuMintuneon(u
architecturesucomps(!R
R'RRR_R�RR�RRNRRRRRRRRR R"RR�R[R\R�R�R�R�R�R�R�RZR(R3t	sanitizedR9R�RR R&R_tsource_entryt	list_argstkwarg((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytexpand_repo_defI	sH	
"





cC@s�i}t|tj�r*|jd�}nxV|D]N}|r1|j�\}}||kro||j|�q|g||<q1q1W|S(u�
    Parses the format from ``dpkg --get-selections`` and return a format that
    pkg.get_selections and pkg.set_selections work with.
    u
(R|RRPRNRn(t
dpkgselectionRVRZt_pkgt_state((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt_parse_selections�	s
cC@sti}ddg}|j|r$|nd�td|dddt�}t|�}|rpi|j|g�|6S|S(u
    View package state from the dpkg database.

    Returns a dict of dicts containing the state, and package names:

    .. code-block:: python

        {'<host>':
            {'<state>': ['pkg1',
                         ...
                        ]
            },
            ...
        }

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.get_selections
        salt '*' pkg.get_selections 'python-*'
        salt '*' pkg.get_selections state=hold
        salt '*' pkg.get_selections 'openssh*' state=hold
    udpkgu--get-selectionsu*ucmd.run_stdoutR�utraceR�(RnR+RRzR
(R�RzRVR4tstdout((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyR��	s
	c@si}|r|r|S|r9|r9d}t|��nt|tj�r�ytjjj|�}Wq�tjjjj	tjjj
jfk
r�}tdj|���q�Xn|r't
d||�}tjjj|d��5}g|j�D]}tjjj|�^q�}	WdQXt|	�}n|rd}
g|D]}||
kr:|^q:}|rtd
jdj|����n|r�dd
g}tds�t|dt�}
|
ddkr�dj|
d�}tj|�t|��q�q�ni}xCtjt��D]/\�}|jt�fd�|D���qWx�tj|�D]�\�}x�|D]�}�|j|�kr�qanddg}dj|��}tdsat|dtd|�}
|
ddkr�tjd�|�qi|j|�d6�d6||<qaqaWqNWn|S(u�
    Change package state in the dpkg database.

    The state can be any one of, documented in ``dpkg(1)``:

    - install
    - hold
    - deinstall
    - purge

    This command is commonly used to mark specific packages to be held from
    being upgraded, that is, to be kept at a certain version. When a state is
    changed to anything but being held, then it is typically followed by
    ``apt-get -u dselect-upgrade``.

    Note: Be careful with the ``clear`` argument, since it will start
    with setting all packages to deinstall state.

    Returns a dict of dicts containing the package names, and the new and old
    versions:

    .. code-block:: python

        {'<host>':
            {'<package>': {'new': '<new-state>',
                           'old': '<old-state>'}
            },
            ...
        }

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.set_selections selection='{"install": ["netcat"]}'
        salt '*' pkg.set_selections selection='{"hold": ["openssh-server", "openssh-client"]}'
        salt '*' pkg.set_selections salt://path/to/file
        salt '*' pkg.set_selections salt://path/to/file clear=True
    usThe 'selection' and 'path' arguments to pkg.set_selections are mutually exclusive, and cannot be specified togetheru#Improperly-formatted selection: {0}u
cp.cache_fileurNuinstalluholdu	deinstallupurgeuInvalid state(s): {0}u, udpkgu--clear-selectionsutestR2uretcodeiu+Running dpkg --clear-selections failed: {0}ustderrc3@s|]}|�fVqdS(N((RCRx(Ry(s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pys	<genexpr>
su--set-selectionsu{0} {1}RSu%failed to set state %s for package %suoldunew(uinstalluholdu	deinstallupurge( R
R|RRPRRtyamlt	safe_loadtparsertParserErrortscannertScannerErrorRR+tfilestfopent	readlineststringutilst
to_unicodeRzRkRaR6RR7R�RR�R�RR}R
(R2R�tclearRKRVterrR�tifileRDtcontenttvalid_statest
bad_statesR4R�t
sel_revmapt_pkgsRxtcmd_in((Rys7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyR��	sf(-1%


'


c	K@sOg}xN|D]F}tjjd|dtj��}|j�r
|j|j�q
q
W|rKdddg}|ddg}|ddg}|jd	�|j|�td
|d|j	d�d
t
�}|dkr�tdj|���qKy7ddg|}td|d|j	d�d
t
�WqKt
k
rG}t|��qKXndS(u�
    Installs missing dependencies and marks them as auto installed so they
    are removed when no more manually installed packages depend on them.

    .. versionadded:: 2014.7.0

    :depends:   - python-apt module
    R_tcacheuapt-getu-qu-yu-ouDPkg::Options::=--force-confolduDPkg::Options::=--force-confdefuinstallucmd.retcodeR�uenvR�iu.Error: unable to resolve dependencies for: {0}uapt-markuautoucmd.runN(tapttdebfilet
DebPackagetCachetcheckR-tmissing_depsRnR+R
RRRR	(	RWRXR3R�tpkg_fileR�R4RVR�((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyR�'
s6	
!

	cG@s�|s
dSi}xs|D]k}dd|g}td|dddt�}|jd�d	||<d
||j�krd||<qqWt|�dkr�ttj|��S|S(uv
    .. versionadded:: 2014.7.0

    Return the name of the package that owns the file. Multiple file paths can
    be passed. Like :mod:`pkg.version <salt.modules.aptpkg.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:

    .. code-block:: bash

        salt '*' pkg.owner /usr/bin/apachectl
        salt '*' pkg.owner /usr/bin/apachectl /usr/bin/basename
    uudpkgu-Sucmd.run_stdoutR�utraceR�u:iu
no path foundi(R+RRNRORJR~RR�(tpathsRVR2R4Re((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytownerT
s

	c@s�tjjj|�}|jdt�}tjjj|jdg�d���|rjtjjj|�n|rzt�n|s�iSt	ddgt
|�dt�}d�}�fd�}i}i}x�tjjj|d	d
�D]�}|j
�}|rdy5g|jdd�D]}	|	j
�^q\}
}Wntk
rGqzX||
�rz|||
<qzq�|||�i}q�q�W|||�|S(
u�
    .. versionadded:: 2019.2.0

    Runs an ``apt-cache show`` on the passed package names, and returns the
    results in a nested dictionary. The top level of the return data will be
    the package name, with each package name mapping to a dictionary of version
    numbers to any additional information returned by ``apt-cache show``.

    filter
        An optional comma-separated list (or quoted Python list) of
        case-insensitive keys on which to filter. This allows one to restrict
        the information returned for each package to a smaller selection of
        pertinent items.

    refresh : False
        If ``True``, the apt cache will be refreshed first. By default, no
        refresh is performed.


    CLI Examples:

    .. code-block:: bash

        salt myminion pkg.show gawk
        salt myminion pkg.show 'nginx-*'
        salt myminion pkg.show 'nginx-*' filter=description,provides
    urefreshufiltercS@s)t|tj�stj|�S|j�S(N(R|RRPR�RO(RD((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyR��
su	apt-cacheushowR2cS@sh|jdd�}|jdd�}|dk	rd|dk	rd|j|i�j|i�j|�ndS(NuPackageuVersion(RHRIRR(RVtpkginfoRWR^((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt_add�
sc@s-|j�}|dks�r#tS|�kS(Nupackageuversion(upackageuversion(ROR,(R�(tfilter_(s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt
_check_filter�
sustdoutu
u:i(RRR1tclean_kwargsRHRtsplit_inputtinvalid_kwargsRLR6RbRMRNRR�(RQR3RRR�R�R�RVR�RZRDR�tval((R�s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytshoww
s<
"	#5


c	O@s4tjjj|�}|jdt�}|rCtjjj|�nt�}x�tdd||�j	�D]�\}}t�}x�|j	�D]�\}}|dkr�||d<q�|dkr�||d<q�|dkr�||d	<q�|d
kr�||d<q�|dkr||d
<q�|||<q�W|||<qiW|S(u<
    Return the information of the named package(s) installed on the system.

    .. versionadded:: 2015.8.1

    names
        The names of the packages for which to return information.

    failhard
        Whether to throw an exception if none of the packages are installed.
        Defaults to True.

        .. versionadded:: 2016.11.3

    CLI example:

    .. code-block:: bash

        salt '*' pkg.info_installed <package1>
        salt '*' pkg.info_installed <package1> <package2> <package3> ...
        salt '*' pkg.info_installed <package1> failhard=false
    ufailhardulowpkg.infoRoupackageunameuoriginuvendorusectionugroupu
maintainerupackageruhomepageuurl(
RRR1R�RHR,R�R}R+RB(	RQR3RoRVRtpkg_nfott_nfoR�R<((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pytinfo_installed�
s*	)	




cC@s�d}tdd�}tdd�}tdd�}tdd�}|r�|r�|ry|rydj||||�}q�dj||�}n|S(	u�
    Returns the http_proxy_url if proxy_username, proxy_password, proxy_host, and proxy_port
    config values are set.

    Returns a string.
    uu
config.optionu
proxy_hostu
proxy_portuproxy_usernameuproxy_passworduhttp://{0}:{1}@{2}:{3}uhttp://{0}:{1}(R+R(R^thosttporttusernametpassword((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyRV�
s (wt__doc__t
__future__RRRR�RRltloggingRftsalt.extRtsalt.ext.six.moves.urllib.errorRt!salt.ext.six.moves.urllib.requestRRRRtsalt.configRt
salt.syspathstsalt.modules.cmdmodRtsalt.utils.argstsalt.utils.datatsalt.utils.filestsalt.utils.functoolstsalt.utils.itertoolstsalt.utils.jsontsalt.utils.pathtsalt.utils.pkgtsalt.utils.pkg.debtsalt.utils.stringutilstsalt.utils.systemdtsalt.utils.versionstsalt.utils.yamltsalt.utils.environmenttsalt.exceptionsRR	R
t	getLoggerRGR7t	apt.cacheR�tapt.debfilet
aptsourcesRR,R&tImportErrorRR�R�tsoftwareproperties.ppaRRRdR"Rt	frozensetR[RtPY2RRFtencodeRRRR$R%R'R6R:R]t	functoolstalias_functiontavailable_versionR^RLRIR�R�R�R�R�R�R�R�RKR�R�R�RBR�R
R�RR/R:R=RERFRRRnRpRqRvRzR�R�R�R�R�R�RV(((s7/usr/lib/python2.7/site-packages/salt/modules/aptpkg.pyt<module>s�









						
	
	Z	R��17,,YIJb0	
8		,	=		K	q		HG7�M			8	+i	-	#	T	3

Zerion Mini Shell 1.0