관리-도구
편집 파일: debug.cpython-39.pyc
a �����&c1����������������������@���s����d�dl�mZ�d�dl�mZ�d�dlmZ�d�dlmZmZ�d�dlZd�dl Zd�dl Z d�dlZd�dlZd�dl Z d�dlZd�dlZdZG�dd��dej�ZG�d d ��d ejj�ZG�dd��dejj�Zd d��Zdd��Zdd��ZdS�)�����)�absolute_import)�unicode_literals��ucd)�_�loggerNzdnf-debug-dump version 1 c�����������������������s ���e�Zd�ZdZ��fdd�Z���ZS�)�Debug�debugc��������������������sD���t�t|���||��||�_||�_|�jd�ur@|�j�t��|�j�t��d�S��N)�superr����__init__�base�cliZregister_command�DebugDumpCommand�DebugRestoreCommand)�selfr ���r����� __class__���5/usr/lib/python3.9/site-packages/dnf-plugins/debug.pyr���)���s���� zDebug.__init__)�__name__� __module__�__qualname__�namer���� __classcell__r���r���r���r���r���%���s���r���c�����������������������st���e�Zd�ZdZed�Z��fdd�Zdd��Zedd���Z d d ��Z dd��Zd d��Zdd��Z dd��Zdd��Zdd��Z���ZS�)r���)z debug-dumpz5dump information about installed rpm packages to filec��������������������s���t�t|���|��d�|�_d�S�r ���)r���r���r���� dump_file)r���r���r���r���r���r���7���s����zDebugDumpCommand.__init__c�����������������C���s���d|�j�j_d|�j�j_d�S��NT)r����demands�sack_activation�available_repos�r���r���r���r���� configure;���s���� zDebugDumpCommand.configurec�����������������C���s.���|�j�dddtd�d��|�j�ddtd�d ��d�S�) Nz --norepos� store_trueFz/do not attempt to dump the repository contents.)�action�default�help�filename�?zoptional name of dump file��nargsr%�����add_argumentr�����parserr���r���r���� set_argparser?���s������zDebugDumpCommand.set_argparserc�����������������C���s����|�j�j}|s6t�dt�t�����}dt���d�|f�}tj�|�}|� d�r\t �|d�|�_nt |d�|�_|��t��|�����|�����|�����|��|�j�j���|�����|�j����ttd�|���dS�)z{create debug txt file and compress it, if no filename specified use dnf_debug_dump-<timestamp>.txt.gz by defaultz%Y-%m-%d_%Tzdnf_debug_dump-%s-%s.txt.gz�����.gz�wzOutput written to: %sN)�optsr&����time�strftime� localtime�os�uname�path�abspath�endswith�gzip�GzipFiler����open�write� DEBUG_VERSION�dump_system_info�dump_dnf_config_info�dump_rpm_problems� dump_packagesZnorepos�dump_rpmdb_versions�close�printr���)r���r&���Znowr���r���r����runH���s ���� zDebugDumpCommand.runc�����������������C���s4���t�jjr t|�jtj�r t|d�}t�j�|�j|��d�S�)N�utf8) �dnfZpycompZPY3� isinstancer���r;���r<����bytesZ write_to_file)r����msgr���r���r���r>���a���s���� zDebugDumpCommand.writec�����������������C���sX���|���d��t���}|���d|d�|d�f���|���dtj���|���dtj�dd����d�S�) Nz%%%%SYSTEM INFO z uname: %s, %s ��������z rpm ver: %s z python ver: %s � ��)r>���r6���r7����rpm�__version__�sys�version�replace)r���r7���r���r���r���r@���f���s���� z!DebugDumpCommand.dump_system_infoc�����������������C���s����|�j�jj}d�dd��|�j�jjD���}|��d��|��d|d����|��d|d����|��d |d ����|��dtjj ���|��d|���|��d d�|�j�jj ����d�S�)N�,c�����������������S���s���g�|�] }|j��qS�r���)r���)�.0�pr���r���r���� <listcomp>p��������z9DebugDumpCommand.dump_dnf_config_info.<locals>.<listcomp>z %%%%DNF INFO z arch: %s �archz basearch: %s Zbasearchz releasever: %s Z releaseverz dnf ver: %s z enabled plugins: %s z global excludes: %s )r ����confZ substitutions�joinZ_plugins�pluginsr>���rI����constZVERSION�excludepkgs)r����varr^���r���r���r���rA���n���s���� z%DebugDumpCommand.dump_dnf_config_infoc�����������������C���sP���|���d��t|�j�\}}|���d�dd��|D�����|���d�dd��|D�����d�S�)Nz%%%%RPMDB PROBLEMS rP���c�����������������S���s$���g�|�]\}}d�t�|�t�|�f��qS�)zPackage %s requires %s r����rW����req�pkgr���r���r���rY���}���s����z6DebugDumpCommand.dump_rpm_problems.<locals>.<listcomp>c�����������������S���s$���g�|�]\}}d�t�|�t�|�f��qS�)zPackage %s conflicts with %s r����rW���r\���rd���r���r���r���rY������s�����)r>����rpm_problemsr ���r]���)r����missing� conflictsr���r���r���rB���z���s���� � �z"DebugDumpCommand.dump_rpm_problemsc����������� ������C���s\��|�j�j���}|��d��t|����D�]}|��dt|����q"|sBd�S�|��d��|���}t|�j�j� ��dd��d�D�]�}z�d�}|j d�ur�|j }n*|jd�ur�|j}nt|j �dkr�|j d�}|��d|j|f���|��d d �|j����t|j|jd��D�]}|��dt|����q�W�ql�tjj�yT�}�z.|��d|t|�f���W�Y�d�}~qlW�Y�d�}~qld�}~0�0�qld�S�) N� %%%%RPMDB z %s z %%%%REPOS c�����������������S���s���|�j�S�r ���)�id)�xr���r���r����<lambda>����rZ���z0DebugDumpCommand.dump_packages.<locals>.<lambda>)�keyr���z %%%s - %s z excludes: %s rV���)ZreponamezError accessing repo %s: %s )r ����sack�queryr>����sorted� installed�pkgspec� availableZreposZiter_enabledZmetalinkZ mirrorlist�lenZbaseurlrj���r]���r`����filterrI���� exceptions�Error�str) r���Z load_repos�qrX���rs���Zrepo�urlZpo�er���r���r���rC�������s2���� $zDebugDumpCommand.dump_packagesc�����������������C���s(���|���d��|�jj���}|���d|���d�S�)Nz%%%%RPMDB VERSIONS z all: %s )r>���r ���Z_tsZdbCookie)r���rT���r���r���r���rD�������s���� z$DebugDumpCommand.dump_rpmdb_versions)r���r���r����aliasesr����summaryr���r!����staticmethodr.���rG���r>���r@���rA���rB���rC���rD���r���r���r���r���r���r���2���s��� r���c�������������������@���sP���e�Zd�ZdZed�Zdd��Zedd���Zdd��Z d d ��Z dd��Zed d���ZdS�)r���)z debug-restorez,restore packages recorded in debug-dump filec�����������������C���s4���d|�j�j_d|�j�j_d|�j�j_|�jjs0d|�j�j_d�S�r���)r���r���r���r���Z root_userr2����outputZ resolvingr ���r���r���r���r!�������s ���� zDebugRestoreCommand.configurec�����������������C���s~���|�j�ddtd�d��|�j�ddtd�d��|�j�ddtd�d��|�j�d d dtd�d ��|�j�ddtd�d��|�j�ddtd�d��d�S�)Nz--outputr"���z,output commands that would be run to stdout.)r#���r%���z--install-latestz0Install the latest version of recorded packages.z --ignore-archz_Ignore architecture and install missing packages matching the name, epoch, version and release.z--filter-typesz[install, remove, replace]zinstall, remove, replacezlimit to specified type)�metavarr$���r%���z--remove-installonlyzqAllow removing of install-only packages. Using this option may result in an attempt to remove the running kernel.r&���r/���zname of dump filer(���r*���r,���r���r���r���r.�������s0��������� �z!DebugRestoreCommand.set_argparserc�����������������C���sV���|�j�jr$t|�j�j�dd�����|�j�_|��|�j�jd��}|��||�j���|��||�j���dS�)z Execute the command action here.rV���� r���N) r2����filter_types�setrU����split�read_dump_filer&����process_installed�process_dump)r���� dump_pkgsr���r���r���rG�������s�����zDebugRestoreCommand.runc�����������������C���s����|�j�j������}|�j��|�}|D�]�}d}t|�}|�|j|jfd��}|d�ur�|j |j |jf} | |v�rnd|| <�q�||v�r|d}q�d|jv�r�d} nd} |� ��D�]}| ||<�q�nd}|r d|jv�r ||vs�|jr |jr�td|���q |�j��|��q d�S�)NF�skipTrU����removezremove %s)r ���rn���ro���rq���Z_get_installonly_queryrr����getr���r[����epochrT����releaser�����keysZremove_installonlyr���rF���Zpackage_remove)r���r����r2���rq���Zinstallonly_pkgsrd���Z pkg_remove�spec�dumped_versionsZevrr#���Zd_evrr���r���r���r��������s.���� z%DebugRestoreCommand.process_installedc�������������� ���C���s����t�|����D�]�\}}|||f�}t�|����D�]�\}}}||||f�} | dkrNq,|jrZd} nd|�} |jr~| dkr~d|| f�}nt|| |||�}| |jv�r,|jr�td| |f���q,z|�j� |��W�q,�t jjy����t �td�|��Y�q,0�q,qd�S�)Nr����rP����.�installz%s%sz%s %szPackage %s is not available)rp���r����Zignore_archZinstall_latest�pkgtup2specr����r���rF���r ���r����rI���rv���ZMarkingErrorr����errorr���)r���r����r2����n�ar����r{����v�rr#���r[����pkg_specr���r���r���r��������s&���� z DebugRestoreCommand.process_dumpc�����������������C���s����|���d�rt�|��}nt|��}t|����tkrFt�t d�|���t jj�d}i�}|D�]h}t|�}|rp|dkrRd}qR|r�|d�dkr��q�|� ��}t�|�}d|�|j|jfi��|j|j|jf<�qR|S�) Nr0���zBad dnf debug file: %sTri���Fr���r����r����)r:���r;���r<���r=���r����readliner?���r���r����r���rI���rv���rw����strip�hawkeyZsplit_nevra� setdefaultr���r[���r����rT���r����)r&���Zfobjr����Zpkgs�liner����Znevrar���r���r���r������s.���� ��z"DebugRestoreCommand.read_dump_fileN) r���r���r���r|���r���r}���r!���r~���r.���rG���r����r����r����r���r���r���r���r�������s��� #r���c��������������������s����t�j�|��}|��������t��}t��}��D�]8�|��fdd��jD����|��fdd��jD����q(��fdd�|D��}��fdd�|D��}||fS�)Nc��������������������s.���g�|�]&}t�|�d�kst�|��d�s|��f�qS�)zsolvable:prereqmarkerzrpmlib()rx���� startswith)rW���rc����rd���r���r���rY���:��s����z rpm_problems.<locals>.<listcomp>c��������������������s���g�|�]}|��f�qS�r���r���)rW���r\���r����r���r���rY���=��rZ���c��������������������s$���g�|�]\}}��j�|d��s||f�qS��)Zprovides�ru���rb�����allpkgsr���r���rY���?��s����c��������������������s$���g�|�]\}}��j�|d��r||f�qS�r����r����re���r����r���r���rY���A��s����) rI���rn���Z_rpmdb_sackro���rq���r�����update�requiresrh���)r ���Zrpmdbr����rh���Zmissing_requiresZexisting_conflictsr���)r����rd���r���rf���3��s����rf���c�����������������C���s���t�|�j|�j|�j|�j|�j�S�r ���)r����r���r[���r����rT���r����r����r���r���r���rr���F��s����rr���c�����������������C���s<���|sdnd|��d��}|dv�r"dnd|�}d|�||||f�S�)NrP���z.%sr����)NrP���z%s:z%s-%s%s-%s%s)�lstrip)r���r[���r����rT���r����r����r{���r���r���r���r����J��s����r����)Z __future__r���r���Zdnf.i18nr���Zdnfpluginscorer���r���rI���Zdnf.clir;���r����r6���rQ���rS���r3���r?���ZPluginr���r���ZCommandr���r���rf���rr���r����r���r���r���r����<module>���s&��� w�