3 ©ft`Sã@s€ddlmZddlmZddlZddlmZddlZddlZddl m Z ddl m Z ddl mZejdƒZGd d „d e jƒZdS) é)Úabsolute_import)Úunicode_literalsN)Úchain)Úcommands)Ú OptionParser)Ú_Údnfc@s’eZdZdZejejejdœZdZ de ej ƒƒZ e dƒZedd „ƒZd d „Zd d „Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„ZdS)ÚInstallCommandzUA class containing methods needed by the cli to execute the install command. )z install-nz install-naz install-nevrazalternative-for({})ÚinstallÚ localinstallÚinz,install a package or packages on your systemcCs"|jddtdƒtjtdƒd�dS)NÚpackageú+ZPACKAGEzPackage to install)ÚnargsÚmetavarÚactionÚhelp)Ú add_argumentrrZParseSpecGroupFileCallback)Úparser©rú/usr/lib/python3.6/install.pyÚ set_argparser1szInstallCommand.set_argparsercCsH|jj}d|_d|_d|_d|_tj|j|jƒ|j j sDtj |jƒdS)zÄVerify that conditions are met so that this command can run. That there are enabled repositories with gpg keys, and that this command is called with appropriate arguments. TN) ÚcliÚdemandsZsack_activationZavailable_reposZ resolvingZ root_userrZ _checkGPGKeyÚbaseÚoptsÚ filenamesZ_checkEnabledRepo)ÚselfrrrrÚ configure7szInstallCommand.configurec CsPg}g}g}|jƒ}|jj|jƒ|jjdkrf|jjs>|jjrf|j|jjƒ|jj j rft j j tdƒƒ‚g}|jjo||jjdk�rTt jj�rLy,t jjj|jƒ}|j|jj|jj j d�Wn’t j jk �rH}zp|jrîx|jD]}|j|ƒqÜW|j�rx|jD]}|jd|ƒqþW|j} | �r8tjt jjj| dƒƒWYdd}~XnXn|jj}|jj�r�|�r�|j|jjƒ|jj j �r˜t j j tdƒƒ‚n|jƒ}|�rÌ|�rÌ|j|ƒ|jj j �rêt j j tdƒƒ‚n|�rê|jjdk�rê|j|ƒ|jjdk�r|j |ƒ}t!|ƒdk�s$t!|ƒdk�s$|�rL|jj j �rLt j j"tdƒdj#|ƒ|d�‚dS) Nr zNothing to do.)Ústrictú@rzUnable to find a matchú )Úpkg_specZpackages)$Ú_get_nevra_forms_from_commandrZ _populate_update_security_filterrÚcommandÚ grp_specsÚ pkg_specsÚ_log_not_valid_rpm_file_pathsrÚconfrrÚ exceptionsÚErrorrZ WITH_MODULESÚmoduleÚ module_baseZ ModuleBaser Z MarkingErrorsZno_match_group_specsÚappendZerror_group_specsÚmodule_depsolv_errorsÚloggerÚerrorZformat_modular_solver_errorsrÚ_inform_not_a_valid_combinationÚ_install_filesÚ_install_groupsÚ_install_packagesÚlenZPackagesNotAvailableErrorÚjoin) rÚerr_pkgsÚerrsZerror_module_specsÚ nevra_formsZskipped_grp_specsr,ÚeZe_specr.rrrÚrunEsX            . zInstallCommand.runcCs&|jj|jkr|j|jjgSgSdS)N)rr$r9)rrrrr#zsz,InstallCommand._get_nevra_forms_from_commandcCsJtdd„|ƒ}x6t|jj|ƒD]$}tdƒ}tj||jjj j |ƒƒqWdS)NcSsd|S)Nr r)ÚgrrrÚ�sz>InstallCommand._log_not_valid_rpm_file_paths..zNot a valid rpm file path: %s) Úmaprrr&rr/ÚinforÚoutputÚtermÚbold)rr%Z group_namesÚpkgÚmsgrrrr'€sz,InstallCommand._log_not_valid_rpm_file_pathscCs2x,|D]$}tdƒ}tj||jjjj|ƒƒqWdS)NzNot a valid form: %s)rr/Zwarningrr@rArB)rÚformsZformrDrrrr1†s z.InstallCommand._inform_not_a_valid_combinationc Cs’g}|jjj}x~|jj|jj||jjjd�D]^}y|jj||d�Wq,t j j k rˆt dƒ}t j||jjjj|jƒƒ|j|ƒYq,Xq,W|S)N)rÚprogress)rzNo match for argument: %s)rr(rZadd_remote_rpmsrrr@rFZpackage_installrr)Ú MarkingErrorrr/r?rArBÚlocationr-)rr7rrCrDrrrr2‹s zInstallCommand._install_filesc CsPy&|jj|t|jjjƒ|jjjd�Wn$tjjk rJ|jjjrF‚YnXdS)N)r) rZenv_group_installÚtupler(Zgroup_package_typesrrr)r*)rr%rrrr3™s  zInstallCommand._install_groupscCsV|jjjƒj|jj|ƒd�}|rRtdƒ}tj|j|dj t t dd„|DƒƒƒƒƒƒdS)N)Zprovidesz/There are following alternatives for "{0}": {1}z, cSsg|] }|j‘qSr)Úname)Ú.0Zaltrrrú ©sz7InstallCommand._report_alternatives..) rZsackÚqueryZfiltermÚalternatives_provideÚformatrr/r?r6ÚsortedÚset)rr"rMrDrrrÚ_report_alternatives¢s z#InstallCommand._report_alternativescCs¦g}|jjj}x’|jjD]†}y|jj|||d�Wqtjjk rœ}zJdj |j |jj j j |ƒƒ}tj|ƒ|jj|ƒ|j|ƒ|j|ƒWYdd}~XqXqW|S)N)rrEz{}: {})rr(rrr&r rr)rGrOÚvaluer@rArBr/r?Z_report_icase_hintrRr-)rr9r8rr"r:rDrrrr4«s     z InstallCommand._install_packagesN)r r r )Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚhawkeyZ FORM_NAMEZFORM_NAZ FORM_NEVRAr9rNrIÚkeysÚaliasesrZsummaryÚ staticmethodrrr;r#r'r1r2r3rRr4rrrrr %s"  5  r )Z __future__rrZloggingÚ itertoolsrrXZdnf.exceptionsrZdnf.clirZdnf.cli.option_parserrZdnf.i18nrZ getLoggerr/ZCommandr rrrrÚs