Your IP : 13.58.232.94


Current Path : /usr/lib/python3.6/site-packages/dnf/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dnf/__pycache__/base.cpython-36.opt-1.pyc

3

��f���@sXdZddlmZddlmZddlmZddlmZddlZddlZddlZ	ddl
mZddlm
Z
dd	lmZmZmZdd
lmZddlmZddlmZydd
lmZWn ek
r�dd
lmZYnXddlZddlZddlZddlZddlZddl Zddl!Zddl"Zddl#Zddl$Zddl%Zddl&Zddl'Zyddl(ZdZ)Wnek
�r`dZ)YnXddl*Zddl+Zddl,Zddl-Zddl.Zddl/Zddl0Zddl1Zddl2Zddl3Zddl4Zddl5ZddlZddl6Zddl7Z7ddl8Z8ddl9Z9ddl:Z:ddl;Z;ddl<Z<ddl=Z=ddl>Z>ddl?Z?ddl@Z@ddlAZAddlBZBe;jCd�ZDGdd�deE�ZFdd�ZGdS)z
Supplies the Base class.
�)�absolute_import)�division)�print_function)�unicode_literalsN)�deepcopy)�
CompsQuery)�_�P_�ucd)�_parse_specs)�
SwdbInterface)�misc)�SequenceTF�dnfc@s�eZdZd�dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Ze	dd��Z
dd�Zd�dd�Zdd�Z
edd��Zedd��Zedd��Zejdd��Zeejjd�dd ���Zed!d"��Zed#d$��Zed%d&��Zejd'd&��Zd(d)�Zffdfd*d+�Zd,d-�Zd.d/�Zd0d1�Zd�d2d3�Z d�d5d6�Z!d�d7d8�Z"d9d:�Z#d;d<�Z$d�d=d>�Z%d�d?d@�Z&dAdB�Z'e(j)e(j*e(j+e(j,e(j-e(j.e(j/dC�Z0e1e(dD��r�e(j2e0dE<dFe(j3e(j4BiZ5edGdH��Z6edIdJ��Z7e7jdKdJ��Z7d�dLdM�Z8dNdO�Z9edPdQ�dRdQ�dSdQ�dTdU�Z:dVdW�Z;dXdY�Z<dZd[�Z=d\d]�Z>d^d_�Z?d�d`da�Z@ffdbdc�ZAddde�ZBdfdg�ZCdhdi�ZDd�djdk�ZEd�dldm�ZFd�dndo�ZGd�dpdq�ZHdrds�ZIdtdu�ZJdvdw�ZKd�dydz�ZLd�d{d|�ZMd}d~�ZNdd��ZOd�d��ZPd�d��ZQd�d�d��ZRd�d��ZSd�d�d��ZTd�d�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d�d��Z`d�d�d��Zad�d�d��Zbd�d�d��Zcd�d�d��Zdd�d��Zed�d��Zfd�d��Zgd�d�d��Zhd�d�d��Zid�d�d��Zjd�d�d��Zk�dd�d��Zl�dd�d��Zm�dd�d��Znd�d��Zo�dd�d„Zpd�dĄZqffffffd�dƄZrd�dȄZs�dd�dʄZt�dd�d̄Zu�dd�d΄Zvd�dЄZw�dd�dӄZx�dd�dՄZyd�dׄZzd�dلZ{d�dۄZ|d�d݄Z}d�d߄Z~d�d�Zd�d�Z�dS(	�BaseNcCs�d|_|p|j�|_d|_d|_d|_d|_d|_d|_t	j
j�|_d|_
t�|_t�|_t	jj�|_t	jj�|_t	jj�|_ttjg�|_t	jj�|_d|_ d|_!d|_"g|_#i|_$d|_%t�|_&d|_'dS)NF)(�_closed�_setup_default_conf�_conf�_goal�_repo_persistor�_sack�_transaction�_priv_ts�_compsr�comps�TransactionBunch�_comps_trans�_history�set�
_tempfiles�_trans_tempfiles�callbackZDepsolve�_ds_callback�loggingZLogging�_logging�repodict�RepoDict�_repos�rpmZRPMPROB_FILTER_OLDPACKAGE�_rpm_probfilterZpluginZPlugins�_plugins�_trans_success�_trans_install_set�_tempfile_persistor�_update_security_filters�_update_security_options�_allow_erasing�_repo_set_imported_gpg_keys�output)�self�conf�r5�/usr/lib/python3.6/base.py�__init__]s2z
Base.__init__cCs|S)Nr5)r3r5r5r6�	__enter__zszBase.__enter__cGs|j�dS)N)�close)r3Zexc_argsr5r5r6�__exit__}sz
Base.__exit__cCs|j�dS)N)r9)r3r5r5r6�__del__�szBase.__del__cCs.|jr|jj|�n|jjrn|jj|�dS)N)rr �updater4�destdirr)r3�filesr5r5r6�_add_tempfiles�s
zBase._add_tempfilescCs�|j�td|jdd�}|jr&d|d<y|jj|jfddi|��WnTtjk
r�}z6t	j
td�j|j
|��tjjtd�j|j
���WYdd}~XnXdS)NT)�load_filelists�load_presto�load_updateinfo�
load_other�build_cachezloading repo '{}' failure: {}z"Loading repository '{}' has failed)�load�dict�deltarpm�load_metadata_otherr�	load_repo�_repo�hawkey�	Exception�logger�debugr�format�idr�
exceptions�	RepoError)r3�repo�mdload_flags�er5r5r6�_add_repo_to_sack�szBase._add_repo_to_sackcCs.tjj�}|j}d|kr*tjj|j�|d<|S)N�
releasever)rr4ZConf�
substitutionsr(Zdetect_releasever�installroot)r4Zsubstr5r5r6r�s

zBase._setup_default_confcCs�dd�|jj�D�}y0|jj|j||jj|jjd|jj|jj	d�}Wn4t
jk
rx}ztj
jt|���WYdd}~XnX|r�tjtjjj|d��dS)NcSsg|]}|jr|j�qSr5)Zmodule_hotfixesrP)�.0�ir5r5r6�
<listcomp>�sz0Base._setup_modular_excludes.<locals>.<listcomp>F)Zupdate_onlyZdebugsolver�module_obsoletesr)�repos�iter_enabled�sackZfilter_modules�_moduleContainerr4rYZmodule_platform_id�debug_solverr]rKrLrrQ�Errorr
rM�warning�module�module_baseZformat_modular_solver_errors)r3Z
hot_fix_reposZ
solver_errorsrUr5r5r6�_setup_modular_excludes�s"zBase._setup_modular_excludesFc	Cs�t|jj�}d|kr$tr$|j�dSg}g}|�s>�x|jj�D]�}|j|krPq@t|j	�dkr�|j
j�jdd�}x8t|j	�D]*}t
jj|�}|j|j|j
dddd��}q|W|j|jd�|j|j�|jf�|j
j�jdd�}	x8t|j�D]*}
t
jj|
�}|	j|j|j
dddd��}	q�W|	j|jd�|	r@|j|	|jf�q@Wd|k�r6|j
j�jdd�}t|jj	�dk�r�x<t|jj	�D],}t
jj|�}|j|j|j
dddd��}�qzW|j
j�jdd�}x<t|jj�D],}
t
jj|
�}|j|j|j
dddd��}�q�Wt|jj	�dk�r$|j
j|�|j
jd�|�r6|j
j|�|�rjx,|D]$\}
}|j
j|
�|j
jd|��qBW|�r�x|D]\}
}|j
j|
��qvW|�r�t�r�|j�dS)	N�allrT)�emptyF)�
with_nevra�
with_provides�with_filenames)�reponame�main)rr4Zdisable_excludes�WITH_MODULESrgr^r_rP�lenZincludepkgsr`�query�filtermr�subject�Subject�union�get_best_query�append�applyZexcludepkgsZadd_includesZset_use_includes�add_excludes)r3�	only_mainZdisabledZ
repo_includesZ
repo_excludes�rZ
incl_queryZincl�subjZ
excl_queryZexclZ
include_query�
exclude_queryrq�repoidr5r5r6�_setup_excludes_includes�sh

zBase._setup_excludes_includescCsP|jr<|jjr<dd�|jj�D�}|jjj|�|jj�|jrL|jj�dS)NcSs"g|]}|jr|jj�r|j�qSr5)�metadatarJZ	isExpiredrP)rZr{r5r5r6r\�sz/Base._store_persistent_data.<locals>.<listcomp>)	rr4�	cacheonlyr^r_Zexpired_to_addr<�saver-)r3Zexpiredr5r5r6�_store_persistent_data�s
zBase._store_persistent_datacCs|jdkr|jdd�|jS)NT)�arch_filter)r�
read_comps)r3r5r5r6r�s
z
Base.compscCs|jS)N)r)r3r5r5r6r4�sz	Base.confcCs|jS)N)r')r3r5r5r6r^sz
Base.reposcCs
d|_dS)N)r')r3r5r5r6r^sZ
_priv_rpmconncCstjjj|jj�S)N)rr(Z
connectionZ
RpmConnectionr4rY)r3r5r5r6�_rpmconnsz
Base._rpmconncCs|jS)N)r)r3r5r5r6r`sz	Base.sackcCsP|jdkrtjjd��|jjdkrHtjjd|jj	|jj
d|jj�|j_|jjS)NzSack was not initializedF�arch)r`rrQrcra�libdnfreZModulePackageContainerr4rYrX�
persistdir)r3r5r5r6ras
 zBase._moduleContainercCs|jS)N)r)r3r5r5r6�transactionszBase.transactioncCs|jrtd��||_dS)Nztransaction already set)r�
ValueError)r3�valuer5r5r6r�$scCstjj|jj�|_dS)N)r�	persistorZ
RepoPersistorr4�cachedirr)r3r5r5r6�_activate_persistor+szBase._activate_persistorcCs,|jjr|jj|j||�|jj||�dS)z&Load plugins and run their __init__().N)r4Zpluginsr*�_loadZ	_run_init)r3Z
disabled_globZenable_plugins�clir5r5r6�init_plugins.szBase.init_pluginscCs|jj�dS)z#Run plugins pre_configure() method.N)r*Z_run_pre_config)r3r5r5r6�pre_configure_plugins5szBase.pre_configure_pluginscCs|jj�dS)zRun plugins configure() method.N)r*Z_run_config)r3r5r5r6�configure_plugins:szBase.configure_pluginscCs|jj�dS)zRun plugins unload() method.N)r*Z_unload)r3r5r5r6�unload_plugins?szBase.unload_pluginsc
Cs�|jj}|jdkr|j�|j}|r�tjj�rDtd�}tj	|�dStjj
�dkrhtd�}tj	|�dS|dkr�td�}tj	|�dS|j�}|dk	r�||kr�tj	td��dSx|jj
�D]}|jjd�q�W|jj�s�tj	td�jd	j|jj���dSx�|jj�D]�}|j�\}}	|	dk�r6tj	td
�|j�nx|�sH|	dk�rftjtd�|j�|jj�nH|�r�|	|k�r�td�}tj||j|	�|jj�ntjtd
�|j|	��qW|�r�d|_|jddd�tj	td��dS)NzCMetadata timer caching disabled when running on metered connection.Fz:Metadata timer caching disabled when running on a battery.rz Metadata timer caching disabled.z"Metadata cache refreshed recently.�z*There are no enabled repositories in "{}".z", "z4%s: will never be expired and will not be refreshed.z&%s: has expired and will be refreshed.zC%s: metadata will expire after %d seconds and will be refreshed nowz!%s: will expire after %d seconds.T)�load_system_repo�load_available_reposzMetadata cache created.)r4Zmetadata_timer_syncrr�r�utilZon_metered_connectionrrM�infoZon_ac_power�since_last_makecacher^�valuesrJZsetMaxMirrorTries�_any_enabledrO�joinZreposdirr_Z_metadata_expire_inrPrN�expireZreset_last_makecache�	fill_sack)
r3�timerZperiodr��msgr�rSr{Zis_cacheZ
expires_inr5r5r6�update_cacheDsZ






zBase.update_cacheTc CsPtjjd�}|jddd�tjj|�|_tjj|j	j
|j	j�}|���|dk	r�y|jjdd�Wnt
k
r~|dkrz�YnX|�r�g}d}tj�}|j	jr�tjjj�x�|jj�D]�}y`|j|�|jj�|kr�|jj�}|jj�|kr�|jj�}tjtd�|jtjj|jj���Wq�tj j!k
�rz}	z>|jj"�|j#dk�rJ�tj$d	|	�|j%|j�|j&�WYd
d
}	~	Xq�Xq�W|�r�tj$td�dj'|��|jj(��r�|dk�r�|dk�r�tj)td
�t*j+t,|�d�tjj|��n|jj-�j&�Wd
QRX|j	}
|jj.|
j/|
j0|
j1�|j2�|�tj3j4|j�|_5|
j6|j5_6|j7j8�|jS)z'Prepare the Sack and the Goal objects. z
sack setupT)r`�goalF)rD�autorz%s: using metadata from %s.z	Error: %sNzIgnoring repositories: %sz, z-Last metadata expiration check: %s ago on %s.)Zseconds)9rr#�Timer�resetr`�_build_sackr�lock�build_metadata_lockr4r��exit_on_lockr��IOError�time�gpgkey_dns_verification�dnssec�RpmImportedKeys�check_imported_keys_validityr^r_rVrJZgetTimestampZgetAgerMrNrrPr��normalize_time�getMaxTimestamprQrRr��skip_if_unavailablerdrw�disabler�r�r��datetimeZ	timedelta�intrh�
_configure�installonlypkgs�installonly_limit�allow_vendor_changerr��Goalr�protect_running_kernelr*�run_sack)r3r�r�r�r��error_reposZmtsZager{rUr4r5r5r6r�|sf






zBase.fill_sackc	 Cstjjd�}|jddd�tjj|�|_tjj|j	j
|j	j�}|��n|dk	r�y|jjdd�Wnt
k
r~|dkrz�YnXg}|j	jr�tjjj�x�|jj�D]�}yf|jjddd�td|jdd�}|jr�d|d	<|jj|jf|�tjtd
�|jtjj|jj ���Wq�t!t"j#fk
�r�}zZ|j$dk�rPtj%j&td�j'|j|���ntjtd�j'|j|��|j(|j�|j)�WYdd}~Xq�Xq�W|�r�tj*td
�dj+|��WdQRX|j	}|jj,|j-|j.|j/�|j0�|�tj1j2|j�|_3|j4|j3_4|j5j6�|jS)a�
        Prepare Sack and Goal objects and also load all enabled repositories from cache only,
        it doesn't download anything and it doesn't check if metadata are expired.
        If there is not enough metadata present (repond.xml or both primary.xml and solv file
        are missing) given repo is either skipped or it throws a RepoError exception depending
        on skip_if_unavailable configuration.
        z
sack setupT)r`r�F)rDr�)ZthrowExceptZ
ignoreMissing)r@rArBrCz%s: using metadata from %s.zloading repo '{}' failure: {}NzIgnoring repositories: %sz, )7rr#r�r�r`r�rr�r�r4r�r�r�r�r�r�r�r�r^r_rJZ	loadCacherFrGrHrIrMrNrrPr�r�r��RuntimeErrorrKrLr�rQrRrOrwr�rdr�r�r�r�r�rr�r�rr�r*r�)	r3r�r�r�r�rSrTrUr4r5r5r6�fill_sack_from_repos_in_cache�sX	

z"Base.fill_sack_from_repos_in_cachecCs�tjj|jj�|_|jjsl|j|j�|j	r\|j
j|jj��|jj
�|jrl|j|j
�n|jjj|j
�|jjr�tjtd��tjtd�djtjjd��|jdk	r�|jj�|j�|j�d|_	dS)NzRThe downloaded packages were saved in cache until the next successful transaction.z1You can remove cached packages by executing '%s'.z{prog} clean packages)�progF)rr�ZTempfilePersistorr4r�r-Z	keepcache�_clean_packagesrr+r r<Zget_saved_tempfilesrir,Ztempfiles_to_addrMr�rrOr�Z	MAIN_PROGr�historyr9r��_closeRpmDB)r3r5r5r6�_finalize_base�s*



zBase._finalize_basecCsB|jr
dStjtjjd�d|_|j�|jdddd�d|_dS)ztClose all potential handles and clean cache.

        Typically the handles are to data sources and sinks.

        NzCleaning up.T)r`r^r�)	rrM�logrr#�DDEBUGr�r�r*)r3r5r5r6r9sz
Base.closecCsftjjj|j|�}xN|D]F}y|jj|�Wqtjjk
r\}ztj	|�WYdd}~XqXqWdS)z?Read repositories from the main conf file and from .repo files.N)
rr4�readZ
RepoReaderr^�addrQZConfigErrorrMrd)r3Zopts�readerrSrUr5r5r6�read_all_repos"s
zBase.read_all_reposcCs�|r
d|_|rtjj�|_|r�d|_|jdk	rJtjj|j�|_|jj	|j_	|jr`|j
r`|j
j�|jdk	rt|j
j�tjj�|_d|_g|_|r�|r�tj�dS)z1Make the Base object forget about various things.N)rrr%r&r'rr�r�r4r�raZrollbackrr�r9rrrrr.�gcZcollect)r3r`r^r�r5r5r6r�-s$



'z
Base.resetcCs|`dS)z6Closes down the instances of rpmdb that could be open.N)�_ts)r3r5r5r6r�jszBase._closeRpmDB)Z	noscriptsZ
notriggersZnodocs�testZjustdbZ
nocontexts�nocrypto�RPMTRANS_FLAG_NOCAPSZnocapsr�cCs|jS)N)r)r3r5r5r6r�|sz	Base.goalcCs�|jdk	r|jStjjj|jj�|_|jjd�xb|jjD]V}|j	j
|�}|dkrdtjt
d�|�q:|jj|�|jj
|�}|dk	r:|jj|�q:W|jjs�|jjtj�|jjr�|jjtj�tjtj|jd�}|jj|�|jS)zMSet up the RPM transaction set that will be used
           for all the work.Nrz!Invalid tsflag in config file: %s)rrr(r�ZTransactionWrapperr4rY�setFlagsZtsflags�_TS_FLAGS_TO_RPM�getrM�criticalrZ	addTsFlag�_TS_VSFLAGS_TO_RPM�pushVSFlagsZdiskspacecheckr)r�ZRPMPROB_FILTER_DISKSPACEZ
ignorearchZRPMPROB_FILTER_IGNOREARCH�	functools�reduce�operator�or_Z
setProbFilter)r3�flagZrpm_flagZvs_flagZ
probfilterr5r5r6r��s*
zBase._tscCs&|jdkrdS|jj�|`d|_dS)z"Releases the RPM transaction set. N)rr9)r3r5r5r6r��s


cCs$tjjd�}tjj�|_tjtjjd�x�|j	j
�D]�}|js@q4|jsHq4|j
j�}|sXq4tjtjjd|j�|j
j�tjjkr�tj|d�}tjj|�s�q4ntj|d�}y|jj|�Wq4tjjk
r�}ztd�}tj||j|�WYdd}~Xq4Xq4W|�r|jjj|j j!dg�|�|jS)z6Create the groups object to access the comps metadata.z
loading compszGetting group metadataz%Adding group file from repository: %sz
groups.xmlz1Failed to add groups file for repository: %s - %sN�basearch)"rr#r�rZCompsrrMr�r�r^r_Zenablegroupsr�rJZ
getCompsFnrPZgetSyncStrategyrSZSYNC_ONLY_CACHEr
Zcalculate_repo_gen_dest�os�path�existsZrepo_gen_decompressZ_add_from_xml_filenamerQ�
CompsErrorrr�Z_ir�rrX)r3r�r�rSZcomps_fnZdecompressedrUr�r5r5r6r��s:


&zBase.read_compscCs*|jdkr$|jj}t|jj|d�|_|jS)zeauto create the history object that to access/append the transaction
           history information. N)rW)rr4rWrr�)r3rWr5r5r6�_getHistory�s
zBase._getHistorycCs|j�S)N)r�)r3r5r5r6�<lambda>�sz
Base.<lambda>cCst|d|�S)Nr)�setattr)r3r�r5r5r6r��scCst|dd�S)Nr)r�)r3r5r5r6r��szDNF SWDB Interface Object)�fget�fset�fdel�doccsF�jj}t|j����j�}|j�|j�j�}xT|j�D]H�|j��}|d}�j	j
|d��j	j
�d�|j�||dd��q:Wx�|j�D]x��j	j
�d�|j��}t
��}g}x0|D](}	t
|	�|kr�|jd|	�q�|j|	�q�W|d}
|j�|
|dd��q�Wx�|j�D]���j	j
�d�|j��}��fdd�|D�}|j��}�|k�rt|j�jd	��rt|j��}x0|D](}|j|�}
tjj||
�dk�rz|
}�qzW|j�||��fd
d�}tjj||��qWx�|j�D]ȉ|j��}d}x"|D]}|j�jk�r�|}P�q�W|dk�r*|jd�}n
|j|���fdd�|D�}�fd
d�}tjj||��|k�rz|j�|�n|j�||��j	j
|d��j	j
�d��q�W|j �}|�rB�j!j"t#j$d�j�}|j%|d�xh|D]`�|j�jd	��r|d}|j|��jj&||j|���j	j
�d�|j��}|j'�|��q�W|S)NrZdd�dr�r{r[cs$g|]}|�ks|j�jkr|�qSr5)�name)rZr[)�
all_obsoleted�pkgr5r6r\�sz*Base._goal2transaction.<locals>.<listcomp>)r�cs�jj|d�S)N�od)r"�	pkg_added)r�)r3r5r6r�
sz(Base._goal2transaction.<locals>.<lambda>cs$g|]}|�ks|j�jkr|�qSr5)r�)rZr[)r�r�r5r6r\scs�jj|d�S)Nr�)r"r�)r�)r3r5r6r�!sZud�u)�flags)Zpkg__neqrU���)(r�r(rZlist_obsoleted�_get_installonly_queryrx�	installed�list_downgradesZobsoleted_by_packager"r�Z
add_downgrade�list_reinstalls�str�insertrwZ
add_reinstall�
list_installs�
get_reason�filterr�r�r�ZTransactionItemReasonCompareZadd_installrr�Zmapall�
list_upgrades�pop�removeZadd_upgradeZ
list_erasuresr`rqrK�IGNORE_EXCLUDESrr�
set_reasonZ	add_erase)r3r��tsZinstallonly_queryZinstallonly_query_installedZobsZ
downgradedZ	nevra_pkg�	obsoletesZobs_pkgZreinstalled�reasonZobsoleteZreason_obsolete�cbZupgradedr[ZerasuresZremaining_installed_queryZ	remainingr5)r�r�r3r6�_goal2transaction�s�
















zBase._goal2transactioncCsd|j�}|j�}|j�j�}g}g}x6|D].}||krJ|j||d�q*|j||�q*W||fS)aJ See what packages in the query match packages (also in older
            versions, but always same architecture) that are already installed.

            Unlike in case of _sltr_matches_installed(), it is practical here
            to know even the packages in the original query that can still be
            installed.
        r)r��_na_dict�	availablerw)r3�q�instZ
inst_per_archZavail_per_archZavail_lZinst_lZnar5r5r6�_query_matches_installed7s
zBase._query_matches_installedcCs"|jj�j�j|j�d�}t|�S)z� See if sltr matches a patches that is (in older version or different
            architecture perhaps) already installed.
        )r�)r`rqr�rr�matches�list)r3�sltrrr5r5r6�_sltr_matches_installedKszBase._sltr_matches_installedcs�fdd��jj�j�D�S)z5Get iterator over the packages installed by the user.c3s|]}�jj|�r|VqdS)N)r�Zuser_installed)rZr�)r3r5r6�	<genexpr>Tsz*Base.iter_userinstalled.<locals>.<genexpr>)r`rqr�)r3r5)r3r6�iter_userinstalledRszBase.iter_userinstalledcCs0|j||jj|jjd�}|jjr,|jd�|S)N)�allow_uninstall�
force_bestZignore_weak_depsz./debugdata/rpms)�runr4�bestZinstall_weak_depsrbZwrite_debugdata)r3r��
allow_erasing�retr5r5r6�_run_hawkey_goalWs
zBase._run_hawkey_goalc	Cstd}|j�tjjd�}|jj�|j}|j�rJ|j|j	j
�j�|j�n|j
jsd|j�}|j|�|j|j	j
�j|j
jd��|j||�s�|j
jdkr�|j�tjj|j��}tjj|�}n|j|�|_|jj�|�|jdk	o�t|j�dk}|�r|jj �}|�rtjj!|�}|dk	�r"|�|j"j#�|jj$�}||jj%�7}||jj&�7}||jj'�7}|j	j(|j)|�|S)zBuild the transaction set.NZdepsolve)r��r)*�_finalize_comps_transrr#r�r"�startrZ
req_has_eraseZpush_userinstalledr`rqr�r�r4Zupgrade_group_objects_upgrade�_build_comps_solverZ'_exclude_packages_from_installed_groupsZ
add_protectedrrZprotected_packagesr�
debuglevelZ
log_decisionsr��_format_resolve_problems�
problem_rulesrQZ
DepsolveErrorrr�endrpZ_rpm_limitationsrcr*Zrun_resolvedr�r�r�r�Zset_modules_enabled_by_pkgsetra)	r3r�excr�r��solverr�Zgot_transactionZnew_pkgsr5r5r6�resolve_sH








zBase.resolvecCs^t|t�s|g}tjjj�gt|�}|js�|jj	�|jj
�|jr�|jjsV|jj
r�d}t|d�rx|jrxdj|j�}nt|d�r�|jr�dj|j�}|jj�}|dkr�|jj�}n|j}|jj|gg|�|jj|�|jj�|jj�d|_dSd}tjtd��tj j!|j"j#|j"j$�}|���|jj%|j&�|j'�}|�rxtd�}tj(|�x|D]}tj(|��qXWtj)j*|��tjtd��tj+j,d�}	tjtd	��|j&j-�|j&j.�tjjj/|dd
�}
|j&j0|
�}t1|�dk�r\x&|
j2�D]}tj3td�j4|���q�Wtd
�d}x|D]}
|dt5|
�7}�qW|j6|�}|�rP|d|7}tj)j7|��~
tjtd��|j&j8t9j:��r�dS|	�|jj	�|jj
�tj+j,d�}	tjjj/||d�}|j"j;dk�r�x|j<D]}d|_=�q�W|jj�tjtd��|j>|d�}WdQRX|	�|jj?|j�|jj�dd�}x&tj@jA||j|�D]}tjB|��qFW|S)N�args� �cmdsTzRunning transaction checkz%Error: transaction check vs depsolve:zTransaction check succeeded.ztransaction testzRunning transaction test)r�rzRPM: {}zTransaction test error:�
z  %s
zTransaction test succeeded.r�)�displays�FzRunning transaction)rcSs,g}x"|D]}|jdj|t|���q
W|S)Nz{}: {})rwrOr�)�actionZtsis�msgs�tsir5r5r6�
_pto_callback�s
z*Base.do_transaction.<locals>._pto_callback)C�
isinstancerrZyumZrpmtransZLoggingTransactionDisplayrr�rar�ZupdateFailSafeDatar�group�env�hasattrr"r�r$r��lastr`�_rpmdb_version�end_rpmdb_version�begrr*Zrun_pre_transactionZrun_transactionr+rMr�rr�Zbuild_rpmdb_lockr4r�r�Z_populate_rpm_tsr��_run_rpm_check�errorrQZTransactionCheckErrorr#r��orderZcleanZRPMTransactionr�rp�messagesr�rOr
�_trans_error_summaryrc�isTsFlagSetr(�RPMTRANS_FLAG_TESTrr&r2�_run_transactionZunload_removed_pluginsr�Z_post_transaction_outputrN)r3Zdisplay�cmdline�oldZ
rpmdb_version�tidr�r)r�r�ZtestcbZtserrors�	errstringZdescr�summaryrZdisplay_r+r5r5r6�do_transaction�s�
















zBase.do_transactioncCs�d}tjd�}i}x�|j|�D]t}|jd�dkr>t|jd��ntjt|jd��d�}|jd�|krr|||jd�<||jd�|kr|||jd�<qW|r�|td�d	7}x4|D],}|d
tdd||�j	|||�d	7}q�W|s�dStd
�d|}|S)z�Parse the error string for 'interesting' errors which can
        be grouped, such as disk space issues.

        :param errstring: the error string
        :return: a string containing a summary of the errors
        �z9needs (\d+)(K|M)B(?: more space)? on the (\S+) filesystemr'�Mr�g�@�zDisk Requirements:r%z   z7At least {0}MB more space needed on the {1} filesystem.Nz
Error Summaryz
-------------
)
�re�compile�finditerr-r��mathZceilrr	rO)r3r?r@�pZdisk�mZ
size_in_mb�kr5r5r6r8s&
 
*zBase._trans_error_summarycCs|jjo|jjtj�S)N)r4Zhistory_recordr�r9r(r:)r3r5r5r6�_record_history%szBase._record_historycCs�d}|j�r�t|jj�}|jj�j�}|j|d�j�}|jj	�}|j
j�}|dk	rX|j}|dksh||kr�t
jtd�jtjjd��d}t|d�r�|jr�dj|j�}nt|d�r�|jr�dj|j�}|jjr�|jjnd}	|j
j||g||	�}|jj�r$tjd	�}
|
�r$ytj|
�Wnd	}
YnXt
jtjjd
�|j j|j!d�}t
jtjjd�|jj�rzytj|
�WnYnXtjj"|j |j#�|dk�r�n�t$|�d	k�r�dd
�|j D�}|�sfx&|j%�D]}
t
j&td�j|
���q�Wtd�}
tj'j(|
��nlt
j&td��x |D]}t
j&t)|d	���qW|j��rR|j j*t+j,��rR|j
j-|�td�}
tj'j(|
��xbdD]Z}t||��rlt.||�}yt/j0|�Wn.t1t2fk
�r�td�}
t
j&|
|�YnX�qlWt3|j#j4�|_5|j j*t+j,��s�|j6|j7�|S)zh
        Perform the RPM transaction.

        :return: history database transaction ID or None
        N)r�z RPMDB altered outside of {prog}.)r�r"r#r$rBrzRPM transaction start.zRPM transaction over.cSsg|]}|j�r|�qSr5)ZFailed)rZZelr5r5r6r\esz)Base._run_transaction.<locals>.<listcomp>zRPM: {}zCould not run transaction.zTransaction couldn't start:�	ts_all_fn�
ts_done_fnz$Failed to remove transaction file %s)rMrN)8rLrr4Zhistory_record_packagesr`rqr�r�rr1r�r0r2rMrNrrOrr�ZMAIN_PROG_UPPERr/r"r�r$�commentr3Z
reset_nicer��nicer�r#r�r�r!Z_sync_rpm_trans_with_swdbrrpr7r�rQrcr
r9r(r:r�getattrr
�unlink_fr��OSError�boolZinstall_setr,�_verify_transactionZverify_tsi_package)r3rr>Zusing_pkgs_pats�installed_queryZ
using_pkgs�rpmdbvZlastdbvr<rOZonice�errorsZfailedr�rUr[�fnr5r5r6r;)s~









zBase._run_transactioncs�dd�|jD�}t|����fdd�}tjjd�}d}tjj|�}|j�j�}t	dd�|D��}xH|j
jD]<}	|	j�}
x.|
j
�D]"}|j�|kr�|jd�|j�q�WqjWx|D]}||j|�}q�W|j�}
|j
j|
�|�d|_dS)	NcSsg|]}|jtjjkr|�qSr5)r(r�r�Z#TransactionItemAction_REASON_CHANGE)rZr*r5r5r6r\�sz,Base._verify_transaction.<locals>.<listcomp>cs |d7}�dk	r�||��|S)Nr�r5)r��count)�total�
verify_pkg_cbr5r6�display_banner�sz0Base._verify_transaction.<locals>.display_bannerzverify transactionrcSsg|]
}|j�qSr5)r�)rZr[r5r5r6r\�sT)r�rprr#r�r`�
rpmdb_sackrqr�rr�r-ZgetCompsGroupItemZgetPackagesZgetNameZsetInstalledr�r�r1rr+)r3r\Ztransaction_itemsr]r�rZr^r�namesZti�grIr*rWr5)r[r\r6rU�s(

zBase._verify_transactionc
sXtjj|jj|jj�}|���tj�}tdd�|D��}tdd�|D��}	�j	j
jdkrn�j	t|�||	d�n�j	t|�|�tjj
|||���j�r�tjj�j���t�fdd�|D��}
tjjd|�j�}|jj}|dk}
xԈjo�|
s�|dk�r�|dk�r|d	8}td
�}tj|�dd��jD�}�fdd�|D�}td
d�|D��}�j	t|�|�tjj
|||���j��r�tjj�j���|
t�fdd�|D��7}
tjj||i�}q�W�j�r�tjjj�j�}tj|�WdQRX|dk	�r�||
|�|\}}||k�rT||k�rtd�}n||k�r,td�}d||d}tj||d|d|�dS)Ncss|]}|jVqdS)N)�
download_size)rZ�ploadr5r5r6r�sz1Base._download_remote_payloads.<locals>.<genexpr>cSsg|]}t|tjj�r|�qSr5)r,r�drpmZDeltaPayload)rZZpayloadr5r5r6r\�sz2Base._download_remote_payloads.<locals>.<listcomp>�)Ztotal_drpmsc3s|]}�j|�VqdS)N)�_bandwidth_used)rZrb)rXr5r6r�srr�z,Some packages were not downloaded. Retrying.cSsg|]}|�qSr5r5)rZr�r5r5r6r\�scs g|]}tjj|�tjj��qSr5)rrS�_pkg2payload�
RPMPayload)rZr�)�progressr5r6r\�scss|]}|jVqdS)N)ra)rZrbr5r5r6r�sc3s|]}�j|�VqdS)N)re)rZrb)rXr5r6r�sz?Delta RPMs reduced %.1f MB of updates to %.1f MB (%d.1%% saved)zIFailed Delta RPMs increased %.1f MB of updates to %.1f MB (%d.1%% wasted)�dir')rrii)rr�Zbuild_download_lockr4r�r�r��sumrpr�__code__�co_argcountrSZ_download_payloadsZ_irrecoverablerQZ
DownloadErrorZ_update_savingZ_recoverable�retriesrrMr�Z
errmap2str)r3�payloadsrcrh�callback_totalZ	fail_fastr�Zbeg_downloadZest_remote_sizeZ
total_drpmZremote_sizeZsavingrmZforeverr�Zremaining_pkgs�realZfullZpercentr5)rXrhr6�_download_remote_payloads�sb












zBase._download_remote_payloadsc	s�|j|�\}}|rz�dkr$tjj��tjj|jj�j��|j	j
��|jdd�|D����fdd�|D�}|j|��|�|j	j
r�xX|D]P}|jr�tjj|j�|jjd��}ntjj|jj|jjd��}tj||j	j
�q�WdS)aDownload the packages specified by the given list of packages.

        `pkglist` is a list of packages to download, `progress` is an optional
         DownloadProgress instance, `callback_total` an optional callback to
         output messages about the download operation.

        NcSsg|]}|j��qSr5)�localPkg)rZr�r5r5r6r\sz*Base.download_packages.<locals>.<listcomp>cs$g|]}tjj|��jtjj��qSr5)rrSrfZ
delta_factoryrg)rZr�)rcrhr5r6r\s�/)�_select_remote_pkgsrr!ZNullDownloadProgressrcZ	DeltaInfor`rqr�r4Zdeltarpm_percentager?rqr=Zbaseurlr�r�r�Zget_local_baseurl�location�lstriprSZpkgdir�shutil�copy)	r3Zpkglistrhro�remote_pkgsZ
local_pkgsrnr�rur5)rcrhr6�download_packages�s"	

zBase.download_packagescCs�g}|s|S|jj�r&tjjtd���g}x�|D]�}tjj|�rhd|krhtj	j
||j|�}|j|g�y|j
|jj|��Wq0tk
r�}ztj|�|j
|�WYdd}~Xq0Xq0W|jdd�|r�|r�ttd�jdj|����|S)NzACannot add local packages, because transaction job already existsz://T)rzzCould not open: {}r#)rZ
req_lengthrrQrcrr�r�r�r�Z_urlopen_progressr4r?rwr`Zadd_cmdline_packager�rMrdrrOr�)r3�	path_list�strictrh�pkgsZ
pkgs_errorr�rUr5r5r6�add_remote_rpmss(



 zBase.add_remote_rpmscCs|jr|jj}d}n|j|j}|j}|j}|�r|jj}tj	j
j|�}tj	jj
||j��}tjj|j��}~|dkr�d}	d}
n�|dkr�|r�d}	nd}	td�|}
n\|dkr�d}	td�|}
nB|dkr�|r�d}	nd}	d}	td�|}
n|d	k�rd}	td
�|}
nd}	d}
|	|
fS)a�Verify the GPG signature of the given package object.

        :param po: the package object to verify the signature of
        :return: (result, error_string)
           where result is::

              0 = GPG signature verifies ok or verification is not required.
              1 = GPG verification failed but installation of the right GPG key
                    might help.
              2 = Fatal GPG verification error, give up.
        rrBr�r'z"Public key for %s is not installedzProblem opening package %srDz Public key for %s is not trustedrdzPackage %s is not signed)�
_from_cmdliner4Zlocalpkg_gpgcheckr^r~Zgpgcheck�gpgkeyrYrr(r��initReadOnlyTransactionZ	miscutilsZcheckSigrrr�r��basenamer)r3�po�checkZ	hasgpgkeyrS�rootrZ	sigresultZlocalfn�resultr�r5r5r6�_sig_check_pkg(sF

zBase._sig_check_pkgcCs
|j|�S)a�Verify the GPG signature of the given package object.

        :param pkg: the package object to verify the signature of
        :return: (result, error_string)
           where result is::

              0 = GPG signature verifies ok or verification is not required.
              1 = GPG verification failed but installation of the right GPG key
                    might help.
              2 = Fatal GPG verification error, give up.
        )r�)r3r�r5r5r6�package_signature_checkcs
zBase.package_signature_checkc
Cslxf|D]^}tjj|�sqytj|�Wn&tk
rLtjtd�|�wYqXtj	t
jjtd�|�qWdS)NzCannot remove %sz
%s removed)
r�r�r�r
rRrSrMrdrr�rr#r�)r3�packagesrYr5r5r6r�rs

zBase._clean_packagesrhcCsv|dkr|jj}|dkr*|j|||||�Stj|j||||d�}|dksTt|�dkr\|d�St||�}tjdd�|�S)aRReturn a :class:`misc.GenericHolder` containing
        lists of package objects.  The contents of the lists are
        specified in various ways by the arguments.

        :param pkgnarrow: a string specifying which types of packages
           lists to produces, such as updates, installed, available,
           etc.
        :param patterns: a list of names or wildcards specifying
           packages to list
        :param showdups: whether to include duplicate packages in the
           lists
        :param ignore_case: whether to ignore case when searching by
           package names
        :param reponame: limit packages list to the given repository
        :return: a :class:`misc.GenericHolder` instance with the
           following lists defined::

             available = list of packageObjects
             installed = list of packageObjects
             upgrades = tuples of packageObjects (updating, installed)
             extras = list of packageObjects
             obsoletes = tuples of packageObjects (obsoleting, installed)
             recent = list of packageObjects
        N)�showdups�ignore_casermrcSs
|j|�S)N)Zmerge_lists)�a�br5r5r6r��sz(Base._do_package_lists.<locals>.<lambda>)r4Zshowdupesfromrepos�
_list_patternr��partialrp�mapr�)r3�	pkgnarrow�patternsr�r�rmZlist_fnZyghsr5r5r6�_do_package_listss

zBase._do_package_listsc&s���fdd���fdd�}�fdd�}tj|d�}g}	g}
g}g}g}
g}g}g}g}g}|}�jj�}|dk	r�tjj||d�}|j�jd	d
�}|dk�r�i}i}xH|j�D]<}|||j	<|r�q�|j
|jf}||ks�|||kr�|||<q�Wt||j
���}	||j��}|�s|jdd
�}x�|D]�}|�rN|j	|k�rB|j|�n
|
j|�nT|j
|jf}|j	|k�rr|j|�n0||k�s�|j||��r�|
j|�n
|j|��q W�n�|dk�r�||�jdd�}
�j|
dd�}
|
jddgd�|
j�j�}
�nP|dk�rt||j���}	�n2|dk�rB|�r�||�j�}|j�j�}x\|D]T��j
�jf}|j|g�}�fdd�|D�}t|�dk�r�|j��n
|
j���q@Wn�||�j�jdd
�j�}|j�j�j�}xz|D]r\} }!|| |!fd�|j| |!fdg�d}"|"�s
�j|"��r|
j��n"�j|"��r.|j��n
|j���q�W�n|dk�rh||�j�jj�}#|#j�}n�|dk�r��fdd�|j�D�}n�|dk�r|j�}$|�jj��j|$d�}�j|d	dd�}|jddgd�g}xl|D],��j}%|j�fdd�|$j|%d �D���q�Wn6|d!k�rD|j�}|�s2|jdd
�}||�j �j!j"�}|	|_|
|_||_#||_$|
|_%||_||_&||_"||_||_'|S)"Ncs�dkrdS�jj|��kS)z:Test whether given package originates from the repository.NT)r�rS)�package)rmr3r5r6�is_from_repo�sz(Base._list_pattern.<locals>.is_from_repocs�fdd�|D�S)z=Filter out the packages which do not originate from the repo.c3s|]}�|�r|VqdS)Nr5)rZr�)r�r5r6r�sz=Base._list_pattern.<locals>.pkgs_from_repo.<locals>.<genexpr>r5)r�)r�r5r6�pkgs_from_repo�sz*Base._list_pattern.<locals>.pkgs_from_repocs�dkr|S|j�d�S)z=Filter out the packages which do not originate from the repo.N)rm)r�)rq)rmr5r6�query_for_repo�sz*Base._list_pattern.<locals>.query_for_repo)�iter)r�F)rkrhT)Zlatest_per_arch_by_priority�upgrades)Zupgrades_by_priority)�upgrade�src�nosrc)�	arch__neqr�rcsg|]}|j�jkr|�qSr5)�evr)rZr�)�	avail_pkgr5r6r\sz&Base._list_pattern.<locals>.<listcomp>r�
autoremove�extrascsg|]}�|�r|�qSr5r5)rZr�)r�r5r6r\sr)Zobsoletes_by_priority)rdr�csg|]}�|f�qSr5r5)rZr=)�newr5r6r\.s)�provides�recent)(r
Z
GenericHolderr`rqrrsrtrvr�Zpkgtupr�r�rr�rrrrwZevr_gt�_merge_update_filters�latestrrr�rpZevr_eq�	_unneededr��swdbr�r�r�extendZ_recentr4r��reinstall_available�
old_available�updates�obsoletesTuplesr�)&r3r��patternr�r�rmr�r�Zyghr�rr�r�r�rr�r�r�r�Zicrr|ZdinstZndinstr��keyZavailr�Zinstalled_dict�installed_pkgsZsame_verZavailable_dictr�r�Zinst_pkgZautoremove_qrZobsoleted_reldepsr5)r�r�r�rmr3r6r��s�














zBase._list_patterncCs|j|7_t|�S)N)rrp)r3�transr5r5r6�_add_comps_transEszBase._add_comps_transcs�|j�}|sdS|j�jjdd�}|j�fdd�|D�d�}|j|�}x|D]}�jj|tjj	�qLW|j
|�}|j
|�}|r�x |D]}�jj|�j
jd�q�WdS)z�
        Mark to remove packages that are not required by any user installed package (reason group
        or user)
        :param query: dnf.query.Query() object
        NF)rbcs g|]}�jjj|j�r|�qSr5)r�r-Zis_removable_pkgr�)rZr[)r3r5r6r\Usz,Base._remove_if_unneeded.<locals>.<listcomp>)r�)�
clean_deps)r�Z_safe_to_remover�r�r��
differencer�r�r�Z TransactionItemReason_DEPENDENCY�intersectionr�eraser4�clean_requirements_on_remove)r3rqZ
unneeded_pkgsZunneeded_pkgs_historyZpkg_with_dependent_pkgsr�Zremove_packagesr5)r3r6�_remove_if_unneededIs




zBase._remove_if_unneededcs>�j}�jjd}�fdd�}�fdd�}dd�}�jj�jdd	�}|jtj|dd
�f|j	tj|dd
�f|j
|f|j|ff}x�|D]�\}}	x�|D]�}
d|
ji}|
j
r�|jd
|i��jj�jf|�j�}|jddgd�|�s|
j}
|
j
r�|
d|7}
tjtd�j|
��q�|	|||
�}�jjj|
j�q�Wq�W�j|�dS)Nr�cs,tjj�j�}|j|d��jj|d�|S)N)r�)�select)r�selector�Selectorr`rrr�)rq�remove_query�	comps_pkgr)r3r5r6�
trans_upgradegsz1Base._finalize_comps_trans.<locals>.trans_upgradecs��jjdkrr|js"�j||d�q�|j�j�}�j|�tjj	�j
�}|jdj|j
|j�d��jj||d�nltjj	�j
�}|jr�|jdj|j
|j�d�n,�jjr�|j�j
j�j|d��}|j|d��jj||d�|S)Nrh)r|z
({} if {}))r�)r��optional)r)r�)r4�multilib_policyZrequires�_install_multiarchr�rx�_report_already_installedrr�r�r`rrOr�r�installrrurqrr)rqr�r�r|rVr)r3r5r6�
trans_installms 
z1Base._finalize_comps_trans.<locals>.trans_installcSs|j|�}|S)N)ru)rqr�r�r5r5r6�trans_remove�s
z0Base._finalize_comps_trans.<locals>.trans_removeT)ri)r|Fr�r�r�r�)r��.zNo match for group package "{}")rr4rXr`rqrrr�r�r��install_optr�r�r�Zbasearchonlyr<rxrMrdrrOrZ
group_membersr�r�)r3r�r�r�r�r�r�Zattr_fn�attrrYr�Z
query_argsrZpackage_stringr5)r3r6rcs4

zBase._finalize_comps_transcs �fdd�}tjj�j�j|�S)NcsN�jj�j�j|d�}|sdSy�jjj|d�Stk
rHtj	j
SXdS)N)r�r)r`rqr�rrr�r(r��AttributeErrorr�r�ZTransactionItemReason_UNKNOWN)Zpkgnamer)r3r5r6�	reason_fn�sz+Base._build_comps_solver.<locals>.reason_fn)rrZSolverr�r)r3r�r5)r3r6r�s	zBase._build_comps_solvercCsH|j�}t|t�stjj|�}|j|||p.t�||�}|s>dS|j|�S)a&Installs packages of environment group identified by env_id.
        :param types: Types of packages to install. Either an integer as a
            logical conjunction of CompsPackageType ids or a list of string
            package type ids (conditional, default, mandatory, optional).
        r)	rr,r�r�r��listToCompsPackageTypeZ_environment_installrr�)r3�env_id�types�excluder|�exclude_groupsr r�r5r5r6�environment_install�s
zBase.environment_installcCs|j�}|j|�}|j|�S)N)rZ_environment_remover�)r3r�r r�r5r5r6�environment_remove�s
zBase.environment_removec
s��fdd��d}|r2�fdd�|D�}tjj|�}�j�}t|t�sPtjj|�}|j	||||�}|shdS|rt|j
}	n|j}	tj
td�||	��j|�S)anInstalls packages of selected group
        :param pkg_types: Types of packages to install. Either an integer as a
            logical conjunction of CompsPackageType ids or a list of string
            package type ids (conditional, default, mandatory, optional).
        :param exclude: list of package name glob patterns
            that will be excluded from install set
        :param strict: boolean indicating whether group packages that
            exist but are non-installable due to e.g. dependency
            issues should be skipped (False) or cause transaction to
            fail to resolve (True)
        cs6tjj|�r,�jj�j|d�}tdd�|�S|fSdS)N)�
name__globcSs|jS)N)r�)rIr5r5r6r��szABase.group_install.<locals>._pattern_to_pkgname.<locals>.<lambda>)rr��is_glob_patternr`rqrrr�)r�r)r3r5r6�_pattern_to_pkgname�sz/Base.group_install.<locals>._pattern_to_pkgnameNcsg|]}�|��qSr5r5)rZrI)r�r5r6r\�sz&Base.group_install.<locals>.<listcomp>rz#Adding packages from group '%s': %s)�	itertools�chain�
from_iterablerr,r�r�r�r�Z_group_installr�r�rMrNrr�)
r3�grp_idZ	pkg_typesr�r|Zexclude_pkgnamesZnested_excludesr r�Zinstlogr5)r�r3r6�
group_install�s"


zBase.group_installcCs�t|j|jtjtjBtj�}d}d}x�|D]�}	y|j|	�}
Wn:tjj	k
rv}zt
jt|��d}w*WYdd}~XnXx2|
j
D](}|s�||kr�||j||||d�7}q�Wx&|
jD]}
||j|
||||d�7}q�Wq*W|r�|r�tjjtd���|S)NrTF)r�r|)r�r|r�zNothing to do.)rrr��ENVIRONMENTS�GROUPS�	AVAILABLEr�rrQr�rMr5r
�groupsr��environmentsr�rcr)r3r�r�r|r�r�r�cnt�doner��res�errZgroup_idr�r5r5r6�env_group_install�s(

zBase.env_group_installcCs|j�}|j|�}|j|�S)N)rZ
_group_remover�)r3r�r r�r5r5r6�group_removes
zBase.group_removecCs�t|j|jtjtjBtj�}y|j|�}WnFtjj	k
rp}z&t
jdt|��tjj
td���WYdd}~XnXd}x|jD]}||j|�7}q~Wx|jD]}||j|�7}q�W|S)NzWarning: %szNo groups marked for removal.r)rrr�r�r��	INSTALLEDr�rrQr�rMr5r
rcrr�r�r�r�)r3r�rr�r�r�r.�grpr5r5r6�env_group_removes

"zBase.env_group_removec
 CsLt|j|jtjtjBtj�}d}�x
|D�]}y|j|�}Wn6tjj	k
rr}zt
jt|��w(WYdd}~XnXxX|j
D]N}y|j|�d}Wq|tjj	k
r�}zt
jt|��w|WYdd}~Xq|Xq|WxZ|jD]P}y|j|�d}Wq�tjj	k
�r$}zt
jt|��w�WYdd}~Xq�Xq�Wq(W|�sHtd�}	tjj|	��dS)NFTzNo group marked for upgrade.)rrr�r�r�r�r�rrQr�rMr5r
r��environment_upgrader��
group_upgraderr�ZCliError)
r3r�rZgroup_upgradedr�r�r�r.r�r�r5r5r6�env_group_upgrades6



zBase.env_group_upgradecCs|j�}|j|�}|j|�S)N)rZ_environment_upgrader�)r3r�r r�r5r5r6r�9s
zBase.environment_upgradecCs|j�}|j|�}|j|�S)N)rZ_group_upgrader�)r3r�r r�r5r5r6r�@s
zBase.group_upgradecCs�|jjd}tjj|�rdS|jj}tjjj	|d�}|j
tjtjB�|j
dd�}t|�}~~|dkrldStjj|�}tjj|�s�tj|�t|d�}|j�~dSdS)	z�Checks for the presence of GPG keys in the rpmdb.

        :return: 0 if there are no GPG keys in the rpmdb, and 1 if
           there are keys
        z/.gpgkeyschecked.yumr�)r�r�z
gpg-pubkeyr�wN)r4r�r�r�r�rYrr(r�r�r��_RPMVSF_NOSIGNATURES�_RPMVSF_NODIGESTSZdbMatchrp�dirname�makedirs�openr9)r3ZgpgkeyscheckedrYZmyts�idx�keysZmydirZfor5r5r6�_gpg_key_checkGs&

zBase._gpg_key_checkc	Cs�|j|�\}}|j|�x~|D]v}tjj|j�}|jj�j|d�}|jj	rb|j
|jj�j|d��}|j|d�}|dk	r�|j|d�}|jj
||d�qWt|�S)N)r�)r)rm)r�r�)r	r�rr�r�r`rqrrr4rrurrr�rp)	r3rqrmr|�already_instrr�rrr5r5r6r�es

zBase._install_multiarchcCs,tj�}tj�}t||�t||�||fS)a�
        Categorize :param install and :param exclude list into two groups each (packages and groups)

        :param install: list of specs, whether packages ('foo') or groups/modules ('@bar')
        :param exclude: list of specs, whether packages ('foo') or groups/modules ('@bar')
        :return: categorized install and exclude specs (stored in argparse.Namespace class)

        To access packages use: specs.pkg_specs,
        to access groups use: specs.grp_specs
        )�argparseZ	Namespacer)r3r�r��
install_specs�
exclude_specsr5r5r6�_categorize_specsss


zBase._categorize_specscsddd�|jD���fdd�|jD�}|jj�j|d�}|jj�j�d�}|jj|�|jj|�dS)NcSsg|]}tjj|�r|�qSr5)rr�r�)rZr�r5r5r6r\�sz/Base._exclude_package_specs.<locals>.<listcomp>csg|]}|�kr|�qSr5r5)rZr�)�
glob_excludesr5r6r\�s)r�)r�)�	pkg_specsr`rqr�ry)r3r��excludesr}Zglob_exclude_queryr5)r�r6�_exclude_package_specs�szBase._exclude_package_specsc
Cs�t�}t|j|jtjtjBtjtjB�}x�|D]�}y|j|�}Wn8t	j
jk
rx}ztj
dt|��w.WYdd}~XnX|j|j�|j|j�x8|jD].}|jj|�}x|j�D]}	|j|	j�q�Wq�Wq.Wt|�S)NzWarning: Module or %s)rrrr�r�r�r�r�r�rrQr�rMr5r
r<r�r�Z_environment_by_idZgroups_iterr�rPr)
r3�group_specsr�rr�r�r�Zenvironment_idZenvironmentr-r5r5r6�_expand_groups�s"


zBase._expand_groupsc
Cs�x�|D]x}yL|jj}d|kr<|jd�}|d}|djd�}|j|g|||j|j�Wqtjjk
r||j	d|�YqXqWdS)Nrsrr��,�@)
r4Zgroup_package_types�splitr�r��	grp_specsrrQrcrw)r3r�r�Zskippedr|Z
group_specr�rr5r5r6�_install_groups�s

zBase._install_groupscCs�|dkrg}g}g}g}g}	|j||�\}
}|j|�xd|
jD]Z}y|j||||d�Wq>tjjk
r�}
ztjt	|
��|j
|�WYdd}
~
Xq>Xq>Wg}f}to�|
j�rLy tj
jj|�}|j|
j|�Wnxtjjk
�rH}
zV|
j�r
x|
jD]}|j
|�q�W|
j�r2x|
jD]}|j
d|��qW|
j}WYdd}
~
XnXn|
j}|�rv|j|j�|_|j||||�|�s�|�s�|�s�|	�s�|�r�tjj||||	|d��dS)N)rmr|�formsr)�no_match_group_specs�error_group_specs�no_match_pkg_specs�error_pkg_specs�module_depsolv_errors)r�r�r�r�rrQ�MarkingErrorrMr5r�rwrorrerfZ
ModuleBaseZ
MarkingErrorsrrr	r�r)r3r�r�rmr|rrrrrr�r��specrUZno_match_module_specsr	rfZe_specr5r5r6r��sN
 zBase.install_specsc
Cs�tjj|�}|j|j|dd�}|jjdks4|j|�rr|d}|dk	rP|j|d�|sb|j	|||�|j
|||d�S|jjdkr�|j|||jj|d	|d
�}|s�|j	|||�x|D]}	|j
j|	|d�q�WdSd
S)z@Mark package(s) given by pkg_spec and reponame for installation.F)r�with_srcrhrqN)rm)rmr|rT)rrrm�reports�solution)r�r�r�r)rrsrt�get_best_solutionr`r4r�Z_is_arch_specifiedrr�_raise_package_not_found_errorr��_get_best_selectorsrrr�)
r3�pkg_specrmr|rr|rr�sltrsrr5r5r6r��s,
zBase.installcCs�|jrd}t|��|jj�j�j|j|jdgd�}|shtd�}t	j
||j�tjj
td�|j|j��n\t|�d|kr�tjj|j�}|j|gd�|jj||d�d	Std
�}t	j
||j�dSdS)Nz-downgrade_package() for an installed package.�noarch)r�r�z.Package %s not installed, cannot downgrade it.zNo match for argument: %sr)r�)r�r�r�zCPackage %s of lower version already installed, cannot downgrade it.)�_from_system�NotImplementedErrorr`rqr�rrr�r�rrMrdrrQr
ru�sortedr�r�rrr�)r3r�r|r�rrr5r5r6�package_downgrades  zBase.package_downgradecCs�|jj�j|j|j|j�}|j|�\}}||kr>|j|g�nT|tj	j
|�krdtjj
td�|j��n.tjj|j�}|j|gd�|jj||d�dS)NzNo match for argument: %s)r�)r�r�r�)r`rq�_nevrar�r�r�r	r�r�r�r�rrQ�PackageNotFoundErrorrrur�r�rrr�)r3r�r|rr�rrr5r5r6�package_installszBase.package_installcCsf|jj�j�j|j|j|jd�r0|jj|�dSt	d�}t
j|t|��t
jjt	d�|j|j��dS)N)r�r�r�r�z.Package %s not installed, cannot reinstall it.zNo match for argument: %s)r`rqr�rrr�r�r�rr�rrMrdr�rrQr
ru)r3r�r�r5r5r6�package_reinstall(s zBase.package_reinstallcCs|jj|�dS)Nr�)rr�)r3r�r5r5r6�package_remove0szBase.package_removecCs`|jrd}t|��|jdkr6td�}tj||j�dS|jj�j	�j
�}|jjr�|jj�j
|gd�j
|d�r�tjj|j�}|j|gd�|jj|d�dS|jd	kr�|j|jd
�}n|j|j|jd	gd�}|�std�}tj||j�tjjtd
�|j|j��nZt|�d|k�rBtjj|j�}|j|gd�|jj|d�dStd�}tj||j�dSdS)Nz+upgrade_package() for an installed package.r�z<File %s is a source package and cannot be updated, ignoring.r)r�)r)r�r�r)r�)r�r�z+Package %s not installed, cannot update it.zNo match for argument: %szHThe same or higher version of %s is already installed, cannot update it.r�)rrr�rrMr�rur`rqr�rxr4rrrrr�r�rrr�r�r�rdrQr
r)r3r�r�r�rrr5r5r6�package_upgrade4s:
$
zBase.package_upgradec	Cs�|jj�j�}|j|jj�jdd�|D�d��}|j�}|rf|jj�j�j|j|j��d�}|j|�}|dk	rz|j|d�|j||dd�}|r�|j|j	�j
dd�|D�d��}tjj
|j�}|j|d	�|jj|d
�dS)NcSsg|]
}|j�qSr5)r�)rZr�r5r5r6r\\sz*Base._upgrade_internal.<locals>.<listcomp>)r�)r)rmT)rr�cSsg|]
}|j�qSr5)r�)rZr�r5r5r6r\xs)r�)r�r�)r`rqr�r�rrrrur�r�r�r�rr�r�rrr�)	r3rqrrmrZ
installed_allrrVrr5r5r6�_upgrade_internalYs "
 zBase._upgrade_internalc
Csttjj|�}|j|j�}|d}|�rZtjj|�}|oH|doH|dj�r*|dj}|jj�j	�j
�}|jjr||j
|d�n|jj�jdd�}	|	�s*|j
|d�j
�}
|
s�td�}tj||�tjjtd�||��nV|djo�tjj|dj��r*|
j|djd	��s*td
�}tj|dj||dj��|jj�oH|d�oH|dj�}|j||||�Stjjtd�||��dS)Nrq�nevra)rT)ri)r�z(Package %s available, but not installed.zNo match for argument: %s)r�z?Package %s available, but installed for different architecture.z{}.{})rrsrtrr`r�r�r�rqr�rxr4rr�rrrrMrdrQ�PackagesNotInstalledErrorr�rOZ
has_just_namerr
)
r3rrmr|rrZwildcard�pkg_namer�Z
obsoletersZinstalled_namer�rr5r5r6r�s0
& zBase.upgradecCs|j|jj�|jj|dd�S)N)r)rr`rqr4r)r3rmr5r5r6�upgrade_all�szBase.upgrade_allcCs�|dkr|jj�nxtjj|�}|j|jdd�}|djtj	d�|j
|||jjdd�}|spt
jtd�|�dSx|D]}|jj|d	�qvWd
S)NF)rrq)�
reponame__neqT)rrr
zNo package %s installed.r)r�r�)rZdistupgrade_allrrsrtrr`rrrKZSYSTEM_REPO_NAMErr4rrMr�rZdistupgrade)r3rrsrrrr5r5r6�distro_sync�s
zBase.distro_synccCs�t|||g�r�||7}d}|rF|rFx4|D]}td�}tj||�q(Wn|rX|j|�rXd}xX|D]P}y|j||d�Wn4tjjk
r�}	ztj	t
|	��WYdd}	~	Xq^Xd}q^W|s�tjtd��n4|jj�j
|jj|jjd�}
x|
D]}|j|�q�WdS)z�Removes all 'leaf' packages from the system that were originally
        installed as dependencies of user-installed packages but which are
        no longer required by any such package.FzNot a valid form: %sT)rNzNo packages marked for removal.)rb)�anyrrMrdr�r�rrQr
r�r�r`rqr�r�r�r4rbr)r3rr�r�	filenamesr�Zgrp_specr�rrUr}r�r5r5r6r��s,


 
zBase.autoremovecsptjj|�j�j|d�}��fdd�|j�D�}|sB�j||���jj}x|D]}�j	j
||d�qPWt|�S)z'Mark the specified package for removal.)rcs(g|] }�dks �jj|��kr|�qS)N)r�rS)rZr�)rmr3r5r6r\�szBase.remove.<locals>.<listcomp>)r�)rrsrtrvr`r��"_raise_package_not_installed_errorr4r�rr�rp)r3rrmrr
r�r�r�r5)rmr3r6r��s
zBase.removecstjj|�}|j�j�}��fdd�|j�D�}|j�}	|dk	rL|	j|d�|dk	r`|	j|d�tjj	|	�}
|s�tj
jd||
j���d}�j
j}x\|D]T}
y|
t|
�}Wn*tk
r�|s�w��jj|
|d�YnX�jj|�|d7}q�W|dk�rtj
jd||��|S)	Ncs(g|] }�dks �jj|��kr|�qS)N)r�rS)rZr�)�old_reponamer3r5r6r\�sz"Base.reinstall.<locals>.<listcomp>)rm)r$zno package matchedr)r�r�)rrsrtrvr`r�rrrrqZ_per_nevra_dictrQr!r�r4r�r
�KeyErrorrr�r�ZPackagesNotAvailableError)r3rr)Znew_reponameZnew_reponame_neqZ	remove_nar|rr�Zavailable_qZavailable_nevra2pkgr�r�Z
installed_pkgZ
available_pkgr5)r)r3r6�	reinstall�s6


zBase.reinstallcCs
|j|�S)z�Mark a package to be downgraded.

        This is equivalent to first removing the currently installed package,
        and then installing an older version.

        )�downgrade_to)r3rr5r5r6�	downgrade	szBase.downgradec
Cstjj|�}|j|j�}|s6td�|}tjj||��d}|j�}t	|j
�j��}|jj�j
�j|d�}	t|	�dkr�td�|}tjj|||��xn|	j
�j�D]^}
|j�j|
d�}|s�td�}tj||
�q�tjj|j�}|j|d�|jj||d�d}q�W|S)	z�Downgrade to specific version if specified otherwise downgrades
        to one version lower than the package installed.
        zNo match for argument: %sr)r�z6Packages for argument %s available, but not installed.zDPackage %s of lowest version already installed, cannot downgrade it.)r�)r�r�r�)rrsrtrvr`rrQrrr�
_name_dictr�rqr�rrrpr!Z
downgradesr�rMrdr�r�rrr�)
r3rr|r|rr�r�Zavailable_pkgsZavailable_pkg_namesZq_installedr"Zdowngrade_pkgsrr5r5r6r,	s.zBase.downgrade_tocs�|jj�j�d�}|r |�gfStjj|j��}|r>|�gfS�jd�sR�jd�r^d�g}n&�jd�rr|�gfS�fdd�d
D�}|jj�j|d�|fS)N)Z
file__glob�/bin/�/sbin/z/usrrscsg|]}|��qSr5r5)rZ�prefix)�
provides_specr5r6r\E	sz!Base.provides.<locals>.<listcomp>�	/usr/bin/�
/usr/sbin/)r/r0r3r4)r`rqrrrZ_by_provides�
startswith)r3r2Z	providersZbinary_providesr5)r2r6r�6	s




z
Base.providesc
Cs�ddd�}||krtd��||}|rDd|}	|jj|	t��j|�|rfd|}	|jj|	t��j|�|r�d|}	|jj|	t��j|�|r�d|}	|jj|	t��j|�|r�d	|}	|jj|	t��j|�d
S)a�
        It modifies results of install, upgrade, and distrosync methods according to provided
        filters.

        :param cmp_type: only 'eq' or 'gte' allowed
        :param types: List or tuple with strings. E.g. 'bugfix', 'enhancement', 'newpackage',
        'security'
        :param advisory: List or tuple with strings. E.g.Eg. FEDORA-2201-123
        :param bugzilla: List or tuple with strings. Include packages that fix a Bugzilla ID,
        Eg. 123123.
        :param cves: List or tuple with strings. Include packages that fix a CVE
        (Common Vulnerabilities and Exposures) ID. Eg. CVE-2201-0123
        :param severity: List or tuple with strings. Includes packages that provide a fix
        for an issue of the specified severity.
        Z__eqgZ	__eqg__gt)�eqZgtez Unsupported value for `cmp_type`Z
advisory_type�advisoryZadvisory_bugZadvisory_cveZadvisory_severityN)r�r/�
setdefaultrr<)
r3Zcmp_typer�r7ZbugzillaZcvesZseverityZcmp_dictZcmpr�r5r5r6�add_security_filtersI	s&
zBase.add_security_filterscCs
i|_dS)z,
        Reset all security filters
        N)r/)r3r5r5r6�reset_security_filtersn	szBase.reset_security_filtersc
Cs>|jp
|js|r|S|jj�jdd�}|jrRx|jD]}|j|�}q8W|g|_|jr�x<|jj�D].\}}|rx|d}||i}	|j|jf|	��}qdW|j|�}|�s:|�r:|j	�}t
|j�j��}
|
dk�r:|dk�rt
d�j|
�}t
d�j|
�}tjt|||
��n2t
d�j||
�}t
d	�j||
�}tjt|||
��|S)
z�
        Merge Queries in _update_filters and return intersection with q Query
        @param q: Query
        @return: Query
        T)riZ	__upgraderNz3No security updates needed, but {} update availablez4No security updates needed, but {} updates availablez<No security updates needed for "{}", but {} update availablez=No security updates needed for "{}", but {} updates available)r/r.r`rqrrru�itemsr�r�r�rpr.r�rrOrMrdr	)
r3rrrdr�Zmerged_queriesrqZfilter_namer��kwargsrZZmsg1Zmsg2r5r5r6r�u	s>


zBase._merge_update_filtersc
s�jrtd�}t|���|j�j��j|jk}|r:gn�j}��fdd�}d}|jj�j��x |D�]}	t	j
j|	��}
�x|
D�]�}tj
|j|j|j�dkr�td�}tj||	|j�q�|jjr�t	jjj|j|j�}t	jjj|�}
tjt	jj||
��|	|_|jj�rt	j
j||
�nt	j
j |�d}|jj!�r:d}n�|jj"�r�|jj�r�|
t	jj#j$t	jj#j%fk�r�d}tjt	jj&td���nd}tjt	jj&td	���nd}n<|�r�|�|j|j|	|j'|jd
��}n|�r�|�|j|j�}|�s�d}q�|jj(t)j*�}|�r|jj+�}|jj,|t)j*�|jj-tj.|j��}|�rD|jj,|�|dk�rjtd�|}t	j/j0||���tjtd��d}q�WqhW|�r�|�r�t	j/j0td
���|�s�td��j1}t	j/j0||���|j2��\}}|dk�r|�r�td�}tj|�t3|�}t	j/j0||���dS)a�Retrieve a key for a package. If needed, use the given
        callback to prompt whether the key should be imported.

        :param po: the package object to retrieve the key of
        :param askcb: Callback function to use to ask permission to
           import a key.  The arguments *askcb* should take are the
           package object, the userid of the key, and the keyid
        :param fullaskcb: Callback function to use to ask permission to
           import a key.  This differs from *askcb* in that it gets
           passed a dictionary so that we can expand the values passed.
        :raises: :class:`dnf.exceptions.Error` if there are errors
           retrieving the keys
        z6Unable to retrieve a key for a commandline package: %scs0|td��d7}|td�dj�j�7}|S)Nz. Failing package is: %sz
 zGPG Keys are configured as: %sz, )rr�r�)r�)r�rSr5r6�_prov_key_data�	sz1Base._get_key_for_package.<locals>._prov_key_dataFrz)GPG key at %s (0x%s) is already installedTzThe key has been approved.zThe key has been rejected.)r��useridZhexkeyid�keyurl�fingerprint�	timestampzKey import failed (code %d)zKey imported successfullyzDidn't install any keysz�The GPG keys listed for the "%s" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.z+Import of key(s) didn't help, wrong key(s)?N)4rrr�r^r~rPr1r�r�rZcryptoZretriever
ZkeyInstalledr�Zrpm_idrArMr�Zshort_idr4r�r�ZKeyInfoZfrom_rpm_key_objectr>Zraw_keyZDNSSECKeyVerificationZverifyZ
nice_user_msg�urlZlog_dns_key_importZlog_key_importZassumenoZ	assumeyesZValidityZVALIDZPROVEN_NONEXISTENCEZany_msgr@r9r(r:Z
getTsFlagsr�ZpgpImportPubkeyZ
procgpgkeyrQrcr�r�r
)r3r��askcb�	fullaskcbr�Z
key_installedZkeyurlsr=Zuser_cb_failr?r�r�Z
dns_input_keyZ
dns_resultZrcZ	test_flagZ
orig_flagsr��errmsgr5)r�rSr6�_get_key_for_package�	s�








zBase._get_key_for_packagecCs|j|||�dS)a�Retrieve a key for a package. If needed, use the given
        callback to prompt whether the key should be imported.

        :param pkg: the package object to retrieve the key of
        :param askcb: Callback function to use to ask permission to
           import a key.  The arguments *askcb* should take are the
           package object, the userid of the key, and the keyid
        :param fullaskcb: Callback function to use to ask permission to
           import a key.  This differs from *askcb* in that it gets
           passed a dictionary so that we can expand the values passed.
        :raises: :class:`dnf.exceptions.Error` if there are errors
           retrieving the keys
        N)rF)r3r�rCrDr5r5r6�package_import_key$
szBase.package_import_keycCs4g}|jj�x |jj�D]}|jt|��qW|S)N)r�r�Zproblemsrwr
)r3�resultsZprobr5r5r6r45
s

zBase._run_rpm_check�w+bcKstjj||j||f|�S)z�
        Open the specified absolute url, return a file object
        which respects proxy setting even for non-repo downloads
        )rr�Z_urlopenr4)r3rBrS�moder<r5r5r6�urlopen@
szBase.urlopencCs,|dkr|jjtjd�}|j|jjd�}|S)N)r�)r�)rrqrKr�r�r4r�)r3rZinstallonlyr5r5r6r�H
szBase._get_installonly_querycCsrtjj|dd�}|j|jdddd�}|drn|drn|djrn||ddjkrntjtd�j	|ddj��dS)	NT)r�F)rjrkrlrqr rz  * Maybe you meant: {})
rrsrtrr`r�rMr�rrO)r3rr|rr5r5r6�_report_icase_hintN
s

zBase._report_icase_hintcCs�dd�}g}g}x6|D].}|j�r:|jtjkrD|j|�q|j|�qWtd�}|||�sjtjjtd���|j	j
r�td�}|||�s�tjjtd���g}||fS)a Check checksum of packages from local repositories and returns list packages from remote
        repositories that will be downloaded. Packages from commandline are skipped.

        :param install_pkgs: list of packages
        :return: list of remote pkgs
        cSsxd}xn|D]f}d}y|j�}Wn0tk
rN}ztjt|��WYdd}~XnX|dk	r
tj|j||j��d}q
W|S)NTF)ZverifyLocalPkgrLrMr�r�rOrm)Zpkg_listZ
logger_msgZall_packages_verifiedr�Zpkg_successfully_verifiedrUr5r5r6�_verification_of_packages]
s
 z;Base._select_remote_pkgs.<locals>._verification_of_packagesz>Package "{}" from local repository "{}" has incorrect checksumz;Some packages from local repository have incorrect checksumz8Package "{}" from repository "{}" has incorrect checksumzVSome packages have invalid cache, but cannot be downloaded due to "--cacheonly" option)Z
_is_local_pkgrmrKZCMDLINE_REPO_NAMErwrrrQrcr4r�)r3Zinstall_pkgsrMryZlocal_repository_pkgsr�r�r5r5r6rtV
s&




zBase._select_remote_pkgscCsx|D]}t|�qWdS)N)�_msg_installed)r3r�r�r5r5r6r��
s
zBase._report_already_installedc	Cs�|jjtjd�}tjj|�}|j|j|d|d�}|dk	rH|dj|d�|dsdtj	j
td�|��nB|jjtjd�}|dj
|�}|r�td�}ntd�}tj	j
||��dS)	N)r�F)rrrqrq)rmzNo match for argumentz?All matches were filtered out by exclude filtering for argumentz?All matches were filtered out by modular filtering for argument)r`rqrKr�rrsrtrrrrQrrZIGNORE_REGULAR_EXCLUDESr�)	r3rrrm�	all_queryrsrZwith_regular_queryr�r5r5r6r�
s
z#Base._raise_package_not_found_errorc	s��jjtjd�j�}tjj|�}|j�j|d|d�}|dsNtj	j
td�|���dk	rp��fdd�|dD�}n|d}|s�td�}ntd	�}tj	j
||��dS)
N)r�F)rrrqrqzNo match for argumentcs g|]}�jj|��kr|�qSr5)r�rS)rZr�)rmr3r5r6r\�
sz;Base._raise_package_not_installed_error.<locals>.<listcomp>zCAll matches were installed from a different repository for argumentz?All matches were filtered out by exclude filtering for argument)r`rqrKr�r�rrsrtrrQr!r)	r3rrrmrOrsrr�r�r5)rmr3r6r(�
s
z'Base._raise_package_not_installed_errorcCs|jj|jdd�dS)z�
        Setup DNF file loggers based on given configuration file. The loggers are set the same
        way as if DNF was run from CLI.
        T)Zfile_loggers_onlyN)r$Z_setup_from_dnf_confr4)r3r5r5r6�
setup_loggers�
szBase.setup_loggerscs�|jjtjtjBtjB@r d}nd}t|j�}|j|dd�}|jf|�}|rl|rlt	j
j|j��}t
j|�t|jdd��}t|jdd��|}	dd���fdd�|D��t��fd	d�|D��}
t��fd
d�|	D��}|
|fS)z�returns set of conflicting packages and set of packages with broken dependency that would
        be additionally installed when --best and --allowerasingTF)rrZignore_weak)rcSstj|j|j|j|j|jd�S)N)r��epoch�version�releaser�)rKZNEVRAr�rQrRrSr�)�itemr5r5r6r�
sz&Base._skipped_packages.<locals>._nevracsg|]}�|��qSr5r5)rZr*)rr5r6r\�
sz*Base._skipped_packages.<locals>.<listcomp>csg|]}�|��kr|�qSr5r5)rZr�)r�transaction_nevrasr5r6r\�
scsg|]}�|��kr|�qSr5r5)rZr�)rrUr5r6r\�
s)rZactionsrK�INSTALLZUPGRADEZUPGRADE_ALLrr0rrr�rrrMrdr�problem_conflictsZproblem_broken_dependency)r3Zreport_problemsr�rZngZparamsrr�rWZproblem_dependencyZskipped_conflictsZskipped_dependencyr5)rrUr6�_skipped_packages�
s(


zBase._skipped_packages)N)F)F)TT)T)N)FFF)F)F)N)T)NN)TN)rhNNFN)N)NTN)NT)TNN)NT)T)NNTN)NTN)F)T)N)N)N)N)NNNN)NN)NNNF)F)NTF)NN)NN)NrI)N)��__name__�
__module__�__qualname__r7r8r:r;r?rV�staticmethodrrgrr��propertyrr4r^�deleterrr�Zlazyattrr�r`rar��setterr�r�r�r�r�r�r�r�r�r9r�r�r�r(ZRPMTRANS_FLAG_NOSCRIPTSZRPMTRANS_FLAG_NOTRIGGERSZRPMTRANS_FLAG_NODOCSr:ZRPMTRANS_FLAG_JUSTDBZRPMTRANS_FLAG_NOCONTEXTSZRPMTRANS_FLAG_NOFILEDIGESTr�r/r�r�r�r�r�r�r�r�r�rr	r
rrr!rAr8rLr;rUrqrzr~r�r�r�r�r�r�r�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rrrrrrr�r#r%r�r�r+r-r,r�r9r:r�rFrGr4rKr�rLrtr�rr(rPrXr5r5r5r6r[s�
	
=
	
8
;
>

=


	
'\
8l"]
*
B

;

)
=

*



/


%
&


#&
%)-rcCs t|�}td�}tj||�dS)Nz Package %s is already installed.)r
rrMr�)r�r�r�r5r5r6rN�
srN)H�__doc__Z
__future__rrrrr�rZlibdnf.transactionr�rxrZ	dnf.compsrZdnf.i18nrr	r
Zdnf.utilrZdnf.db.historyrZdnf.yumr
�collections.abcr�ImportError�collectionsr�Zdnf.callbackZdnf.confZ
dnf.conf.readZ
dnf.cryptoZ
dnf.dnssecZdnf.drpmZdnf.exceptionsZdnf.goalZdnf.historyZdnf.lockZdnf.loggingZdnf.module.module_baseroZ
dnf.persistorZ
dnf.pluginZ	dnf.queryZdnf.repoZdnf.repodictZdnf.rpm.connectionZdnf.rpm.miscutilsZdnf.rpm.transactionZdnf.sackZdnf.selectorZdnf.subjectZdnf.transactionZdnf.yum.rpmtransr�r�rKr�r#rHr�r�rEr(r�rwZ	getLoggerrM�objectrrNr5r5r5r6�<module>s�



?>