관리-도구
편집 파일: copr.cpython-39.opt-1.pyc
a �������gYv����������������������@���s���d�dl�mZ�d�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dl Z d�dl Z d�dlZd�dlmZm Z �d�dlZd�dlmZ�d�dlmZ�d�dlZz$d�dlmZmZmZmZ�dd��ZW�nF�ey����d d ��Zzd�dlmZ�W�n�ey����dd��ZY�n0�Y�n0�d Zeed�ed�g�Zeed�ed�dg�Ze�r^d�dl m!Z!m"Z"m#Z#�d�dl$m%Z%m&Z&m'Z'�n(d�dl!m!Z!m"Z"m#Z#�d�dl(m%Z%m&Z&m'Z'�ej)j*G�dd��dej+j,��Z-ej)j*G�dd��de-��Z.dS�)�����)�print_functionN)�_�logger)�PY3)�ucd)�name�version�codename�os_release_attrc�������������������C���s���t���t��t��fS��N)r���r���r �����r���r����4/usr/lib/python3.9/site-packages/dnf-plugins/copr.py�linux_distribution.���s����r���c�����������������C���s���dS�)N��r���)r���r���r���r ���r ���1���s����r ���)r���c��������������� ���C���s����t�d��h}�i�}|�D�]<}z$|����d�\}}|�d�||<�W�q�tyL���Y�q0�q|d�|d�d�fW��d�����S�1�sv0����Y��d�S�)Nz/etc/os-release�=�"�NAMEZ VERSION_ID)�open�rstrip�split�strip� ValueError)Zos_release_fileZos_release_data�lineZos_release_keyZos_release_valuer���r���r ���r���7���s���� �coprZyes�y�no�nr���)�ConfigParser� NoOptionError�NoSectionError)�urlopen� HTTPError�URLErrorc�������������������@���s��e�Zd�ZdZdZdZdZdZdZed�e�Z dZ ed �Zd Z ed�Zedd ���Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zd d!��Zd"d#��Zed$d%���Zd&d'��Zd(d)��Zd*d+��Z d,d-��Z!d.d/��Z"d0d1��Z#ed2d3���Z$ed4d5���Z%ed6d7���Z&dS�)8�CoprCommandz Copr plugin for DNF Nzcopr.fedorainfracloud.orgZfedora�httpsi����://)r���z Interact with Copr repositories.Ta��� enable name/project [chroot] disable name/project remove name/project list --installed/enabled/disabled list --available-by-user=NAME search project Examples: copr enable rhscl/perl516 epel-6-x86_64 copr enable ignatenkobrain/ocltoys copr disable rhscl/perl516 copr remove rhscl/perl516 copr list --enabled copr list --available-by-user=ignatenkobrain copr search tests c�����������������C���s����|�j�ddg�d�d��|����}|j�ddtd�d��|j�d dtd �d��|j�ddtd�d��|j�d dtd�d��|�j�dtd�d��|�j�ddd��d�S�)N� subcommand����)�help�enable�disable�remove�list�search��nargs�choicesz--installed� store_truez.List all installed Copr repositories (default))�actionr(���z --enabledzList enabled Copr repositoriesz --disabledzList disabled Copr repositoriesz--available-by-userr���z-List available Copr repositories by user NAME)�metavarr(���z--hubz(Specify an instance of Copr to work with)r(����arg�*)r/���)�add_argument�add_mutually_exclusive_groupr���)�parserZlist_optionr���r���r ���� set_argparserp���s$���������zCoprCommand.set_argparserc�����������������C���s���|�j�jjjdkrd�S�d�}t��}g�}|�jjjd�}tj� |t d��}tj�|�r�|�|��|� |��|�dd�r�|�dd�r�|�dd�}|�dd�}||g|�_n ddg|�_t�tj� |t d���D�],}|�d�r�tj� |t d�|�} |�| ��q�g�} t|�jj��r|�jjd��d �} t| �d k�rR|�jj�rRt�td�td����tj��td ���nJ|�jj�s|t| �d k�r||�j|�_|�j|�_n t| �d k�r�| d�}n|�jj}|�rB|�rBd�|�_|� t |dd���|��!||dd��}|�rB|��!||d|�j"�}|��!||d|�j#�} ||�_|d�|�|�_t$| �|�j#k�rB|��jd| �7��_|��jd| �7��_|�j�s�d|v�rl||�_|�j"d�|�|�_n|�dd�d�|�_||�_d�S�)Nr���r���z.conf�main�distribution� releaseverFz.d�/�����Error: z^specify Copr hub either with `--hub` or using `copr_hub/copr_username/copr_projectname` formatzmultiple hubs specifiedT)�reverse�hostname�protocol�portr%����:r'���)%�cliZcommand�optsr����base�confZpluginconfpath�os�path�join�PLUGIN_CONF�isfile�append�readZ has_option�get� chroot_config�listdir�endswith�lenr4���r����hubr����criticalr����dnf�CliError�default_hostname� copr_hostname�default_url�copr_url�sorted�_read_config_item�default_protocol�default_port�int)�selfZcopr_hubZcopr_plugin_configZconfig_filesZconfig_pathZdefault_config_filer;���r<����filenameZconfig_file�projectrA���rB���rC���r���r���r ���� configure����sv���� � �� � � zCoprCommand.configurec�������������� ���C���s.���z|��||�W�S��ttfy(���|�Y�S�0�d�S�r���)rP���r���r���)rb���ZconfigrU����section�defaultr���r���r ���r^�������s����zCoprCommand._read_config_itemc�����������������C���s���t�j�d�|������d�S�)N�{0} )�sys�stderr�write�formatr���)rb����textr���r���r ����_user_warning_before_prompt����s����z'CoprCommand._user_warning_before_promptc����������� ��� ���C���s���|�j�jd�}|dkr&|�jj�|���dS�|dkrl|�j�jrH|��|�j�j��d�S�|��|�jj j d�|�j�j|�j�j��d�S�z|�j�j d�}W�nJ�ttfy����t�td�td����|�jj�|���tj�td���Y�n0�z\|�j�j d�}t|�j�j �dkr�tj�td���|�d �|�_t|�j�d k��r"tj�td���W�n(�t�yL���|����}|�d �|�_Y�n0�|dk�rf|��|��d�S�|�d �}t|�dv�r�t�td�td����tj�td���n<t|�dk�r�|d�}|d�}n|d�}|d�}|d �|�}d�|�jj j|�j|��|�|�}|dk�rj|�� ���td�}d �!|�j||g�}d�|�} |��"|| ��|��#||��t�$td���|��%||��nr|dk�r�|�� ���|��&||��t�$td���nD|dk�r�|�� ���|��'||��t�$td���ntj�td��|���d�S�)Nr���r(���r,���r?���z>exactly two additional parameters to copr command are requiredr'�������zToo many arguments.�-r>���zOBad format of optional chroot. The format is distribution-version-architecture.r-���r=���)ro���r>���zEuse format `copr_username/copr_projectname` to reference copr projectzbad copr project formatz{0}/_copr:{1}:{2}:{3}.repor)���a�� Enabling a Copr repository. Please note that this repository is not part of the main distribution, and quality may vary. The Fedora Project does not exercise any power over the contents of this repository beyond the rules outlined in the Copr FAQ at <https://docs.pagure.org/copr.copr/user_documentation.html#what-i-can-build-in-copr>, and packages are not held to any quality or security level. Please do not file bug reports about these packages in Fedora Bugzilla. In case of problems, contact the owner of this repository. z!Do you really want to enable {0}?z Repository successfully enabled.r*���z!Repository successfully disabled.r+���z Repository successfully removed.�Unknown subcommand {}.)(rF���r&���rE���Z optparser� print_helpZavailable_by_user�_list_user_projects�_list_installed_repositoriesrG���rH���Zreposdir�enabledZdisabledr4���r���� IndexErrorr���rV���r���rW���rX���rT���� exceptions�Errorr����chroot_parts� _guess_chroot�_searchrl����get_reposdirrZ����_sanitize_username� _need_rootrK���� _ask_user�_download_repo�info�_runtime_deps_warning� _disable_repo�_remove_repo) rb���r&����project_name�chrootrd���� copr_username�copr_projectname� repo_filenamer�����msgr���r���r ����run����s��������� �� � � �zCoprCommand.runc�����������������C���s���|j��d�d�}t�d|�j�|�}|�j|�jko8t�d|�}t�d|�}|�jjr\|sd|sdd�S�n|sdd�S�t�d|�rtd�S�t�d|�r�d�S�|j } | r�|s�| s�|r�d�S�d} t�d |�r�|�d d�\}}} }|d�| �d�|�}n�t�d|��r,|�dd �}|� d d�d��d d �d �}|d�|d��d�|d ��}n.|�dd �}|�jd�|d��d�|d ��}d} | �sh|d7�}| �rv|d7�}t|��| S�)Nr=�������_copr:Z_copr_z_copr:|^_copr_zcopr:.*:.*:.*:mlz coprdep:.*F�copr:rD���r>���rp���r'���ro���r���Tz (disabled)z *) �repofiler����re�matchrZ���r\���r[���rF���rU���ru����rsplitrY����print)rb����repo_id�repo�enabled_only� disabled_only� file_nameZ match_newZ match_oldZ match_anyru����old_repor���rZ���Z copr_ownerZcopr_dirr����Z copr_namer���r���r ����_list_repo_file8��sB����zCoprCommand._list_repo_filec�����������������C���sB���d}|�j�j���D�]\}}|��||||�rd}q|r>ttd���d�S�)NFTz�* These coprs have repo file with an old format that contains no information about Copr hub - the default one was assumed. Re-enable the project to fix this.)rG����repos�itemsr����r����r���)rb���Z directoryr����r����r����r����r����r���r���r ���rt���i��s����z(CoprCommand._list_installed_repositoriesc����������� ������C���s����d��|�}|�j|�}|�jj|dd�}zt�|����}W�n(�ty^���tj � td���|���Y�n0�|��|��td���|�}|�� |��|d�D�]@}d��||d��}|d �p�td �} |�jj�t|�| �}t|��q�d�S�)Nz!/api_3/project/list?ownername={0}�w+��modez+Can't parse repositories for username '{}'.zList of {} coprsr����z {0}/{1} : r����descriptionzNo description given�rl���r\���rG���r ����json�loadsrO���r���rW���rw���rx���r����_check_json_output�_print_match_section�outputZ fmtKeyValFillr���r����) rb���Z user_name�api_path�url�res� json_parse�section_text�itemr�����descr���r���r ���rs���s��s&���� �� zCoprCommand._list_user_projectsc����������� ������C���s����d��|�}|�j|�}|�jj|dd�}zt�|����}W�n(�ty^���tj � td���|���Y�n0�|��|��td���|�}|�� |��|d�D�]>}d��|d��}|d �p�td �} |�jj�t|�| �}t|��q�d�S�)Nz/api_3/project/search?query={}r����r����zCan't parse search for '{}'.zMatched: {}r����z{0} : Z full_namer����zNo description given.r����) rb����queryr����r����r����r����r����r����r����r����r���r���r ���r{������s"���� � zCoprCommand._searchc�����������������C���s���|�j�j�|�}t|��d�S�r���)rG���r����Z fmtSectionr����)rb���rm���� formattedr���r���r ���r�������s����z CoprCommand._print_match_sectionc�����������������C���sh���|�j�stj�d��d|�_�tj�d�|������|�j���rd|�jjj s`|�jj jd�|�d�|�d�sddS�dS�)N� Frh���z {} [y/N]: z {} [Y/n]: )r����Zdefaultyes_msgT)� first_warningri���rj���rk���rl���r���rG���Z _promptWantedrH���Zassumenor����Zuserconfirm�rb���r����r����r���r���r ����_ask_user_no_raise���s���� �zCoprCommand._ask_user_no_raisec�����������������C���s ���|���||�stj�td���d�S�)NzSafe and good answer. Exiting.)r����rW���rw���rx���r���r����r���r���r ���r������s����zCoprCommand._ask_userc�����������������C���s ���t����dkrtj�td���d�S�)Nr���z/This command has to be run under the root user.)rI����geteuidrW���rw���rx���r���)�clsr���r���r ���r~������s�����zCoprCommand._need_rootc�����������������C���s��|�j�}|du�s&|d�du�s&|d�du�r,t��}|�jjjd�}d|d�v�r�d|v�rXd|�}n&d td �v�rnd|�}nd�|d�|�}n�d|v�r�t�d �}d|v�r�d�|�}nd�|d�|�}n^d|v�r�t�d�}d|v�r�d�|�}nd�|d�|�}n&d�|d�� dd�d�|�r|nd�}|S�)z2 Guess which chroot is equivalent to this machine Nr���Fr'���ZbasearchZFedoraZRawhidezfedora-rawhide-ZrawhideZredhat_support_product_versionzfedora-{0}-{1}ZMageiaz%{distro_arch}ZCauldronzmageia-cauldron-{}zmageia-{0}-{1}ZopenSUSEz%{_target_cpu}Z Tumbleweedzopensuse-tumbleweed-{}zopensuse-leap-{0}-{1}z epel-{}-{}�.Zx86_64) rQ���r���rG���rH���� substitutionsr ���rl����rpmZexpandMacror���)rb���ZdistZdistarchr����r���r���r ���rz������s,���� &zCoprCommand._guess_chrootc�������������� ���C���s���d��|�jd�d���}|�jd�}d�|||�}z*t|�j|��}tj�|�rRt�|��W��nb�t �yn�}�z�|j dkr�td��|�j|�|j t|��}t j�|��td�}|j�d�} | �r<t�| ��d�} t�| �} |td ��d��|�j�|�7�}| �d ��r.|td�d��d d��| d �D����7�}|td��|�7�}t j�|��n|td��|�7�}t j�|��W�Y�d�}~nTd�}~0��t�y��}�z2td��|�j|�|jj�}t j�|��W�Y�d�}~n d�}~0�0�|���}|�d�}t�d|��r�tj��|�jjjd|dd���d��}|�j|�j k�rV|�!ddd��!|�j"d��!ddd��!dd��!dd�} tj�| ��rVt�| ��t#|d��4}|�$|��|�%��D�]}|�$|���qtW�d�����n1��s�0����Y��t�&|t'j(t'j)B�t'j*B�t'j+B���d�S�)Nrp���r����z%/coprs/{0}/repo/{1}/dnf.repo?arch={2}i���z Request to {0} failed: {1} - {2}z+It wasn't possible to enable this project. zCopr-Error-Datazutf-8z1Repository '{0}' does not exist in project '{1}'.zavailable chrootsz Available repositories: z, c�����������������s���s���|�]}d���|�V��qdS�)z'{}'N�rl���)�.0�xr���r���r ���� <genexpr>���s���z-CoprCommand._download_repo.<locals>.<genexpr>z� If you want to enable a non-default repository, use the following command: 'dnf copr enable {0} <repository>' But note that the installed repo file will likely need a manual modification.zProject {0} does not exist.zFailed to connect to {0}: {1}z\[copr:r���r'������z.repor�����_coprr���rD���Zgroup_�@�wb),rK���ry���rl���r ���r\���rI���rJ����existsr+���r!����coder����strrW���rw���rx���ZheadersrP����base64Z b64decode�decoder����r����r"����reason�strerror�readliner����r����rG���rH���r|���r[����replacerZ���r���rk���� readlines�chmod�stat�S_IRUSR�S_IWUSR�S_IRGRP�S_IROTH)rb���r����r����Zshort_chrootZarchr����Zresponse�eZ error_msgZ error_dataZerror_data_decodedZ first_liner���Zold_repo_filename�fr���r���r ���r�������sj���� �� � " $���� .zCoprCommand._download_repoc��������������������s����|�j�jdd��|�j�����|��|��|�|��g�}�j���D�]}|�d�rHq8|�|��q8|s\dS�t d�}t �d���|�d� ���fdd �|D����}|��|t d ��s�|D�]$}|�j�j��j||�j�jjddi��q�dS�) a,�� In addition to the main copr repo (that has repo ID prefixed with `copr:`), the repofile might contain additional repositories that serve as runtime dependencies. This method informs the user about the additional repos and provides an option to disable them. T)r����r����Na���Maintainer of the enabled Copr repository decided to make it dependent on other repositories. Such repositories are usually necessary for successful installation of RPMs from the main Copr repository (they provide runtime dependencies). Be aware that the note about quality and bug-reporting above applies here too, Fedora Project doesn't control the content. Please review the list: {0} These repositories have been enabled automatically.r'���z c�������������� ������s*���g�|�]"}d�j�t���|�j�|d�d��qS�)z){num:2}. [{repoid}] baseurl={baseurl}�baseurl)Znum�repoidr����)rl����next�cfgZgetValue)r����r�����Zcounterr����r���r ���� <listcomp>8��s�����z5CoprCommand._runtime_deps_warning.<locals>.<listcomp>z!Do you want to keep them enabled?ru����0)rG����resetZread_all_repos�_get_copr_repor}���r�����sections� startswithrN���r���� itertools�countrl���rK���r����rH����write_raw_configfiler����r����)rb���r����r����Zruntime_depsr����r����Zdepr���r����r ���r������s.���� � � �z!CoprCommand._runtime_deps_warningc�����������������C���s����d��|�j�dd�d�|��|�|�}||�jjvr�d��|��|�|��}}||�jjv�r�d|�jj|�jv�r�|�jj|�j�d�d�}z0|�dd �d��dd�d�}||�jkr�W�d�S�W�q��ty����Y�q�0�nd�S�|�jj|�S�) Nzcopr:{0}:{1}:{2}rD���r'���r���z{0}-{1}r����r=���r����ro���) rl���rZ���r����r}���rG���r����r����r���rv���)rb���r����r����r����r����rZ���r���r���r ���r����F��s$������ zCoprCommand._get_copr_repoc�������������� ���C���sv���|���||�}|s,tj�td�|�j||����zt�|j ��W�n4�t yp�}�ztj�t|���W�Y�d�}~n d�}~0�0�d�S�)Nz&Failed to remove copr repo {0}/{1}/{2})r����rW���rw���rx���r���rl���rZ���rI���r+���r�����OSErrorr����)rb���r����r����r����r����r���r���r ���r����\��s������zCoprCommand._remove_repoc�����������������C���s`���|���||�}|d�u�r,tj�td�||����|j���D�]$}|�jj � |j||�jj jddi��q6d�S�)Nz!Failed to disable copr repo {}/{}ru���r����) r����rW���rw���rx���r���rl���r����r����rG���rH���r����r����r����)rb���r����r����r����r����r���r���r ���r����h��s�������zCoprCommand._disable_repoc�����������������C���s<���zt��|����}W�n$�ty6���tj�td���Y�dS�0�|S�)z� Wrapper around response from server check data and print nice error in case of some error (and return None) otherwise return json object. �Unknown response from server.N)r����r����rO���r���rW���rE���rX���r���)r����r����r����r���r���r ���� _get_datat��s����zCoprCommand._get_datac�����������������C���s"���d|v�rt�j�d�|d����d�S�)N�errorz{})rW���rw���rx���rl���)r����Zjson_objr���r���r ���r�������s����zCoprCommand._check_json_outputc�����������������C���s&���|d�dkrd��|dd����S�|S�d�S�)Nr���r����zgroup_{}r'���r����)r����r����r���r���r ���r}������s����zCoprCommand._sanitize_username)'�__name__� __module__�__qualname__�__doc__rQ���rY���Zdefault_hubr_���r`���r[����aliasesr����summaryr�����usage�staticmethodr9���re���r^���rn���r����r����rt���rs���r{���r����r����r����classmethodr~���rz���r����r����r����r����r����r����r����r}���r���r���r���r ���r#���P���sL��� L_1 %82 r#���c�������������������@���sD���e�Zd�ZdZdZed�ZdZdd��Zdd��Z e d d ���Zdd��Zd S�)�PlaygroundCommandz Playground plugin for DNF )Z playgroundz$Interact with Playground repository.z [enable|disable|upgrade]c����������� ��� ���C���s0��|������|��td�td���d�|�j�}|�jj|dd�}|��|�}|����|d�dkrft j �td���|d �D�]�}d �|d�|d��}d �|�jjj |�dd��}zp||d�vr�W�qnd�|�j||�}|�jj|dd�}|��|�}|����|�rd|v��r|d�dk�r|��||��W�qn�t jj�y(���Y�qn0�qnd�S�)Nz!Enabling a Playground repository.zDo you want to continue?z{0}/api/playground/list/r����r����r�����okr����r����z{0}/{1}�usernameZcoprnamez{}/_playground_{}.repor=���rp���Zchrootsz{0}/api/coprs/{1}/detail/{2}/)r~���r���r���rl���r\���rG���r ���r�����closerW���rE���rX���rH���r|���r����r����rw���rx���) rb���r����Zapi_urlr����r����r����r����r����Zoutput2r���r���r ����_cmd_enable���sB������ �� �zPlaygroundCommand._cmd_enablec�����������������C���s2���|������t�d�|�jjj��D�]}|��|��qd�S�)Nz{}/_playground_*.repo)r~����globrl���rG���rH���r|���r����)rb���r����r���r���r ����_cmd_disable���s����zPlaygroundCommand._cmd_disablec�����������������C���s���|�j�ddg�d�d��d�S�)Nr&���r'���)r)���r*����upgrader.���)r6���)r8���r���r���r ���r9������s�����zPlaygroundCommand.set_argparserc�����������������C���s����t�j�d��|�jjd�}|����}|dkrB|��|��t�t d���n`|dkrb|�� ���t�t d���n@|dkr�|�� ���|��|��t�t d���nt�j�t d ��|���d�S�) Nz%Playground is temporarily unsupportedr���r)���z-Playground repositories successfully enabled.r*���z.Playground repositories successfully disabled.r����z-Playground repositories successfully updated.rq���)rW���rw���rx���rF���r&���rz���r����r���r����r���r����rl���)rb���r&���r����r���r���r ���r�������s ���� �zPlaygroundCommand.runN) r����r����r����r����r����r���r����r����r����r����r����r9���r����r���r���r���r ���r�������s��� r����)/Z __future__r���r����r����r����rI���r�����shutilr����ri���r����Zdnfpluginscorer���r���rW���Z dnf.pycompr���Zdnf.i18nr���r����Zdistror���r���r ���r ���r����ImportError�platformrL����setZYESZNOZconfigparserr���r���r���Zurllib.requestr ���r!���r"���Zurllib2ZpluginZregister_commandrE���ZCommandr#���r����r���r���r���r ����<module>���sP��� ����B