I Rc@sdZddlZddlZddlZddlZddlZddlZddlmZm Z m Z ddl Z ddl m Z ddlZddlZddlZddlZddlZddlZddlZddlmZddlmZmZddlmZddlZddlZddlmZmZm Z dd l!m"Z"d Z#d ej$j%fd YZ&d ej'ej(fdYZ)defdYZ*dZ+dS(s/ Command line interface yum class and related. iN(t OptionParsert OptionGroupt SUPPRESS_HELP(tproxy(tisMultiLibArch(t_tP_(tRPMTransaction(t to_unicodetto_utf8t exception2msg(t parsePackagescCstjdIJtjddS(sSIGQUIT handler for the yum cli. This function will print an error message and exit the program. :param signum: unused :param frame: unused s&Quit signal sent - exiting immediatelyiN(tsyststderrtexit(tsignumtframe((s/usr/share/yum-cli/cli.pytsigquit7s tCliErrorcBseZdZddZRS(s)Command line interface related Exception.tcCs tjjj|||_dS(N(tyumtErrorst YumBaseErrort__init__targs(tselfR((s/usr/share/yum-cli/cli.pyRDs(t__name__t __module__t__doc__R(((s/usr/share/yum-cli/cli.pyRAst YumBaseClicBseZdZdZdZd-ddZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZeedZdZdd-dZdedZdZeddZdZdZddZed-dZdZdZ d Z!d!Z"d"Z#d#Z$ed$Z%d%Z&d&Z'ed'Z(d(Z)d)Z*d*Z+d+Z,ed,Z-RS(.s#This is the base class for yum cli.cCstjtjttjj|tjj|tj tj d|_ tj d|_ i|_ t|_|jtj|jtj|jtj|jtj|jtj|jtj|jtj|jtj|jtj|jtj|jtj|jtj|jtj|jtj|jtj |jtj!|jtj"|jtj#|jtj$|jtj%|jtj&|jtj'|jtj(|jtj)|jtj*|jtj+|jtj,|jtj-|jtj.|jtj/dS(Nsyum.clisyum.verbose.cli(0tsignaltSIGQUITRRtYumBaseRtoutputt YumOutputtloggingt basicConfigt getLoggertloggertverbose_loggertyum_cli_commandstTruetuse_txmbr_in_callbacktregisterCommandt yumcommandstInstallCommandt UpdateCommandt InfoCommandt ListCommandt EraseCommandt GroupsCommandtMakeCacheCommandt CleanCommandtProvidesCommandtCheckUpdateCommandt SearchCommandtUpgradeCommandtLocalInstallCommandtResolveDepCommandt ShellCommandtDepListCommandtRepoListCommandt HelpCommandtReInstallCommandtDowngradeCommandtVersionCommandtHistoryCommandtCheckRpmdbCommandtDistroSyncCommandtLoadTransactionCommandt SwapCommandtRepoPkgsCommandtUpdateinfoCommandtUpdateMinimalCommandtFSSnapshotCommand(R((s/usr/share/yum-cli/cli.pyRKsL   cCsVxO|jD]A}||jkrAtjjtd|n||j|ss %-14s %s is%s ( RtmisctuniqueR(tvaluesthasattrRZtsortt getSummaryRKtAttributeErrortNotImplementedError(RtusageR\tcommandsRMtsummary((s/usr/share/yum-cli/cli.pyt _makeUsages'  " c Csii}tjj}g|_g}g}x |D]}|jd}t|dkrk|j|q1nt|dkr|j|q1n|\}} |jd} | dkr)|| } || d}| |krtjj|| |j?f}n"d|j=|j|j>|j?f}d|j@jAd|jB|j@jAdf}t+d||| |jCfGHt+dt/|jD| |jEfGHt+dt/|jF||jGfGHqWt,j-dn|jHd k rtJjK|jHd}nd}||_0d|_Lx$|j0D]}|jLd|7_LqWy|jMWntNk r?t,j-d nXtOjP|d S(!sParse command line arguments, and set up :attr:`self.conf` and :attr:`self.cmds`, as well as logger objects in base instance. :param args: a list of command line arguments tbaseRfiis'Setopt argument has multiple values: %ss Setopt argument has no value: %ss1Main config did not have a %s attr. before setoptsConfig error: %sis%s: %ssOptions error: %sRsGIgnored option -q, -v, -d or -e (probably due to merging: -yq != -y -q)t/s8Ignored option -c (probably due to merging -yc != -y -c)cSstjdtj|S(Ns%Y-%m-%d %H:%M(ttimetstrftimetgmtime(R\((s/usr/share/yum-cli/cli.pyt sm_ui_time;scSstjdtj|S(Ns%Y-%m-%d(RRR(R\((s/usr/share/yum-cli/cli.pyt sm_ui_date=stpatternsRt0s%s-%s.%ss %s:%s-%s.%ss%s%s%stboldtnormals Installed: %s-%s at %ss Built : %s at %ss Committed: %s at %si<syum s%s N(QtYumOptionParserRit optparsert firstParsetversionRt __version__R)tquiettFalsetverboseRRuRsRmRrtgetattrtgetRoott debuglevelt errorleveltpreconftconffiletfntroott nopluginst init_pluginstpluginst TYPE_COREtTYPE_INTERACTIVEt plugin_typest _splitArgtdisablepluginstdisabled_pluginst enablepluginstenabled_pluginst releasevertconfR&twarningRaRRLtcriticalRR RtIOErrorRRtreprtfilenamet ValueErrort set_usagetruntsetupYumConfigtcmdstcachetrun_with_package_namestsortedtrpmdbtreturnPackagestepochtreleasetarchttermtMODERNt installtimetpackagert buildtimet committert committimet sleeptimeRRtrandomt randranget cmdstringt parseCommandsRRtsleep(RRtoptsRxRytoptRtpcRztmsgtet yum_progstdoneRRtpkgtverRNRtarg((s/usr/share/yum-cli/cli.pytgetOptionsConfigs    #               *&      $     "    cCs2|jjdtj|jjtjjd|j|jjtjjd|jj t |jj dkrt |j dkr|jj |_ n|j |j_ t |j dkr|j jtd|jtn|j d|_|j d|_t |jdkrd|jjtjjdx0|jD]"}|jjtjjd|q;Wn|j|jkr|j jtd |jtjdtn|j|j}d }t|d r|j||j|j}nx |jjD]}||_qW|j|jj||j|jd S( sRead :attr:`self.cmds` and parse them out to make sure that the requested base command and argument makes any sense at all. This function will also set :attr:`self.basecmd` and :attr:`self.extcmds`. sYum version: %ss COMMAND: %ssInstallroot: %siisYou need to give some commandsExt Commands: s %ss)No such command: %s. Please use %s --helptwritetcacheRequirementN(R'tdebugRRRSRTtDEBUG_4RRt installrootRoRgRR&RRRfRtbasecmdtextcmdsR(R targvRaRtreposRbt_metadata_cache_reqtdoCheck(RRtcmdtcacheReqR((s/usr/share/yum-cli/cli.pyRgs< -  #  cCs~t|dsdS|js dS|j}g|D]}dj|^q0}|jddj|}|jjd|dS(Nt_shell_history_cmdst Rs s shell-cmds(RaRtjoinRpthistorytwrite_addon_data(RtdataR((s/usr/share/yum-cli/cli.pyt_shell_history_writes  " cCs`tjd|}|j|_t|jdkr@|jn |j|`|j|jfS(sRun a shell-like interface for yum commands. :return: a tuple containing the shell result number, and the shell result messages Ri( tshelltYumShellRRoRtcmdlooptscripttresultt resultmsgs(Rtyumshell((s/usr/share/yum-cli/cli.pytdoShells   cCs"d}tjd}i}x|j|D]}|jd|krkt|jd||jd|jjtddS|j}|jjtjj r~|jj tjj |n,|j j s|j j r|jj|ng}g}tt}xs|jjD]b}|jd'krt}|j}|r4|j|q4qt|j}|r|j|qqW|jjs[|j|n|j|||jj}|d(k r|jj|dkrtd} |d r| td 7} |jjt| q| td 7} tjj| n|j rkd(} |j j s-||} n| sM|jjtd dS| d krkt|j _!qkn|j j!r|jj tjj"tdn|jj tjj"td|j#|d|j$} t| dkrVd} | td7} xI| D]A} tj%j&| | }x"|D]}| d| |f7} q"WqWtjj| n|j'|dkrodS|j(|j)}d(|_)|j*ddt+j+}|jj tjj"td|j,}t}|rt}x)|D]!} | j-drqnt}qW|r$tdGHntdGHt}x|D]} t.| GHq<W|rjdtdgfS|rzdgfSdtd|j j/gfSn|jj0dt+j+|t+j+}|jj tjj"td|jj1|jj2t3|dt}|jj4|}~t|dkrtd} x"|D]}| dt5|7} qIWtjj| d |j6| n|jj tjj"td!|jj0d"t+j+|t7j7t7j8t7j9t+j+}t}x*|jjD]}|j:rt}PqqW|rf|j(|j*dd|jj;|jj1|jj2n||_)t3|d#t<j=t>|}|j j?d krt|j@_<n|jj tjj"td$|jAd%|}|jj0d&t+j+||jj tjj |jBt7j7t7j8tC|jDS()s)Take care of package downloading, checking, user confirmation and actually running the transaction. :return: a numeric return code, and optionally a list of errors. A negative return code indicates that errors occurred in the pre-transaction checks cs|idtdtdtdfd6}}s`|jd|}|dkr\d}n|S|jdtdd|S(Nudtdtdownloadt downloadonlytextratpromptsIs this ok [y/d/N]: (Rt userconfirmRR(Rtdl_onlyR tret(tstuff_to_download(s/usr/share/yum-cli/cli.pyt_downloadonly_userconfirms  is9Trying to run the transaction but nothing to do. Exiting.itituis6future rpmdb ver mismatched saved transaction version,is ignoring, as requested.s aborting.sExiting on user commandR s.Background downloading packages, then exiting:sDownloading packages:tcallback_totalRsError downloading packages: s %s: %s tkeepoldsRunning transaction checksrpmlib(s'ERROR You need to update rpm to handle:s)ERROR with transaction check vs depsolve:sRPM needs to be updatedsPlease report this error in %ssTransaction check time: %0.3fsRunning transaction testttestsTransaction check error: s %s s sTransaction test succeededsTransaction test time: %0.3ftdisplaysRunning transactiontcbsTransaction time: %0.3f(RRN(ERottsInfoR'tinfoRtlistTransactiont isEnabledForRRTtINFO_1RSRtassumenot assumeyesR&twarnRR)t getMemberstts_statetpoRpttstclosetreportRemoveSizetreportDownloadSizet_check_future_rpmdbvRRtfutureRpmDBVersionRRRt _promptWantedR RUt downloadPkgstdownload_callback_total_cbR^R_t gpgsigcheckt initActionTst dsCallbackt populateTsRt_run_rpm_checkt startswithR tbugtracker_urlRtordertcleanRRRRRRtSIG_DFLt reinstalltcheckR!tYumCliRPMCallBacktweakrefRRtrunTransactiontpostTransactionOutputRt return_code(RRtlstst downloadpkgstrmpkgst install_onlyttxmbrR"tcfrRtuctproblemsRR[terrorsterrortdscbtrcd_sttmsgstdepsolvet rpmlib_onlyttt_stttestcbttserrorstdescrtts_stthave_reinstallsRt resultobject((Rs/usr/share/yum-cli/cli.pyt doTransactions                                          csx|D]}j|\}}|dkr4qq|dkrjjoVjj }tjj r| rtjj t dnj |fdqtjj |qWdS(sLPerform GPG signature verification on the given packages, installing keys if possible. :param pkgs: a list of package objects to verify the GPG signatures of :return: non-zero if execution should stop due to an error :raises: Will raise :class:`YumBaseError` if there's a problem iisTRefusing to automatically import keys when running unattended. Use "-y" to override.cs jS(N(R (R\tytz(R(s/usr/share/yum-cli/cli.pyR]s( t sigCheckPkgRRRR tstdintisattyRRRRtgetKeyForPackage(RtpkgsR"Rterrmsgtay((Rs/usr/share/yum-cli/cli.pyR,s    cCs|jd|gdt}|j|j}ttd|}|r|jtddj|}|j j t j j t|ndS(s= If install argument doesn't match with case, tell the user. Rt ignore_casecSs|jS(N(RN(R\((s/usr/share/yum-cli/cli.pyR] ss * Maybe you meant: s, N(tdoPackageListsR)t installedt availabletsettmapt fmtKeyValFillRRR'RSRRTRUR(RRtmatchesR((s/usr/share/yum-cli/cli.pyt_maybeYouMeant sc Cs| s|ddkrdSd}|r0d}n|jd|d|gdt}|jss|j rw|j|rwdS|jjd }|jjd }|jr|jjt j j t d |||dS|jd|d|gdt }|j r,|jr,|jjt j j t d |||dSttd |j}|sS|r~|jjt j j t d |||n|r|jt ddj|}|jjt j j |ndS(sr If the update/remove argument doesn't match with case, or due to not being installed, tell the user. it@NtallR_t pkgnarrowRR]RRs/Package(s) %s%s%s available, but not installed.cSs|jS(N(RN(R\((s/usr/share/yum-cli/cli.pyR]4ssNo package %s%s%s available.s * Maybe you meant: s, (R^RR_R`treturnInstalledPackagesByDepRRR'RSRRTRURR)RaRbRcR( RRt always_outputt rpmdb_onlyRhRdthibegthiendR((s/usr/share/yum-cli/cli.pyt_checkMaybeYouMeants> !   !    csjjsgSg}tdfdxK|D]C}x'|jD]\}}||7}qNW||j7}q>W|S(sGo through the given txmbrs, and for any to be installed packages look for their installed deps. and try to upgrade them, if the configuration is set. Returning any new transaction members to be isntalled. :param txmbrs: a list of :class:`yum.transactioninfo.TransactionMember` objects :return: a list of :class:`yum.transactioninfo.TransactionMember` objects cs|jkrgS|dkr(|}nj|jg}xu|jD]j}xaj|D]P}|jkryq^n|jd|jd|7}||d|7}q^WqHW|S(NRNt requiringPotreqpo(RNRRtaddtrequiresRitupdate(RRpturettreqtnpkg(t_pkg2upsRR(s/usr/share/yum-cli/cli.pyRwMs  N(Rtupgrade_requirements_on_installRaRRt relatedtoR"(RttxmbrsRRAtrtxmbrtT((RwRRs/usr/share/yum-cli/cli.pyt_install_upgraded_requires>s   tinstallcCst|j}t}xN|D]F}|jdrwtjj|sUtjj |rw|j |}|j |qnyutrnh|dkr|j d|}nG|dkry|j dd\}} Wn&|jjtd||wnX|j d|d| }n|d kryO|j dd\} } | j d d \}} } | jd d\} }Wn&|jjtd||wnX|j d|d | d|d| d| }n*|dkst||j d|}Wn`tjjk rN|jjtjjtd|jjd||jjd|j|qXt}|j |qWt|j|krt|j|}d tdd||gfS|sdtdgfSdtdgfS(ssAttempt to take the user specified list of packages or wildcards and install them, or if they are installed, update them to a newer version. If a complete version number is specified, attempt to upgrade (or downgrade if they have been removed) them to the specified version. :param userlist: a list of names or wildcards specifying packages to install :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 s.rpms install-nRNs install-naRkisBad %s argument %s.Rs install-nevrat-it:RRRR~tpatternsNo package %s%s%s available.RRs%d package to installs%d packages to installs Nothing to doi(RoRRtendswithRR^t re_remote_urltostpathtexistst installLocalR}R~trsplitR'RRRntAssertionErrorRt InstallErrorRSRTRURRReR)R(RtuserlistRtrepoidtoldcountRRRztntatnevrtevtrRR}tchange((s/usr/share/yum-cli/cli.pyt installPkgses` !       icCs1t|j}t|dkr.|jnx|D]}|jdrtjj|sntjj |r|j |dd}|j |q5n|jd|d|}|j ||s5|j |q5q5Wt|j|krt|j|}dt dd ||gfSdtd gfSd S( sTake user commands and populate transaction wrapper with packages to be updated. :param userlist: a list of names or wildcards specifying packages to update. If *userlist* is an empty list, yum will perform a global update :param quiet: unused :param update_to: if *update_to* is True, the update will only be run if it will update the given package to the given version. For example, if the package foo-1-2 is installed, updatePkgs(["foo-1-2], update_to=False) will work identically to updatePkgs(["foo"]), but updatePkgs(["foo-1-2"], update_to=True) will do nothing :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 is.rpmt updateonlyiRt update_tois%d package marked for updates%d packages marked for updatesNo packages marked for updateN(RoRRsRRR^RRRRRR}RnRR(RRRRRRzRzR((s/usr/share/yum-cli/cli.pyt updatePkgss"  !  c Csd}|rH|ddkrH|d}|d}|dkrHd}qHng}i}x0t|jjd|D]}|||jdd?dd dtd@|jdAddBdd dtdC|jdDddBdd dt|jdEdd dtdF|jdGdtdHddI|jdJddddKd|ddLdgdtdMddN|jdOddddKd|ddLdgdtdPddN|jdQdRdgddSdtdTddU|jd1dVdgddSdtdWddN|jd1dXdgddSdtdYddN|jdZdd dtd[|jd\dd dtd]|jd^dd dtd_|jd1d`ddadgddSdtdbddc|jd1ddddedgddSdtdfddc|jdgdd ddhdtdi|jd1djddkdddtdl|jd1dmddndddtdo|jdpddqdd dtdr|jdsddtdddtdu|jd1dvddwdgddSdtdx|jdydd dtdz|jd{dd dtd||jd}d~dddgddSdtd|jddgddSdtd|jddgddSdtd|jdddgddddSdtddS(NcSs*td|j}|j||fdS(sCallback for the enablerepo and disablerepo option. Combines the values given for these options while preserving order from command line. sparser.values.%sN(tevaltdestRp(toptobjRRRR((s/usr/share/yum-cli/cli.pyt repo_optcbssYum Base Optionstresolves-hs--helptactionRthelpsshow this help message and exitRFs-ts --tolerantt store_truesbe tolerant of errorss-Cs --cacheonlyRRs2run entirely from system cache, don't update caches-cs--configRtdefaults/etc/yum/yum.confsconfig file locationtmetavars [config file]s-Rs --randomwaitRttypeRsmaximum command wait times [minutes]s-ds --debuglevelRsdebugging output levels [debug level]s--showduplicatesRs2show duplicates, in repos, in list/search commandss--show-duplicatess-es --errorlevelRserror output levels [error level]Rs--rpmverbositysdebugging output level for rpms[debug level name]s-qs--quietRsquiet operations-vs --verboseRsverbose operations-ys --assumeyesRsanswer yes for all questionss --assumenoRsanswer no for all questionss--nodepss --versionsshow Yum version and exits --installrootsset install roots[path]s --enablerepotstringRs3enable one or more repositories (wildcards allowed)s[repo]s --disablerepos4disable one or more repositories (wildcards allowed)s-xs --excludeRps"exclude package(s) by name or globs [package]s--disableexcludess7disable exclude from main, for a repo or for everythings--disableincludess0disable includepkgs for a repo or for everythings --obsoletess*enable obsoletes processing during updatess --nopluginssdisable Yum pluginss --nogpgchecksdisable gpg signature checkings--disablepluginRsdisable plugins by names[plugin]s--enablepluginRsenable plugins by names --skip-brokenRs&skip packages with depsolving problemss--colorRscontrol whether color is useds --releaseverRs5set value of $releasever in yum config and repo filess--downloadonlyRsdon't update, just downloads --downloaddirRs2specifies an alternate directory to store packagess--setoptRus%set arbitrary config and repo optionss--bugfixs,Include bugfix relevant packages, in updatess --securitys.Include security relevant packages, in updatess --advisorys --advisoriesR}s=Include packages needed to fix the given advisory, in updatess--bzss7Include packages needed to fix the given BZ, in updatess--cvess8Include packages needed to fix the given CVE, in updatess--sec-severitys --secseverityRsDInclude security relevant packages matching the severity, in updates( RpRRrtconflict_handlert add_optionRRRRR(RRR((s/usr/share/yum-cli/cli.pyRss                            N(RRRRRFRt staticmethodRRRRRRRRs(((s/usr/share/yum-cli/cli.pyRs   |  cCsfg}t|}xMt|dkra|jd}d|kry|jdd\}}||kr^|j|q^q|dkr|j|q||kr|j|q||krt|dkrt|n|jd}|ddkrt|n|j||gqx?|D]7}t|dkr#|j|r#|j|q#q#WqW|S(sKeep only specific options from the command line argument list This function allows us to peek at specific command line options when using the optparse module. This is useful when some options affect what other options should be available. @param novalopts: A sequence of options to keep that don't take an argument. @param valopts: A sequence of options to keep that take a single argument. @param args: The command line arguments to parse (as per sys.argv[:1] @return: A list of strings containing the filtered version of args. Will raise ValueError if there was a problem parsing the command line. iRjis--Ri(tlistRoRRnRpRRR1(t novaloptstvaloptsRtoutRRRtnext((s/usr/share/yum-cli/cli.pyRvt s.         !(,RRRR RRR#toptparseRRRtrpmR9RR!RRt yum.Errorstyum.logginglevelstyum.misct yum.pluginst rpmUtils.archRRRt yum.rpmtransRRR,tyum.i18nRR R t yum.packagesR RRRRR R"RRRv(((s/usr/share/yum-cli/cli.pytsH                 ]