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

�
���^c@@s[dZddlmZmZmZddlZddlZddlZddlZddl	Z
ddlZ
ddlZ
ddl
mZddlmZmZddlmZeje�ZdZd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zed�Z d�Z!d�Z"e#e#d�Z$e#d�Z%e#d�Z&d�Z'd�Z(dS(u�
Install software from the FreeBSD ``ports(7)`` system

.. versionadded:: 2014.1.0

This module allows you to install ports using ``BATCH=yes`` to bypass
configuration prompts. It is recommended to use the :mod:`ports state
<salt.states.freebsdports>` to install ports, but it is also possible to use
this module exclusively from the command line.

.. code-block:: bash

    salt minion-id ports.config security/nmap IPV6=off
    salt minion-id ports.install security/nmap
i(tabsolute_importtunicode_literalstprint_functionN(tstring_types(tSaltInvocationErrortCommandExecutionError(tsixuportscC@stddkrtStdfS(u&
    Only runs on FreeBSD systems
    uosuFreeBSDuVThe freebsdports execution module cannot be loaded: only available on FreeBSD systems.(t
__grains__t__virtualname__tFalse(((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyt__virtual__'scC@s3dg}ttd�dkr/|jd�n|S(uN
    Return 'portsnap --interactive' for FreeBSD 10, otherwise 'portsnap'
    uportsnapu	osreleasei
u
--interactive(tfloatRtappend(tret((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyt	_portsnap1s	cC@swt|t�sd|kr4tdj|���ntjjd|�}tjj|�sstdj|���n|S(uc
    Check if portname is valid and whether or not the directory exists in the
    ports tree.
    u/u+Invalid port name '{0}' (category required)u
/usr/portsuPath '{0}' does not exist(t
isinstanceRRtformattostpathtjointisdir(tnameR((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyt_check_portname;scC@smt|�d}tjj||jdd��}tjj||jd�d�}tjj|�ri|S|S(uO
    Retrieve the path to the dir containing OPTIONS file for a given port
    u
/var/db/portsu/u_i����(RRRRtreplacetsplitR(Rt_roottnew_dirtold_dir((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyt_options_dirLs
!"cC@s%tjjtjjt|�d��S(uh
    Returns True/False based on whether or not the options file for the
    specified port exists.
    uoptions(RRtisfileRR(R((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyt_options_file_exists]sc

C@sVt|�tt|��}||}t|�}tjj|�s�ytj|�Wq�tk
r�}t	dj
||���q�Xntjj
jtjj|d�d���}t|�}|j�|jtjjjdj
|dj|����d}xL|D]D}	|jtjjj|j
||	dkr8dnd	|	���qWWd
QXd
S(u#
    Writes a new OPTIONS file
    uUnable to make {0}: {1}uoptionsuwu�# This file was auto-generated by Salt (http://saltstack.com)
# Options for {0}
_OPTIONS_READ={0}
_FILE_COMPLETE_OPTIONS_LIST={1}
u uOPTIONS_FILE_{0}SET+={1}
uonuuUNN(RtnexttiterRRRRtmakedirstOSErrorRRtsalttutilstfilestfopenRtlisttsorttwritetstringutilstto_str(
Rt
configurationtpkgtconf_ptrtdirnametexctfp_tsorted_optionstopt_tmpltopt((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyt_write_optionses,

*

cC@s0t|t�r|rdSdStj|�j�S(u�
    Fix Salt's yaml-ification of on/off, and otherwise normalize the on/off
    values to be used in writing the options file
    uonuoff(RtboolRt	text_typetlower(tval((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyt
_normalize�scC@s:t|�}td�}|j|jd�d�rBt|�nddg}|rd|jd�n|jd�td|d	|d
tdt�}|dd
kr�|dtd<ntjdd�td�}t
jjj
||�}|r6|dd
kr6ii|j|d�d6|j|d�d6|6}n|S(u�
    Install a port from the ports tree. Installs using ``BATCH=yes`` for
    non-interactive building. To set config options for a given port, use
    :mod:`ports.config <salt.modules.freebsdports.config>`.

    clean : True
        If ``True``, cleans after installation. Equivalent to running ``make
        install clean BATCH=yes``.

    .. note::

        It may be helpful to run this function using the ``-t`` option to set a
        higher timeout, since compiling a port may cause the Salt command to
        exceed the default timeout.

    CLI Example:

    .. code-block:: bash

        salt -t 1200 '*' ports.install security/nmap
    u
pkg.list_pkgsu/i����umakeuinstallucleanu	BATCH=yesucmd.run_alltcwdtreset_system_localetpython_shelluretcodeiustderruports.install_erroruuoldunewN(Rt__salt__tgettrsplitt	deinstallRR	t__context__tpoptNoneR#R$tdatat
compare_dicts(RtcleantportpathtoldtcmdtresulttnewR
((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pytinstall�s,


	
cC@sqt|�}td�}tddddgd|dt�}tjdd�td�}tjjj	||�S(	ux
    De-install a port.

    CLI Example:

    .. code-block:: bash

        salt '*' ports.deinstall security/nmap
    u
pkg.list_pkgsucmd.run_allumakeu	deinstallu	BATCH=yesR;R=N(
RR>R	RBRCRDR#R$RERF(RRHRIRKRL((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyRA�s

	
cC@s,t|�}tdddgd|dt�S(u�
    Clear the cached options for the specified port; run a ``make rmconfig``

    name
        The name of the port to clear

    CLI Example:

    .. code-block:: bash

        salt '*' ports.rmconfig security/nmap
    ucmd.runumakeurmconfigR;R=(RR>R	(RRH((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pytrmconfig�s

c	C@s4t|�}|r�t|�r�t|dtdt�}t|�t|�r[td��nt|dtd|�}t||�|SyYtdddgd|dt�}|d	j	�}|d
dkr�|d}nd
}Wnt
k
r�|}nX|r+dj||�}	tj
|	�t|	��n|s>dj|�S|sUd|dkrYiSy!|dj�djd�}
Wn3ttt
fk
r�}tj
dj|��iSXii|
6}|d}xX|D]P}
y%tjd|
�j�\}}}Wntk
rq�nX|||
|<q�W||
s0iS|S(u�
    Show the configuration options for a given port.

    default : False
        Show the default options for a port (not necessarily the same as the
        current configuration)

    dict_return : False
        Instead of returning the output of ``make showconfig``, return the data
        in an dictionary

    CLI Example:

    .. code-block:: bash

        salt '*' ports.showconfig security/nmap
        salt '*' ports.showconfig security/nmap default=True
    tdefaulttdict_returnu#Unable to get default configurationucmd.run_allumakeu
showconfigR;R=ustdouturetcodeiustderruu,Error running 'make showconfig' for {0}: {1}u
uconfiguration optionsi����u:u%Unable to get pkg-version string: {0}iu\s+([^=]+)=(off|on): (.+)(RRt
showconfigR	tTrueRNRR5R>t
splitlinest	TypeErrorRtlogterrorRRRtrstript
IndexErrortAttributeErrortretmatchtgroups(RRORPRHtsaved_configtdefault_configRKtoutputRVtmsgR-R0R
tlineR4R9tdesc((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyRQ�s`
	
	





!




c@s�t|�}|rt|�nt|dt�}|sOtdj|���ntt|��}||�t�fd��D��}g|D]}|�kr�|^q�}|r�t	dj|dj
|����ngtj|�D]*\}}	|	dkr�dj||	�^q�}
|
r=t	d	jdj
|
����n�j
|�t||�t|dt��y�tt����Wnttfk
r�tSXt��fd
��D��S(u
    Modify configuration options for a given port. Multiple options can be
    specified. To see the available options for a port, use
    :mod:`ports.showconfig <salt.modules.freebsdports.showconfig>`.

    name
        The port name, in ``category/name`` format

    reset : False
        If ``True``, runs a ``make rmconfig`` for the port, clearing its
        configuration before setting the desired options

    CLI Examples:

    .. code-block:: bash

        salt '*' ports.config security/nmap IPV6=off
    RPu*Unable to get port configuration for '{0}'c3@s=|]3}|jd�stj|�t�|�fVqdS(u_N(t
startswithRR7R:(t.0tx(tkwargs(s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pys	<genexpr>hsu2The following opts are not valid for port {0}: {1}u, uonuoffu{0}={1}u.The following key/value pairs are invalid: {0}c3@s(|]}�|�j|�kVqdS(N(R?(RdRe(R.t
new_config(s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pys	<genexpr>�s(uonuoff(RRNRQRRRRRR tdictRRRt	iteritemstupdateR5t
StopIterationRTR	tall(RtresetRfRHR,R-toptsRetbad_optstytbad_vals((R.RfRgs=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pytconfigDs>


%$

cC@s�tdt�dgdt�}|ddksLtdj|d���ng}y#tjd|d	�jd
�}Wntk
r�d}nXy#tjd|d	�jd
�}Wntk
r�d}nX|j	dj|��|j	d
j|��|rMtdt�dgdt�}|ddksMtdj|d���qMntdt�dgdt�}|ddks�tdj|d���nt
jdd�dj
|�S(u
    Update the ports tree

    extract : False
        If ``True``, runs a ``portsnap extract`` after fetching, should be used
        for first-time installation of the ports tree.

    CLI Example:

    .. code-block:: bash

        salt '*' ports.update
    ucmd.run_allufetchR=uretcodeiu#Unable to fetch ports snapshot: {0}ustderruFetching (\d+) patchesustdoutiu!Fetching (\d+) new ports or filesuApplied {0} new patchesuFetched {0} new ports or filesuextractu$Unable to extract ports snapshot {0}uupdateu#Unable to apply ports snapshot: {0}uports.list_allu
N(R>RR	RRRZtsearchtgroupRYRRBRCRDR(textractRKR
tpatch_counttnew_port_count((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyRj�sH	





		cC@s�dtkr�gtd<xxtjjjd�D]^\}}}|td�}|jd�dks,|jd�ruq,ntdj|d�q,WntdS(u�
    Lists all ports available.

    CLI Example:

    .. code-block:: bash

        salt '*' ports.list_all

    .. warning::

        Takes a while to run, and returns a **LOT** of output
    uports.list_allu
/usr/portsu/iu/CVSi(	RBR#R$Rtos_walktlentcounttendswithR(RtdirsR%tstripped((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pytlist_all�s
%$cC@s�tj|�}t�}d|kr[|jd�dkrHtd��q�tj||�SnJg}x=|D]5}tj|jd�d|�rh|j|�qhqhW|SdS(u=
    Search for matches in the ports tree. Globs are supported, and the category
    is optional

    CLI Examples:

    .. code-block:: bash

        salt '*' ports.search 'security/*'
        salt '*' ports.search 'security/n*'
        salt '*' ports.search nmap

    .. warning::

        Takes a while to run
    u/iuGInvalid search string '{0}'. Port names cannot have more than one slashi����N(	RR7R~RzRtfnmatchtfilterR@R(Rt	all_portsR
tport((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyRs�s	
()t__doc__t
__future__RRRRRRZtloggingtsalt.utils.dataR#tsalt.utils.filestsalt.utils.pathtsalt.ext.sixRtsalt.exceptionsRRtsalt.extRt	getLoggert__name__RURR
RRRRR5R:RRRMRARNR	RQRrRjR~Rs(((s=/usr/lib/python2.7/site-packages/salt/modules/freebsdports.pyt<module>s8	
	
				&	
3		QF@	

Zerion Mini Shell 1.0