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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlZ	ddl
mZddlmZddlmZddlmZddlmZd	Zeje�Zd
�Zidd6dd
6dd6dd6dd6dd6dd6dd6Zd�Zd�Zed�Z d�Z!e"d�Z#ed�Z$ed �Z%d!�Z&d"�Z'e	j(jj)e'd#�Z*d$�Z+d%�Z,d&�Z-ed'�Z.dedded(�Z0ddd)�Z1d*�Z2dS(+u
IPS pkg support for Solaris

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

This module provides support for Solaris 11 new package management - IPS (Image Packaging System).
This is the default pkg module for Solaris 11 (and later).

If you want to use also other packaging module (e.g. pkgutil) together with IPS, you need to override the ``pkg`` provider
in sls for each package:

.. code-block:: yaml

    mypackage:
      pkg.installed:
        - provider: pkgutil

Or you can override it globally by setting the :conf_minion:`providers` parameter in your Minion config file like this:

.. code-block:: yaml

    providers:
      pkg: pkgutil

Or you can override it globally by setting the :conf_minion:`providers` parameter in your Minion config file like this:

.. code-block:: yaml

    providers:
      pkg: pkgutil

i(tabsolute_importtprint_functiontunicode_literalsN(tstring_types(tCommandExecutionError(tsix(tzip(treduceupkgcC@sItddkr?ttd�dkr?tjjjd�r?tStdfS(u<
    Set the virtual pkg module if the os is Solaris 11
    u	os_familyuSolarisu
kernelreleasegffffff@upkguPThe solarisips execution module failed to load: only available on Solaris >= 11.(t
__grains__tfloattsalttutilstpathtwhicht__virtualname__tFalse(((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyt__virtual__=suCommand succeeded.uAn error occurred.iu,Invalid command line options were specified.iuDMultiple operations were requested, but only some of them succeeded.iu%No changes were made - nothing to do.iu=The requested operation cannot be performed on a  live image.iu�The requested operation cannot be completed because the licenses for the packages being installed or updated have not been accepted.iuHThe image is currently in use by another process and cannot be modified.icC@s!|j�djd�dj�S(uG
    Extracts package name from "pkg list -v" output.
    Input: one line of the command output
    Output: pkg name (e.g.: "pkg://solaris/x11/library/toolkit/libxt")
    Example use:
    line = "pkg://solaris/x11/library/toolkit/libxt@1.1.3,5.11-0.175.1.0.0.24.1317:20120904T180030Z i--"
    name = _ips_get_pkgname(line)
    iu@(tsplittstrip(tline((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyt_ips_get_pkgnameXs	cC@s!|j�djd�dj�S(u\
    Extracts package version from "pkg list -v" output.
    Input: one line of the command output
    Output: package version (e.g.: "1.1.3,5.11-0.175.1.0.0.24.1317:20120904T180030Z")
    Example use:
    line = "pkg://solaris/x11/library/toolkit/libxt@1.1.3,5.11-0.175.1.0.0.24.1317:20120904T180030Z i--"
    name = _ips_get_pkgversion(line)
    iu@i(RR(R((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyt_ips_get_pkgversionds	cC@sEtjjjt�|r-tdd�dkStdd�dkSdS(u1
    Updates the remote repos database.

    full : False

        Set to ``True`` to force a refresh of the pkg DB from all publishers,
        regardless of the last refresh time.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.refresh_db
        salt '*' pkg.refresh_db full=True
    ucmd.retcodeu/bin/pkg refresh --fulliu/bin/pkg refreshN(R
Rtpkgt
clear_rtagt__opts__t__salt__(tfull((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyt
refresh_dbpscC@sid}ddd|g}td|�j�}|s8iSi}x$|D]}t|�|t|�<qEW|S(u�
    Check if there is an upgrade available for a certain package
    Accepts full or partial FMRI. Returns all matches found.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade_available apache-22
    upkgulistu-Huvucmd.run_stdoutN(tNoneRt
splitlinesRR(tnametversiontcmdtlinestretR((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytupgrade_available�s
cK@sltjjj|�r%tdt�ni}tdd�j�}x$|D]}t|�|t	|�<qHW|S(u�
    Lists all packages available for update.

    When run in global zone, it reports only upgradable packages for the global
    zone.

    When run in non-global zone, it can report more upgradable packages than
    ``pkg update -vn``, because ``pkg update`` hides packages that require
    newer version of ``pkg://solaris/entire`` (which means that they can be
    upgraded only from the global zone). If ``pkg://solaris/entire`` is found
    in the list of upgrades, then the global zone should be updated to get all
    possible updates. Use ``refresh=True`` to refresh the package database.

    refresh : True
        Runs a full package database refresh before listing. Set to ``False`` to
        disable running the refresh.

        .. versionchanged:: 2017.7.0

        In previous versions of Salt, ``refresh`` defaulted to ``False``. This was
        changed to default to ``True`` in the 2017.7.0 release to make the behavior
        more consistent with the other package modules, which all default to ``True``.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_upgrades
        salt '*' pkg.list_upgrades refresh=False
    Rucmd.run_stdoutu/bin/pkg list -Huv(
R
Rtdatatis_trueRtTrueRRRR(trefreshtkwargstupgradesR!R((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyt
list_upgrades�s
cK@s�tjjj|�rt�nt�}ddddg}td|dddt�}tj	d	d�t�}tjjj||�}|d
dkr�tdd
i|d6t
|d
d
6|d6��n|S(u�
    Upgrade all packages to the latest possible version.
    When run in global zone, it updates also all non-global zones.
    In non-global zones upgrade is limited by dependency constrains linked to
    the version of pkg://solaris/entire.

    Returns a dictionary containing the changes:

    .. code-block:: python

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

    When there is a failure, an explanation is also included in the error
    message, based on the return code of the ``pkg update`` command.


    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade
    upkguupdateu-vu--acceptucmd.run_alltoutput_loglevelutracetpython_shellu
pkg.list_pkgsuretcodeiu&Problem encountered upgrading packagestinfouchangesuresultN(R
RR$R%Rt	list_pkgsRRt__context__tpopRt
compare_dictsRtips_pkg_return_values(R'R(toldR tresulttnewR"((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytupgrade�s"
	
		
c	K@stgd	D]$}tjjj|j|��^q
�r;iSdtkr}|rUtdStjtd�}t	d|�|Sni}d}t	d|�j
�}x:|D]2}t|�}t|�}t	d|||�q�Wt	d|�tj|�td<|st	d|�n|S(
u�
    List the currently installed packages as a dict::

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

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_pkgs
    uremovedu
purge_desiredu
pkg.list_pkgsupkg_resource.stringifyu/bin/pkg list -Hvucmd.run_stdoutupkg_resource.add_pkgupkg_resource.sort_pkglist(uremovedu
purge_desired(
tanyR
RR$R%tgetR/tcopytdeepcopyRRRR(	tversions_as_listR(txR"R R!RRR((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyR.�s*
1
c@st|�dkrdSdddg}|j|�td|dt�j�}i}x$|D]}t|�|t|�<q[Wtg|D]'�t�fd�|t	�s��^q��}|j
t|tj
d
���t|�d	kryttj|��SWqtk
rdSXn|S(u�
    Common interface for obtaining the version of installed packages.
    Accepts full or partial FMRI. If called using pkg_resource, full FMRI is required.
    Partial FMRI is returned if the package is not installed.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.version vim
        salt '*' pkg.version foo bar baz
        salt '*' pkg_resource.version pkg://solaris/entire

    iuu/bin/pkgulistu-Hvucmd.run_stdouttignore_retcodec@s|p�|kS(N((R<ty(R(s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyt<lambda>>si(u(tlentextendRR&RRRtlistRRtupdateRt	itertoolstcycletnextRt
itervaluest
StopIteration(tnamesR(R R!R"Rt	unmatched((Rs>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyR$s 

:
c@s�t|�dkrdSdddg}|j|�td|dt�j�}i}x$|D]}t|�|t|�<q[Wt|�}t|�dkr�i|t|�dkr�t|�dn|d6}nxA|D]9��|kr�q�n|�|�kr�d|�<q�q�Wtg|D]'�t	�fd	�|t
�s�^q�}|jt|t
jd
���t|�dkr�yttj|��SWq�tk
r�dSXn|S(u�
    The available version of packages in the repository.
    Accepts full or partial FMRI. Partial FMRI is returned if the full FMRI
    could not be resolved.

    If the latest version of a given package is already installed, an empty
    string will be returned for that package.

    Please use pkg.latest_version as pkg.available_version is being deprecated.

    .. versionchanged:: 2019.2.0
        Support for multiple package names added.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.latest_version bash
        salt '*' pkg.latest_version pkg://solaris/entire
        salt '*' pkg.latest_version postfix sendmail
    iuu/bin/pkgulistu-Hnvucmd.run_stdoutR=ic@s|p�|kS(N((R<R>(R(s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyR?ys(u(R@RARR&RRRRRBRRRCRRDRERFRRGRH(RIR(R R!R"Rt	installedRJ((Rs>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytlatest_versionKs0

6
:
uavailable_versioncK@ss|jd�r|Sddd|g}td|�j�}|sEdSg}x!|D]}|jt|��qRW|S(u�
    Returns FMRI from partial name. Returns empty string ('') if not found.
    In case of multiple match, the function returns list of all matched packages.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.get_fmri bash
    upkg://u/bin/pkgulistu-aHvucmd.run_stdoutu(t
startswithRRtappendR(RR(R R!R"R((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytget_fmri�s
cK@s_|jd�r|Sddd|g}td|�j�}t|�dkrQ|St|d�S(u

    Internal function. Normalizes pkg name to full FMRI before running
    pkg.install. In case of multiple matches or no match, it returns the name
    without modifications.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.normalize_name vim
    upkg://u/bin/pkgulistu-aHvucmd.run_stdoutii(RMRRR@R(RR(R R!((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytnormalize_name�scK@s&ddd|g}td|�dkS(u

    Returns True if the package is installed. Otherwise returns False.
    Name can be full or partial FMRI.
    In case of multiple match from partial FMRI name, it returns True.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.is_installed bash
    u/bin/pkgulistu-Hvucmd.retcodei(R(RR(R ((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytis_installed�s
cK@s�i}ddd|g}td|dt�}|ddkrBiSxD|dj�D]2}t|�}t|�}td	|||�qSW|s�td
|�n|S(u�
    Searches the repository for given pkg name.
    The name can be full or partial FMRI. All matches are printed. Globs are
    also supported.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.search bash
    u/bin/pkgulistu-aHvucmd.run_allR=uretcodeiustdoutupkg_resource.add_pkgupkg_resource.stringify(RR&RRR(RR;R(R"R toutRR((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytsearch�s
c
K@sF|st|�riSn|r/tdt�nd}|rg}x�|D]�}t|dt�r�t|j��ddr�|jdjt|j��ddt|j��dd��q�|jt|j��dd�qH|jdj|��qHWt	j
d||�n*|r-dj||�}ndj|�}d	d
ddg}|rd|jd
�nt�}	t|t
�r�|j|�nt|t�r�||}ntd|dd�}
tjdd�t�}tjjj|	|�}|
ddkr8tddi|d6t|
dd6|
dgd6��n|rBdS|S(u~
    Install the named package using the IPS pkg command.
    Accepts full or partial FMRI.

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

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


    Multiple Package Installation Options:

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


    CLI Example:

    .. code-block:: bash

        salt '*' pkg.install vim
        salt '*' pkg.install pkg://solaris/editor/vim
        salt '*' pkg.install pkg://solaris/editor/vim refresh=True
        salt '*' pkg.install pkgs='["foo", "bar"]'
    Ruuitemsiiu{0}@{1}u{0}u+Installing these packages instead of %s: %supkguinstallu-vu--acceptu-nucmd.run_allR+utraceu
pkg.list_pkgsuretcodeu$Error occurred installing package(s)R-uchangesustderruerrorsuTest succeeded.N(RQRR&tgetattrRRBtitemsRNtformattlogtdebugR.t
isinstanceRRR/R0RR
RR$R1RR2(
RR'tpkgsRttestR(tpkg2instRR R3RRR5R"((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytinstall�sT
#!$	
	
	c	K@s�|rtjjj|�n|g}|s.iS|rJtjd||�nt�}dddg|}td|dd�}tj	dd�t�}tjjj||�}|d	d
kr�t
ddi|d
6t|d	d	6|dgd6��n|S(u�
    Remove specified package. Accepts full or partial FMRI.
    In case of multiple match, the command fails and won't modify the OS.

    name
        The name of the package to be deleted.


    Multiple Package Options:

    pkgs
        A list of packages to delete. Must be passed as a python list. The
        ``name`` parameter will be ignored if this option is passed.


    Returns a list containing the removed packages.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.remove <package name>
        salt '*' pkg.remove tcsh
        salt '*' pkg.remove pkg://solaris/shell/tcsh
        salt '*' pkg.remove pkgs='["foo", "bar"]'
    u)Removing these packages instead of %s: %su/bin/pkgu	uninstallu-vucmd.run_allR+utraceu
pkg.list_pkgsuretcodeiu"Error occurred removing package(s)R-uchangesustderruerrorsN(R
Rtargstsplit_inputRWRXR.RR/R0RR$R1RR2(	RRZR(ttargetsR3R RRR5R"((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytremoveMs&$		cK@s
t||�S(u�
    Remove specified package. Accepts full or partial FMRI.

    Returns a list containing the removed packages.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.purge <package name>
    (Ra(RR(((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pytpurge�s(3t__doc__t
__future__RRRR9tloggingRDtsalt.utils.dataR
tsalt.utils.functoolstsalt.utils.pathtsalt.utils.pkgtsalt.ext.sixRtsalt.exceptionsRtsalt.extRtsalt.ext.six.movesRt	functoolsRRt	getLoggert__name__RWRR2RRRRR#R&R*R6R.RRLRtalias_functiontavailable_versionRORPRQRSRR]RaRb(((s>/usr/lib/python2.7/site-packages/salt/modules/solarisipspkg.pyt<module>%sT	

			)4)	'	<			];

Zerion Mini Shell 1.0