7m`c@@shdZddlmZddlmZddlmZyddlmZWn!ek rmddlmZnXddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlmZdd lmZdd lmZmZddlZddlZddlZddlZddlZddl Zddl!Zddl"Zddl#Zddl$Zddl%Zddl&Zddl'Zddl(Zddl)Zddl*Zddl+Zddl,Zddl-Zddl.Zddl/Zddl0Zddl1Zddl2Zddl3Zddl4Zddl5Zddl6Zddl7Zddl8Zddl9Zddl:Zddl;Zddl<Zddl=Zddl>Zddl?Zddl@ZddlAZddlBZddlCZe jDd ZEd d ZFdZGdZHdejIfdYZJdeKfdYZLdS(u/ Command line interface yum class and related. i(tprint_function(tabsolute_import(tunicode_literals(tSequenceNi(toutput(tCliError(tucdt_udnfucC@st|jdt|jt|}t|j}t|j}xWd|fd|fd|ffD]4\}}||j|d|||cd7}nd }|r|j j?|}tj|xA|D]6}|j@tAj jBkrztj)j0tdqzqzWn| S(uTake care of package downloading, checking, user confirmation and actually running the transaction. :param display: `rpm.callback.TransactionProgress` object(s) :return: history database transaction ID or None uExcludes in dnf.conf: u, uIncludes in dnf.conf: uExcludes in repo u: uIncludes in repo u4DNF will only download packages for the transaction.utestuMDNF will only download packages, install gpg keys, and check the transaction.uOperation aborted.uNothing to do.NuDownloading Packages:uError downloading packages:u %siuTransaction failed(CRBt excludepkgstloggertdebugRtjointsortedtsett includepkgstrepost iter_enabledtidt transactionRtlist_transactiontinfoR3tactionR,tFORWARD_ACTIONStappendRtBACKWARD_ACTIONSR/t_tstreportRemoveSizetreportDownloadSizet_moduleContainert isChangedt_historytgrouptenvt downloadonlyttsflagst _promptWantedtassumenot userconfirmRtdownload_callback_total_cbtdownload_packagestprogresst exceptionst DownloadErrortclitformatt indent_blockRR2tErrort gpgsigcheckt isinstanceRtCliTransactionDisplaytlistRDRAtdo_transactiontNonethistorytoldtdbtRPMTransactiont_transtpost_transaction_outputtstatetlibdnftTransactionItemState_ERROR(RGtdisplaytrepottranstpkg_strt install_pkgstrmpkgst install_onlyttsittotal_cbtetspecificterrstrttidtmsg((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyRss & & # '  !      !  "c @sDg}x|D]}j|\}}|dkr:q q |dkrjjo\jj }tj sytjj r| rtjj t dnfd}yj ||Wqtjj k r}|j t |qXq |j |q W|r@x|D]} tj| qWtjj t dndS(uPerform GPG signature verification on the given packages, installing keys if possible. :param pkgs: a list of package objects to verify the GPG signatures of :raises: Will raise :class:`Error` if there's a problem iiuTRefusing to automatically import keys when running unattended. Use "-y" to override.c@s jjS(N(RRe(R*tytz(RG(s//usr/lib/python2.7/site-packages/dnf/cli/cli.pytsuGPG check FAILEDN(t_sig_check_pkgRBt assumeyesRdtsyststdintisattyR,RiRnRt_get_key_for_packageRWtstrRItcritical( RGR<terror_messagestpotresultterrmsgtaytfnRR((RGs//usr/lib/python2.7/site-packages/dnf/cli/cli.pyRos&   ! cC@sd}xP|jjjd|jD]3}|tj}|r"tjj |d}Pq"q"Wg|j D](}|dks|d|krc|^qc}|S(uBReturn list of changelogs for package newer then installed versionunameiu timestampN( Rtt_rpmconnt readonly_tstdbMatchR trpmtRPMTAG_CHANGELOGTIMEtdatetimetdatet fromtimestampt changelogs(RGtpackagetnewesttmitchangelogtimestchlogtchlogs((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pytlatest_changelogs)s" (cC@sDd|djdtjj|dtjj|df}|S(u)Return changelog formated as in spec fileu * %s %s %s u timestampu%a %b %d %X %Yuauthorutext(R(R,ti18nR(RGt changelogt chlog_str((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pytformat_changelog7s cC@st}x3|D]+}|j|jp+|jgj|qWxt|jD]|}||}ttdj dj g|D]}t |^q~x.|j |dD]}t|j |qWqRWdS(NuChangelogs for {}u, i(tdictR t source_nameR RWRLtkeysR2RRlRKRRR(RGtpackagestbysrpmtpRt bin_packagesRtchl((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pytprint_changelogs?s  ) ;cC@s|jd|d|}|jjs0|jjrc|jd|d|}|j|_|j|_n|rt|j|}t|jdkri}|jj j d} | rx]t |jD]I} | j } t jj| r| jr| || j| jfqXqW|jj|} | dkr}tjjtdndS(uaAttempt to take the user specified list of packages or wildcards and downgrade them. If a complete version number is specified, attempt to downgrade them to the specified version :param specs: a list of names or wildcards specifying packages to downgrade :param file_pkgs: a list of pkg objects from local files tstrictuNo match for argument: %suNo package %s available.u6Packages for argument %s available, but not installed.iu!No packages marked for downgrade.N(RRtpackage_downgradeR,Rit MarkingErrorRIRTRRR7R8tlocationt downgrade_totPackageNotFoundErrortPackagesNotInstalledErrorRRn( RGtspecst file_pkgsRRRRtargterrRR((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyt downgradePkgss,  !  " uallc!C@sy5|jjjd}|j||d|d|}Wn)tjjk r`}dt|gfSXi}i} i} d} |dkrt |j|} n|r |j r x]|j |j |j D]A} | j| jf} | |ks| || kr| || u}tt|j|\}}|j||j|q+Wx$|D]}|jj|||qtW||j_|st j j t dndS(uPrint out a list of packages that provide the given file or feature. This a cli wrapper to the provides methods in the rpmdb and pkgsack. :param args: the name of a file or feature to search for :return: (exit_code, [ errors ]) exit_code is:: 0 = we're done, exit 1 = we've errored, exit with error string 2 = we've got work yet to do, onto the next stage uNo Matches foundN( RBRR3RDRAtprovidestextendRtmatchcallback_verboseR,RiRnR( RGtargstold_sduptmatchestused_search_stringstspecR0tused_search_stringR((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyR6s      cC@s!|jjr|jj rtStS(N(RBRRdR/R3(RG((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyRcUscC@sP|stjtddS|jj|}|sLtjtddS|S(NuNo transaction ID givenuNot found given transaction ID(RIRRRtRuRv(RGtextcmdsRv((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyt_history_get_transactions[scC@sO|j|}|dkrdSt|dkrGtjtdn|dS(Niu#Found more than one transaction ID!i(RRtRRIRR(RGRRv((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pythistory_get_transactionfs  cC@s|j|f}|dkr+ddgfS|jj}|dkrSddgfS|j|jkrrddgfSd}x|jjtt|jd|jdD]}|jrt j t d|jn%|j rt j t d|jn|dkrt jjj|}q|j|qWt jj|j}td|j|ft|jjd d jd |jD|jj|y*|j||jdtd |jjWnt jjk r}t j t d |jj!j"t#|j$ddgfSt jj%k rn}t j t d|jj!j"t#|j$ddgfSt jj&k rnXdd|jfgfSdS(uRollback given transaction.iu'Failed history rollback, no transactionu!Failed history rollback, no last?iu"Rollback to current, nothing to dou-Transaction history is incomplete, before %u.u,Transaction history is incomplete, after %u.u#Rollback to transaction %u, from %su& Undoing the following transactions: u, cs@s|]}t|VqdS(N(R(t.0R*((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pys sRuNo package %s installed.uA transaction cannot be undoneuNo package %s available.iuRollback to transaction %uN('RRtRutlastRRvRrtrangetaltered_lt_rpmdbRItwarningRtaltered_gt_rpmdbR,RwtMergedTransactionWrappertmergetutiltnormalize_timet beg_timestampR2Rt fmtKeyValFillRKttidsthistoryInfoCmdPkgsAlteredt_history_undo_operationsR3RBRRiRRTR7R8RRtPackagesNotAvailableErrorR(RGtextcmdRvR!tmobjRttmR((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pythistory_rollback_transactionnsL     6   # *  cC@s|j|f}|d kr+ddgfStjj|j}tdj|jt |}t j ||j j |tjjj|}y#|j||jd|jjWntjjk r }t j td|j jjt |jddgfStjjk rY}t j td|j jjt |jddgfStjjk rrnXdd |jfgfSd S( uUndo given transaction.iuFailed history undouUndoing transaction {}, from {}RuNo package %s installed.uAn operation cannot be undoneuNo package %s available.iuUndoing transaction %uN(RRtR,R(R)R*RRlRRRIRTRR-RwRuR&R.RBRRiRR7R8RR/R(RGR0RvR2RR1R((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pythistory_undo_transactions*  ! #  N((((t__name__t __module__t__doc__RtRERsRoRRRR3R/RRRRRRRcRRR3R4(((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyRAs&  i '   & $Z/    8tClicB@seZdZdZdZdZdZddZddZ dddZ ddd Z e j d Zd Zd Zd ZdZRS(cC@s||_i|_d|_tjjj|_|j tjj j j |j tjj j j|j tjj jj|j tjj jj|j tjj jj|j tjj jj|j tjj jj|j tjj jj|j tjj jj|j tjj jj|j tjj jj |j tjj j!j"|j tjj j#j$|j tjj j%j&|j tjj j'j(|j tjj j)j*|j tjj j+j,|j tjj j-j.|j tjj j/j0|j tjj j1j2|j tjj j3j4|j tjj j5j6|j tjj j7|j tjj j8|j tjj j9|j tjj j:|j tjj j;|j tjj j<|j tjj j=dS(N(>R=t cli_commandsRttcommandR,Rktdemandt DemandSheettdemandstregister_commandtcommandstaliast AliasCommandRtAutoremoveCommandtcheckt CheckCommandtcleant CleanCommandt distrosynctDistroSyncCommandtdeplisttDeplistCommandt downgradetDowngradeCommandR_t GroupCommandtinstalltInstallCommandt makecachetMakeCacheCommandtmarkt MarkCommandtmodulet ModuleCommandt reinstalltReinstallCommandtremovet RemoveCommandtrepolisttRepoListCommandt repoquerytRepoQueryCommandtsearcht SearchCommandtshellt ShellCommandtswapt SwapCommandt updateinfotUpdateInfoCommandtupgradetUpgradeCommandtupgrademinimaltUpgradeMinimalCommandt InfoCommandt ListCommandtProvidesCommandtCheckUpdateCommandtRepoPkgsCommandt HelpCommandtHistoryCommand(RGR=((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyREsB   cC@s|jj||jrwx[|jjD]G\}}|jjj||jjd|g|jj|dfq)Wn|j r|jj dd |jj g|j D]}|df^qnt }yx|jD]\}}|jjj |}|sO|jjjr?|dkr?td} tjj| |n|j|n|dkrh|jq|jqWWn@tjjk r} tj| |jjtjdnXx$|D]}tjtd|qWxE|jjjD]1} |jjj | }|r|j!j"qqW|jj#j$\} |j_%|jjj&j'| t#j(|j|jj#} |jjj&j)| dS( Ntbaseurluenableiu*udisableuUnknown repo: '%s'iuNo repository match: %s(u*udisable(*R=tread_all_repost repofrompathtitemsROt add_new_repoRBtrepos_edRWRtinsertRRMt get_matchingRRR,Rit RepoErrortaddtenabletdisablet ConfigErrorRIRt optparsert print_helpRtexitR$t_repo_persistortget_expired_repostgett_repotexpireRtsetup_progress_callbackst _ds_callbacktalltset_progress_bart CliKeyImportt_set_key_import(RGtoptstlabelRtrtnotmatchRt operationRZRRRtbart key_import((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyt_configure_repossD % /       cC@stjdtjjtjtjjd|jtjtjjd|j j j tjtjjd|j j j tjd|j j j dS(NuDNF version: %su Command: %suInstallroot: %suReleasever: %su cachedir: %s(RIRJR,tconsttVERSIONtlogtloggingtDDEBUGt cmdstringR=RBt installroott releasevertcachedir(RG((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyt_log_essentialss cC@sx|j}|jj}|jrKtjjsKtjjt dqKn|j rwx |j D]}t |_ qaWn|js|jjjrt |jj_x|jD]}|jjtjjqWni|jrx]|j D]}|jjqWn9|js7x-|jD]}|jjtjjqWn|jrt|jjd|jjr^dntd|jjndS(Nu/This command has to be run under the root user.tload_system_repouautotload_available_repos(R=R=ROt root_userR,R(t am_i_rootRiRnRRRPR3tload_metadata_othert cacheonlyRBtvaluesRtsetSyncStrategyRtSYNC_ONLY_CACHEtfreshest_metadataRtfresh_metadatat SYNC_LAZYtsack_activationt fill_sackRR/tavailable_repos(RGR=ROR((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyt_process_demands!s,        cC@s|j}|jj|}|dkrtjtd|tjd|j j j rotjtd|ntjtdt n|||_tj tjjd|tj tjjd|dS(u,Check that the requested CLI command exists.u)No such command: %s. Please use %s --helpiuFIt could be a DNF plugin command, try: "dnf install 'dnf-command(%s)'"uOIt could be a DNF plugin command, but loading of plugins is currently disabled.uBase command: %suExtra commands: %sN(R:R9RRtRIRRRtargvR=RBtpluginsRRR,RR(RGRRRt command_cls((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyt_parse_commands>s    c C@s7tjjj}|j|}|dkr?tjjjn||_|jj |}|j rt tj j t|jjj|j|jjtjdn|jrd|_d|_n|jrtj j|_|_ny|jr4|jjjd}|j|jjjtjjt|j _n|jjj!||j"|j#d|krx|j$|jj_$n|jjj%Wntj&j't(fk r}t)j*t+d|tjdn[t,k r'}dt-t.|t/|j0f}t)j*t+d|tjdnX|j1dk r|j1|jj_1|jjj2 r|j3dkrt)j*t+d tjdqn|j4s|j5r|j3d krt)j*t+d tjdn|j6dk rt7j8t9j:|j6dn|jj;|j<d|jj=|j>|j?||jj;|j<d|j3so|jj@tjdn||j_Atj jBd|_Cx'|jjAD]}|jCd|7_CqW|jDy|jE||WntFk rtjdnX|jGr#|jj@|j3tjdn|jjH|j3|}|jIrb|jI|j _Jt|j_Kn|jLr}|jL|j _Ln|jMrt|jj_Nn|jOrt|jj_On|j3jP|jjQ|jjR|jS||jjT|jjj!||j3jU|jjj1r]tjVjW|jjj1|jjj1|jjXjY_Zn|jjj[dkr|jjj\j]d|jjj[nt^j_ddkr3t`}x8|jjXjaD]$} | jbrqnt| _bt}qW|jjjcst|jj_ct}n|r3t)jdt+dq3ndS(uParse command line arguments, and set up :attr:`self.base.conf` and :attr:`self.cmds`, as well as logger objects in base instance. :param args: a list of command line arguments :param option_parser: a class for parsing cli options iiucachediruarchuConfig error: %siu%s: %sudownloadusystem-upgradeureposyncub--destdir or --downloaddir must be used with --downloadonly or download or system-upgrade command.uconfig-manageru_--enable, --set-enabled and --disable, --set-disabled must be used with config-manager command.i<umainupluginu u%s uautotcoloru%_pkgverify_levelu signatureualluWarning: Enforcing GPG signature check globally as per active RPM security policy (see 'gpgcheck' in dnf.conf(5) for how to squelch this message)N(udownloadusystem-upgradeureposync(u signatureuall(eR,RktaliasestAliasestresolveRtt option_parsert OptionParserR~tparse_main_argsR5R2RRR@R=RBthistory_record_packagesRRRtquiett debuglevelt errorlevelRt VERBOSE_LEVELRt _get_optiont_settsystem_cachedirt PRIO_DEFAULTR3R=t_configure_from_optionst_read_conf_fileRR t_adjust_conf_optionsRiR}t ValueErrorRIRRtIOErrorRRtreprtfilenametdestdirRaR:t set_enabledt set_disabledt sleeptimeR'tsleeptrandomt randranget add_commandsR9t init_pluginst disableplugint enablepluginRRt PROGRAM_NAMERRRRthelptparse_command_argst allowerasingt allow_erasingt_allow_erasingRt debugsolvert debug_solverRt pre_configuretpre_configure_pluginst_activate_persistorRtconfigure_pluginst configureR(t ensure_dirRORtpkgdirRR7treinitRt expandMacroR/RPtgpgchecktlocalpkg_gpgcheckR$( RGRRRRtoptRRtforcingR((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyRRs'        % !                  !%    cC@s4tjjd}|jj}|jd|jdtjj|jd|j}|j |j |dkr|j dkrtj j|j }n!|dkrtj j|}n|dk r||_ n|j dkrtjtdnxd D]}|j|qW|jjj|||S( Nuconfiguconfig_file_pathtpriorityureposdiru/uPUnable to detect release version (use '--releasever' to specify release version)ucachedirulogdiru persistdir(ucachedirulogdiru persistdir(R,RtTimerR=RBt_search_inside_installroottreadtPRIO_MAINCONFIGt substitutionstupdate_from_etcRRtRRtdetect_releaseverRIR$Rtprepend_installroott_loggingt_setup_from_dnf_conf(RGRttimerRBtsubstR((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyRs(        ueqc C@s|dkr|dkrdSg}|js1|r[idd|6}|j|j|n|jsj|ridd|6}|j|j|n|js|ridd|6}|j|j|n|js|ridd|6}|j|j|n|jr<i|jd|6}|j|j|n|jrri|jd|6}|j|j|n|j ri|j d |6}|j|j|n|j ri|j d |6}|j|j|n||j _ dS( u :param opts: :param query: base package set for filters :param cmp_type: string like "eq", "gt", "gte", "lt", "lte" :param all: :return: Nubugfixuadvisory_type__u enhancementu newpackageusecurityu advisory__uadvisory_bug__uadvisory_cve__uadvisory_severity__( RttbugfixRWtfiltert enhancementt newpackagetsecuritytadvisorytbugzillatcvestseverityR=t_update_security_filters(RGRR0tcmp_typeRtfiltersR((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyt _populate_update_security_filters8     cC@sN|dk r%|jjjj|n|dk rJ|jjjj|ndS(u Change minimal logger level for terminal output to stdout and stderr according to specific command requirements @param stdout: logging.INFO, logging.WARNING, ... @param stderr:logging.INFO, logging.WARNING, ... N(RtR=Rtstdout_handlertsetLeveltstderr_handler(RGtstdouttstderr((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pytredirect_logger)s  cC@sAtjjj|}||jj_|jjjj|dS(N( R,RkRhtMultiFileProgressMeterR=RRORR(RGtfoRh((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pytredirect_repo_progress5scC@s|jjj}|dkr"dS|jjjjd|j}|j}|jdd|}x#|D]}||krl|}qlqlW||krtd|td|ndS(NRt advisory_typeusecurityu,Security: %s is an installed security updateu-Security: %s is the currently running version( R=R-tget_running_kernelRtR0R1R RR2(RGtkerneltqtikpkgR((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyt_check_running_kernel:s !     cC@s;t|jjtjjtdj||dS(Nu)argument {}: not allowed with argument {}(R2R~t print_usageR,RiRnRRl(RGtoption_string_1toption_string_2((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyt_option_conflictLscC@sSxL|jD]A}||jkr>tjjtd|n||j|QscC@s|j|jjS(u2Call the base command, and pass it the extended commands or arguments. :return: (exit_code, [ errors ]) exit_code is:: 0 = we're done, exit 1 = we've errored, exit with error string 2 = we've got work yet to do, onto the next stage (RR:trun(RG((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyRXs N(R5R6RERRRRRtRRRRRRR RRR>R(((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyR8s $ /   "&    (MR7t __future__RRRtcollections.abcRt ImportErrort collectionsRRRRRRRR'Rtlibdnf.transactionR|tRtdnf.cliRtdnf.i18nRRR,tdnf.cli.aliasestdnf.cli.commandstdnf.cli.commands.aliastdnf.cli.commands.autoremovetdnf.cli.commands.checktdnf.cli.commands.cleantdnf.cli.commands.deplisttdnf.cli.commands.distrosynctdnf.cli.commands.downgradetdnf.cli.commands.grouptdnf.cli.commands.installtdnf.cli.commands.makecachetdnf.cli.commands.marktdnf.cli.commands.moduletdnf.cli.commands.reinstalltdnf.cli.commands.removetdnf.cli.commands.repolisttdnf.cli.commands.repoquerytdnf.cli.commands.searchtdnf.cli.commands.shelltdnf.cli.commands.swaptdnf.cli.commands.updateinfotdnf.cli.commands.upgradetdnf.cli.commands.upgrademinimaltdnf.cli.demandtdnf.cli.formattdnf.cli.option_parsertdnf.conftdnf.conf.substitutionst dnf.consttdnf.db.historytdnf.exceptionst dnf.loggingt dnf.persistort dnf.plugintdnf.rpmtdnf.sacktdnf.transactiontdnf.utilt dnf.yum.misct getLoggerRIRR&R@tBaseRAtobjectR8(((s//usr/lib/python2.7/site-packages/dnf/cli/cli.pyts                                                      4