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

�
���^c@@s~dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlm
Z
mZddlmZeje�ZdZd�Zddd�Zd	�Zd
�Ze	jjjed�Zd�Zd
�Ze e d�Z!de dddd�Z"ddd�Z#e	jjje#d�Z$e	jjje#d�Z%d�Z&d�Z'd�Z(dS(u\
Remote package support using ``pkg_add(1)``

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

.. warning::

    This module has been completely rewritten. Up to and including version
    0.17.0, it supported ``pkg_add(1)``, but checked for the existence of a
    pkgng local database and, if found,  would provide some of pkgng's
    functionality. The rewrite of this module has removed all pkgng support,
    and moved it to the :mod:`pkgng <salt.modules.pkgng>` execution module. For
    versions <= 0.17.0, the documentation here should not be considered
    accurate. If your Minion is running one of these versions, then the
    documentation for this module can be viewed using the :mod:`sys.doc
    <salt.modules.sys.doc>` function:

    .. code-block:: bash

        salt bsdminion sys.doc pkg


This module acts as the default package provider for FreeBSD 9 and older. If
you need to use pkgng on a FreeBSD 9 system, you will need to override the
``pkg`` provider by setting the :conf_minion:`providers` parameter in your
Minion config file, in order to use pkgng.

.. code-block:: yaml

    providers:
      pkg: pkgng

More information on pkgng support can be found in the documentation for the
:mod:`pkgng <salt.modules.pkgng>` module.

This module will respect the ``PACKAGEROOT`` and ``PACKAGESITE`` environment
variables, if set, but these values can also be overridden in several ways:

1. :strong:`Salt configuration parameters.` The configuration parameters
   ``freebsdpkg.PACKAGEROOT`` and ``freebsdpkg.PACKAGESITE`` are recognized.
   These config parameters are looked up using :mod:`config.get
   <salt.modules.config.get>` and can thus be specified in the Master config
   file, Grains, Pillar, or in the Minion config file. Example:

   .. code-block:: yaml

        freebsdpkg.PACKAGEROOT: ftp://ftp.freebsd.org/
        freebsdpkg.PACKAGESITE: ftp://ftp.freebsd.org/pub/FreeBSD/ports/ia64/packages-9-stable/Latest/

2. :strong:`CLI arguments.` Both the ``packageroot`` (used interchangeably with
   ``fromrepo`` for API compatibility) and ``packagesite`` CLI arguments are
   recognized, and override their config counterparts from section 1 above.

   .. code-block:: bash

        salt -G 'os:FreeBSD' pkg.install zsh fromrepo=ftp://ftp2.freebsd.org/
        salt -G 'os:FreeBSD' pkg.install zsh packageroot=ftp://ftp2.freebsd.org/
        salt -G 'os:FreeBSD' pkg.install zsh packagesite=ftp://ftp2.freebsd.org/pub/FreeBSD/ports/ia64/packages-9-stable/Latest/

    .. note::

        These arguments can also be passed through in states:

        .. code-block:: yaml

            zsh:
              pkg.installed:
                - fromrepo: ftp://ftp2.freebsd.org/
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortMinionError(tsixupkgcC@s�tddkr�ttd�dkr�i}dtkrEtd}n|r~d|kr~|ddkr~tjd�td	fStStd
fS(u�
    Load as 'pkg' on FreeBSD versions less than 10.
    Don't load on FreeBSD 9 when the config option
    ``providers:pkg`` is set to 'pkgng'.
    uosuFreeBSDu	osreleasei
u	providersupkgupkgngu]Configuration option 'providers:pkg' is set to 'pkgng', won't load old provider 'freebsdpkg'.ulThe freebsdpkg execution module cannot be loaded: the configuration option 'providers:pkg' is set to 'pkgng'urThe freebsdpkg execution module cannot be loaded: either the os is not FreeBSD or the version of FreeBSD is >= 10.(t
__grains__tfloatt__opts__tlogtdebugtFalset__virtualname__(t	providers((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pyt__virtual___s&
"

cC@s�|dk	r|ntddd�}|dk	r7|ntddd�}i}|dk	ri||d<n|dk	r�||d<n|S(u
    Return a list of tuples to seed the "env" list, which is used to set
    environment variables for any pkg_add commands that are spawned.

    If ``fromrepo`` or ``packagesite`` are None, then their corresponding
    config parameter will be looked up with config.get.

    If both ``fromrepo`` and ``packagesite`` are None, and neither
    freebsdpkg.PACKAGEROOT nor freebsdpkg.PACKAGESITE are specified, then an
    empty list is returned, and it is assumed that the system defaults (or
    environment variables) will be used.
    u
config.getufreebsdpkg.PACKAGEROOTufreebsdpkg.PACKAGESITEuPACKAGEROOTuPACKAGESITEN(tNonet__salt__(tfromrepotpackagesitetroottsitetret((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pyt_get_repo_optionsqs


c

C@s�tdt�}g}g}tddgdddt�}xF|j�D]8}y|j|j�d�WqGtk
r~qGqGXqGWg|D]}||kr�|^q�}g}g}	x�t|�t|�D]�}
|j	|
�}|d
k	r�t|�dkr|jd	j|
|d��qo|	j|
�|jd
j|
dj
g|D]}d	j|
|�^qG���q�q�Wt|�t|�t|�t|	�}x$|D]}
|jdj|
��q�W|||fS(u/
    Since pkg_delete requires the full "pkgname-version" string, this function
    will attempt to match the package name with its version. Returns a list of
    partial matches and package names that match the "pkgname-version" string
    required by pkg_delete, and a list of errors encountered.
    tversions_as_listucmd.run_stdoutupkg_infotoutput_loglevelutracetpython_shelliiu{0}-{1}uJAmbiguous package '{0}'. Full name/version required. Possible matches: {1}u, uPackage '{0}' not foundN(t	list_pkgstTrueRRt
splitlinestappendtsplitt
IndexErrortsettgetRtlentformattjoin(
tnamestpkgsterrorstfull_pkg_stringstouttlinetxtfull_matchestmatchest	ambiguoustnametcvertnot_matched((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pyt_match�s8	
% 
9*
cO@s*t|�dkrdStd�|D��S(ua
    ``pkg_add(1)`` is not capable of querying for remote packages, so this
    function will always return results as if there is no package available for
    install or upgrade.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.latest_version <package name>
        salt '*' pkg.latest_version <package1> <package2> <package3> ...
    iucs@s|]}|dfVqdS(uN((t.0R+((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pys	<genexpr>�s(R"tdict(R%tkwargs((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pytlatest_version�s
uavailable_versioncO@s�|jdt�}td||�}tjjj|�s>|St|�dkrdi||d6}ntj	di�}t
gtj|�D]2\}}|i|j	|d�d6|d6f^q��S(	u

    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.

    with_origin : False
        Return a nested dictionary containing both the origin name and version
        for each specified package.

        .. versionadded:: 2014.1.0


    CLI Example:

    .. code-block:: bash

        salt '*' pkg.version <package name>
        salt '*' pkg.version <package1> <package2> <package3> ...
    uwith_originupkg_resource.versioniiu
pkg.originuuoriginuversion(
tpopRRtsalttutilstdatatis_trueR"t__context__R!R4Rt	iteritems(R%R5twith_originRtoriginsR+ty((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pytversion�scC@stjjjt�tS(u�
    ``pkg_add(1)`` does not use a local database of available packages, so this
    function simply returns ``True``. it exists merely for API compatibility.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.refresh_db
    (R8R9tpkgt
clear_rtagRR(((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pyt
refresh_db�sc
K@s^tjjj|�}tgdD]$}tjjj|j|��^q�rPiSdtkr�tjtd�}|s�t	d|�ntjjj|�r�tjdi�}t
gtj|�D]2\}}|i|j|d�d6|d6f^q��S|Si}i}t	d	d
dgdd
dt
�}tjd�}xz|j|�D]i\}	}
|	sbqJny|	jdd�\}}Wntk
r�qJnXt	d|||�|
||<qJWt	d|�tj|�td<|td<|s�t	d|�ntjjj|�rZt
gtj|�D]2\}}|i|j|d�d6|d6f^q!�S|S(u`
    List the packages currently installed as a dict::

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

    with_origin : False
        Return a nested dictionary containing both the origin name and version
        for each installed package.

        .. versionadded:: 2014.1.0

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_pkgs
    uremovedu
purge_desiredu
pkg.list_pkgsupkg_resource.stringifyu
pkg.originuuoriginuversionucmd.run_stdoutupkg_infou-aoRutraceRu,Information for ([^:]+):\s*Origin:\n([^\n]+)u-iupkg_resource.add_pkgupkg_resource.sort_pkglist(uremovedu
purge_desired(R8R9R:R;tanyR!R<tcopytdeepcopyRR4RR=Rtretcompiletfindalltrsplitt
ValueError(
RR>R5R+RR?R@R)tpkgs_reRBtorigintpkgnametpkgver((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pyRsN1F	

Fc	K@s�y#td||||�\}}Wntk
rD}t|��nX|sOiS|jd�}	|rt|	rt|	}nt||jd��}
g}|dkr�|jd�n|j|�t�}tddg|d|
d	d
dt�}
|
dd
kr|
dr|
dg}ng}t	j
dd�t�}t�t
jjj||�}|r~tddi|d6|d6��n|S(u�
    Install package(s) using ``pkg_add(1)``

    name
        The name of the package to be installed.

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

    fromrepo or packageroot
        Specify a package repository from which to install. Overrides the
        system default, as well as the PACKAGEROOT environment variable.

    packagesite
        Specify the exact directory from which to install the remote package.
        Overrides the PACKAGESITE environment variable, if present.


    Multiple Package Installation Options:

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

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install pkgs='["foo", "bar"]'

    sources
        A list of packages to install. Must be passed as a list of dicts,
        with the keys being package names, and the values being the source URI
        or local path to the package.

        CLI Example:

        .. code-block:: bash

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

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

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

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.install <package name>
    upkg_resource.parse_targetsupackagerootupackagesiteu
repositoryu-rucmd.run_allupkg_addtenvRutraceRuretcodeiustderru
pkg.list_pkgsu)Problem encountered installing package(s)tinfouerrorsuchangesN(RRRR!RRtextendRRR<R7Rt_rehashR8R9R:t
compare_dicts(R/trefreshRR&tsourcesR5t
pkg_paramstpkg_typetexctpackagerootRQtargstoldR)R'tnewR((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pytinstallBsB:
	
	
		c
K@sDytd||�d}Wntk
r<}t|��nXt�}tg|D]}|^qP�\}}x|D]}	tj|	�qrW|s�iStddg|dddt�}
|
ddkr�|
d	r�|
d	g}ng}tj	d
d�t�}tjj
j||�}|r@tddi|d
6|d6��n|S(u6
    Remove packages using ``pkg_delete(1)``

    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"]'
    upkg_resource.parse_targetsiucmd.run_allu
pkg_deleteRutraceRuretcodeustderru
pkg.list_pkgsu'Problem encountered removing package(s)RRuerrorsuchangesN(RRRRR2R	terrorRR<R7RR8R9R:RU(
R/R&R5RXRZR]R+ttargetsR'R`R)R^R((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pytremove�s2	%

		udeleteupurgecC@sDtdd�}|jd�ddkr@tddd	d
�ndS(
u�
    Recomputes internal hash table for the PATH variable. Use whenever a new
    command is created during the current session.
    uenviron.getuSHELLu/i����ucshutcshu	cmd.shellurehashRutraceN(ucshutcsh(RR(tshell((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pyRT�scG@sKt|�}g}x(tj|d�D]}|j|�q&W||d<|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
    ufiles(t	file_dictRt
itervaluesRS(tpackagesRtfilest	pkg_files((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pyt	file_list�s
cG@sHg}i}|rGd}ddgg|D]}|j|�^q(}nddg}td|dddt�}x%|d	j�D]}|j|�q�Wd}x�|d
j�D]�}|dk	r�|jd�r�||j|�q�d|kr�|jd
d�\}}	|jdd�\}}
|	g||<q�q�q�Wi|d6|d6S(uj
    List the files that belong to a package, grouped by package. Not
    specifying any packages will return a list of _every_ file on the
    system's package database (not generally recommended).

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.file_list httpd
        salt '*' pkg.file_list httpd postfix
        salt '*' pkg.file_list
    u'{0}-[0-9]*'upkg_infou-QLu-QLaucmd.run_allRutraceRustderrustdoutu/u:/u:iu-uerrorsufilesN(	R#RRRRRt
startswithRRK(RfR'Rgt
match_patterntptcmdRR*RBtfntver((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pyRds*/
	()t__doc__t
__future__RRRRFtloggingRHtsalt.utils.dataR8tsalt.utils.functoolstsalt.utils.pkgtsalt.exceptionsRRtsalt.extRt	getLoggert__name__R	RRRRR2R6R9t	functoolstalias_functiontavailable_versionRARDRRR_RbtdeletetpurgeRTRiRd(((s;/usr/lib/python2.7/site-packages/salt/modules/freebsdpkg.pyt<module>Js<		1		"	Af?	
	

Zerion Mini Shell 1.0