관리-도구
편집 파일: download.cpython-39.opt-1.pyc
a �����&c*0����������������������@���s����d�dl�mZ�d�dl�mZ�d�dlmZmZ�d�dlmZ�d�dlZd�dl Zd�dl Zd�dlZd�dlZd�dl Zd�dlZd�dlZd�dlZd�dlZejjG�dd��dejj��ZdS�)�����)�absolute_import)�unicode_literals)�_�logger)�OptionParserNc�����������������������s����e�Zd�ZdgZed�Z��fdd�Zedd���Zdd��Z d d ��Z dd��Zd d��Zdd��Z dd��Zdd��Zd dd�Zd!dd�Zedd���Zdd��Zdd��Z���ZS�)"�DownloadCommandZdownloadz%Download package to current directoryc��������������������s ���t�t|���|��d�|�_d�|�_d�S��N)�superr����__init__�opts�parser)�self�cli�� __class__���8/usr/lib/python3.9/site-packages/dnf-plugins/download.pyr ���+���s����zDownloadCommand.__init__c�������������� ���C���s����|�j�ddtd�d��|�j�ddtd�d��|�j�d dtd �d��|�j�ddtd�d��|�j�d ddg�tjdtd�d��|�j�ddtd�d��|�j�ddtd�d��|�j�ddddtd�d��|�j�ddg�d�g�td�d ��d�S�)!N�packages�+zpackages to download)�nargs�helpz--source� store_truezdownload the src.rpm instead)�actionr���z--debuginfoz'download the -debuginfo package insteadz --debugsourcez)download the -debugsource package insteadz--archz --archlist�archesz[arch]z5limit the query to packages of given architectures.)�dest�defaultr����metavarr���z --resolvez(resolve and download needed dependenciesz --alldepsz^when running with --resolve, download all dependencies (do not exclude already installed ones)z--urlz--urls�urlzJprint list of urls where the rpms can be downloaded instead of downloading)r���r���r���z--urlprotocols�append)�http�https�rsync�ftpz4when running with --url, limit to specific protocols)r����choicesr���r���)�add_argumentr���r���Z_SplitCallback)r���r���r���r���� set_argparser0���s<�������������zDownloadCommand.set_argparserc�����������������C���s����|�j�j}d|_d|_|�jjr*|�jjr*d|_|�jjr>|�j j ����|�jjsN|�jj rZ|�j j ����|�jjrr|�jj|�j j_ntj�t����|�j j_d�S�)NTF)r����demandsZsack_activationZavailable_reposr����resolveZalldepsZload_system_repo�source�baseZreposZenable_source_repos� debuginfo�debugsourceZenable_debug_repos�destdir�conf�dnf�i18n�ucd�os�getcwd)r ���r&���r���r���r���� configureK���s����zDownloadCommand.configurec�����������������C���s����|�j�js(|�j�js(|�j�js(|��|�j�j�}nXg�}|�j�jrH|�|��|�j�j���|�j�jrd|�|��|�j�j���|�j�jr�|�|�� |�j�j���|�j�j r�|D�]\}|jtj kr�|j|�j�jd�}|r�t|��q�td�|j�}|�jjjr�tj�|��t�|��q�dS�|��|��dS�)zExecute the util action here.)�schemesz$Failed to get mirror for package: %sN)r���r(���r*���r+����_get_pkg_objs_rpmsr����extend�_get_pkg_objs_source�_get_pkg_objs_debuginfo�_get_pkg_objs_debugsourcer����repoid�hawkey�CMDLINE_REPO_NAMEZremote_locationZurlprotocols�printr����namer)���r-����strictr.���� exceptions�Errorr���Zwarning� _do_downloads)r ����pkgs�pkgr����msgr���r���r����run^���s2������ zDownloadCommand.runc�����������������C���s��i�}|D�]}|��t|�g���|��qg�}g�}|���D�]D}dd��|D��}|rZ|�|d���q4|jdd��d��|�|d���q4|r�|�j�||�jjj��|r�|D�]V}|� ��}t j�|�jj jt j�|��} t j�| �r�t j�|| �r�q�t�||�jj j��q�tdd��||�D���} | S�)z= Perform the download for a list of packages c�����������������S���s���g�|�]}|j�tjkr|�qS�r���)r:���r;���r<�����.0rD���r���r���r���� <listcomp>����s����z1DownloadCommand._do_downloads.<locals>.<listcomp>r���c�����������������S���s���|�j�j|�j�jfS�r���)Zrepo�priorityZcost)�xr���r���r����<lambda>���������z/DownloadCommand._do_downloads.<locals>.<lambda>)�keyc�����������������S���s���g�|�]}|�����qS�r���)�localPkgrG���r���r���r���rI�������rM���)� setdefault�strr����values�sortr)���Zdownload_packages�output�progressrO���r1����path�joinr-���r,����basename�exists�samefile�shutil�copy�sorted)r ���rC���Zpkg_dictrD���Zto_downloadZcmdlineZpkg_listZpkgs_cmdline�src�dstZ locationsr���r���r���rB�������s.����zDownloadCommand._do_downloadsc�����������������C���s"���|�j�jr|��|�}n |��|�}|S�)zc Return a list of dnf.Package objects that represent the rpms to download. )r���r'����_get_packages_with_deps� _get_packages)r ���� pkg_specsrC���r���r���r���r5�������s���� z"DownloadCommand._get_pkg_objs_rpmsc�����������������C���s*���|���|�}|��|�}t|�j|dd��}|S�)zj Return a list of dnf.Package objects that represent the source rpms to download. T)r(���)r5����_get_source_packages�setra���)r ���rb���rC����source_pkgsr���r���r���r7�������s���� z$DownloadCommand._get_pkg_objs_sourcec�������������� ���C���sz���t���}|�jj������}|��|�D�]T}|j|jfD�]B}|j|t |j �|j|j|j d�}|sZq0|D�]}|�|��q^�q q0q |S�)zm Return a list of dnf.Package objects that represent the debuginfo rpms to download. �r>����epoch�version�release�arch)rd���r)����sack�query� availablera���Z debug_nameZsource_debug_name�filter�intrg���rh���ri���rj����add)r ���rb����dbg_pkgs�qrD���Zdbg_name� dbg_available�pr���r���r���r8�������s"�����z'DownloadCommand._get_pkg_objs_debuginfoc�����������������C���s`���t���}|�jj������}|��|�D�]:}|j|jt|j �|j |j|jd�}|D�]}|� |��qJq |S�)zo Return a list of dnf.Package objects that represent the debugsource rpms to download. rf���)rd���r)���rk���rl���rm���ra���rn���Zdebugsource_namero���rg���rh���ri���rj���rp���)r ���rb���rq���rr���rD���rs���rt���r���r���r���r9�������s�����z)DownloadCommand._get_pkg_objs_debugsourceFc�����������������C���s����|r |�j�n|�j}g�}|D�]v}z|�||���W�q�tjjy��}�zBt�tj� |���|�j jjrxt�t d���tj�|��W�Y�d}~qd}~0�0�qttj|���}|S�)z Get packages matching pkg_specs.zExiting due to strict setting.N)�_get_query_source� _get_queryr���r.���r@����PackageNotFoundErrorr����errorr/���r0���r)���r-���r?���r���rA����list� itertools�chain)r ���rb���r(����funcZqueries�pkg_spec�erC���r���r���r���ra�������s���� $zDownloadCommand._get_packagesc����������� ������C���s����|���|�}t|�}|D�]�}t�|�jj�}|�|��|���}|r\|�|� ����|�|� ����qtd�g}t� d�|dd��|D������t� tj�|������tj����q|S�)z-Get packages matching pkg_specs and the deps.zError in resolve of packages:z c�����������������S���s���g�|�]}t�|��qS�r���)rQ���rG���r���r���r���rI�����rM���z;DownloadCommand._get_packages_with_deps.<locals>.<listcomp>)ra���rd���r;���ZGoalr)���rk����installrF����updateZ list_installsZ list_upgradesr���r���rx���rW���r.����utilZ_format_resolve_problemsZ problem_rulesr@���rA���) r ���rb���r(���rC���Zpkg_setrD���Zgoal�rcrE���r���r���r���r`�������s���� z'DownloadCommand._get_packages_with_depsc�����������������C���sv���t���}|�D�]b}|jr6|�|j��t�dt|�|j��q |jdkrX|�d|j|jf���q t� t d�t|���q t|�S�)z4Get list of source rpm names for a list of packages.z --> Package : %s Source : %sr^���z %s-%s.src.rpmzNo source rpm defined for %s)rd���Z sourcerpmrp���r����debugrQ���rj���r>���Zevr�infor���ry���)rC���re���rD���r���r���r���rc�����s���� � z$DownloadCommand._get_source_packagesc�����������������C���s����t�jj�|�d�}|o|dv�}|s8|�d�rdtj�|�rd|�jj|g|�jj j d�}|�jj���j |d�S�t�j�|�}|j|�jj|�jjd�}|���}|j dd�}|�jjr�|j|�jjd �}t|����dkr�td �|�}t�j�|��|S�)z#Return a query to match a pkg_spec.r���)r���r"����filer ���z.rpm)rU���)rD���)Zwith_srcT)Zlatest_per_arch_by_priority)rj����No package %s available.)r.���Zpycomp�urlparse�endswithr1���rV����isfiler)���Zadd_remote_rpmsrT���rU���rk���rl���Zfilterm�subject�SubjectZget_best_queryr���r(���rm���r���rn����lenrF���r���r@���rw���)r ���r}���r4���Zis_urlrC����subjrr���rE���r���r���r���rv�����s����zDownloadCommand._get_queryc�����������������C���sd���|dd��}t�j�|�}|���D�]&}|�|�jj����}|r |�����S�q t d�|�}t�j �|��dS�)z/Return a query to match a source rpm file name.N���r����)r.���r����r����Zget_nevra_possibilitiesZto_queryr)���rk���rm���Zlatestr���r@���rw���)r ���r}���r����Z nevra_objZ tmp_queryrE���r���r���r���ru���,��s����z!DownloadCommand._get_query_source)F)F)�__name__� __module__�__qualname__�aliasesr���Zsummaryr ����staticmethodr%���r3���rF���rB���r5���r7���r8���r9���ra���r`���rc���rv���ru���� __classcell__r���r���r���r���r���%���s$��� #! r���)Z __future__r���r���Zdnfpluginscorer���r���Zdnf.cli.option_parserr���r.���Zdnf.cliZdnf.exceptionsZdnf.i18nZdnf.subjectZdnf.utilr;���rz���r1���r[���ZpluginZregister_commandr���ZCommandr���r���r���r���r����<module>���s���