3 ft`S@sddlmZddlmZddlZddlmZddlZddlZddl m Z ddl m Z ddl mZejdZGd d d e jZdS) )absolute_import)unicode_literalsN)chain)commands) OptionParser)_dnfc@seZdZdZejejejdZdZ de ej Z e dZedd Zd d Zd d ZddZddZddZddZddZddZddZdS)InstallCommandzUA class containing methods needed by the cli to execute the install command. )z install-nz install-naz install-nevrazalternative-for({})install localinstallinz,install a package or packages on your systemcCs"|jddtdtjtdddS)Npackage+ZPACKAGEzPackage to install)nargsmetavaractionhelp) add_argumentrrZParseSpecGroupFileCallback)parserr/usr/lib/python3.6/install.py set_argparser1szInstallCommand.set_argparsercCsH|jj}d|_d|_d|_d|_tj|j|j|j j sDtj |jdS)zVerify 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) clidemandsZsack_activationZavailable_reposZ resolvingZ root_userrZ _checkGPGKeybaseopts filenamesZ_checkEnabledRepo)selfrrrr configure7szInstallCommand.configurec CsPg}g}g}|j}|jj|j|jjdkrf|jjs>|jjrf|j|jj|jj j rft j j tdg}|jjo||jjdkrTt jjrLy,t jjj|j}|j|jj|jj j dWnt j jk rH}zp|jrx|jD]}|j|qW|jrx|jD]}|jd|qW|j} | r8tjt jjj| dWYdd}~XnXn|jj}|jjr|r|j|jj|jj j rt j j tdn|j}|r|r|j||jj j rt j j tdn|r|jjdkr|j||jjdkr|j |}t!|dks$t!|dks$|rL|jj j rLt j j"tddj#||ddS) Nr zNothing to do.)strict@rzUnable to find a match )pkg_specZpackages)$_get_nevra_forms_from_commandrZ _populate_update_security_filterrcommand grp_specs pkg_specs_log_not_valid_rpm_file_pathsrconfrr exceptionsErrorrZ WITH_MODULESmodule module_baseZ ModuleBaser Z MarkingErrorsZno_match_group_specsappendZerror_group_specsmodule_depsolv_errorsloggererrorZformat_modular_solver_errorsr_inform_not_a_valid_combination_install_files_install_groups_install_packageslenZPackagesNotAvailableErrorjoin) rerr_pkgserrsZerror_module_specs nevra_formsZskipped_grp_specsr,eZe_specr.rrrrunEsX            . 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)grrrsz>InstallCommand._log_not_valid_rpm_file_paths..zNot a valid rpm file path: %s) maprrr&rr/inforoutputtermbold)rr%Z group_namespkgmsgrrrr'sz,InstallCommand._log_not_valid_rpm_file_pathscCs2x,|D]$}td}tj||jjjj|qWdS)NzNot a valid form: %s)rr/Zwarningrr@rArB)rformsZformrDrrrr1s z.InstallCommand._inform_not_a_valid_combinationc Csg}|jjj}x~|jj|jj||jjjdD]^}y|jj||dWq,t j j k rt d}t j||jjjj|j|j|Yq,Xq,W|S)N)rprogress)rzNo match for argument: %s)rr(rZadd_remote_rpmsrrr@rFZpackage_installrr) MarkingErrorrr/r?rArBlocationr-)rr7rrCrDrrrr2s zInstallCommand._install_filesc CsPy&|jj|t|jjj|jjjdWn$tjjk rJ|jjjrFYnXdS)N)r) rZenv_group_installtupler(Zgroup_package_typesrrr)r*)rr%rrrr3s  zInstallCommand._install_groupscCsV|jjjj|jj|d}|rRtd}tj|j|dj t t dd|DdS)N)Zprovidesz/There are following alternatives for "{0}": {1}z, cSsg|] }|jqSr)name).0Zaltrrr sz7InstallCommand._report_alternatives..) rZsackqueryZfiltermalternatives_provideformatrr/r?r6sortedset)rr"rMrDrrr_report_alternativess z#InstallCommand._report_alternativescCsg}|jjj}x|jjD]}y|jj|||dWqtjjk r}zJdj |j |jj j j |}tj||jj||j||j|WYdd}~XqXqW|S)N)rrEz{}: {})rr(rrr&r rr)rGrOvaluer@rArBr/r?Z_report_icase_hintrRr-)rr9r8rr"r:rDrrrr4s     z InstallCommand._install_packagesN)r r r )__name__ __module__ __qualname____doc__hawkeyZ FORM_NAMEZFORM_NAZ FORM_NEVRAr9rNrIkeysaliasesrZsummary staticmethodrrr;r#r'r1r2r3rRr4rrrrr %s"  5  r )Z __future__rrZlogging itertoolsrrXZdnf.exceptionsrZdnf.clirZdnf.cli.option_parserrZdnf.i18nrZ getLoggerr/ZCommandr rrrrs