a !c}@sdZddlmZddlmZddlmZddlmZddlZ ddl Z ddl Z ddl Z ddl Z ddlZe dZedd Zed d Zed Zd dZd ddZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZdS)!z< Classes for subcommands of the yum command line interface. )print_function)unicode_literals) OptionParser)_Ndnfz+To diagnose the problem, try running: '%s'.zrpm -Va --nofiles --nodigestzDYou probably have corrupted RPMDB, running '%s' might fix the issue.zrpm --rebuilddba You have enabled checking of packages via GPG keys. This is a good thing. However, you do not have any GPG public keys installed. You need to download the keys for packages you wish to install and install them. You can do that by running the command: rpm --import public.gpg.key Alternatively you can specify the url to the key you would like to use for a repository in the 'gpgkey' option in a repository section and {prog} will install it for you. For more information contact your distribution or package provider.cCsj|jjs dS|sf|jD]F}|js.|jr|jstdt j t j j dttd|t jjqdS)zVerify that there are gpg keys for the enabled repositories in the rpm database. :param base: a :class:`dnf.Base` object. :raises: :class:`cli.CliError` Nz %s progzProblem repository: %s)confZgpgcheckZ_gpg_key_checkreposZ iter_enabledZ repo_gpgcheckZgpgkeyloggerZcriticalgpg_msgformatrutilMAIN_PROG_UPPERrcliCliError)baserrepor=/usr/lib/python3.9/site-packages/dnf/cli/commands/__init__.py _checkGPGKey:srrcCs||jrdS|D]@}|dr2tj|r2dStjj|d}|dvrdSqt d d |j j }tj|dS)zVerify that there is at least one enabled repo. :param base: a :class:`dnf.Base` object. :param possible_local_files: the list of strings that could be a local rpms :raises: :class:`cli.CliError`: Nz.rpmr)httpftpfilehttpsz*There are no enabled repositories in "{}".z", ")r Z _any_enabledendswithospathexistsrZpycompurlparserr joinr Zreposdirrr)rZpossible_local_filesZlfileschememsgrrr_checkEnabledRepoKs r#c@seZdZdZgZdZdZddZeddZ edd Z ed d Z d d Z ddZ ddZddZddZddZddZdS)Commandz%Abstract base class for CLI commands.NcCs ||_dSNrselfrrrr__init__fszCommand.__init__cCs|jjSr&)rrr)rrrrjsz Command.basecCs |jdS)Nraliasesr+rrr_basecmdoszCommand._basecmdcCs |jjjSr&)rroutputr+rrrr/sszCommand.outputcCsdS)z4Define command specific options and arguments. #:apiNr)r)parserrrr set_argparserwszCommand.set_argparsercCsdS)z*Do any command-specific pre-configuration.Nrr+rrr pre_configure{szCommand.pre_configurecCsdS)z&Do any command-specific configuration.Nrr+rrr configureszCommand.configurecCs&t|tjjrttfStd|dS)z.Get suggestions for resolving the given error.zerror not supported yet: %sN) isinstancer exceptionsZTransactionCheckError _RPM_VERIFY_RPM_REBUILDDBNotImplementedError)r)errorrrrget_error_outputszCommand.get_error_outputcCsdS)zExecute the command.Nrr+rrrrunsz Command.runcCsdS)z$Finalize operation after resolvementNrr+rrr run_resolvedszCommand.run_resolvedcCsdS)z%Finalize operations post-transaction.Nrr+rrrrun_transactionszCommand.run_transaction)__name__ __module__ __qualname____doc__r-summaryoptsr*propertyrr.r/r1r2r3r:r;r<r=rrrrr$_s$   r$c @sReZdZdZdZedZdZddddd d d d eh Ze d dZ ddZ ddZ dS) InfoCommandzRA class containing methods needed by the cli to execute the info command. )infoifz4display details about a package or group of packagesall available installedextrasupdatesupgrades autoremoverecent obsoletesc Cs|}|jdddddtdd|jddddtd d |jd ddd td d |jddddtdd |jddddtdd |jddddtdd |jddddtdd |jddddtdd |jddtd|j|jtjtdddS) N--all_packages_action store_constrHshow all packages (default)destactionconstdefaulthelp --availablerIshow only available packagesrVrWrXrZ --installedrJshow only installed packages--extrasrKshow only extras packages --updatesrMshow only upgrades packages --upgrades --autoremoverNshow only autoremove packages--recentrO#show only recently changed packagespackages*PACKAGEzPackage name specificationnargsmetavarchoicesrYrWrZ)add_mutually_exclusive_group add_argumentr pkgnarrowsDEFAULT_PKGNARROWrPkgNarrowCallback)clsr0narrowsrrrr1sLzInfoCommand.set_argparsercCs||jj}d|_|jjr"|jj|j_|jjdkr4d|_|jjrd|jjr\|jdd|jjnd|j_|jjdkrxd|j_dS)NTrJ --obsoletes--rPrLrM) rdemandssack_activationrCrRpackages_actionavailable_reposrP_option_conflictr)ryrrrr3s   zInfoCommand.configurecCs&|j|j|jd|jj|jjS)NrFr _populate_update_security_filterrCroutput_packagesr{rir+rrrr;szInfoCommand.runN) r>r?r@rAr-rrBrsrr classmethodr1r3r;rrrrrEs  rEc@s$eZdZdZdZedZddZdS) ListCommandzRA class containing methods needed by the cli to execute the list command. )listZlsz$list a package or groups of packagescCs&|j|j|jd|jj|jjS)Nrrr+rrrr;szListCommand.runN)r>r?r@rAr-rrBr;rrrrrsrc@s8eZdZdZdZedZeddZddZ dd Z d S) ProvidesCommandzVA class containing methods needed by the cli to execute the provides command. )providesZ whatprovidesZprovZwpz*find what package provides the given valuecCs|jddtdtdddS)N dependency+ZPROVIDEz#Provide specification to search forrmrnrZrqrr0rrrr1szProvidesCommand.set_argparsercCs|jj}d|_d|_d|_dSNTF)rryr|Zfresh_metadatarzr~rrrr3szProvidesCommand.configurecCsttd|j|jjS)NzSearching Packages: )r debugrrrrCrr+rrrr;szProvidesCommand.runN r>r?r@rAr-rrB staticmethodr1r3r;rrrrrs rc@s8eZdZdZdZedZeddZddZ dd Z d S) CheckUpdateCommandzZA class containing methods needed by the cli to execute the check-update command. ) check-updatez check-upgradez$check for available package upgradescCs0|jddddtdd|jddtd d dS) Nz --changelogs changelogsF store_truezshow changelogs before update)rVrYrWrZrirjrk)rmrnrrrrrr1s z CheckUpdateCommand.set_argparsercCs6|jj}d|_d|_d|_|jjr(d|_t|jdSNT) rryrzr|Zplugin_filtering_enabledrCrr#rr~rrrr3 szCheckUpdateCommand.configurecCsR|jj|jdd|jj|jjd|jjd}|r:d|jj_|jj j rN|j dS)NZgte)Zcmp_typeT)print_rd) rrrCr check_updatesrirrysuccess_exit_statusr Zautocheck_running_kernelZ_check_running_kernelr)foundrrrr;s  zCheckUpdateCommand.runNrrrrrrs  rc seZdZdZGdddeZGdddeZGdddeZGdd d eZGd d d eZ Gd d d eZ GdddeZ GdddeZ GdddeZ GdddeZGdddeZeeeee e e e e eeh ZdZedZfddZddZddZd d!ZZS)"RepoPkgsCommandz2Implementation of the repository-packages command.c@s$eZdZdZdZddZddZdS)z%RepoPkgsCommand.CheckUpdateSubCommand'Implementation of the info sub-command.)rcCs|jj}d|_d|_dSr)rryr|rzr~rrrr3(sz/RepoPkgsCommand.CheckUpdateSubCommand.configurecCs*|jj|jj|jdd}|r&d|jj_dS)?Execute the command with respect to given arguments *cli_args*.T)rrN)rrrC pkg_specsreponamerryrrrrr run_on_repo-s  z1RepoPkgsCommand.CheckUpdateSubCommand.run_on_repoNr>r?r@rAr-r3rrrrrCheckUpdateSubCommand#src@s$eZdZdZdZddZddZdS)zRepoPkgsCommand.InfoSubCommandr)rFcCsh|jj}d|_|jjr"|jj|j_|jjdkr4d|_|jjrd|jjr\|jdd|jjnd|j_dS)NTrJrwrxrP) rryrzrC_pkg_specs_actionpkg_specs_actionr|rPr}r~rrrr39s  z(RepoPkgsCommand.InfoSubCommand.configurecCs.|j|j|jd|jj|jj|jdS)rrFNrrrCrrrrrr+rrrrFs z*RepoPkgsCommand.InfoSubCommand.run_on_repoNrrrrrInfoSubCommand4s rc@s$eZdZdZdZddZddZdS)z!RepoPkgsCommand.InstallSubCommandz*Implementation of the install sub-command.)installcCs$|jj}d|_d|_d|_d|_dSrrryr|rz resolving root_userr~rrrr3Qs z+RepoPkgsCommand.InstallSubCommand.configurec Cs|j|jt|j|jd}|jjshz|jd|jWn$tj j y`t t dYq0d}nt|jjD]j}z|j||jWnLtj j y}z0d|j|jjj|}t |WYd}~qpd}~00d}qp|stj t ddS)NFrjNo package available.Tz{}: {}zNo packages marked for install.)rrrCrrrrrrr5 MarkingErrorr rFrr valuer/termboldError)r)donepkg_specer"rrrrXs$  z-RepoPkgsCommand.InstallSubCommand.run_on_repoNrrrrrInstallSubCommandLsrc@seZdZdZdZddZdS)zRepoPkgsCommand.ListSubCommandz'Implementation of the list sub-command.)rcCs.|j|j|jd|jj|jj|jdS)rrNrr+rrrrzs z*RepoPkgsCommand.ListSubCommand.run_on_repoN)r>r?r@rAr-rrrrrListSubCommandusrc@s$eZdZdZdZddZddZdS)z RepoPkgsCommand.MoveToSubCommandz*Implementation of the move-to sub-command.)zmove-tocCs$|jj}d|_d|_d|_d|_dSrrryrzr|rrr~rrrr3s z*RepoPkgsCommand.MoveToSubCommand.configurec Cst|j|jd}|jjsz|jjd|jdWnftjj yTt t dYnHtjj yvt t dYn&tjjydsJdYn0d}n|jjD]}z|jj||jdWntjj yt d}t ||Yqtjj yd}z^|jD]J}d }|jj|}|r,t d |}t d }t ||jj||qWYd }~qd }~0tjjydsJdYq0d}q|stjt d d S)rFrj)Z new_reponamezNo package installed.r+Only the above marking errors are expected.TNo match for argument: %sr% (from %s)%Installed package %s%s not available.NNothing to do.)rrrrCr reinstallrrr5PackagesNotInstalledErrorr rFrPackagesNotAvailableErrorrrihistoryrr/rrr)r)rrr"errpkgxmsgpkgreporrrrsB   0 z,RepoPkgsCommand.MoveToSubCommand.run_on_repoNrrrrrMoveToSubCommandsrc@s$eZdZdZdZddZddZdS)z&RepoPkgsCommand.ReinstallOldSubCommandz0Implementation of the reinstall-old sub-command.)z reinstall-oldcCs$|jj}d|_d|_d|_d|_dSrrr~rrrr3s z0RepoPkgsCommand.ReinstallOldSubCommand.configurec Cst|j|jd}|jjsz|jd|j|jWnjtjj yZt d}t |YnHtjj y|t t dYn&tjjydsJdYn0d}n|jjD]}z|j||j|jWntjj yt d}t ||Yqtjj yl}z^|jD]J}d}|jj|}|r4t d |}t d }t ||jj||q WYd }~qd }~0tjjydsJdYq0d}q|stjt d d S) rFrj)No package installed from the repository.rrTrr%rrNr)rrrrCrrrrr5rrr rFrrrirrr/rrr)r)rr"rrrrrrrrrsH    0 z2RepoPkgsCommand.ReinstallOldSubCommand.run_on_repoNrrrrrReinstallOldSubCommandsrcs4eZdZdZdZfddZddZddZZS) z#RepoPkgsCommand.ReinstallSubCommandz,Implementation of the reinstall sub-command.)rcs,ttj||t|t|f|_dS)Initialize the command.N)superrReinstallSubCommandr*rrwrapped_commandsr( __class__rrr*sz,RepoPkgsCommand.ReinstallSubCommand.__init__cCs2d|jj_|jD]}|j|_|j|_|qdSr)rryr|rrCrr3r)Zcommandrrrr3s   z-RepoPkgsCommand.ReinstallSubCommand.configurec CsZt|j|j|jD]0}z |Wntjjy>YqYq0qVqtjtddS)rz!No packages marked for reinstall.N) rrrrrrr5rrrrrrrs   z/RepoPkgsCommand.ReinstallSubCommand.run_on_repo) r>r?r@rAr-r*r3r __classcell__rrrrrs  rc@s,eZdZdZdZddZddZddZd S) z,RepoPkgsCommand.RemoveOrDistroSyncSubCommandz8Implementation of the remove-or-distro-sync sub-command.)zremove-or-distro-synccCs$|jj}d|_d|_d|_d|_dSrrr~rrrr3s z6RepoPkgsCommand.RemoveOrDistroSyncSubCommand.configurec s|jjjtj|}||jjj}|jjjfdd| D}|s`tj d|| }|jjj j}|D]<}|j|j|jdr|jjj|qx|jjjj||dqxdS)z;Synchronize a package with another repository or remove it.csg|]}|kr|qSr)r).0rrrrr "szIRepoPkgsCommand.RemoveOrDistroSyncSubCommand._replace..zno package matched)namearch) clean_depsN)rrZsackZ disable_reporsubjectZSubjectZget_best_queryrrJr5rrIr Zclean_requirements_on_removefilterrrZ_goalZ distupgradeZerase) r)rrrmatchesrJrIrpackagerrr_replaces"    z5RepoPkgsCommand.RemoveOrDistroSyncSubCommand._replacec Cst|j|jd}|jjs\z|d|jWn(tjj yTt d}t |Yq0d}nP|jjD]F}z|||jWn*tjj yt d}t ||Yqd0d}qd|stj t ddS)rFrjrTrrN)rrrrCrrrrr5rrr rFrr)rr"rrrrr0s$ z8RepoPkgsCommand.RemoveOrDistroSyncSubCommand.run_on_repoN)r>r?r@rAr-r3rrrrrrRemoveOrDistroSyncSubCommands rc@s$eZdZdZdZddZddZdS)z+RepoPkgsCommand.RemoveOrReinstallSubCommandz6Implementation of the remove-or-reinstall sub-command.)zremove-or-reinstallcCs$|jj}d|_d|_d|_d|_dSrrr~rrrr3Rs z5RepoPkgsCommand.RemoveOrReinstallSubCommand.configurec Cst|j|jd}|jjsz|jjd|j|jddWnHtjj y^t d}t |Yn&tjj y~dszJdYn0d}nz|jjD]p}z|jj||j|jddWnJtjj yt d}t ||Yqtjj ydsJdYq0d}q|stjt dd S) rFrjT)Z old_reponameZnew_reponame_neqZ remove_narz)Only the above marking error is expected.rrN)rrrrCrrrrr5rrr rFrrrrrrrYs8    z7RepoPkgsCommand.RemoveOrReinstallSubCommand.run_on_repoNrrrrrRemoveOrReinstallSubCommandMsrc@s$eZdZdZdZddZddZdS)z RepoPkgsCommand.RemoveSubCommandz)Implementation of the remove sub-command.)removecCs*|jj}d|_d|_d|_d|_d|_dSr)rryrzZ allow_erasingr|rrr~rrrr3s z*RepoPkgsCommand.RemoveSubCommand.configurec Csd}|jjsPz|jd|jWn(tjjyHtd}t |Yq0d}n^|jjD]T}z|j||jWn6tjjy}zt t |WYd}~qXd}~00d}qX|st tddS)rFrjrTNzNo packages marked for removal.) rCrrrrrr5rrr rFstrZwarning)r)rr"rrrrrrs  $z,RepoPkgsCommand.RemoveSubCommand.run_on_repoNrrrrrRemoveSubCommand~src@s$eZdZdZdZddZddZdS)z!RepoPkgsCommand.UpgradeSubCommandz*Implementation of the upgrade sub-command.)upgradez upgrade-tocCs$|jj}d|_d|_d|_d|_dSrrr~rrrr3s z+RepoPkgsCommand.UpgradeSubCommand.configurec Cst|j|jd}|jjs.|j|jd}nN|jjD]D}z|j||jWn&tj j ytt t d|Yq60d}q6|stj t ddS)rFTrzNo packages marked for upgrade.N)rrrrCrZ upgrade_allrrrr5rr rFrr)r)rrrrrrs z-RepoPkgsCommand.UpgradeSubCommand.run_on_repoNrrrrrUpgradeSubCommandsr)zrepository-packagesz repo-pkgsz repo-packageszrepository-pkgsz7run commands on top of all packages in given repositorycs>tt|fdd|jD}d|_dd|D|_dS)rc3s|]}|VqdSr&rrsubcmdr'rr z+RepoPkgsCommand.__init__..NcSsi|]}|jD] }||qqSrr,rraliasrrr sz,RepoPkgsCommand.__init__..)rrr*SUBCMDSr_subcmd_name2obj)r)rZ subcmd_objsrr'rr*s zRepoPkgsCommand.__init__c Cs`|}|jdddddtdd|jddddtd d |jd ddd td d |jddddtdd |jddddtdd |jddddtdd |jddddtdd |jddddtdd |jddtjtdtddd d!|jD}d"d!|jD}|jd#dd$|d%|d&d}|d dddd'ddh}|jd(d)td*||tjtd+d,dS)-NrQrrSrHrTrUr[rIr\r]r^rJr_r`rKrarbrMrcrdrerNrfrgrOrhrZREPOIDz Repository ID)rmrWrnrZcSsg|]}|jdqS)rr,rrrrrrz1RepoPkgsCommand.set_argparser..cSsg|]}|jD]}|qqSrr,rrrrrrrZ SUBCOMMANDz, )rmrnrorZrPrrjrkzPackage specificationrl)rprqrrZ_RepoCallbackEnablerr rt)r)r0rvZsubcommand_choicesZsubcommand_choices_allrsrrrrrr1sh   zRepoPkgsCommand.set_argparserc Csz|j|jjd|_Wn@tjjtfyX}z |jjtjjWYd}~n d}~00|j|j_|jj d|j_ |j dS)z8Verify whether the command can run with given arguments.rN) rrCrrrrKeyError optparser print_usagerr3)r)rrrrr3s  zRepoPkgsCommand.configurecCs|jdS)z>Execute the command with respect to given arguments *extcmds*.N)rrr+rrrr;szRepoPkgsCommand.run)r>r?r@rAr$rrrrrrrrrrrrr-rrBr*r1r3r;rrrrrr s0) 79>1(# + rc@s0eZdZdZdZedZeddZddZ dS) HelpCommandzRA class containing methods needed by the cli to execute the help command. )rZzdisplay a helpful usage messagecCs*|jddtdtdjtjjdddS)Ncmd?ZCOMMANDz{prog} command to get help forrr)rqrr rrrrrrrr1s zHelpCommand.set_argparsercCsL|jjr|jj|jjvr&|jjn"|jj|jj}|jj||dSr&)rCrrZ cli_commandsr print_helprrrrr;$s zHelpCommand.runN) r>r?r@rAr-rrBrr1r;rrrrrs  r)r)rAZ __future__rrZdnf.cli.option_parserrZdnf.i18nrZdnf.clirZdnf.exceptionsZ dnf.pycompZdnf.utilZloggingrZ getLoggerr r6r7r rr#objectr$rErrrrrrrrrs>      9?$y