Edit File: builddep.cpython-36.pyc
3 �*�d�$������������������@���s����d�dl�mZ�d�dl�mZ�d�dlmZmZ�d�dlZd�dlZd�dlZd�dl Zd�dl Zd�dlZd�dlZ d�dlZd�dlZd�dlZd�dlZejjG�dd��dejj��ZdS�)�����)�absolute_import)�unicode_literals)�_�loggerNc�������������������s����e�Zd�ZdZdZee�Zed�Z��fdd�Zdd��Z d d ��Z edd���Zd d��Z dd��Zdd��Zedd���Zdd��Zdd��Zdd��Zdd��Z���ZS�)�BuildDepCommand�builddep� build-depz3Install build dependencies for package or spec filez[PACKAGE|PACKAGE.spec]c����������������s(���t�t|��j|��tjjj��|�_g�|�_d�S�)N) �superr����__init__�dnf�rpmZtransactionZinitReadOnlyTransaction�_rpm_ts�tempdirs)�self�cli)� __class__���/usr/lib/python3.6/builddep.pyr ���/���s����zBuildDepCommand.__init__c�������������C���s���x|�j�D�]}tj|��qW�d�S�)N)r����shutilZrmtree)r����temp_dirr���r���r����__del__4���s����zBuildDepCommand.__del__c�������������C���s����t�jjj|�}|d�dkr |jS�tjj��}tjdd�}t jj |t jj|��}|�jj |��t|d�}zFy|j|�jjj||j����W�n$�tk r��}�z��W�Y�dd}~X�nX�W�d|j���X�|S�) z� In case pkgspec is a remote URL, download it to a temporary location and use the temporary file instead. r����file��Z dnf_builddep_)�prefixzwb+N)r���r���)r���ZpycompZurlparse�path�libdnfZrepoZ Downloader�tempfileZmkdtemp�os�join�basenamer����append�openZdownloadURL�baseZconfZ_config�fileno�RuntimeError�close)r����pkgspec�locationZ downloaderr���Z temp_fileZtemp_fo�exr���r���r����_download_remote_file8���s���� z%BuildDepCommand._download_remote_filec���������� ���C���s����dd��}|�j�dddtd�d��|�j�dd d g�d|td�d ��|�j�dddtd�d��|�j��}|j�ddtd�d��|j�ddtd�d��d�S�)Nc�������������S���s:���|�r|�j�d�d�ng�}t|�dk�r6td�|��}tj|��|S�)N��������z&'%s' is not of the format 'MACRO EXPR')�split�lenr����argparseZArgumentTypeError)�argZarglist�msgr���r���r���� macro_defR���s ���� z0BuildDepCommand.set_argparser.<locals>.macro_def�packages�+�packagez"packages with builddeps to install)�nargs�metavar�helpz-Dz--definer ���z'MACRO EXPR'z$define a macro for spec file parsing)�action�defaultr6����typer7���z--skip-unavailable� store_trueFz5skip build dependencies not available in repositories)r8���r9���r7���z--specz)treat commandline arguments as spec files)r8���r7���z--srpmz)treat commandline arguments as source rpm)�add_argumentr���Zadd_mutually_exclusive_group)�parserr1���Zptyper���r���r���� set_argparserP���s���� zBuildDepCommand.set_argparserc�������������C���s���|�j�jsd|�j�_d�S�)N�error)�optsZrpmverbosity)r���r���r���r���� pre_configuref���s����zBuildDepCommand.pre_configurec�������������C���sr���|�j�j}d|_d|_d|_d|_|�jjp.|�jjsnx<|�jj D�]0}|j d�pZ|j d�pZ|j d�s:|�jjj ���P�q:W�d�S�)NTz.src.rpmz .nosrc.rpmz.spec)r����demandsZavailable_reposZ resolvingZ root_userZsack_activationr@����spec�srpmr2����endswithr"���ZreposZenable_source_repos)r���rB���r&���r���r���r���� configurej���s���� zBuildDepCommand.configurec�������������C���s\��t�jjj|�j�}x$|�jjD�]}tj|d�|d���qW�d}x�|�jj D�]�}|�j |�}yl|�jjrh|�j|��nT|�jj r||�j|��n@|jd�s�|jd�r�|�j|��n |jd�r�|�j|��n |�j|��W�qD�t�jjk �r�}�z:x$|j��D�]}tjtd�j|���q�W�tj|��d}W�Y�d�d�}~X�qDX�qDW�x |�jjD�]}tj|d����q*W�|�rXt�jjtd ���d�S�) Nr���r*���Fz.src.rpmz nosrc.rpmz.speczRPM: {}Tz!Some packages could not be found.)r���ZyumZrpmtransZRPMTransactionr"���r@����definer���ZaddMacror2���r)���rD���� _src_depsrC���� _spec_depsrE����_remote_deps� exceptions�ErrorZmessagesr���r?���r����formatZdelMacro)r���ZrpmlogZmacroZ pkg_errorsr&����e�liner���r���r����runz���s2���� zBuildDepCommand.runc�������������C���s���|�j���dd���S�)Nr+���)ZDNEVR)Zrpm_depr���r���r����_rpm_dep2reldep_str����s����z#BuildDepCommand._rpm_dep2reldep_strc�������������C���s����t�jj|�jj�}|j|d��|j��}|�rX|jd�rXt�jj|�jj�}|j|d��|j��}|�r�|jd��r�td�}t j ||��|�jjdkS�|r�|�jj |�}|r�x|D�]}t�jj|��q�W�|�jjj|dd��dS�) N)Zprovides�/)r����(z$No matching package to install: '%s'TF)ZselectZoptional)r���ZselectorZSelectorr"����sack�setZmatches� startswithr���r����warningr@���Zskip_unavailableZ_sltr_matches_installedZ_msg_installedZ_goalZinstall)r���� reldep_strZsltr�foundr0���Zalready_instr4���r���r���r����_install����s$���� zBuildDepCommand._installc������� ������C���s����t�j|t�j�}y|�jj|�}W�nR�tjk rp�}�z4t|�dkrJtd�|�}t�j |��t jj|��W�Y�d�d�}~X�nX�t�j |��|j d�}d}x0|D�](}|�j|�}|jd�r�q�||�j|�M�}q�W�|s�td�} t jj| ��|�jjr�tjtd���d�S�)Nzerror reading package headerz2Failed to open: '%s', not a valid source rpm file.ZrequirenameTzrpmlib(zNot all dependencies satisfiedzJWarning: -D or --define arguments have no meaning for source rpm packages.)r���r!����O_RDONLYr ���ZhdrFromFdnor���r?����strr���r%���r���rK���rL���ZdsFromHeaderrQ���rV���rZ���r@���rG���r���rW���) r���Zsrc_fn�fd�hrN����ds�done�deprX����errr���r���r���rH�������s*���� zBuildDepCommand._src_depsc������� ������C���s����yt�j|�}W�n>�tk rL�}�z"td�||f�}tjj|��W�Y�d�d�}~X�nX�d}x.t�j|jd�D�]}|�j |�}||�j |�M�}qbW�|s�td�}tjj|��d�S�)Nz/Failed to open: '%s', not a valid spec file: %sT�requireszNot all dependencies satisfied)r���rC���� ValueErrorr���r���rK���rL���r_���ZsourceHeaderrQ���rZ���) r���Zspec_fnrC���r(���r0���r`���ra���rX���rb���r���r���r���rI�������s���� zBuildDepCommand._spec_depsc������� ������C���s����t�jj|�j|�jj�jdd�}tdd��|D���}|�jjj��j ��j||g�dd�j ��j��}|spt�jj td�|���d}x.|D�]&}x |jD�]}||�jt|��M�}q�W�qzW�|s�td�}t�jj |��d�S�) N�src)Z arch__neqc�������������S���s���h�|�] }|j��qS�r���)Zsource_name)�.0�pkgr���r���r���� <setcomp>����s����z/BuildDepCommand._remote_deps.<locals>.<setcomp>)�nameZarchzno package matched: %sTzNot all dependencies satisfied)r���ZsubjectZSubjectZget_best_queryr"���rT����filter�listZquery� availableZlatestrP���rK���rL���r���rc���rZ���r\���) r���r4���rl���ZsourcenamesZpkgsr`���rg���Zreqrb���r���r���r���rJ�������s���� zBuildDepCommand._remote_deps)r���r���)�__name__� __module__�__qualname__�aliasesr0���r���ZsummaryZusager ���r���r)����staticmethodr>���rA���rF���rP���rQ���rZ���rH���rI���rJ���� __classcell__r���r���)r���r���r���'���s ���!r���)Z __future__r���r���Zdnfpluginscorer���r���r.���r���Zdnf.cliZdnf.exceptionsZdnf.rpm.transactionZdnf.yum.rpmtransZlibdnf.repor���r���r���r���r���ZpluginZregister_commandr���ZCommandr���r���r���r���r����<module>���s���