403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/ansible/galaxy/collection/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/ansible/galaxy/collection/__pycache__/__init__.cpython-311.pyc
�

���cy'���dZddlmZmZmZeZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZmZddl m!Z!ddl"m#Z#dd	l$m%Z%dd
l&m'Z'	ddl(m)Z*dZ+n#e,$rGd
�d��Z*dZ+YnwxYw	ddl-m.Z.ddl/m0Z0dZ1n
#e,$rdZ1YnwxYwej2r�ddl3m4Z4ej5dZ6ej5dZ7ej5dddddddddddd d!d"e7fZ8ej9e8ej:e;e<ej=e<ej9e<e<fdffZ>ej9e6e>fZ?ej9e7ej:e<e;dffZ@ej9ej5d#ej:ej=e@e;ffZAddlBmCZDdd$lEmFZFdd%lGmHZHdd&l3mIZImJZJmKZKmLZLmMZMdd'lNmOZOdd(lPmQZQmRZRmSZSmTZT	dd)lUmVZVdd*lWmXZXmYZYdd+lZm[Z[m\Z\m]Z]dZ^n
#e,$rdZ^YnwxYwdd,l_m`Z`m)Z)maZadd-lbmcZcdd.ldmeZedd/lfmgZgdd0lhmiZimjZjmkZkdd1llmmZmdd2lnmoZodd3lpmqZqdd4lrmsZsdd5ltmuZumvZvdd6lwmxZxes��ayd7Zzd8Z{ed9gd:���Z|d;Z}eGd<�d=����Z~Gd>�d?e��Z�Gd@�dA��Z�dB�Z�dC�Z�dD�Z�dE�Z�dF�Z�dG�Z�dH�Z�dI�Z�dJ�Z�dK�Z�edL���Z�edfdM���Z�dN�Z�dO�Z�dgdQ�Z�dR�Z�dS�Z�dT�Z�dU�Z�dV�Z�dW�Z�dX�Z�dY�Z�dZ�Z�d[�Z�d\�Z�d]�Z�d^�Z�dfd_�Z�d`�Z�da�Z�db�Z�dc�Z�dfdd�Z�de�Z�dS)hz)Installed collections management package.�)�absolute_import�division�print_functionN)�
namedtuple)�contextmanager)�	dataclass�fields)�sha256)�BytesIO)�distribution)�chain)�RequirementTc��eZdZdS)�PkgReqN)�__name__�
__module__�__qualname__���G/usr/lib/python3.11/site-packages/ansible/galaxy/collection/__init__.pyrr%s�������rrF)�Manifest)�DistlibException)�ConcreteArtifactsManager��collection_info�file_manifest_file�format��name�ftype�chksum_type�
chksum_sha256r�	namespacer�version�authors�readme�tags�description�license�license_file�dependencies�
repository�
documentation�homepage�issues��filesr)�AnsibleError)�	GalaxyAPI)�
_consume_file�_download_file�_get_json_from_installed_dir�_get_meta_from_src_dir�_tarfile_extract)�MultiGalaxyAPIProxy)�run_gpg_verify�parse_gpg_errors�get_signature_from_source�
GPG_ERROR_MAP)�$build_collection_dependency_resolver)�(CollectionDependencyResolutionImpossible�)CollectionDependencyInconsistentCandidate)�RESOLVELIB_VERSION�RESOLVELIB_LOWERBOUND�RESOLVELIB_UPPERBOUND)�	Candidater�_is_installed_collection_dir)�meets_requirements)�get_all_plugin_loaders)�
raise_from)�to_bytes�	to_native�to_text)�is_sequence)�	yaml_dump)�AnsibleCollectionRef)�Display)�secure_hash�
secure_hash_s)�Sentinel�z
MANIFEST.json�ModifiedContent��filename�expected�	installedz0^(?P<strict>\+)?(?:(?P<count>\d+)|(?P<all>all))$c�H��eZdZUdZeeed<dZeed<�fd�Z	�xZ
S)�ManifestControlN�
directivesF�omit_default_directivesc����t|��D]P}t||j���9t���|j|������QdS�N)�	dc_fields�getattrr�super�__setattr__�type)�self�field�	__class__s  �r�
__post_init__zManifestControl.__post_init__�s[����t�_�_�	>�	>�E��t�U�Z�(�(�0����#�#�E�J��
�
���=�=�=��	>�	>r)rrrr[�list�str�__annotations__r\�boolrg�
__classcell__)rfs@rrZrZ�s_�������� �J��S�	� � � �$)��T�)�)�)�>�>�>�>�>�>�>�>�>rrZc�.�eZdZdd�Zd�Zd�Zd�Zd�ZdS)	�CollectionSignatureErrorNFc�L�||_||_||_||_d|_dSr^)�reasons�stdout�rc�ignore�_reason_wrapper)rdrprqrrrss     r�__init__z!CollectionSignatureError.__init__�s,��������������#����rc�,�d|�d|j�d|j��S)NzUnexpected error for 'z<': GnuPG signature verification failed with the return code z and output )rrrq�rd�collection_names  r�_report_unexpectedz+CollectionSignatureError._report_unexpected�s>��
k�_�
k�
k�HL��
k�
k�]a�]h�
k�
k�	
rc�L�d|�d|j�d�}||���zS)N�#Signature verification failed for 'z' (return code z):)rr�_format_reasons)rdrx�headers   r�_report_expectedz)CollectionSignatureError._report_expected�s5��b��b�b�W[�W^�b�b�b����,�,�.�.�.�.rc����j�tjdd����_�fd��jD��}dd�|��zS)Nz    * z      )�initial_indent�subsequent_indentc�j��g|]/}d��j�|������0S)�
)�joinrt�wrap)�.0�reasonrds  �r�
<listcomp>z<CollectionSignatureError._format_reasons.<locals>.<listcomp>�sF���
�
�
��
�I�I�d�*�/�/��7�7�8�8�
�
�
rr�)rt�textwrap�TextWrapperrpr�)rd�wrapped_reasonss` rr|z(CollectionSignatureError._format_reasons�so�����'�#+�#7�'�"*�$�$�$�D� �

�
�
�
��,�
�
�
��
�d�i�i��0�0�0�0rc�d�|jr|�|��S|�|��Sr^)rpr~ryrws  r�reportzCollectionSignatureError.report�s4���<�	:��(�(��9�9�9��&�&��7�7�7r)NNNF)rrrruryr~r|r�rrrrnrn�sd������$�$�$�$�
�
�
�/�/�/�1�1�1�8�8�8�8�8rrnc��eZdZd�ZdS)�CollectionVerifyResultc�"�||_d|_dS)NT)rx�successrws  rruzCollectionVerifyResult.__init__�s��.�������rN)rrrrurrrr�r��s#����������rr�c
�
�t|j��}t|jd���}t�d�|�����t�d�t
|j�������g}|du}tjt|��}tjt|��}|sZ|j|jkrJd�|j|j|j�	��}	t�|	��d
|_|Stj�t
|d���t ��}
t#|j��}|r"|j�d�|jdD��|z}n |s|jrt#|j��|z}|jdu}|s|rt�d
��nP|rNt-|j|
||j|j|j��s	d
|_|St�d|����|r|t ��}
n�|r|jr|t ��}
n�|jr|jn|j|��}t�d�t
|�������tjt<|��}tjt>|��}|t ��}
tA|t |
|��t�d�|
�����|t ��}|d}|d}|d|dz}tA||||��||��}tC��}tj�|d��tj�|d��h}|dD]�}|d}|ddkre|�"tj�|t|d�������|d|dz}tA||||��|ddkrB|�"tj�|t|d���������tj#|��D]�\}}}|D]t}tj�||��}t
|tI|��dzd�d���}||vr%|�%tM|dd������u|D]t}tj�||��}t
|tI|��dzd�d���}||vr%|�%tM|d d!������u��|r�d
|_t�d"�t
|j���#����|D]N}t�d$|j'z��t�(d%|j)�d&|j*�����On5|rd'nd(}t�d)�||�*����|S)+a5Verify integrity of the locally installed collection.

    :param local_collection: Collection being checked.
    :param remote_collection: Upstream collection (optional, if None, only verify local artifact)
    :param artifacts_manager: Artifacts manager.
    :return: a collection verify result object.
    �surrogate_or_strict��errorszVerifying '{coll!s}'.��collz(Installed collection found at '{path!s}'��pathNzX{local_fqcn!s} has the version '{local_ver!s}' but is being compared to '{remote_ver!s}')�
local_fqcn�	local_ver�
remote_verFc��g|]
}|d��S)�	signaturer)r��infos  rr�z+verify_local_collection.<locals>.<listcomp>�s��_�_�_�D�d�;�'�_�_�_r�
signaturesz�The GnuPG keyring used for collection signature verification was not configured but signatures were provided by the Galaxy server. Configure a keyring for ansible-galaxy to verify the origin of the collection. Skipping signature verification.z>GnuPG signature verification succeeded, verifying contents of z&Remote collection cached as '{path!s}'z#MANIFEST.json hash: {manifest_hash})�
manifest_hashrrz	chksum_%sr!�
MANIFEST.json�
FILES.jsonr1r �file�dirrSzthe file does not existzthe file existsrUzthe directory does not existzthe directory existszECollection {fqcn!s} contains modified content in the following files:��fqcnz    %sz    Expected: z
    Found: z+are internally consistent with its manifestzmatch the remote collectionz=Successfully verified that checksums for '{coll!s}' {what!s}.)r��what)+r�r�rI�src�displayrrK�	functools�partialr6�_get_file_hash�verr��osr�r��MANIFEST_FILENAMErhr��source_info�keyring�warning�verify_file_signatures�#required_successful_signature_count�ignore_signature_errors�vvvv�is_concrete_artifact�get_artifact_path�get_galaxy_artifact_path�vvv�_get_json_from_tar_file�_get_tar_file_hash�_verify_file_hash�set�add�walk�len�appendrTrV�vrWrX)�local_collection�remote_collection�artifacts_manager�result�b_collection_path�modified_content�verify_local_only�get_json_from_validation_source�get_hash_from_validation_source�err�
manifest_filer��keyring_configuredr��b_temp_tar_path�manifest�file_manifest_data�file_manifest_filename�
expected_hash�
file_manifest�collection_dirs�collection_files�
manifest_datar�root�dirsr1�	full_pathr��content_changer�s                               r�verify_local_collectionr��s6��$�$4�$9�
:�
:�F� �!1�!5�>S�T�T�T���O�O�+�2�2�8H�2�I�I�J�J�J��O�O�3���G�,�0�1�1��2�2����
��)�T�1��'0�&7�8T�Vg�&h�&h�#�&/�&7��HY�&Z�&Z�#��
���#4�#8�8�8�8�8>��/�4�.�2�0�4�9?�9�9�
�
�O�O�C� � � �"�F�N��M��G�L�L��):�CX�!Y�!Y�!Y�[l�m�m�M��&�1�2�2�J��E�-�9�E�_�_�4D�4P�Q]�4^�_�_�_�bl�l�
�
�
�E�#4�#?�E��+�6�7�7�*�D�
�*�2�$�>���j�*�j����
/�	
�	
�	
�	
�
�j�%��!����%��A��5�

�
�		�#�F�N��M����h�Vf�h�h�i�i�i��a�7�7�8I�J�J�
�
�	�a� 1� <�a�7�7�8I�J�J�
�
�
<� �5�
<��/�/�"�;�
�	���	���5�<�<�'�/�BZ�BZ�<�[�[�	
�	
�	
�
+4�*;�<S�Ud�*e�*e�'�*3�*;�<N�P_�*`�*`�'�8�7�8I�J�J�
��+�->�
�O_�`�`�`��O�O�9�@�@�}�@�]�]�^�^�^�.�.�/@�A�A�H�"�"6�7��/��7��&�{�5G�
�5V�'V�W�M��'�)?��P`�a�a�a�3�3�4J�K�K�M��e�e�O�
����&�(8�9�9�
����&�
�6�6���'�w�/�
�
�
��V�$����!�V�+�+�� � �����.���F[�0\�0\�0\�]�]�
�
�
�*�+�
�m�8T�*T�U�M��/��}�FV�W�W�W���!�U�*�*��������.���F[�0\�0\�0\�]�]�
�
�
��
 �W�%6�7�7�����d�E��	�	�D�����T�4�0�0�I��9�S�):�%;�%;�a�%?�%A�%A�B�K`�a�a�a�D�� 0�0�0� �'�'�#�T�<U�ar�s�s�s������	�	�D�����T�4�0�0�I��9�S�):�%;�%;�a�%?�%A�%A�B�K`�a�a�a�D���/�/� �'�'�#�T�<Z�f|�}�}�}�����	��
�������
&��F�� 0� 5�6�6�F�7�7�	
�	
�	
�
/�	o�	o�N��O�O�H�~�'>�>�?�?�?��I�I�I�>�;R�;R�;R�Tb�Tl�Tl�m�n�n�n�n�	o�AR�t�<�<�Wt�����K��F�(�t�F�4�4�	
�	
�	
�
�Mrc���d}g}tjt|�����}|dpd}	|d}
|d}|�t	|��}|D]�}t|d���}	t
||||��|dz
}|
r�.||krnL�7#t$r>}
|
jrYd}
~
�M|�	|
�
|����Yd}
~
�zd}
~
wwxYw|	r#|s!d}t�d	|�d
���nO|
r$|}|st�d	|�d���n)|p||k}|st�d	|�d���|s|D]}t�|���|S)
Nr�strictF�all�countr�r�rSr{z': no successful signaturesz': some signatures failedz,': fewer successful signatures than required)
�re�match�SIGNATURE_COUNT_RE�	groupdict�intrK�verify_file_signaturernrsr�r�r�r�)r�r��detached_signaturesr��required_successful_countr��
successful�error_messages�signature_count_requirementsr��require_all�
require_countr��error�verified�msgs                rr�r�ys
���J��N�#%�8�,>�@Y�#Z�#Z�#d�#d�#f�#f� �
)�(�
3�
<�u�F�.�u�5�K�0��9�M�� ��M�*�*�
�(���	��I�.C�D�D�D�	�	�!�-��G�E\�]�]�]�
�!�O�J��
���]�*�*���+��(�	6�	6�	6��|�
�������!�!�%�,�,�t�"4�"4�5�5�5�5�5�5�5�5�����		6�����
v�j�
v������_�d�_�_�_�`�`�`�`�	�v�%�%���	c��O�O�a�$�a�a�a�b�b�b��*�*�I�m�z�.I���	v��O�O�t�$�t�t�t�u�u�u���!�	�	�C��L�L�������Os�2B�
C�C�+(C�Cc�r�t|||t��\}}|�rt|��}	t|��}g}d}	t	|g|��D]�}tt
j����tt
j�����	|j
��}
|
|vr|	dz
}	|�|�������t|��|	k}tt|��|||����#t $rYnwxYw|rt||����dS)zURun the gpg command and parse any errors. Raises CollectionSignatureError on failure.rrS)rprqrrrs)rqrrN)r:r�r;�nextr
rhr=�keys�values�indexrfr��get_gpg_error_descriptionr�rnr��
StopIteration)r��detached_signaturer�r��
gpg_result�gpg_verification_rcr�r�rp�ignored_reasons�status_coderss            rr�r��s\��'5�]�DV�X_�ah�&i�&i�#�J�#��{�!�*�-�-��	{���L�L�E��G��O���w��/�/�
B�
B��"�=�#5�#7�#7�8�8��m�>R�>T�>T�9U�9U�9[�9[�\a�\k�9l�9l�m���"9�9�9�#�q�(�O����u�>�>�@�@�A�A�A�A���\�\�_�4�F�*�3�w�<�<�
�Wj�sy�z�z�z�z���	�	�	��D�	���� �R�&�j�=P�Q�Q�Q�Q��4s�D�
D!� D!c�&�t|d���}	t|��}nA#t$r4}tt	t|����|��Yd}~nd}~wwxYwt
d
i|��}t||d|d|d|d��}d�|d|d|d	�
��}tj
�t|��t|d�����}	tj
�|	��r_tj
�
|	��rt	dt|	��z���|st	dt|	��z���t||	||��}
|
S)a�Creates the Ansible collection artifact in a .tar.gz file.

    :param u_collection_path: The path to the collection to build. This should be the directory that contains the
        galaxy.yml file.
    :param u_output_path: The path to create the collection build artifact. This should be a directory.
    :param force: Whether to overwrite an existing collection build artifact or fail.
    :return: The path to the collection build artifact.
    r�r�Nr#r�build_ignorer�z{ns!s}-{name!s}-{ver!s}.tar.gzr$)r�nsr�zQThe output collection artifact '%s' already exists, but is a directory - abortingzWThe file '%s' already exists. You can use --force to re-create the collection artifact.r)rIr7�LookupErrorrHr2rJ�_build_manifest�_build_files_manifestrr�r�r��exists�isdir�_build_collection_tar)�u_collection_path�
u_output_path�forcer��collection_meta�
lookup_err�collection_manifestr��artifact_tarball_file_name�b_collection_output�collection_outputs           r�build_collectionr�s���!�!2�;P�Q�Q�Q��D�0�1B�C�C�����D�D�D��<�	�*� 5� 5�6�6�
�C�C�C�C�C�C�C�C�����D����*�<�<�O�<�<��)����$������'��
�#���M�"B�!H�!H�
�V�
$��;�'��I�&�"I�"�"��
�'�,�,������+�4I�J�J�J����

�w�~�~�)�*�*�\�
�7�=�=�,�-�-�	\�� ?�AJ�K^�A_�A_� `�a�a�
a��	\�� :�<E�FY�<Z�<Z� [�\�\�
\�.�.?�AT�Vi�kx�y�y���s�#�
A!�*A�A!c���td��5tt|��|d|||ddd��	�	}ddd��n#1swxYwYt|d���}g}td�|�����5|������D�]�\}	}
|
jr<t�d	�t|
���
�����It�d�t|
��t|�������|
j
r|jn|j|
��}tj�|tj�|����}|
jr@tt%t|d���t|d���d
���d���}n/t'jt)|��t)|����t�d�|
�
����|�t)tj�|����|
jd������tj�|d��}
t|
d���}t�d�t|
�������tt/d|i��d���}t1|d���5}|�|��ddd��n#1swxYwYddd��dS#1swxYwYdS)a�Download Ansible collections as their tarball from a Galaxy server to the path specified and creates a requirements
    file of the downloaded requirements to be used for an install.

    :param collections: The collections to download, should be a list of tuples with (name, requirement, Galaxy Server).
    :param output_path: The path to download the collections to.
    :param apis: A list of GalaxyAPIs to query when search for a collection.
    :param validate_certs: Whether to validate the certificate if downloading a tarball from a non-Galaxy host.
    :param no_deps: Ignore any collection dependencies and only download the base requirements.
    :param allow_pre_release: Do not ignore pre-release versions when selecting the latest.
    zProcess download dependency mapNF��galaxy_apis�preferred_candidates�concrete_artifacts_manager�no_deps�allow_pre_release�upgrade�include_signatures�offliner�r�z2Starting collection download process to '{path!s}'r�z/Virtual collection {coll!s} is not downloadabler�z/Downloading collection '{coll!s}' to '{path!s}'�r�r�T)r
z1Collection '{coll!s}' was downloaded successfully)rr$zrequirements.ymlzEWriting requirements.yml file of downloaded collections to '{path!s}'�collections�wb��mode)�_display_progress�_resolve_depenency_mapr�rIr�copy�items�
is_virtualr�rKr�r�r�r�r�r��basename�is_dirr�shutilrJr�r�rM�open�write)r�output_path�apisrrr��dep_map�
b_output_path�requirementsr��concrete_coll_pin�
b_src_path�b_dest_path�requirements_path�b_requirements_path�
yaml_bytes�req_fds                 r�download_collectionsr7�s]��$
�<�	=�	=�
�
�(������!%�'8��/��$��
�
�
��
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��[�1F�G�G�G�M��L�	�@��F��F�$�$�
�
�D%�D%�(/�|�|�~�~�';�';�'=�'=�1	�1	�#�D�#� �+�
����E��F��(9� :� :�F�;�;������O�O�B���G�$5�6�6�W�]�=S�=S��T�T�
�
�
�@�$�9�@�!�3�3�&�?��	!�!�J��'�,�,���� � ��,�,���K�
!�'�

K�&�$��
�3H�I�I�I���4I�J�J�J�"����
1�
�������I�j�1�1�9�[�3I�3I�J�J�J��O�O�C���-��.�.�
�
�
�
���"�"�'�"2�"2�;�"?�"?�@�@�,�0�	!�	!�	
�	
�	
�	
��G�L�L��6H�I�I��&��&;�
�
�
��	���
�"�F��0A�(B�(B�F�C�C�	
�	
�	
���}�l�3�4�4�(�
�
�
�
��%�D�
1�
1�
1�	%�V��L�L��$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�GD%�D%�D%�D%�D%�D%�D%�D%�D%�D%�D%�D%����D%�D%�D%�D%�D%�D%sH�&A�A�	A�JM�!M�7M�M	�M�
M	�M�M�"Mc�
�|�|��}|r�d}t|�d����D]}|r|}n�	|std|z���t	d�|�����5|�||��ddd��n#1swxYwYt�d|j�d|j	����dSt�d|j�d|j	�d	|����dS)
ayPublish an Ansible collection tarball into an Ansible Galaxy server.

    :param collection_path: The path to the collection tarball to publish.
    :param api: A GalaxyAPI to publish the collection to.
    :param wait: Whether to wait until the import process is complete.
    :param timeout: The time in seconds to wait for the import process to finish, 0 is indefinite.
    N�/zoPublishing the collection did not return valid task info. Cannot wait for task status. Returned task info: '%s'zRCollection has been published to the Galaxy server {api.name!s} {api.api_server!s})�apizMCollection has been successfully published and imported to the Galaxy server � z0Collection has been pushed to the Galaxy server zi, not waiting until import has completed due to --no-wait being set. Import task results can be found at )
�publish_collection�reversed�splitr2r!r�wait_import_taskr�r�
api_server)�collection_pathr:�wait�timeout�
import_uri�task_id�path_segments       rr<r<ds����'�'��8�8�J��B�
��$�Z�%5�%5�c�%:�%:�;�;�	�	�L��
�&����
��	_�� Q�T^� ^�_�_�
_�
�2�28�&�S�&�/�/�
�
�	3�	3�
� � ��'�2�2�2�		3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�
	�����8�8�8�S�^�^�5�	6�	6�	6�	6�	6�	�����8�8�8�S�^�^�^�Z�Z�A�	B�	B�	B�	B�	Bs�<B�B#�&B#c���	���d�t|�	��D���ttj�	fd�|D������}d�|D���||s|rt��n
�fd�|D��z}|s|st�d��dS�fd��D��}
|rgn|r|
n�}d�|D��}td	��5t
|||�	||||
|�
�	�	}ddd��n#1swxYwY�	jdu}td��5|���D�]$\}}|j	r<t�
d�t|���
�����I||vr<t�d�t|���
������|
s#|j
r|st�d��	t||�	����#t $rX}|rJt�d�t|��t|�������n�Yd}~��d}~wwxYw	ddd��dS#1swxYwYdS)a�Install Ansible collections to the path specified.

    :param collections: The collections to install.
    :param output_path: The path to install the collections to.
    :param apis: A list of GalaxyAPIs to query when searching for a collection.
    :param validate_certs: Whether to validate the certificates if downloading a tarball.
    :param ignore_errors: Whether to ignore any errors when installing the collection.
    :param no_deps: Ignore any collection dependencies and only install the base requirements.
    :param force: Re-install a collection if it has already been installed.
    :param force_deps: Re-install a collection as well as its dependencies if they have already been installed.
    c	�\�h|])}t|j|j|j|jd����*Sr^)rr�r�r�rc�r�r�s  r�	<setcomp>z&install_collections.<locals>.<setcomp>�s@������	�D�I�t�x���4�9�d�C�C���rc3��K�|]A}|jr3�fd���|�����D��n|fV��BdS)c3�B�K�|]}tj|���V��dSr^)r�
from_dir_path)r��sub_collr�s  �r�	<genexpr>z0install_collections.<locals>.<genexpr>.<genexpr>�sE�����
�
���)�(�4E�F�F�
�
�
�
�
�
rN)�
is_subdirs�"get_direct_collection_dependenciesr�)r��install_reqr�s  �rrOz&install_collections.<locals>.<genexpr>�s������
�
���%�
;�
�
�
�
�&�6�6�{�C�C��D�F�F�
�
�
�
�-8�?�
�
�
�
�
�
rc��h|]	}|j��
Srr�)r��reqs  rrJz&install_collections.<locals>.<setcomp>�s��#Q�#Q�#Q��C�H�#Q�#Q�#Qrc�r��h|]3}�D].}|j|jk�t|j|j���,|��/�4Sr)r�rFr�)r�rT�exs�existing_collectionss   �rrJz&install_collections.<locals>.<setcomp>�sb���C�C�C��'�C�C�
��8�s�x���$6�s�w���$H�$H��	� ���rzxNothing to do. All requested collections are already installed. If you want to reinstall them, consider using `--force`.Nc�&��h|]
}|j�v�|��Srr�)r�r��requested_requirements_namess  �rrJz&install_collections.<locals>.<setcomp>�s1���*�*�*���9�8�8�8�	
�8�8�8rc	�\�h|])}t|j|j|j|jd����*Sr^)rDr�r�r�rcrIs  rrJz&install_collections.<locals>.<setcomp>�sB�����
�	�$�)�T�X�t�x���D�A�A���rzProcess install dependency maprz#Starting collection install processz '{coll!s}' is virtual, skipping.r�z*'{coll!s}' is already installed, skipping.aThe GnuPG keyring used for collection signature verification was not configured but signatures were provided by the Galaxy server to verify authenticity. Configure a keyring for ansible-galaxy to use or disable signature verification. Skipping signature verification.zeFailed to install collection {coll!s} but skipping due to --ignore-errors being set. Error: {error!s})r�r�)�find_existing_collectionsr�r
�
from_iterabler�r!r"r�r$r%r�rrKr�r��installr2)rr+r,�
ignore_errorsrr
�
force_depsrrr��disable_gpg_verifyr�unsatisfied_requirements�"existing_non_requested_collections�preferred_requirements�preferred_collections�dependency_map�keyring_existsr�r0r�rWrYs         `           @@r�install_collectionsrg�s%�����2��-�k�;L�M�M�����
 #�
��
�
�
�
� +�
�
�
�	
�	
�
 �
 ��$R�#Q�8P�#Q�#Q�#Q� ���!�*�!�����C�C�C�C�+�C�C�C���$��G�����
(�	
�	
�	
�
	��*�*�*�*�-�*�*�*�&��	"���38�"�
/�
/�
!��
��+�����

�;�	<�	<�
�
�/���!6�'8��/��#5�5��

�

�

��
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�'�.�d�:�N�	�@�	A�	A�(�(�'5�';�';�'=�'=�'	�'	�#�D�#� �+�
����6��F��(9� :� :�F�;�;����� �$9�9�9����@��F��(9� :� :�F�;�;�����%�	
�*;�*F�	
�~�	
����7����

��)�;�8I�J�J�J�J���
�
�
� �
��O�O�M���!(�):�!;�!;�")�#�,�,������������������
����9'	�(�(�(�(�(�(�(�(�(�(�(�(����(�(�(�(�(�(sP�
C3�3C7�:C7�CI�G,�+I�,
I�6A
I	�I�	I�I�I#�&I#c��|�d��\}}}tj|��r|Std|z���)z�Validates the collection name as an input from the user or a requirements file fit the requirements.

    :param name: The input name with optional range specifier split by ':'.
    :return: The input value, required for argparse validation.
    �:z�Invalid collection name '%s', name must be in the format <namespace>.<collection>. 
Please make sure namespace and collection name contains characters from [a-zA-Z0-9_] only.)�	partitionrN�is_valid_collection_namer2)r�
collection�dummys   r�validate_collection_namernsZ�� $�~�~�c�2�2��J��u��4�Z�@�@����
�<�?C�C�D�D�Drc��tj�|��ddkr tj�|d��S|S)z�Ensure a given path ends with 'ansible_collections'

    :param collection_path: The path that should end in 'ansible_collections'
    :return: collection_path ending in 'ansible_collections' if it does not already.
    rS�ansible_collections)r�r�r>r�)rAs r�validate_collection_pathrq$s@��
�w�}�}�_�%�%�a�(�,A�A�A��w�|�|�O�-B�C�C�C��rc��g}t||��}t��5|D�]�}	|jr)td�|j�������d|jz}	|D]�}
ttj	�
|
|j|j��d���}tj	�
|��s�\t|��sd|jz}	�vtj||��}d�|jpgD��}
t|j|j|j|jt)|
���	��}nt|	����|rd
}n�|�|��}|�d�|jpgD����t|j|jdkr|jn|jd
d
t)|����}	|s|js|�|��nW#t$rJ}d�|���}|j|kr#td�|�������d
}~wwxYwt3|||��}|�|����@#t$rK}|r=t6�d�|t;|�������n�Yd
}~���d
}~wwxYw	d
d
d
��n#1swxYwY|S)aMVerify the integrity of locally installed collections.

    :param collections: The collections to check.
    :param search_paths: Locations for the local collection lookup.
    :param apis: A list of GalaxyAPIs to query when searching for a collection.
    :param ignore_errors: Whether to ignore any errors when verifying the collection.
    :param local_verify_only: When True, skip downloads and only verify local manifests.
    :param artifacts_manager: Artifacts manager.
    :return: list of CollectionVerifyResult objects describing the results of each collection verification
    zM'{coll_type!s}' type is not supported. The format namespace.name is expected.)�	coll_type)�messagez>Collection %s is not installed in any of the collection paths.r�r�z�Collection %s does not have a MANIFEST.json. A MANIFEST.json is expected if the collection has been built and installed via ansible-galaxyc�8�g|]}t|t����Sr�r<r��r��sources  rr�z&verify_collections.<locals>.<listcomp>js2��/�/�/�"�2�&�'�B�B�/�/�/r)r�Nc�8�g|]}t|t����Srrvrws  rr�z&verify_collections.<locals>.<listcomp>~s2��'�'�'�"�2�&�'�B�B�'�'�'r�*�galaxyz4Failed to find collection {coll.fqcn!s}:{coll.ver!s}r�zHFailed to find remote collection '{coll!s}' on any of the galaxy serverszdFailed to verify collection '{coll!s}' but skipping due to --ignore-errors being set. Error: {err!s})r�r�)r9r!r�r2rrcr�rIr�r�r�r#rrrErDrM�signature_sourcesr�r��	frozenset�get_signatures�extend�get_collection_version_metadatartr�r�r�r�rK)r�search_pathsr,r^�local_verify_onlyr��results�	api_proxyrl�default_err�search_path�
b_search_pathr��supplemental_signaturesr�r��e�expected_error_msgr�r�s                    r�verify_collectionsr�1s��$�G�#�D�*;�<�<�I�	�	�	�j�j�%�i	�i	�J�h
��2��&�!A������9�9�����_�ak�ap�p��#/�#<�#<�K�$,�����'�&�0�*�/��� 5�%�%�%�M��7�=�=��7�7�!� �7�
�F�F�!�?�AK��Q�$�
!�'0�'>�%�'8�(�(�$�/�/�&0�&B�&H�b�/�/�/�+�(1�(�-�(�,�(�,�(�-�#,�-D�#E�#E�(�(�(�$��E�&�{�;�;�;�;�$�(�(,�%�%�!*�!9�!9�:J�!K�!K�J��%�%�'�'�&0�&B�&H�b�'�'�'����
)2�"��*4�.�C�*?�*?�
���-�1��h�!�*�-�-�)�)�%�� *��*�2N��%�E�E� 1������(����S�"�F�
�F�3�3�+��9�(:�:�:�".�!J� &��J�� 7� 7�#�#��
���������1�1A�CT�Vg�h�h�����v�&�&�&�&���	
�	
�	
� ���O�O�)���J�G�C�L�L��A�A�	��������������	
����Ai	�j�j�j�j�j�j�j�j�j�j�j����j�j�j�j�X�Nsa�K	�FI$�G%�$I$�%
H9�/AH4�4H9�9)I$�"K	�$
J9�.AJ4�.K	�4J9�9K	�	K
�K
c#��K�tjttjd������}	|V�tj|��dS#tj|��wxYw)Nr�r�)r�)�tempfile�mkdtemprI�C�DEFAULT_LOCAL_TMPr(�rmtree)�b_temp_paths r�_tempdirr��sg�����"�x��0C�La�'b�'b�'b�c�c�c�K�#������
�k�"�"�"�"�"���
�k�"�"�"�"���s�A�A"c#�$K�tj}|�tj���n|}|�t
�|��|sdV�dSd�}Gd�dt��}t
}	tj��}||��atj
|||f���}d|_|j��	dV�d|_
|j��n#d|_
|j��wxYwn#t$r�wxYw	|adS#|awxYw)Nc��|�d��tj��}	dD]�}|�|dzd���t	jd��		|�dd���\}}}t||��}||i|��n#tj	$rYnwxYw�Kt|d	d��r|�d
��dS����)Nz(Starting display_progress display threadTz|/-\�F)�newlineg�������?)�blockrC�finishz7Received end signal for display_progress display thread)
�debug�	threading�current_threadr��time�sleep�getr`�queue�Empty)�
display_queue�actual_display�t�c�method�args�kwargs�funcs        r�progressz#_display_progress.<locals>.progress�s�����G�H�H�H��$�&�&��	��
�
���&�&�q�4�x��&�?�?�?��
�3����.�.�/<�/@�/@�u�VY�/@�/Z�/Z�,���f� '�~�v�>�>����d�-�f�-�-�-�-��	!�;����������.��1�h��.�.��"�(�(�)b�c�c�c��F�F��	s�B�B$�#B$c��eZdZd�Zd�ZdS)�(_display_progress.<locals>.DisplayThreadc��||_dSr^)r�)rdr�s  rruz1_display_progress.<locals>.DisplayThread.__init__�s��!.�D���rc������fd�}|S)Nc�B���j��||f��dSr^)r��put)r�r��attrrds  ��r�call_displayzJ_display_progress.<locals>.DisplayThread.__getattr__.<locals>.call_display�s'����"�&�&��d�F�';�<�<�<�<�<rr)rdr�r�s`` r�__getattr__z4_display_progress.<locals>.DisplayThread.__getattr__�s*����
=�
=�
=�
=�
=�
=� �rN)rrrrur�rrr�
DisplayThreadr��s2������	/�	/�	/�	 �	 �	 �	 �	 rr�)�targetr�T)r��GALAXY_DISPLAY_PROGRESS�sysrq�isattyr��objectr��Queuer��Thread�daemon�startr�r��	Exception)r��config_display�
display_wheelr�r��old_displayr�r�s        rr!r!�sh�����.�N�+9�+A�C�J�%�%�'�'�'�~�M������������
���������.	 �	 �	 �	 �	 ��	 �	 �	 ��K����
�
�
��-�
�.�.����H�M�;�3O�P�P�P��������	�	�	�	��E�E�E��A�H��A�F�H�H�H�H���A�H��A�F�H�H�H�H����H������
�����
�
�����+�����s7�3AC7�C�C7�C3�3C7�6D�7D�D�Dc��ttj�t	|��|��d���}tj�|��sd}n8t
|d���5}t|��}ddd��n#1swxYwY||kr'|�t|||�����dSdS)Nr�r��rbrrU)
rIr�r�r�rK�isfiler)r4r�rT)�b_pathrVr��error_queue�b_file_path�actual_hash�file_objects       rr�r�s����2�7�<�<������B�B�K`�a�a�a�K�
�7�>�>�+�&�&�5����
�+�D�
)�
)�
)�	5�[�'��4�4�K�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5���#�#����?�H�}�`k�l�l�l�m�m�m�m�m�$�#s�0B�B�Bc�.�ddddtd�gtd�S)N�.r�rr0��MANIFEST_FORMATrrr�_make_manifestr�s6����#�!%�)�
�
�
�"���rr
c
�2�d|d|d|r|ndd|��|dtiS)Nrr r!�chksum_rr�)rr r!�chksums    r�_make_entryr�s6�������f�6�{�{�$��+�����/��rc��|r|turtd���|turt||||��St||||��S)Nz4"build_ignore" and "manifest" are mutually exclusive)rRr2�_build_files_manifest_distlib�_build_files_manifest_walk)r�r#r�ignore_patterns�manifest_controls     rrr)se���S�+�8�;�;��Q�R�R�R��x�'�'�,�����	
�
�	
�&�&7��D�/�Z�Z�Zrc
��tstd���|�i}	td!i|��}n$#t$r}td|�����d}~wwxYwt	|j��s!td|jjj�����t|j	t��s!td|j	jj�����|j	r|jstd���g}|j	r|�|j��n�|�gd���td�t��D����}t|��D].}|dvr�|tjvr|�d	|�d
����/|�ddg��|�|j��|�d
|�d|�d�ddg��t$�d��t$�t)jd�|��d����t/|d���}	t1|	��}
|D][}	|
�|���#t4$r}td|�����d}~wt6$r}td|�����d}~wwxYwt9��}
|
�d���D]�}t:j�||	��}t:j� |��rtC|d��}n'tC|ddtE|tF������}|
d �|����|
S)"Nz7Use of "manifest" requires the python "distlib" libraryzInvalid "manifest" provided: z+"manifest.directives" must be a list, got: zE"manifest.omit_default_directives" is expected to be a boolean, got: z�"manifest.omit_default_directives" was set to True, but no directives were defined in "manifest.directives". This would produce an empty collection artifact.)zinclude meta/*.ymlz(include *.txt *.md *.rst COPYING LICENSEzrecursive-include tests **zArecursive-include docs **.rst **.yml **.yaml **.json **.j2 **.txtz4recursive-include roles **.yml **.yaml **.json **.j2z2recursive-include playbooks **.yml **.yaml **.jsonz+recursive-include changelogs **.yml **.yamlz!recursive-include plugins */**.pyc3�\K�|]'\}}|j�d��dV��(dS)r����N)�packager>)r��d�ls   rrOz0_build_files_manifest_distlib.<locals>.<genexpr>es9����T�T�4�1�a�a�i�o�o�c�*�*�2�.�T�T�T�T�T�Tr)�modules�module_utilszrecursive-include plugins/z **.yml **.yamlz7recursive-include plugins/modules **.ps1 **.yml **.yamlz;recursive-include plugins/module_utils **.ps1 **.psm1 **.csz8exclude galaxy.yml galaxy.yaml MANIFEST.json FILES.json �-z	-*.tar.gzz!recursive-exclude tests/output **zglobal-exclude /.* /__pycache__zManifest Directives:r�z    r�r�zInvalid manifest directive: z-Unknown error processing manifest directive: T)�wantdirsr�r�r
��	hash_func�r!r�r1r)$�HAS_DISTLIBr2rZ�	TypeErrorrLr[rfr�
isinstancer\rkrr�rG�sortedr��DOCUMENTABLE_PLUGINSr�r�r�r��indentr�rKr�process_directiverr�r�r�r��relpathrr�rPr
)r�r#rr��control�exr[�plugins�pluginr�m�	directiver�r��abs_path�rel_path�manifest_entrys                 rr�r�9s"���V��T�U�U�U�����A�!�5�5�$4�5�5�����A�A�A��?�2�?�?�@�@�@�����A�����w�)�*�*�r��p��I[�Ie�In�p�p�q�q�q��g�5�t�<�<�
��
D��.�8�A�
D�
D�
�
�	
�
�&�
�w�/A�
��
Y�
�
�	
�
�J��&�"����'�,�-�-�-�-����	
�	
�	
�		�		�		��T�T�;Q�;S�;S�T�T�T�T�T���W�o�o�	�	�F��4�4�4���1�1�1�1��!�!�H��H�H�H�����	���E�I�
�	�	�	�
	���'�,�-�-�-����b�y�b�b�SW�b�b�b�/�-�
�	�	�	��K�K�&�'�'�'��K�K����	�	�*� 5� 5�v�>�>�?�?�?�� 1�:O�P�P�P���"�#�#�A��T�T�	�	T�
���	�*�*�*�*���	C�	C�	C��A�a�A�A�B�B�B������	T�	T�	T��R�q�R�R�S�S�S�����	T�������H��H�H�d�H�+�+�1�1���7�?�?�8�->�?�?��
�7�=�=��"�"�	�(��5�9�9�N�N�(���$�"�8�v�>�>�>�	���N�	��� � ��0�0�0�0��Os8�)�
A
�A�A
�I�
J�'I9�9
J�J�Jc�������ddddddddtd	�||����g	��d
�|D��z
�tgd����t�������fd���||���S)
Nr�r�s
galaxy.ymlsgalaxy.yaml�.gits*.pycs*.retrystests/outputz{0}-{1}-*.tar.gzc�,�g|]}t|����Sr)rI�r��ps  rr�z._build_files_manifest_walk.<locals>.<listcomp>�s��?�?�?�!�(�1�+�+�?�?�?r)sCVSs.bzrs.hgr�s.svns__pycache__s.toxc������tj|��D�]N�tj�|���}||krdn|t	|��dzd�}tj�|����t�d���}tj�|���r1t�fd��	D����st�fd��
D����r+t�	dt|��z����tj�
|��r[tj�|��}t||��s,t�
dt|��z����q�d	�t|d
����tj�
|��s�||�����t�fd��
D����r,t�	dt|��z�����d	�t|dd
t!|t"����������PdS)NrrSr�r�c3�$�K�|]
}�|kV��dSr^r)r�r��b_items  �rrOz<_build_files_manifest_walk.<locals>._walk.<locals>.<genexpr>�s(�����D�D�F�v��'�D�D�D�D�D�Drc3�B�K�|]}tj�|��V��dSr^��fnmatch�r��	b_pattern�
b_rel_paths  �rrOz<_build_files_manifest_walk.<locals>._walk.<locals>.<genexpr>�s/�����f�f�y�G�O�J�	�B�B�f�f�f�f�f�frz"Skipping '%s' for collection buildzLSkipping '%s' as it is a symbolic link to a directory outside the collectionr1r�c3�B�K�|]}tj�|��V��dSr^r�rs  �rrOz<_build_files_manifest_walk.<locals>._walk.<locals>.<genexpr>�s/�����a�a�)�w��z�9�=�=�a�a�a�a�a�arr�r
r�r�)r��listdirr�r�r�rKr�anyr�r��islink�realpath�_is_child_pathr�r�r�rPr
)r��b_top_level_dir�
b_abs_path�b_rel_base_dirr��
b_link_targetr�r�_walk�
b_ignore_dirs�b_ignore_patternsr�s      @@����rrz)_build_files_manifest_walk.<locals>._walk�sb������j��(�(�&	�&	�F�����f�f�5�5�J�$*�o�$=�$=�S�S�6�#�o�J^�J^�ab�Jb�Jc�Jc�Cd�N�����n�f�=�=�J��z�2G�H�H�H�H��w�}�}�Z�(�(� 
��D�D�D�D�m�D�D�D�D�D���f�f�f�f�Te�f�f�f�f�f���K�K� D�w�z�GZ�GZ� Z�[�[�[���7�>�>�*�-�-�!�$&�G�$4�$4�Z�$@�$@�M�)�-��I�I�!����(v�*1�*�*=�*=�)>�?�?�?� ���!�(�(��X�u�)E�)E�F�F�F��w�~�~�j�1�1�7��E�*�o�6�6�6���a�a�a�a�O`�a�a�a�a�a���K�K� D�w�z�GZ�GZ� Z�[�[�[����!�(�(�� ��$,�*�:��H�H�H�	�������?&	�&	r)rIrr}r�)r�r#rr�rrrr�s    @@@@rr�r��s�������
	���������#�*�*�9�d�;�;�<�<�
���?�?��?�?�?�?���b�b�b�c�c�M����H�'�'�'�'�'�'�'�'�R
�E�
�.�/�/�/��Orc
�`�||||||||
d|pd||	|
||d�ddddtd�td�}|S)Nr))r#rr$r%r&r'r(r)r*r+r,r-r.r/�
FILES.jsonr�r
rrr�)r#rr$r%r&r'r(r*r+r,r-r.r/r�r�s               rrr�su��#������&��i�(�(�0�D�(�$�*� ��
�
�"!��#�!�%�
�
�"�1��H�6�Orc
�4�ttj|d���d���}t|t���|dd<ttj|d���d���}t��5}tj�|tj�	|����}tj|d�	��5}t|fd
|ffD]\}	}
t|
��}tj|	��}t|
��|_t#t%j����|_d|_|�||�����|d
D�]�}
|
ddkr�t-|
dd���}tj�|t|d�����}d�}tj�|��r�tj�|��}t3||��r�tj�|tj�|�����}tj|��}tj|_t-|d���|_||��}|�|�����C|�t-tj�|����|d|������	ddd��n#1swxYwYtAj!t-|��t-|����|dd�d|dd��}tE|��}tF�#d|�d|����|cddd��S#1swxYwYdS)z:Build a tar.gz collection artifact from the manifest data.T�r�r�r�r�rr"zw:gzrr�)�tarinfo�fileobjr1rr�c���|jtjkr3|jtjz}|s|���rdnd|_dx|_|_dx|_	|_
|S)N��rr�)rc�tarfile�SYMTYPEr �stat�S_IXUSRr�uid�gid�uname�gname)r�existing_is_execs  r�
reset_statz)_build_collection_tar.<locals>.reset_stats_���|�w��6�6�+2�<�$�,�+F�(�1A�'`�W�]�]�_�_�'`�v�v�Z`���01�1�G�K�'�+�46�6�G�M�G�M�"�Nr)r�)rF)�arcname�	recursive�filterNrr#zCreated collection for z at )$rI�json�dumpsrQr
r�r�r�r�r&rr)r�r�TarInfor��sizer�r��mtimer �addfilerJrrr	r��dirnamerrc�linknamer�r(r#rKr�)r��
b_tar_pathr
r��files_manifest_json�collection_manifest_jsonr��b_tar_filepath�tar_filer�b�b_io�tar_info�	file_inforVr1r$r
rrx�tar_paths                     rrr�s���#�4�:�m�D�#I�#I�#I�Rg�h�h�h��AN�Ob�nt�Au�Au�Au��,�-�o�>�'��
�3F�t�(T�(T�(T�]r�s�s�s��	���8�{�����k�2�7�3C�3C�J�3O�3O�P�P��
�\�.�v�
6�
6�
6�.	�(�.�0H�I�L�Zm�Kn�o�
A�
A���a��q�z�z��"�?�4�0�0�� #�A����
�!$�T�Y�[�[�!1�!1��� &��
�� � ��4� �@�@�@�@�*�7�3�$
�$
�	��V�$��+�+��%�Y�v�%6�?T�U�U�U���W�\�\�*;�X�h�Wl�=m�=m�=m�n�n�
�#�#�#��7�>�>�*�-�-�!�$&�G�$4�$4�Z�$@�$@�M�%�m�5F�G�G�	!�%'�W�_�_�]�"�'�/�/�Zd�Je�Je�_�%f�%f�
�#*�?�8�#<�#<��(/���
�,5�j�I^�,_�,_�,_��)�#-�:�h�#7�#7�� �(�(��(�:�:�:� �����b�g�.�.�z�:�:�;�;�$�#�%�	�����?$
�.	�.	�.	�.	�.	�.	�.	�.	�.	�.	�.	����.	�.	�.	�.	�`	��I�n�-�-�y��/D�/D�E�E�E�%8�9J�%K�K�%X�%X�%X�%8�9J�%K�F�%S�%S�U���:�&�&������o�o�o�x�x�X�Y�Y�Y��q8�8�8�8�8�8�8�8�8�8�8�8����8�8�8�8�8�8s9�8AN
�HK7�+N
�7K;	�;N
�>K;	�?BN
�
N�Nc��tj|d���ttj|d���d���}t|t���|dd	<ttj|d���d���}t|fd
|ffD]�\}}tj�	|t|d�����}t|d��5}	t|��5}
tj
|
|	��ddd��n#1swxYwYddd��n#1swxYwYtj|d
����g}t|dd����D�]}|ddkr�tj�	|t|dd�����}
tj�	|t|dd�����}tj|
��jt jz}|rdnd
}tj�|
��r-d}|�|
��tj||��ntj|
|��tj||����t/|��}|S)z|Build a collection directory from the manifest data.

    This should follow the same pattern as _build_collection_tar.
    rrTrr�r�r�rr"rrNrr1c��|dS)Nrr)�xs r�<lambda>z'_build_collection_dir.<locals>.<lambda>Xs
��!�F�)�r)�keyrr�)r��makedirsrIr(r)rQr
r�r�r�r)rr(�copyfileobj�chmodr�r�st_moderrr��mkdir�copyfilerK)r�rr
r�r1r2rr5r��file_objr6�base_directoriesr8�src_file�	dest_filer#r rs                  r�_build_collection_dirrIDs���
�K�#�&�1�1�1�1�"�4�:�m�D�#I�#I�#I�Rg�h�h�h��AN�Ob�nt�Au�Au�Au��,�-�o�>�'��
�3F�t�(T�(T�(T�]r�s�s�s��'�(@�A�L�Re�Cf�g�!�!���a�����1�8�D�I^�3_�3_�3_�`�`��
�&�$�
�
�	/�8�W�Q�Z�Z�	/�4���t�X�.�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	���� � � � ����M�'�2�8K�8K�L�L�L�"�"�	��V���#�#���7�<�<� 1�8�I�f�<M�Vk�3l�3l�3l�m�m���G�L�L�!4�h�y��?P�Yn�6o�6o�6o�p�p�	��7�8�,�,�4�t�|�C��)�5�v�v�v��
�7�=�=��"�"�	1��D��#�#�H�-�-�-��H�Y��%�%�%�%��O�H�i�0�0�0�
���D�!�!�!�!�� 3�4�4���s6�D�!D�7D�D�D�
D�D�D	�!D	c
#��K�t|d���}tj|��D�]7}tj�||��}tj�|��r�Ctj|��D]�}tj�||��}tj�|��s�B	tj||��}n4#t$r'}tt|��|��Yd}~nd}~wwxYwt�
d�t|��t|j�������|V����9dS)z�Locate all collections under a given path.

    :param path: Collection dirs layout search path.
    :param artifacts_manager: Artifacts manager.
    r�r�Nz1Found installed collection {coll!s} at '{path!s}'r)rIr�rr�r�r�rrD�from_dir_path_as_unknown�
ValueErrorrHr2r�r�rrKr�)	r�r�r��b_namespace�b_namespace_path�b_collectionr�rT�val_errs	         rr[r[nsl�����d�#8�
9�
9�
9�F��z�&�)�)�����7�<�<���<�<��
�7�>�>�*�+�+�	���J�'7�8�8�	�	�L� "����-=�|� L� L���7�=�=�!2�3�3�
��
;��8�9J�L]�^�^�����
;�
;�
;��<��0�0�'�:�:�:�:�:�:�:�:�����
;����
�K�K�D���G�C�L�L�w�s�w�/?�/?��@�@�
�
�
��I�I�I�I�	�
�s�C�
D	�"D�D	c	��|jr|jn|j|��}tj�||j|j��}t|d���}t�	d�
t|��|�����tj�|��rtj|��|jrt!||||��n`t#|||j|j|j|j|j��|jr+t1|jt4��rt7|||��t�	d�
t|�������dS)z�Install a collection under a given path.

    :param collection: Collection to be installed.
    :param path: Collection dirs layout path.
    :param artifacts_manager: Artifacts manager.
    r�r�z#Installing '{coll!s}' to '{path!s}'rz#{coll!s} was installed successfullyr�N)r�r�r�r�r�r�r#rrIr�rrKrr(r�r'�install_src�install_artifact�_b_working_directoryr�r�r�r��is_online_index_pointerr�r�r3�write_source_metadata)rlr�r��b_artifact_pathrAr�s      rr]r]�s���	8�z�/N�	8��+�+�
�
7����O�
�g�l�l�4��)=�z��O�O�O� ��9N�O�O�O���O�O�.���G�J�'�'�o��>�>����

�w�~�~�'�(�(�)��
�'�(�(�(�����J��1B�DU�V�V�V�V�����2��!��%��A��5�	
�	
�	
�
�.�	�:�j�n�i�3X�3X�	�!��!�!�
�
�
��O�O�-���G�J�'�'��(�(�����rc��|�|��}tt|��d���}|�|��}tj�|��d}tj�|��rtj	|��	t	j
|d���t|d���5}|�|��ddd��n#1swxYwYt	j
|d��dS#t$r5tj�|��rtj	|���wxYw)Nr�r�rrrzw+br)�get_galaxy_artifact_source_inforIrM�construct_galaxy_info_pathr�r�r>rr(r�rCr)r*rAr�r)rlr�r��source_data�b_yaml_source_data�b_info_dest�
b_info_dir�fds        rrVrV�sq��#�C�C�J�O�O�K�!�)�K�"8�"8�AV�W�W�W���7�7�8I�J�J�K�����{�+�+�A�.�J�	�w�~�~�j�!�!�"��
�j�!�!�!�	�
���&�)�)�)�)�
�+�E�
*�
*�
*�	)�b��H�H�'�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�
���f�%�%�%�%�%������
�7�=�=��$�$�	&��M�*�%�%�%�
�	���s0�"'D
�	C+�D
�+C/�/D
�2C/�3D
�
?Ec��d}t|d����tjj��}|d�d|d��}t||||||��st
d|�d����t�d	|����dS)
NFr�r����r����zNot installing z- because GnuPG signature verification failed.z+GnuPG signature verification succeeded for )	rKr>r�r��sepr�r2r�r�)r�r�r��required_signature_countr��
failed_verify�coll_path_partsrxs        r�verify_artifact_manifestrg�s����M��m�4I�J�J�J�P�P�QS�QX�Q\�]�]�O�!0��!4�!4�!4�o�b�6I�6I�J�O�!�/�=�*�g�Wo�rI�J�J�m��k�_�k�k�k�l�l�l��L�L�P��P�P�Q�Q�Q�Q�Qrc
��	tj|d���5}t|t||��|�Gtj�t|d���t��}t|||||��|�	d��}	t||	��5\}
}tjt|�
��d�����}ddd��n#1swxYwYt|d||��|dD]I}
|
d}|d	kr�|
d
dkrt|||||
d�
���8t|||���J	ddd��dS#1swxYwYdS#t$r]t!j|��tj�|��}t	j|��st	j|���wxYw)a.Install a collection from tarball under a given path.

    :param b_coll_targz_path: Collection tarball to be installed.
    :param b_collection_path: Collection dirs layout path.
    :param b_temp_path: Temporary dir path.
    :param signatures: frozenset of signatures to verify the MANIFEST.json
    :param keyring: The keyring used during GPG verification
    :param required_signature_count: The number of signatures that must successfully verify the collection
    :param ignore_signature_errors: GPG errors to ignore during signature verification
    �rrNr�r�rr1rr�r r�r")r�)rr)�_extract_tar_filer�r�r�r�rKrg�	getmemberr8r(�loads�read�_extract_tar_dirr�r(r�r.r�rmdir)�b_coll_targz_pathr�r�r�r�rdr��collection_tarr��files_member_objrm�	files_objr1r8�	file_namerNs                rrSrS�s���#�
�\�+�#�
6�
6�
6�	S�.��n�.?�AR�T_�`�`�`��"� "����W�5F�Od�-e�-e�-e�gx� y� y�
�(��
�G�Me�g~����-�7�7��E�E��!�.�2B�C�C�
\�GY��y��
�7�9�>�>�+;�+;�DY�#Z�#Z�#Z�[�[��
\�
\�
\�
\�
\�
\�
\�
\�
\�
\�
\����
\�
\�
\�
\�
�n�l�<M�{�[�[�[�"�7�^�

S�

S�	�%�f�-�	���#�#���W�%��/�/�%�n�i�AR�T_�4=�o�4N�P�P�P�P�P�%�^�Y�@Q�R�R�R�R�

S�	S�	S�	S�	S�	S�	S�	S�	S�	S�	S�	S�	S����	S�	S�	S�	S�	S�	S��4�����
�'�(�(�(��7�?�?�+<�=�=���z�*�+�+�	'��H�%�&�&�&�
����sU�E-�BE �9C#�E �#C'	�'E �*C'	�+A'E �E-� E$�$E-�'E$�(E-�-A'Gc�2�|�|��}d|vrg|d<tdi|��}t||d|d|d|d��}t||||��}t�d�||�����dS)	a�Install the collection from source control into given dir.

    Generates the Ansible collection artifact data from a galaxy.yml and
    installs the artifact to a directory.
    This should follow the same pattern as build_collection, but instead
    of creating an artifact, install it.

    :param collection: Collection to be installed.
    :param b_collection_path: Collection dirs layout path.
    :param b_collection_output_path: The installation directory for the \
                                     collection artifact.
    :param artifacts_manager: Artifacts manager.

    :raises AnsibleError: If no collection metadata found.
    rr#rr�z+Created collection for {coll!s} at {path!s}rNr)�get_direct_collection_metarrrIr�r)rlr��b_collection_output_pathr�rr
r��collection_output_paths        rrRrRs��� (�B�B�:�N�N�O��_�,�,�*,���'�)�<�<�O�<�<��)����$�o�f�&=���'��
�#�	��M�3��3��]����
�O�O�5���J�%;��<�<�����rc���t|d���g}|d�tjj��s-|�|dtjjz��|D]*}	|�|��}n#t$rY�%wxYwn!tdt|d���z���tj�	|t|d�����}tj�|��}	tj|d���n-#t$r }|jtjkr�Yd}~nd}~wwxYw|jt"jkrbt|jd���}	t)|	||���s#td	t|���d
|	�d����tj|	|��dStj�|��stj|d��dSdS)z- Extracts a directory from a collection tar. r�r�r�z&Unable to extract '%s' from collectionrrN��	link_name�Cannot extract symlink '�@' in collection: path points to location outside of collection '�')rJ�endswithr�r�rcr�rk�KeyErrorr2r�rIr.r?�OSError�errno�EEXISTrcrrr/r	�symlinkrrC)
�tarr.�b_dest�member_names�member�
tar_member�
b_dir_path�
b_parent_pathr��b_link_paths
          rrnrn8s,���g�.C�D�D�D�E�L����$�$�R�W�[�1�1�<����L��,�r�w�{�:�;�;�;��w�w��	����v�.�.�J�J���	�	�	��H�	����
���C�i�PV�_t�Fu�Fu�Fu�u�v�v�v�����f�h�w�?T�&U�&U�&U�V�V�J��G�O�O�J�/�/�M��
��M��/�/�/�/�/�������7�e�l�"�"��#�"�"�"�"�����������'�/�)�)��z�2�;P�Q�Q�Q���k�6�Z�H�H�H�	V��,�4=�g�4F�4F�4F�4F���� U�V�V�
V�	�
�;�
�+�+�+�+�+��w�}�}�Z�(�(�	)��H�Z��(�(�(�(�(�	)�	)s*�/B�
B�B�D�
E�(E�Ec
�N�t||��5\}}|jtjkrt	|��}n>tj|d���5}t	||��}ddd��n#1swxYwY|r=||kr7tdt|d����dt|j	���d����tj�tj�
|t|d�������}	tj�|	��}
t!|
|��s!td	t|d���z���tj�|
��stj|
d
���|jtjkrat|jd���}t!|||	���s#td
t|���d|�d����tj||	��n�t+jt|j	d���|	��|�t|d�����}d}t1j|j��t0jzr|dz}tj|	|��ddd��dS#1swxYwYdS)z( Extracts a file from a collection tar. F)r��deleteNzChecksum mismatch for 'r�r�z' inside collection at 'r~zSCannot extract tar entry '%s' as it will be placed outside the collection directoryrrrzr|r}r�I)�_get_tar_file_memberrcrrr4r��NamedTemporaryFiler2rJrr�r��abspathr�rIr.r	rr?r/r�r(�moverkr�S_IMODEr rrA)
r�rVr�r�r�r��tar_objr��tmpfile_obj�b_dest_filepath�b_parent_dirr��new_modes
             rrjrjas@��	�c�8�	,�	,�(0�0E��W��?�g�o�-�-�'��0�0�K�K��,��U�K�K�K�
B�{�+�G�[�A�A��
B�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B����
B�
B�
B�
B��	k�[�M�9�9��,�"+�H�=R�"S�"S�"S�"S�"S�U^�_b�_g�Uh�Uh�Uh�Uh� j�k�k�
k��'�/�/�"�'�,�,�v�x��Yn�?o�?o�?o�*p�*p�q�q���w����7�7���l�F�3�3�	T��t�!*�8�<Q�!R�!R�!R� S�T�T�
T��w�~�~�l�+�+�	3�
�K��6�2�2�2�2��?�g�o�-�-�"�:�#6�?T�U�U�U�K�!�+�v��Q�Q�Q�
[�"�l�8A�(�8K�8K�8K�8K�[�[�[�$Z�[�[�[�
�J�{�O�4�4�4�4�
�K���!1�:O�P�P�P�Ra�b�b�b����y��BW�'X�'X�'X�Y�Y�J��H��|�J�O�,�,�t�|�;�
#��F�"���H�_�h�/�/�/�Q(0�(0�(0�(0�(0�(0�(0�(0�(0�(0�(0�(0����(0�(0�(0�(0�(0�(0s6�?J�A-�!J�-A1	�1J�4A1	�5HJ�J�!Jc���t|d���}	|�|��}n6#t$r)tdt|j���d|�d����wxYwt||��S)Nr�r�zCollection tar at 'z&' does not contain the expected file 'z'.)rJrkr�r2rr8)r�rV�
n_filenamer�s    rr�r��s����8�,A�B�B�B�J�����z�*�*���������l��c�h������J�J����	�����
�C��(�(�(s	�)�3Ac�d�d}tj|d���5}t||��5\}}d}|�|��}|r)|t	|��z
}|�|��}|�)ddd��n#1swxYwYddd��n#1swxYwYtj|��S)Nrriri)rr)r�rmrKr(rl)r�rV�
file_contentsrqrmr��bufsize�datas        rr�r��s0���M�	��f�3�	'�	'�	'�-�>�
!�.�(�
;�
;�	-�?O��w��G��<�<��(�(�D��
-������.�
��|�|�G�,�,���
-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-�	-����	-�	-�	-�	-�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-��:�m�$�$�$s5�B�AA<�0B�<B	�B�B	�B�B�Bc���tj|d���5}t||��5\}}t|��cddd��cddd��S#1swxYwY	ddd��dS#1swxYwYdS)Nrir)rr)r�r4)r�rVrqrmr�s     rr�r��s��	��f�3�	'�	'�	'�*�>�
!�.�(�
;�
;�	*�?O��w� ��)�)�	*�	*�	*�	*�	*�	*�	*�*�*�*�*�*�*�*�*�	*�	*�	*�	*����	*�	*�	*�	*�	*�*�*�*�*�*�*�*�*�*�*�*�*����*�*�*�*�*�*s3�A,�A�A,�A	�A,�A	�A,�,A0�3A0c���tj�|t|d�����}t	|d��5}t|��cddd��S#1swxYwYdS)Nr�r�r�)r�r�r�rIr)r4)r�rV�filepath�fps    rr�r��s����w�|�|�F�H�X�>S�$T�$T�$T�U�U�H�	
�h��	�	�!���R� � �!�!�!�!�!�!�!�!�!�!�!�!����!�!�!�!�!�!s�A�A �#A c���t|d���}|r�tj�|��sktj�t|d�����}tj�tj�||����}t|d���}||kp3|�|ttjj��z��S)z> Checks that path is a path within the parent_path specified. r�r�)	rIr�r��isabsr.r�r��
startswithrc)r��parent_pathr{r��
b_link_dirr�s      rr	r	�s���
�d�#8�
9�
9�
9�F��C�����v�.�.�C��W�_�_�X�i�@U�%V�%V�%V�W�W�
���������j�&�!A�!A�B�B���[�1F�G�G�G�M��]�"�^�f�&7�&7�
��QS�QX�Q\�H]�H]�8]�&^�&^�^rc	���tstd���tstd���d}		td��}
t	�fd�|
jpgD��d��}	n#t$rYnwxYw|	�Httcxkrtks+ntdtj
�dtj
�����n�|	j�tj
��std|	j
�|	j�����n�#|	�Httcxkrtks+ntdtj
�dtj
�����nB|	j�tj
��std|	j
�|	j�����wxYwt|||||||||�	�	�	}	|�|d
���jS#t"$rc}d�|jD��}
t't)d
|
����}t+td�|����|���d}~wt.$r�}d�|j���D��}d�|j|sdn(d�d�|��������g}|j���D]+}	|�d�|	������,t+td�|����|���d}~wt<$r"}tt?|����|�d}~wwxYw)z#Return the resolved dependency map.zHFailed to import resolvelib, check that a supported version is installedzGFailed to import packaging, check that a supported version is installedNzansible-corec3�P�K�|] }t|��x�jdk��V��!dS)�
resolvelibN)rr)r�ri�rrs  �rrOz)_resolve_depenency_map.<locals>.<genexpr>�s;�����`�`�1��q�	�	�/�"�9O�S_�9_�9_�B�9_�9_�9_�9_�`�`rz#ansible-galaxy requires resolvelib<z,>=zansible-galaxy requires )	rr�user_requirementsr�	with_deps�with_pre_releasesrrri��)�
max_roundsc3�K�|]B}d�|j|j�dnd�|j������V��CdS)z+* {req.fqcn!s}:{req.ver!s} ({dep_origin!s})N�direct request�dependency of {parent!s}��parent�rT�
dep_origin)r�requirementr�)r��req_infs  rrOz)_resolve_depenency_map.<locals>.<genexpr>�sx����	
�	
��
:�@�@��'��>�)�,�+�/���g�n��-�-�
A�
�
�	
�	
�	
�	
�	
�	
r)z_Failed to resolve the requested dependencies map. Could not satisfy the following requirements:r�c�D�g|]}|�|j�d|j�d|j����S)Nr�ri)r#rr�r�s  rr�z*_resolve_depenency_map.<locals>.<listcomp>
s<��
�
�
���}��+�+�+�q�v�v�v�q�u�u�5��}�}rz�Failed to resolve the requested dependencies map. Got the candidate {req.fqcn!s}:{req.ver!s} ({dep_origin!s}) which didn't satisfy all of the following requirements:r�r�z, r�r�z* {req.fqcn!s}:{req.ver!s})rT) �HAS_RESOLVELIBr2�
HAS_PACKAGINGrr��requiresr�rBrArC�vstring�	specifier�containsrr>�resolve�mappingr?�causesrhr
rHr�r@�	criterion�iter_parentr�	candidate�iter_requirementr�rLrJ)�requested_requirementsrrrrrrrrrT�dist�collection_dep_resolver�dep_exc�conflict_causes�error_msg_lines�parents�excr�s                 @rr"r"�s(����g��e�f�f�f��f��d�e�e�e�
�C�U��N�+�+���`�`�`�`���!4�"�`�`�`�bf�g�g�����
�
�
���
����
�;�)�,>�V�V�V�V�AV�V�V�V�V�"�{�:O�:W�{�{�\q�\y�{�{����W���'�'�(:�(B�C�C�	U��S�#�(�S�C�M�S�S�T�T�T�	U���;�)�,>�V�V�V�V�AV�V�V�V�V�"�{�:O�:W�{�{�\q�\y�{�{����W���'�'�(:�(B�C�C�	U��S�#�(�S�C�M�S�S�T�T�T�T�T�T�T�B��#=�0�1��+�+��-��
�
�
��;4�&�.�.�"��/�
�
��	��4�
�
�
�	
�	
�#�>�	
�	
�	
���u�
�

�
 
� 
���������?�3�3�4�4��
�
�	
�����5�
�
�
�
�
��&�2�2�4�4�
�
�
��K����)�"� 6�/�/�(B��F�$�)�)�G�"4�"4�F�5�5�	���
���$�5�5�7�7�	�	�C��"�"�,�3�3��3�<�<�
�
�
�
������?�3�3�4�4��
�
�	
������4�4�4��9�S�>�>�*�*��3�����4���s\�A$�$D�$
A1�.D�0A1�1D�BF�,G�
M�AH0�0
M�=C L�
M�*M�Mr^)r
N)��__doc__�
__future__rrrrc�
__metaclass__r�rr�r(r�r�r�r(rr�rr�r�r�r��typingr�rr�
contextlibr�dataclassesrr	r_�hashlibr
�ior�importlib.metadatar�	itertoolsr
�packaging.requirementsrrr��ImportError�distlib.manifestr�distlibrr��
TYPE_CHECKING�3ansible.galaxy.collection.concrete_artifact_managerr�Literal�ManifestKeysType�FileMetaKeysType�CollectionInfoKeysType�Dict�Unionr�ri�List�ManifestValueType�CollectionManifestType�FileManifestEntryType�FilesManifestType�ansible.constants�	constantsr��ansible.errorsr2�ansible.galaxy.apir3r4r5r6r7r8�*ansible.galaxy.collection.galaxy_api_proxyr9�ansible.galaxy.collection.gpgr:r;r<r=�$ansible.galaxy.dependency_resolutionr>�+ansible.galaxy.dependency_resolution.errorsr?r@�.ansible.galaxy.dependency_resolution.providersrArBrCr��0ansible.galaxy.dependency_resolution.dataclassesrDrE�/ansible.galaxy.dependency_resolution.versioningrF�ansible.plugins.loaderrG�ansible.module_utils.sixrH�ansible.module_utils._textrIrJrK�'ansible.module_utils.common.collectionsrL� ansible.module_utils.common.yamlrM�ansible.utils.collection_loaderrN�ansible.utils.displayrO�ansible.utils.hashingrPrQ�ansible.utils.sentinelrRr�r�r�rTr�rZr�rnr�r�r�r�rr7r<rgrnrqr�r�r!r�r�r�rr�r�rrrIr[r]rVrgrSrRrnrjr�r�r�r�r	r"rrr�<module>r�s���0�/�B�B�B�B�B�B�B�B�B�B��
�����������������	�	�	�	�����	�	�	�	�
�
�
�
�����
�
�
�
�������������������������"�"�"�"�"�"�%�%�%�%�%�%�6�6�6�6�6�6�6�6�������������+�+�+�+�+�+��������<�<�<�<�<�<��M�M��
����
�
�
�
�
�
�
�
��M�M�M�	�����)�)�)�)�)�)�(�(�(�(�(�(��K�K�������K�K�K�����
�?�j��������y�:����y�	����Y��V�Y��8��
��>���o��H�	�		�����5�q�w�s�C���PS��VW�V\�]`�be�]e�Vf�hl�?l�7m�m�n���V�$4�6G�$G�H���F�#3�Q�W�S�#�t�^�5L�#L�M����q�y�):�;�Q�W�Q�V�La�Eb�dg�Eg�=h�h�i��������'�'�'�'�'�'�(�(�(�(�(�(���������������K�J�J�J�J�J���������������������������������������N�N�������N�N�N�����
����������O�N�N�N�N�N�9�9�9�9�9�9�/�/�/�/�/�/�C�C�C�C�C�C�C�C�C�C�?�?�?�?�?�?�6�6�6�6�6�6�@�@�@�@�@�@�)�)�)�)�)�)�<�<�<�<�<�<�<�<�+�+�+�+�+�+��'�)�)����#���*�.�0U�0U�0U�V�V��H���
>�
>�
>�
>�
>�
>�
>���
>�%8�%8�%8�%8�%8�y�%8�%8�%8�R��������h�h�h�V/�/�/�d���@,�,�,�^g%�g%�g%�T"B�"B�"B�JF�F�F�T
D�
D�
D�"
�
�
�B�B�B�J�#�#���#��@�@�@���@�F
n�
n�
n��������
[�
[�
[� _�_�_�D?�?�?�F���@C�C�C�L'�'�'�T���@-�-�-�`���.R�R�R�.�.�.�b%�%�%�P&)�&)�&)�R*0�*0�*0�*0�Z	)�	)�	)�%�%�%�*�*�*�!�!�!�
_�
_�
_�
_�j4�j4�j4�j4�j4s6�<B�B�B� B/�/B9�8B9�G"�"G,�+G,

Youez - 2016 - github.com/yon3zu
LinuXploit