%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/archive.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlmZddlmZddlmZddlZddlZddlZddlZddlZddlZddlmZm Z ej!e"�Z#d	�Z$d
�Z%d�Z&d�Z'd
�Z(dd�Z*d�Z+d�Z,d�Z-dde.e.ddde.e.e.ddde.de/e/ddd�Z0dS(u0
Extract an archive

.. versionadded:: 2014.1.0
i(tabsolute_importtprint_functiontunicode_literalsN(tclosing(tsix(tshlex_quote(turlparse(tCommandExecutionErrortCommandNotFoundErrorcC@s=|dkrtSytjj|�SWntk
r8tSXdS(u�
    Return a bool telling whether or ``path`` is absolute. If ``path`` is None,
    return ``True``. This function is designed to validate variables which
    optionally contain a file path.
    N(tNonetTruetostpathtisabstAttributeErrortFalse(R((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt_path_is_abs%s
cC@s6|r|dcd7<n|r2|dcd7<ndS(uq
    Common code to add additional explanation to the state's comment field,
    both when test=True and not
    ucommentu, due to source_hash updateu*, due to absence of one or more files/dirsN((trettsource_hash_triggertcontents_missing((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt_add_explanation4scC@s/itjjj|dtd�d6tdd6S(Ntformu	hash_typeuhsum(tsalttutilst	hashutilstget_hasht__opts__(R((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt
_gen_checksum?s#cC@sQyrdjtjj|td�df�}tjd|�rqtjjjdtjj	|�dj
d��}nWn�tk
r}tj
|�jd�r�tjj	|�\}}tjjjd|jd	�|j
d��}qt|�jd
�rtjjjd|�}q�nXtjjjtdd|�}tjd
||�|S(Nu.ucachediruhashu..[/\\]ulocali����u/\u
path is onu:uCannot mix UNCuuncuarchive_hashu1Using checksum file %s for cached archive file %s(tjoinRRtrelpathRtretmatchRRt
splitdrivetlstript
ValueErrorRt	text_typet
startswithtrstriptstrtlogtdebug(RRtexctdriveR((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt_checksum_file_pathDs&()cC@s
t|�}tjj|�}tjj|�s@tj|�nt|�}|jd�}|jd�}|r	|r	g}yOystj	j
j|d��U}xK|D]C}y&|j|j
d�jdd��Wq�tk
r�q�q�Xq�WWdQXWn1ttfk
r%}	|	jtjkr&�q&nXtj	j
j|d���}xA|D]9}|d|krk||d<n|jd	j|��qHW|g|D]}
|
d^q�kr�|jd	j||��nWdQXWq	ttfk
r}	tjd
||	j�dt�q	XndS(Nu	hash_typeuhsumuru
u:iuwiu{0}:{1}
u$Failed to update checksum for %s: %stexc_info(R+RRtdirnametisdirtmakedirsRtgetRRtfilestfopentappendR%tsplitR"tIOErrortOSErrorterrnotENOENTtwritetformatR'twarningt__str__R
(Rt
checksum_filetchecksum_dirt
source_sumt	hash_typethsumtlinestfp_tlineR)tx((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt_update_checksum_s>
&



#&cC@s�|dkrtd}nt|�}yktjjj|d��M}xC|D]7}|jd�jdd�\}}||krJPqJqJWdSWdQXWnt	t
tfk
r�dSXi|d6|d6SdS(Nu	hash_typeuru
u:iuhsum(R	RR+RRR1R2R%R4R5R6R"(RRR=RCRDR@RA((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt_read_cached_checksum�s

!cC@s,t|d|jdtd��}||kS(NRu	hash_type(RGR0R(tcachedR?t
cached_sum((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt_compare_checksum�scC@s dtdddgdt�kS(Nubsdtarucmd.runutaru	--versiontpython_shell(t__salt__R(((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt
_is_bsdtar�scC@s)ytj|�Wntk
r$nXdS(u3
    Attempt to remove the specified directory
    N(RtrmdirR6(tname((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt_cleanup_destdir�s
cT'K@s�i|d6td6id6dd6}tjjj|�}d|koLd|kr�|jdg�jd	�t|jd��}|jd�nNd|kr�t|jd��}n*d|kr�t|jd��}nt	}t
|�rd
j|�|d<|Snc|rd|d<|Sn|jt
j�}t
jj|�rXdj|�|d<|Sn|t
j7}t
|�r�d
|d<|Snt
|�r�d|d<|Snr|tk	ry)t
jj||�jdt
j�}Wntk
r�t	}nX|rdj|�|d<|Snn|tk	o.t
jj|�rUt	|d<dj|�|d<|Sn|p^|
rtjjj�r�d|d<|Sn|r�td|�}|dkr�dj|�|d<|Snnd}|
rtd|
�}|dkrdj|
�|d<|Snnd}n
d}}|o%|rD|jdg�jd�nytd||t�d}Wn.tk
r�}t|d<|j|d<|SnX|r�t|d<dj|�|d<|Snt|�}|j}t
jj|j|j�jt
j�}|o|j �t!j"kr3dj||g�}d}n|p?|j} |tjj#j$k}!|!r�t
jj%t
jj&|��}t
jj|�r�djtjj'j(|��|d<|Snndd d!f}"|rtjj#j)| �}|tkrd"jd#j|"��|d<|Snny|j �}Wnt*k
r:nX||"krmd$j|d#j|"��|d<|Sn|tk	o�t+|t,j-�r�t,j.|�}nt}#|o�|dkr�y%t/t0j1d%|�j2d&��}#Wnt*t3fk
r�nXn|d!kr�|rp|tkr/t4j5d'|�t	}n|rGd(|d<|Sn|rmd)tkrjd*|d<|Snnn|r�|tkr�t4j5d+|�t}n"|r�|jdg�jd,�nnn|r�d-|d<|Sn|d krd.tkrd/|d<|Snndd!f}$|o!||$krGd0jd#j|$��|d<|Sn|r�|t	krbd1}nNt+|tt,j6f�r�yt/|�}Wnt7k
r�d2|d<|SnXnn|ry)td3d4|d5|d6|d7t�}%Wn$tk
r}|j|d<|SnXni}%|!r!|}&nLt8d8r^t|d<d9jtjj'j(|��|d<|Snd:t9kr�d;jtjj'j(|��|d<|Sny,t9d:|d5|d6|d<|d7t�}'WnUtk
r	}d=jtjj'j(|�|j:��}(t4j;|(�|(|d<|SnXt4j<d>|'�|'drJ	td?|d7t�}&n#t4j<d@tjj'j(|��|'St=|&�})|o�	|o�	|r�	t>|&�n|d!ko�	|r"
t4j<dA|�y tdB|&dCtd7t�}*Wntk
r�	n0X|*r
dDjtjj'j(|��|d<|Snny2tdE|&dF|dG|dH|#dCtdIt	�}+Wn�tk
r3}t}+g},|r�
|,jdJ�n|o�
|p�
|
r�
|,jdK�n|j}(|,r"|(dL7}(|dkr�
|(dM7}(n
|(dN7}(|(dOj|�7}(x!|,D]}-|(dPj|-�7}(qWn|(|d<|SnX|oo|+tk	oot?|+dQ�d&kpot?|+dR�dkr�dSj|t
jj|dT�|�|d<|Sn|
}.t}/yt
jj|�}0Wnt7k
r�t}0nX|0r2|+tkr[yt
j@|�t}.WnNtAk
rW}|jBtBjCkr4t	}.n dUj||j:��|d<|SnXn�g}1x|+dVtDjEf|+dWdX�f|+dYtDjFffD]�\}2}3x�|2D]�}4tjjj||4�}5y?t
j@|5jt
j��jG}6|3|6�r
|1j|4�nWn]tAk
rg
}|jBtBjCkr;
t	}.t	}/n)|jBtBjHkrd
|j:�|d<|SnnXq�Wq�W|1r/dLdZjg|1D]}7d[j|7�^q�
�}8d\j|�|d<t8d8o�
|o�
|+tk	r�
t|d<|dcd]j|8�7<|Sn|o
|+tk	r,|	r8|dcd^j|8�7<|Sn�g},x�|1D]�}4t
jj||4�}5yFtjj#jI|5jt
j��|djd_g�j|5�t	}.Wn;tAk
r�}|jBtBjCkr�|,j|j:��nnXqEW|,r)d`}(x!|,D]}-|(dPj|-�7}(q�W|(|d<|Snnnn|.oX|oX|)tk	oXtJ|&|)�rjt	}.t	}9nt}9t}:|.rW|!o�|o�|r�tda||%db�|d<|dr�dcjtjj'j(|�|%db�|d<|Snnt8d8r]t|d<ddjtjj'j(|�|�|d<|o0|+tk	rF|dcde7<ntK||9|/�|Sn|ol|+tk	r�g},t4j<df|�x�|+dQ|+dRD]�}4t
jj||4�}5yPt4j<dg|5�tjj#jI|5jt
j��|djd_g�j|5�Wn;tAk
r@}|jBtBjCkr=|,j|j:��nnXq�W|,r�dh}(x!|,D]}-|(dPj|-�7}(qXW|(|d<|Snnt
jjL|�r�t9di|dj|dkt	�t	}:nt4j<dl|&|�y[|d!krt|rCy,td)|&|dG|dm|dn||�};Wn*ttMfk
r?}|j|d<|SnXn.tdo|&|dG|dm|dn|dp||�};n�|d kr�y td.|&|dm||�};Wn*ttMfk
r�}|j|d<|SnXn\|tkr�y`tNtOjP|&dq���B}<|<jQtjjRjS|��|<jT�};|r5|;| };nWdrQXWnLtOjUk
r�tjjjVds�r\tdtdsdu|&gdvtdwt	�dkr.t4j<dx�dy}=tdz|=jtW|&��d{|dvt	�}>|>d|dkr|:r�tX|�nt|d<|>|d<|SntY�r!|>d}};n
|>d~};n+|:rAtX|�nt|d<d|d<|Sn+|:rotX|�nt|d<d�|d<|SnXn�tjjjVd�r�d�|d<|SntZj[|�}?dg}@d�}Ag}Bx�t\|?�D]{\}C}D|Djd��r|Bj|D�nP|Cdkr-|Bj|D�n4|D}E|Ej]d�d�}E|Ej]d�d�}E|A|E}Aq�Wt^d�j �d�kr�d�|A}An|@j|A�|@j_|B�|@j_d�|&g�tdz|@d{|dvt�}>|>d|dkr�t|d<|>|d<|SntY�r|>d}};n
|>d~};|;r,d�};nWn$tk
rS}|j|d<|SnXng}Fg}G|pl|
r�|r�t
jjL|�r�|g}Hg}Ig}Jng}H|g}Ig}Jn-|+tk	r�|+dQ}H|+dR}I|+d�}Jng}K|r|Kjd��n|
r|Kjd��nd#j|K�}Lt`gd�|fd�|
ffD]\}7}M|Mr_|7|Mf^qA�}Nx|HD]}Ot
jj||O�}5t
jjL|5�r�t8d8r�|Fj|5�nn�t4j<d�|L|Ot8d8r�d�nd�t9di|5dj|d�|
d�|K�}Pt4j<d�|P�|Pjad�r3t	|dd�<ny|PdrQ|Gj|5�nWn*tbt7fk
r~t4jcd�|P|O�nXqoWx'|I|JD]}Qt
jj||Q�}5yt
j@|5�}RWnPtAk
r}t8d8r|jBtBjCkr�|Fj|5�n|Gj|5�nn�X|dko'||RjdkpB|dkoB||Rjekr�t8d8r`t	|dd�<nFy%t
jf|5||�t	|dd�<WntAk
r�|Gj|Q�nXnq�Wn|.rat?|;�dkr2|:r�|g|dd�<n|;|dd�<d�jtjj'j(|�|�|d<tK||9|/�t	|d<n,t|d<d�jtjj'j(|��|d<nmt	|d<|0r�d�j|�|d<n
d�|d<t8d8r�|djad��r�t|d<|dcd�7<nn|Fr%|r�t|d<n|dcd�7<x'|FD]}S|dcdPj|S�7<q�Wn|Grrt|d<|dcd�7<x'|GD]}S|dcdPj|S�7<qLWn|!r�|r�t4j<d�|&�nQt4j<d�|&�t9d�|d7t�}'|'dr�|jdg�j|'d�nn|S(�u�M
    .. versionadded:: 2014.1.0
    .. versionchanged:: 2016.11.0
        This state has been rewritten. Some arguments are new to this release
        and will not be available in the 2016.3 release cycle (and earlier).
        Additionally, the **ZIP Archive Handling** section below applies
        specifically to the 2016.11.0 release (and newer).

    Ensure that an archive is extracted to a specific directory.

    .. important::
        **Changes for 2016.11.0**

        In earlier releases, this state would rely on the ``if_missing``
        argument to determine whether or not the archive needed to be
        extracted. When this argument was not passed, then the state would just
        assume ``if_missing`` is the same as the ``name`` argument (i.e. the
        parent directory into which the archive would be extracted).

        This caused a number of annoyances. One such annoyance was the need to
        know beforehand a path that would result from the extraction of the
        archive, and setting ``if_missing`` to that directory, like so:

        .. code-block:: yaml

            extract_myapp:
              archive.extracted:
                - name: /var/www
                - source: salt://apps/src/myapp-16.2.4.tar.gz
                - user: www
                - group: www
                - if_missing: /var/www/myapp-16.2.4

        If ``/var/www`` already existed, this would effectively make
        ``if_missing`` a required argument, just to get Salt to extract the
        archive.

        Some users worked around this by adding the top-level directory of the
        archive to the end of the ``name`` argument, and then used ``--strip``
        or ``--strip-components`` to remove that top-level dir when extracting:

        .. code-block:: yaml

            extract_myapp:
              archive.extracted:
                - name: /var/www/myapp-16.2.4
                - source: salt://apps/src/myapp-16.2.4.tar.gz
                - user: www
                - group: www

        With the rewrite for 2016.11.0, these workarounds are no longer
        necessary. ``if_missing`` is still a supported argument, but it is no
        longer required. The equivalent SLS in 2016.11.0 would be:

        .. code-block:: yaml

            extract_myapp:
              archive.extracted:
                - name: /var/www
                - source: salt://apps/src/myapp-16.2.4.tar.gz
                - user: www
                - group: www

        Salt now uses a function called :py:func:`archive.list
        <salt.modules.archive.list>` to get a list of files/directories in the
        archive. Using this information, the state can now check the minion to
        see if any paths are missing, and know whether or not the archive needs
        to be extracted. This makes the ``if_missing`` argument unnecessary in
        most use cases.

    .. important::
        **ZIP Archive Handling**

        *Note: this information applies to 2016.11.0 and later.*

        Salt has two different functions for extracting ZIP archives:

        1. :py:func:`archive.unzip <salt.modules.archive.unzip>`, which uses
           Python's zipfile_ module to extract ZIP files.
        2. :py:func:`archive.cmd_unzip <salt.modules.archive.cmd_unzip>`, which
           uses the ``unzip`` CLI command to extract ZIP files.

        Salt will prefer the use of :py:func:`archive.cmd_unzip
        <salt.modules.archive.cmd_unzip>` when CLI options are specified (via
        the ``options`` argument), and will otherwise prefer the
        :py:func:`archive.unzip <salt.modules.archive.unzip>` function. Use
        of :py:func:`archive.cmd_unzip <salt.modules.archive.cmd_unzip>` can be
        forced however by setting the ``use_cmd_unzip`` argument to ``True``.
        By contrast, setting this argument to ``False`` will force usage of
        :py:func:`archive.unzip <salt.modules.archive.unzip>`. For example:

        .. code-block:: yaml

            /var/www:
              archive.extracted:
                - source: salt://foo/bar/myapp.zip
                - use_cmd_unzip: True

        When ``use_cmd_unzip`` is omitted, Salt will choose which extraction
        function to use based on the source archive and the arguments passed to
        the state. When in doubt, simply do not set this argument; it is
        provided as a means of overriding the logic Salt uses to decide which
        function to use.

        There are differences in the features available in both extraction
        functions. These are detailed below.

        - *Command-line options* (only supported by :py:func:`archive.cmd_unzip
          <salt.modules.archive.cmd_unzip>`) - When the ``options`` argument is
          used, :py:func:`archive.cmd_unzip <salt.modules.archive.cmd_unzip>`
          is the only function that can be used to extract the archive.
          Therefore, if ``use_cmd_unzip`` is specified and set to ``False``,
          and ``options`` is also set, the state will not proceed.

        - *Permissions* - Due to an `upstream bug in Python`_, permissions are
          not preserved when the zipfile_ module is used to extract an archive.
          As of the 2016.11.0 release, :py:func:`archive.unzip
          <salt.modules.archive.unzip>` (as well as this state) has an
          ``extract_perms`` argument which, when set to ``True`` (the default),
          will attempt to match the permissions of the extracted
          files/directories to those defined within the archive. To disable
          this functionality and have the state not attempt to preserve the
          permissions from the ZIP archive, set ``extract_perms`` to ``False``:

          .. code-block:: yaml

              /var/www:
                archive.extracted:
                  - source: salt://foo/bar/myapp.zip
                  - extract_perms: False

    .. _`upstream bug in Python`: https://bugs.python.org/issue15795

    name
        Directory into which the archive should be extracted

    source
        Archive to be extracted

        .. note::
            This argument uses the same syntax as its counterpart in the
            :py:func:`file.managed <salt.states.file.managed>` state.

    source_hash
        Hash of source file, or file with list of hash-to-file mappings

        .. note::
            This argument uses the same syntax as its counterpart in the
            :py:func:`file.managed <salt.states.file.managed>` state.

        .. versionchanged:: 2016.11.0
            If this argument specifies the hash itself, instead of a URI to a
            file containing hashes, the hash type can now be omitted and Salt
            will determine the hash type based on the length of the hash. For
            example, both of the below states are now valid, while before only
            the second one would be:

        .. code-block:: yaml

            foo_app:
              archive.extracted:
                - name: /var/www
                - source: https://mydomain.tld/foo.tar.gz
                - source_hash: 3360db35e682f1c5f9c58aa307de16d41361618c

            bar_app:
              archive.extracted:
                - name: /var/www
                - source: https://mydomain.tld/bar.tar.gz
                - source_hash: sha1=5edb7d584b82ddcbf76e311601f5d4442974aaa5

    source_hash_name
        When ``source_hash`` refers to a hash file, Salt will try to find the
        correct hash by matching the filename part of the ``source`` URI. When
        managing a file with a ``source`` of ``salt://files/foo.tar.gz``, then
        the following line in a hash file would match:

        .. code-block:: text

            acbd18db4cc2f85cedef654fccc4a4d8    foo.tar.gz

        This line would also match:

        .. code-block:: text

            acbd18db4cc2f85cedef654fccc4a4d8    ./dir1/foo.tar.gz

        However, sometimes a hash file will include multiple similar paths:

        .. code-block:: text

            37b51d194a7513e45b56f6524f2d51f2    ./dir1/foo.txt
            acbd18db4cc2f85cedef654fccc4a4d8    ./dir2/foo.txt
            73feffa4b7f6bb68e44cf984c85f6e88    ./dir3/foo.txt

        In cases like this, Salt may match the incorrect hash. This argument
        can be used to tell Salt which filename to match, to ensure that the
        correct hash is identified. For example:

        .. code-block:: yaml

            /var/www:
              archive.extracted:
                - source: https://mydomain.tld/dir2/foo.tar.gz
                - source_hash: https://mydomain.tld/hashes
                - source_hash_name: ./dir2/foo.tar.gz

        .. note::
            This argument must contain the full filename entry from the
            checksum file, as this argument is meant to disambiguate matches
            for multiple files that have the same basename. So, in the
            example above, simply using ``foo.txt`` would not match.

        .. versionadded:: 2016.11.0

    source_hash_update : False
        Set this to ``True`` if archive should be extracted if source_hash has
        changed. This would extract regardless of the ``if_missing`` parameter.

        .. versionadded:: 2016.3.0

    skip_verify : False
        If ``True``, hash verification of remote file sources (``http://``,
        ``https://``, ``ftp://``) will be skipped, and the ``source_hash``
        argument will be ignored.

        .. versionadded:: 2016.3.4

    keep_source : True
        For ``source`` archives not local to the minion (i.e. from the Salt
        fileserver or a remote source such as ``http(s)`` or ``ftp``), Salt
        will need to download the archive to the minion cache before they can
        be extracted. To remove the downloaded archive after extraction, set
        this argument to ``False``.

        .. versionadded:: 2017.7.3

    keep : True
        Same as ``keep_source``, kept for backward-compatibility.

        .. note::
            If both ``keep_source`` and ``keep`` are used, ``keep`` will be
            ignored.

    password
        **For ZIP archives only.** Password used for extraction.

        .. versionadded:: 2016.3.0
        .. versionchanged:: 2016.11.0
          The newly-added :py:func:`archive.is_encrypted
          <salt.modules.archive.is_encrypted>` function will be used to
          determine if the archive is password-protected. If it is, then the
          ``password`` argument will be required for the state to proceed.

    options
        **For tar and zip archives only.**  This option can be used to specify
        a string of additional arguments to pass to the tar/zip command.

        If this argument is not used, then the minion will attempt to use
        Python's native tarfile_/zipfile_ support to extract it. For zip
        archives, this argument is mostly used to overwrite exsiting files with
        ``o``.

        Using this argument means that the ``tar`` or ``unzip`` command will be
        used, which is less platform-independent, so keep this in mind when
        using this option; the CLI options must be valid options for the
        ``tar``/``unzip`` implementation on the minion's OS.

        .. versionadded:: 2016.11.0
        .. versionchanged:: 2015.8.11,2016.3.2
            XZ-compressed tar archives no longer require ``J`` to manually be
            set in the ``options``, they are now detected automatically and
            decompressed using the xz_ CLI command and extracted using ``tar
            xvf``. This is a more platform-independent solution, as not all tar
            implementations support the ``J`` argument for extracting archives.

        .. note::
            For tar archives, main operators like ``-x``, ``--extract``,
            ``--get``, ``-c`` and ``-f``/``--file`` should *not* be used here.

    list_options
        **For tar archives only.** This state uses :py:func:`archive.list
        <salt.modules.archive.list_>` to discover the contents of the source
        archive so that it knows which file paths should exist on the minion if
        the archive has already been extracted. For the vast majority of tar
        archives, :py:func:`archive.list <salt.modules.archive.list_>` "just
        works". Archives compressed using gzip, bzip2, and xz/lzma (with the
        help of the xz_ CLI command) are supported automatically. However, for
        archives compressed using other compression types, CLI options must be
        passed to :py:func:`archive.list <salt.modules.archive.list_>`.

        This argument will be passed through to :py:func:`archive.list
        <salt.modules.archive.list_>` as its ``options`` argument, to allow it
        to successfully list the archive's contents. For the vast majority of
        archives, this argument should not need to be used, it should only be
        needed in cases where the state fails with an error stating that the
        archive's contents could not be listed.

        .. versionadded:: 2016.11.0

    force : False
        If a path that should be occupied by a file in the extracted result is
        instead a directory (or vice-versa), the state will fail. Set this
        argument to ``True`` to force these paths to be removed in order to
        allow the archive to be extracted.

        .. warning::
            Use this option *very* carefully.

        .. versionadded:: 2016.11.0

    overwrite : False
        Set this to ``True`` to force the archive to be extracted. This is
        useful for cases where the filenames/directories have not changed, but
        the content of the files have.

        .. versionadded:: 2016.11.1

    clean : False
        Set this to ``True`` to remove any top-level files and recursively
        remove any top-level directory paths before extracting.

        .. note::
            Files will only be cleaned first if extracting the archive is
            deemed necessary, either by paths missing on the minion, or if
            ``overwrite`` is set to ``True``.

        .. versionadded:: 2016.11.1

    user
        The user to own each extracted file. Not available on Windows.

        .. versionadded:: 2015.8.0
        .. versionchanged:: 2016.3.0
            When used in combination with ``if_missing``, ownership will only
            be enforced if ``if_missing`` is a directory.
        .. versionchanged:: 2016.11.0
            Ownership will be enforced only on the file/directory paths found
            by running :py:func:`archive.list <salt.modules.archive.list_>` on
            the source archive. An alternative root directory on which to
            enforce ownership can be specified using the
            ``enforce_ownership_on`` argument.

    group
        The group to own each extracted file. Not available on Windows.

        .. versionadded:: 2015.8.0
        .. versionchanged:: 2016.3.0
            When used in combination with ``if_missing``, ownership will only
            be enforced if ``if_missing`` is a directory.
        .. versionchanged:: 2016.11.0
            Ownership will be enforced only on the file/directory paths found
            by running :py:func:`archive.list <salt.modules.archive.list_>` on
            the source archive. An alternative root directory on which to
            enforce ownership can be specified using the
            ``enforce_ownership_on`` argument.

    if_missing
        If specified, this path will be checked, and if it exists then the
        archive will not be extracted. This path can be either a directory or a
        file, so this option can also be used to check for a semaphore file and
        conditionally skip extraction.

        .. versionchanged:: 2016.3.0
            When used in combination with either ``user`` or ``group``,
            ownership will only be enforced when ``if_missing`` is a directory.
        .. versionchanged:: 2016.11.0
            Ownership enforcement is no longer tied to this argument, it is
            simply checked for existence and extraction will be skipped if
            if is present.

    trim_output : False
        Useful for archives with many files in them. This can either be set to
        ``True`` (in which case only the first 100 files extracted will be
        in the state results), or it can be set to an integer for more exact
        control over the max number of files to include in the state results.

        .. versionadded:: 2016.3.0

    use_cmd_unzip : False
        Set to ``True`` for zip files to force usage of the
        :py:func:`archive.cmd_unzip <salt.modules.archive.cmd_unzip>` function
        to extract.

        .. versionadded:: 2016.11.0

    extract_perms : True
        **For ZIP archives only.** When using :py:func:`archive.unzip
        <salt.modules.archive.unzip>` to extract ZIP archives, Salt works
        around an `upstream bug in Python`_ to set the permissions on extracted
        files/directories to match those encoded into the ZIP archive. Set this
        argument to ``False`` to skip this workaround.

        .. versionadded:: 2016.11.0

    enforce_toplevel : True
        This option will enforce a single directory at the top level of the
        source archive, to prevent extracting a 'tar-bomb'. Set this argument
        to ``False`` to allow archives with files (or multiple directories) at
        the top level to be extracted.

        .. versionadded:: 2016.11.0

    enforce_ownership_on
        When ``user`` or ``group`` is specified, Salt will default to enforcing
        permissions on the file/directory paths detected by running
        :py:func:`archive.list <salt.modules.archive.list_>` on the source
        archive. Use this argument to specify an alternate directory on which
        ownership should be enforced.

        .. note::
            This path must be within the path specified by the ``name``
            argument.

        .. versionadded:: 2016.11.0

    archive_format
        One of ``tar``, ``zip``, or ``rar``.

        .. versionchanged:: 2016.11.0
            If omitted, the archive format will be guessed based on the value
            of the ``source`` argument. If the minion is running a release
            older than 2016.11.0, this option is required.

    .. _tarfile: https://docs.python.org/2/library/tarfile.html
    .. _zipfile: https://docs.python.org/2/library/zipfile.html
    .. _xz: http://tukaani.org/xz/

    **Examples**

    1. tar with lmza (i.e. xz) compression:

       .. code-block:: yaml

           graylog2-server:
             archive.extracted:
               - name: /opt/
               - source: https://github.com/downloads/Graylog2/graylog2-server/graylog2-server-0.9.6p1.tar.lzma
               - source_hash: md5=499ae16dcae71eeb7c3a30c75ea7a1a6

    2. tar archive with flag for verbose output, and enforcement of user/group
       ownership:

       .. code-block:: yaml

           graylog2-server:
             archive.extracted:
               - name: /opt/
               - source: https://github.com/downloads/Graylog2/graylog2-server/graylog2-server-0.9.6p1.tar.gz
               - source_hash: md5=499ae16dcae71eeb7c3a30c75ea7a1a6
               - options: v
               - user: foo
               - group: foo

    3. tar archive, with ``source_hash_update`` set to ``True`` to prevent
       state from attempting extraction unless the ``source_hash`` differs
       from the previous time the archive was extracted:

       .. code-block:: yaml

           graylog2-server:
             archive.extracted:
               - name: /opt/
               - source: https://github.com/downloads/Graylog2/graylog2-server/graylog2-server-0.9.6p1.tar.lzma
               - source_hash: md5=499ae16dcae71eeb7c3a30c75ea7a1a6
               - source_hash_update: True
    unameuresultuchangesuucommentukeep_sourceukeepuwarningsu`Both 'keep_source' and 'keep' were used. Since these both do the same thing, 'keep' was ignored.u{0} is not an absolute pathu0Name of the directory path needs to be specifiedu!{0} exists and is not a directoryu.Value for 'if_missing' is not an absolute pathu8Value for 'enforce_ownership_on' is not an absolute pathu..u3Value for 'enforce_ownership_on' must be within {0}uPath {0} existsu:User/group ownership cannot be enforced on Windows minionsufile.user_to_uiduUser {0} does not existi����ufile.group_to_giduGroup {0} does not existuVThe 'source_hash_update' argument is ignored when 'source_hash' is not also specified.ufile.source_listiuInvalid source "{0}"u:ufileu Source file '{0}' does not existutaruraruzipu�Could not guess archive_format from the value of the 'source' argument. Please set this archive_format to one of the following: {0}u, u�Invalid archive_format '{0}'. Either set it to a supported value ({1}) or remove this argument and the archive format will be guesseed based on file extension.u/--strip(?:-components)?(?:\s+|=)["']?(\d+)["']?iufPresence of CLI options in archive.extracted state for '%s' implies that use_cmd_unzip is set to True.u�'use_cmd_unzip' cannot be set to False if CLI options are being specified (via the 'options' argument). Either remove 'use_cmd_unzip', or set it to True.uarchive.cmd_unzipuParchive.cmd_unzip function not available, unzip might not be installed on minionufPresence of a password in archive.extracted state for '%s' implies that use_cmd_unzip is set to False.u�Using a password in combination with setting 'use_cmd_unzip' to True is considered insecure. It is recommended to remove the 'use_cmd_unzip' argument (or set it to False) and allow Salt to extract the archive using Python's built-in ZIP file support.u:The 'password' argument is only supported for zip archivesu
archive.unraruParchive.unrar function not available, rar/unrar might not be installed on minionuQThe 'options' argument is only compatible with the following archive formats: {0}idu?Invalid value for trim_output, must be True/False or an integerufile.get_source_sumtsourcetsource_hashtsource_hash_nametsaltenvutestuZArchive {0} would be cached (if necessary) and checked to discover if extraction is neededufile.cachedu4Unable to cache {0}, file.cached state not availabletskip_verifyuFailed to cache {0}: {1}ufile.cached: %sucp.is_cachedufailed to download %su.Checking %s to see if it is password-protecteduarchive.is_encryptedtcleanueArchive {0} is password-protected, but no password was specified. Please set the 'password' argument.uarchive.listtarchive_formattoptionststrip_componentstverboseu'if_missing' must be setuCOwnership cannot be managed without setting 'enforce_ownership_on'.u

u_If the source archive is a tar archive compressed using a compression type not natively supported by the tar command, then setting the 'list_options' argument may allow the contents to be listed. Otherwise, if Salt is unable to determine the files/directories in the archive, the following workaround(s) would need to be used for this state to proceedu@The following workarounds must be used for this state to proceedu4 (assuming the source file is a valid {0} archive):
u
- {0}utop_level_dirsutop_level_filesuArchive does not have a single top-level directory. To allow this archive to be extracted, set 'enforce_toplevel' to False. To avoid a '{0}-bomb' it may also be advisable to set a top-level directory by adding it to the 'name' value (for example, setting 'name' to {1} instead of {2}).usome_diru;Failed to check for existence of if_missing path ({0}): {1}udirsufilescS@stj|�otj|�S(N(tstattS_ISLNKtS_ISDIR(RE((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt<lambda>Vsulinksu
u- {0}uThe below paths (relative to {0}) exist, but are the incorrect type (file instead of directory, symlink instead of file, etc.).us Since the 'clean' option is enabled, the destination paths would be cleared and the archive would be extracted.{0}un To proceed with extraction, set 'force' to True. Note that this will remove these paths before extracting.{0}uremovedu�One or more paths existed by were the incorrect type (i.e. file instead of directory or vice-versa), but could not be removed. The following errors were observed:
ufile.check_hashuhsumu.{0} does not match the desired source_hash {1}u%Archive {0} would be extracted to {1}u$, after cleaning destination path(s)u%Cleaning archive paths from within %suRemoving %suLOne or more paths could not be cleaned. The following errors were observed:
ufile.directorytuserR/uExtracting %s to %sttrim_outputtpasswordu
archive.unzipt
extract_permsurNuxzucmd.retcodeu-tRKtignore_retcodeueTar file is XZ-compressed, attempting decompression and extraction using XZ Utils and the tar commandu(xz --decompress --stdout {0} | tar xvf -ucmd.run_alltcwduretcodeustderrustdoutuFailed to read from tar archive using Python's native tar file support. If archive is compressed using something other than gzip or bzip2, the 'options' argument may be required to pass the correct options to the tar command in order to extract the archive.u`Failed to read from tar archive. If it is XZ-compressed, install xz-utils to attempt extraction.u>tar command not available, it might not be installed on minionuxu-ufuosuopenbsdu-funo tar output so farutop_level_linksuuserugroupu;Enforcing %s ownership on %s using a file.directory state%su (dry-run only)tgrouptrecurseufile.directory: %suupdated ownershipu2Bad state return %s for file.directory state on %sudirectories_createduextracted_filesu{0} extracted to {1}u No files were extracted from {0}u
{0} existsu(All files in archive are already presentu>. Ownership would be updated on one or more files/directories.uR

While trying to enforce user/group ownership, the following paths were missing:
ul

While trying to enforce user/group ownership, Salt was unable to change ownership on the following paths:
uKeeping cached source file %suCleaning cached source file %sufile.not_cached(gRRRtargstclean_kwargst
setdefaultR3tbooltpopR
RR:R%RtsepRtisfileR	RR$t	Exceptiontexiststplatformt
is_windowsRLt__env__Rtstrerrort	_urlparsetschemeRtnetloctlowertstringtascii_lowercaseR1tLOCAL_PROTOStrealpatht
expanduserturltredact_http_basic_authtguess_archive_typeRt
isinstanceRtstring_typesR#tintRtsearchReR"R'tinfot
integer_typest	TypeErrorRt
__states__R<t	exceptionR(RGRFtlentlstatR6R7R8R[R]R\tst_modetENOTDIRtrm_rfRJRR.RRttarfiletopent
extractalltstringutilstto_strtgetnamest	ReadErrortwhicht
_cmd_quoteRPRMtshlexR4t	enumeratetreplacet
__grains__textendtdictR0tKeyErrorR;tst_uidtst_gidtlchown(TRORQRRRStsource_hash_updateRURaRXtlist_optionstforcet	overwriteRVR_Ret
if_missingR`t
use_cmd_unzipRbtenforce_topleveltenforce_ownership_onRWtkwargsRtkeep_sourcetnot_reltuidtgidtsource_matchR)turlparsed_sourceturlparsed_schemeturlparsed_pathtsource_hash_basenametsource_is_localtvalid_archive_formatsRYtsupports_optionsR?RHtresulttmsgtexisting_cached_source_sumt
encrypted_ziptcontentsterrorsterrortextraction_neededRtif_missing_path_existstincorrect_typet	path_listtfuncRt	full_patht	path_modeREtincorrect_pathsRtcreated_destdirR1ttartcmdtresultsttar_optsttar_cmdt
tar_shortoptsttar_longoptstpositiontoptt
append_opttenforce_missingtenforce_failedtenforce_dirst
enforce_filest
enforce_linksRftrecurse_strtyt
owner_changesR-t
dir_resulttfilenamet	file_stattitem((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt	extracted�s���"















	






			


		


	


	




	







	





	

	







	 

		&


	
	




	







	





		


	








	



	

	



				


@

	












 


 #(1t__doc__t
__future__RRRR7tloggingRRR�R[RxR�t
contextlibRtsalt.extRtsalt.ext.six.movesRR�tsalt.ext.six.moves.urllib.parseRRttsalt.utils.argsRtsalt.utils.filestsalt.utils.hashutilstsalt.utils.pathtsalt.utils.platformtsalt.utils.urltsalt.exceptionsRRt	getLoggert__name__R'RRRR+RFR	RGRJRMRPRR
R�(((s7/usr/lib/python2.7/site-packages/salt/states/archive.pyt<module>sb					$			

Zerion Mini Shell 1.0