
N_c           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z	 m
 Z
 m Z d d l Z d d l Z d d l Z d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z m Z d d l m Z d d l Z d d l Z d d l  m! Z! m" Z" m# Z# d d	 l$ m% Z% d
   Z& d e j' j( f d     YZ) d e j* e j+ f d     YZ, d e	 f d     YZ- d   Z. d S(   s/   
Command line interface yum class and related.
iN(   t   OptionParsert   OptionGroupt   SUPPRESS_HELP(   t   proxy(   t   isMultiLibArch(   t   _t   P_(   t   RPMTransaction(   t
   to_unicodet   to_utf8t   exception2msg(   t   parsePackagesc         C   s   t  j d IJt  j d  d S(   s   SIGQUIT 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 immediatelyi   N(   t   syst   stderrt   exit(   t   signumt   frame(    (    s   /usr/share/yum-cli/cli.pyt   sigquit:   s    t   CliErrorc           B   s   e  Z d  Z d d  Z RS(   s)   Command line interface related Exception.t    c         C   s    t  j j j |   | |  _ d  S(   N(   t   yumt   Errorst   YumBaseErrort   __init__t   args(   t   selfR   (    (    s   /usr/share/yum-cli/cli.pyR   G   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s   /usr/share/yum-cli/cli.pyR   D   s   t
   YumBaseClic           B   s  e  Z d  Z d   Z d   Z d. d d  Z d   Z d   Z d   Z	 d   Z
 e d	  Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e e d  Z d   Z d d. d  Z d e d  Z d   Z e d d  Z d   Z d   Z d d  Z e d. d  Z d   Z  d    Z! d!   Z" d"   Z# d#   Z$ d$   Z% e d%  Z& d&   Z' d'   Z( e d(  Z) d)   Z* d*   Z+ d+   Z, d,   Z- e d-  Z. RS(/   s#   This is the base class for yum cli.c         C   s  t  j  t  j t  t j j |   t j j |   t j	   t j
 d  |  _ t j
 d  |  _ i  |  _ t |  _ |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j    |  j t j     |  j t j!    |  j t j"    |  j t j#    |  j t j$    |  j t j%    |  j t j&    |  j t j'    |  j t j(    |  j t j)    |  j t j*    |  j t j+    |  j t j,    |  j t j-    |  j t j.    |  j t j/    |  j t j0    d  S(   Ns   yum.clis   yum.verbose.cli(1   t   signalt   SIGQUITR   R   t   YumBaseR   t   outputt	   YumOutputt   loggingt   basicConfigt	   getLoggert   loggert   verbose_loggert   yum_cli_commandst   Truet   use_txmbr_in_callbackt   registerCommandt   yumcommandst   InstallCommandt   UpdateCommandt   InfoCommandt   ListCommandt   EraseCommandt   GroupsCommandt   MakeCacheCommandt   CleanCommandt   ProvidesCommandt   CheckUpdateCommandt   SearchCommandt   UpgradeCommandt   LocalInstallCommandt   ResolveDepCommandt   ShellCommandt   DepListCommandt   RepoListCommandt   HelpCommandt   ReInstallCommandt   DowngradeCommandt   VersionCommandt   HistoryCommandt   CheckRpmdbCommandt   DistroSyncCommandt   LoadTransactionCommandt   SwapCommandt   RepoPkgsCommandt   UpdateinfoCommandt   UpdateMinimalCommandt   FSSnapshotCommandt	   FSCommand(   R   (    (    s   /usr/share/yum-cli/cli.pyR   N   sN    
		c         C   sV   xO | j    D]A } | |  j k rA t j j t d  |   n  | |  j | <q Wd S(   s  Register a :class:`yumcommands.YumCommand` so that it can be called by
        any of the names returned by its
        :func:`yumcommands.YumCommand.getNames` method.
        
        :param command: the :class:`yumcommands.YumCommand` to register
        s   Command "%s" already definedN(   t   getNamesR(   R   R   t   ConfigErrorR   (   R   t   commandt   name(    (    s   /usr/share/yum-cli/cli.pyR+   x   s    i   c         C   s   |  j  r | d k r |  j  S| sD |  j j t j j t d   n  | ri t j j	 |  d | d t
 n t j j	 |  d | | r |  j j t j j t d   |  j d |  n  |  j  S(   s   Grab the repomd.xml for each enabled and set up the basics
        of the repository.

        :param thisrepo: the repository to set up
        :param dosack: whether to get the repo sack
        s   Setting up repositoriest   thisrepot   doSetups/   Reading repository metadata in from local filesN(   t   _repost   NoneR'   t   logR   t   logginglevelst   INFO_2R   R    t	   _getReposR)   t	   _getSacks(   R   RP   t   dosack(    (    s   /usr/share/yum-cli/cli.pyt   doRepoSetup   s    c         C   s   d } t  j j g  |  j j   D]$ } t | d  o: | j s | ^ q  } | j d d    xn | D]f } y. | j   } | d | j	   d | f 7} Wqf t
 t f k
 r | d | j	   d 7} qf Xqf W| S(   sq   
        Format an attractive usage string for yum, listing subcommand
        names and summary usages.
        s*   yum [options] COMMAND

List of Commands:

t   hiddent   keyc         S   s   |  j    d S(   Ni    (   RL   (   t   x(    (    s   /usr/share/yum-cli/cli.pyt   <lambda>   s    s	   %-14s %s
i    s   %s
(   R   t   misct   uniqueR(   t   valuest   hasattrR[   t   sortt
   getSummaryRL   t   AttributeErrort   NotImplementedError(   R   t   usageR]   t   commandsRN   t   summary(    (    s   /usr/share/yum-cli/cli.pyt
   _makeUsage   s    '" c         C   s  i  } t  j j   } g  | _ g  } g  } x9| D]1} | j d  } t |  d k rk | j |  q1 n  t |  d k  r | j |  q1 n  g  | D] } | j   ^ q \ }	 }
 |	 j d  } | d k rB|	 |  } |	 | d }	 | | k rt  j j   | | <g  | | _ n  t	 | | |	 |
  | | j j |	  q1 t	 | |	 |
  | j j |	  q1 W| |  _
 | |  _ | | f S(   s{   parse the setopts list handed to us and saves the results as
           repo_setopts and main_setopts in the yumbase objectt   =i   t   .ii   (   R   R_   t   GenericHoldert   itemst   splitt   lent   appendt   stript   rfindt   setattrt   main_setoptst   repo_setopts(   R   t   setoptst   repooptst   mainoptst   bad_setopt_tmt   bad_setopt_net   itemt   valst   it   kt   vt   periodt   repo(    (    s   /usr/share/yum-cli/cli.pyt   _parseSetOpts   s8    	%
		c         C   s]  t  d |  d |  j    |  _ |  j j |  } | j rV t j GHt | _ t	 | _
 n  |  j | j  \ } } |  j r x3 |  j j D]" } t | | t |  j |   q Wn  |  j j |  } | j r d | _ n  | j
 r d | _ | _ n  yx|  j } | j | _ | | _ | j | _ t j j t j j f | _ |  j | _ | j | _ | j | _ |  j j | j  | _  |  j j | j!  | _" | j# | _# |  j$ x( | D]  } d }	 |  j% j& |	 |  qWx( | D]  } d }	 |  j% j& |	 |  qW|  j rgxe |  j j D]T } t' |  j$ |  sAd }	 |  j% j& |	 |  n  t |  j$ | t |  j |   qWn  Wn t j( j) k
 r}
 |  j% j* t+ d  |
  t, j- d	  n t. k
 r}
 d
 t/ |
 j0 d	  t1 |
 j2  f }
 |  j% j* t+ d  |
  t, j- d	  n9 t3 k
 r?}
 |  j% j* t+ d  |
  t, j- d	  n X|  j j4 |  j    |  j j5 d d | |  j j6 d |  \ } |  _7 | j rt | _ t	 | _
 n  | j rd | _ n  | j
 rd | _ | _ n  | j | j k s| j | j k r|  j% j& t+ d   n  | d k rM| j | j k rM|  j% j& t+ d   n  | j rd	 |  j$ _8 |  j9 } t	 } d   } d   } x t: |  j; j< d |   D]} | rd GHn  t } | j= d k rd | j | j> | j? f } n" d | j= | j | j> | j? f } d |  j@ jA d | jB |  j@ jA d f } t+ d  | | | | jC  f GHt+ d  t/ | jD  | | jE  f GHt+ d  t/ | jF  | | jG  f GHqWt, j- d  n  | jH d  k	 rtJ jK | jH d  } n d } | |  _0 d |  _L x$ |  j0 D] } |  jL d | 7_L q Wy |  jM   Wn tN k
 rKt, j- d	  n XtO jP |  d  S(!   s   Parse 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
        t   baseRg   i    i   s'   Setopt argument has multiple values: %ss    Setopt argument has no value: %ss1   Main config did not have a %s attr. before setopts   Config error: %si   s   %s: %ss   Options error: %sR   sG   Ignored option -q, -v, -d or -e (probably due to merging: -yq != -y -q)t   /s8   Ignored option -c (probably due to merging -yc != -y -c)c         S   s   t  j d t  j |    S(   Ns   %Y-%m-%d %H:%M(   t   timet   strftimet   gmtime(   R]   (    (    s   /usr/share/yum-cli/cli.pyt
   sm_ui_time?  s    c         S   s   t  j d t  j |    S(   Ns   %Y-%m-%d(   R   R   R   (   R]   (    (    s   /usr/share/yum-cli/cli.pyt
   sm_ui_dateA  s    t   patternsR   t   0s   %s-%s.%ss   %s:%s-%s.%ss   %s%s%st   boldt   normals     Installed: %s-%s at %ss     Built    : %s at %ss     Committed: %s at %si<   s   yum s   %s N(Q   t   YumOptionParserRj   t	   optparsert
   firstParset   versionR   t   __version__R)   t   quiett   Falset   verboseR   Rw   Ru   Rn   Rt   t   getattrt   getRoott
   debuglevelt
   errorlevelt   preconft   conffilet   fnt   roott	   nopluginst   init_pluginst   pluginst	   TYPE_COREt   TYPE_INTERACTIVEt   plugin_typest	   _splitArgt   disablepluginst   disabled_pluginst   enablepluginst   enabled_pluginst
   releasevert   confR&   t   warningRb   R   RM   t   criticalR   R   R   t   IOErrorR   R   t   reprt   filenamet
   ValueErrort	   set_usaget   runt   setupYumConfigt   cmdst   cachet   run_with_package_namest   sortedt   rpmdbt   returnPackagest   epocht   releaset   archt   termt   MODERO   t   installtimet   packagert	   buildtimet	   committert
   committimet	   sleeptimeRS   t   randomt	   randranget	   cmdstringt   parseCommandsR   R   t   sleep(   R   R   t   optsRz   R{   t   optR   t   pcR|   t   msgt   et	   yum_progst   doneR   R   t   pkgt   verRO   R   t   arg(    (    s   /usr/share/yum-cli/cli.pyt   getOptionsConfig   s    			#						*&				$				" 			c         C   s  |  j  j d t j  |  j  j t j j d |  j  |  j  j t j j d |  j j	  t
 |  j j  d k r t
 |  j  d k  r |  j j |  _ n |  j |  j _ t
 |  j  d k  r |  j j t d   |  j   t  n  |  j d |  _ |  j d |  _ t
 |  j  d k rd|  j  j t j j d  x0 |  j D]" } |  j  j t j j d |  q;Wn  |  j |  j k r|  j j t d	  |  j t j d  t  n  |  j   |  j |  j j |  |  j |  j  d
 S(   s   Read :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`.
        s   Yum version: %ss   COMMAND: %ss   Installroot: %si    i   s   You need to give some commands   Ext Commands:
s      %ss)   No such command: %s. Please use %s --helpN(   R'   t   debugR   R   RT   RU   t   DEBUG_4R   R   t   installrootRp   Rh   R   R&   R   R   Rg   R   t   basecmdt   extcmdsR(   R   t   argvt   _set_repos_cache_reqt   doCheck(   R   R   (    (    s   /usr/share/yum-cli/cli.pyR   k  s2    -
	#	
c   	      C   s  |  j  |  j } d } t | d  rC | j |  |  j |  j  } n  d } d } x |  j j   D]y } t j	 j
 | j  s d } Pn  t j | j  j } | s | } | } q_ | | k r | } q_ | | k  r_ | } q_ q_ W| r| | d k r d } q| t j   k rd } qn  | s(d } n  t } x5 |  j j   D]$ } | | _ | j   r>t } q>q>W| r| rt j   | d k r| rd S|  j j t d   n  d S(   s<    Set the cacheReq attribute from the commands to the repos. t   writet   cacheRequirementi<   i   i   i   NsJ   Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fasti  iQ i i  iQ i u (   R(   R   Rb   R   R   RS   t   repost   listEnabledt   ost   patht   existst   metadata_cookiet   statt   st_mtimeR   R)   Rc   t   _metadata_cache_reqt   _matchExpireFilterR   R&   R   R   (	   R   R   t   cmdt   cacheReqt   ts_mint   ts_maxR   t   rtst   all_obey(    (    s   /usr/share/yum-cli/cli.pyR     sD    						"c         C   s~   t  |  d  s d  S|  j s  d  S|  j } g  | D] } d j |  ^ q0 } | j d  d j |  } |  j j d |  d  S(   Nt   _shell_history_cmdst    R   s   
s
   shell-cmds(   Rb   R   t   joinRq   t   historyt   write_addon_data(   R   t   dataR   (    (    s   /usr/share/yum-cli/cli.pyt   _shell_history_write  s    		"c         C   s`   t  j d |   } | j |  _ t |  j  d k r@ | j   n
 | j   |  ` | j | j f S(   s   Run a shell-like interface for yum commands.

        :return: a tuple containing the shell result number, and the
           shell result messages
        R   i    (	   t   shellt   YumShellR   Rp   R   t   cmdloopt   scriptt   resultt
   resultmsgs(   R   t   yumshell(    (    s   /usr/share/yum-cli/cli.pyt   doShell  s    
c         C   sA  d } t  j d  } i  } x | j |  D] } | j d  d k r[ t | j d   n t j t | j d   d  } | j d  | k r | | | j d  <n  | | j d  | k  r+ | | | j d  <q+ q+ W| r-| t d  7} x9 | D]. } | t d	 d	 | |  | | | f 7} q Wn  t d
  | } | S(   s   Parse the error string for 'interesting' errors which can
        be grouped, such as disk space issues.

        :param errstring: the error string
        :return: a string containing a summary of the errors
        R   s)   needs (\d+)(K|M)B on the (\S+) filesystemi   t   Mi   g      @i   s   Disk Requirements:
s8     At least %dMB more space needed on the %s filesystem.
s   Error Summary
-------------
(	   t   ret   compilet   finditert   groupt   intt   matht   ceilR   R   (   R   t	   errstringRi   t   pt   diskt   mt
   size_in_mbR   (    (    s   /usr/share/yum-cli/cli.pyt   errorSummary  s    L/c         C   s   d } x t  r y |  j   Wn t j j k
 r } t |  | k rf t |  } |  j j |  n  | j r t j j	 t
 d   n  |  j j s |  j j d  d d l } | j | j |  j  t j d  q t j j	 t
 d   q	 XPq	 Wd S(   s5  Establish the yum lock.  If another process is already
        holding the yum lock, by default this method will keep trying
        to establish the lock until it is successful.  However, if
        :attr:`self.conf.exit_on_lock` is set to True, it will
        raise a :class:`Errors.YumBaseError`.
        R   s   Can't create lock file; exitingsH   Another app is currently holding the yum lock; waiting for it to exit...iNi   sT   Another app is currently holding the yum lock; exiting as configured by exit_on_lock(   R)   t   doLockR   R   t	   LockErrorR
   R&   R   t   errnoR   R   R   t   exit_on_lockt   utilst   show_lock_ownert   pidR   R   (   R   t   lockerrR   R  (    (    s   /usr/share/yum-cli/cli.pyt   waitForLock  s"    		c         C   s   t  } t } |  j |  j } t | d  rI | j |  |  j |  j  } n  | r} t | d  r} | j |  |  j |  j  } n  | s | r y |  j |  Wq t	 j
 j k
 r } d t |  g f SXn  |  j d t  |  j |  j j |  |  j |  j  S(   s2  Call 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
        t   needTst   needTsRemovei   R   (   R)   R   R(   R   Rb   R  R   R  t   _getTsR   R   R   R
   R   t	   doCommand(   R   R  R  R   R   (    (    s   /usr/share/yum-cli/cli.pyt
   doCommands&  s    c   !   
      s    f d   } t  |  j  d k r> |  j j t d   d S|  j   } |  j j t j j	  r~ |  j j
 t j j	 |  n, |  j j s |  j j r |  j j |  n  g  } g  } t   t } xs |  j j   D]b } | j d, k rt } | j } | r4| j |  q4q t   | j } | r | j |  q q W|  j j     s[|  j |  n |  j | |  |  j j } | d- k	 r |  j j   | d k r t d  }	 | d	 r|	 t d
  7}	 |  j j t |	   q |	 t d  7}	 t j j |	   n  |  j    rkd- }
 |  j j s-| |   }
 n  |
 sM|  j j t d   d S|
 d k rkt |  j _! qkn  |  j j! r|  j j
 t j j" t d   n |  j j
 t j j" t d   |  j# | d |  j$ } t  |  d k rVd } | t d  7} xI | D]A } t j% j& | |  } x" | D] } | d | | f 7} q"WqWt j j |  n  |  j' |  d k rod S|  j(   |  j) } d- |  _) |  j* d d  t+ j+   } |  j j
 t j j" t d   |  j,   } t } | rt } x) | D]! }	 |	 j- d  rqn  t } qW| r$t d  GHn t d  GHt } x | D] }	 t. |	  GHq<W| rjd t d  g f S| rzd g  f Sd t d  |  j j/ g f Sn  |  j j0 d t+ j+   |  t+ j+   } |  j j
 t j j" t d   |  j j1   |  j j2   t3 |  d t } |  j j4 |  } ~ t  |  d k rt d  } x" | D] } | d t5 |  7} qIWt j j | d  |  j6 |   n  |  j j
 t j j" t d!   |  j j0 d" t+ j+   |  t7 j7 t7 j8 t7 j9  t+ j+   } t } x* |  j j   D] } | j: rt } PqqW| rf|  j(   |  j* d d  |  j j;   |  j j1   |  j j2   n  | |  _) t3 |  d# t< j= t> |    } |  j j? d	 k  rt | j@ _< n  i d$ g d% 6} x | D] } |  j jA d& |  s|  jB jC d& |  r qn  x | | D]| } y7 tD jE jF |  |  j j
 t j jG t d'  |  WqtH k
 r} |  j j
 t j jG t d(  | | f  qXqWqW|  j j
 t j j" t d)   |  jI d* |  }  |  j j0 d+ t+ j+   |  |  j j
 t j j	 |  jJ    t7 j7 t7 j8 tK  |  jL S(.   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
        c            sx   i d t  d  t  d  t  d  f d 6}   s\ |  j d |  } | d k rX d  } n  | S|  j d t  d  d |  S(   Nu   dt   dt   downloadt   downloadonlyt   extrat   prompts   Is this ok [y/d/N]: (   R   t   userconfirmRS   (   R   t   dl_onlyt   ret(   t   stuff_to_download(    s   /usr/share/yum-cli/cli.pyt   _downloadonly_userconfirmS  s    	i    s9   Trying to run the transaction but nothing to do. Exiting.iR~   t   ui   s6   future rpmdb ver mismatched saved transaction version,i   s    ignoring, as requested.s
    aborting.s   Exiting on user commandR  s.   Background downloading packages, then exiting:s   Downloading packages:t   callback_totalR   s   Error downloading packages:
s	     %s: %s
t   keepolds   Running transaction checks   rpmlib(s'   ERROR You need to update rpm to handle:s)   ERROR with transaction check vs depsolve:s   RPM needs to be updateds   Please report this error in %ss   Transaction check time: %0.3fs   Running transaction testt   tests   Transaction check error:
s     %s
s   
s   Transaction test succeededs   Transaction test time: %0.3ft   displays   libnsssysinit.sos   nss-sysinitRO   s   Preloaded shared library %ss'   Could not preload shared library %s: %ss   Running transactiont   cbs   Transaction time: %0.3f(   R~   R%  N(M   Rp   t   tsInfoR'   t   infoR   t   listTransactiont   isEnabledForR   RU   t   INFO_1RT   R   t   assumenot	   assumeyesR&   t   warnR   R)   t
   getMemberst   ts_statet   poRq   t   tst   closet   reportRemoveSizet   reportDownloadSizet   _check_future_rpmdbvRS   t   futureRpmDBVersionR   R   R   t   _promptWantedR  RV   t   downloadPkgst   download_callback_total_cbR_   R`   t   gpgsigcheckt   initActionTst
   dsCallbackt
   populateTsR   t   _run_rpm_checkt
   startswithR	   t   bugtracker_urlR   t   ordert   cleanR   R(  R   R  R   R   t   SIG_DFLt	   reinstallt   checkR!   t   YumCliRPMCallBackt   weakrefR   R)  t
   matchNaevrR   t   searchNevrat   ctypest   cdllt   LoadLibraryR   t	   Exceptiont   runTransactiont   postTransactionOutputR   t   return_code(!   R   R$  t   lstst   downloadpkgst   rmpkgst   install_onlyt   txmbrR5  t   cfrR   t   uct   problemsR  R\   t   errorst   errort   dscbt   rcd_stt   msgst   depsolvet   rpmlib_onlyt   tt_stt   testcbt   tserrorst   descrt   ts_stt   have_reinstallsR*  t   preloadR   t   libR   t   resultobject(    (   R#  s   /usr/share/yum-cli/cli.pyt   doTransactionK  s$   		

		

 	
						#c            s   x | D] }   j  |  \ } } | d k r4 q q | d k r   j j oV   j j } t j j   r | r t j j	 t
 d   n    j |   f d    q t j j	 |  q Wd S(   sL  Perform 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
        i    i   sT   Refusing to automatically import keys when running unattended.
Use "-y" to override.c            s
     j    S(   N(   R   (   R]   t   yt   z(   R   (    s   /usr/share/yum-cli/cli.pyR^   V  s    (   t   sigCheckPkgR   R1  R0  R   t   stdint   isattyR   R   R   R   t   getKeyForPackage(   R   t   pkgsR5  R   t   errmsgt   ay(    (   R   s   /usr/share/yum-cli/cli.pyR?  =  s    		c         C   s   |  j  d | g d t  } | j | j } t t d   |   } | r |  j t d  d j |   } |  j	 j
 t j j t |   n  d S(   s=    If install argument doesn't match with case, tell the user. R   t   ignore_casec         S   s   |  j  S(   N(   RO   (   R]   (    (    s   /usr/share/yum-cli/cli.pyR^   b  s    s     * Maybe you meant: s   , N(   t   doPackageListsR)   t	   installedt	   availablet   sett   mapt   fmtKeyValFillR   R   R'   RT   R   RU   RV   R   (   R   R   t   matchesR   (    (    s   /usr/share/yum-cli/cli.pyt   _maybeYouMeant^  s    c   	      C   s  | s | d d k r d Sd } | r0 d } n  |  j  d | d | g d t  } | j ss | j rw |  j |  rw d S|  j j d	 } |  j j d
 } | j r |  j j t	 j
 j t d  | | |  d S|  j  d | d | g d t  } | j r,| j r,|  j j t	 j
 j t d  | | |  d St t d   | j   } | sS| r~|  j j t	 j
 j t d  | | |  n  | r|  j t d  d j |   } |  j j t	 j
 j |  n  d S(   sr    If the update/remove argument doesn't match with case, or due
            to not being installed, tell the user. i    t   @Nt   allRz  t	   pkgnarrowR   Rx  R   R   s/   Package(s) %s%s%s available, but not installed.c         S   s   |  j  S(   N(   RO   (   R]   (    (    s   /usr/share/yum-cli/cli.pyR^     s    s   No package %s%s%s available.s     * Maybe you meant: s   , (   Ry  R   Rz  R{  t   returnInstalledPackagesByDepR   R   R'   RT   R   RU   RV   R   R)   R|  R}  R~  R   (	   R   R   t   always_outputt
   rpmdb_onlyR  R  t   hibegt   hiendR   (    (    s   /usr/share/yum-cli/cli.pyt   _checkMaybeYouMeanth  s>    	!		!		c            s    j  j s g  Sg  } t    d     f d    xK | D]C } x' | j D] \ } } |   |  7} qN W|   | j  7} q> W| S(   s  Go 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
        c            s   |  j   k r g  S| d  k r( |  } n   j |  j   g  } xu |  j D]j } xa  j |  D]P } | j   k ry q^ n  |  j d | j  d |  7} |   | d | 7} q^ WqH W| S(   NRO   t   requiringPot   reqpo(   RO   RS   t   addt   requiresR  t   update(   R   R  t   urett   reqt   npkg(   t   _pkg2upsR   R   (    s   /usr/share/yum-cli/cli.pyR    s    	N(   R   t   upgrade_requirements_on_installR|  RS   t	   relatedtoR5  (   R   t   txmbrsR"  RZ  t   rtxmbrt   T(    (   R  R   R   s   /usr/share/yum-cli/cli.pyt   _install_upgraded_requires  s    
	t   installc         C   s  t  |  j  } t } x| D]} | j d  rw t j j |  sU t j j	 |  rw |  j
 |  } |  j |  q n  yt r n| d k r |  j d |  } n| d k r/y | j d d  \ } }	 WnE |  j j t d  | |  |  j j sd t d  g f Sw n X|  j d | d	 |	  } n | d
 k ryO | j d d  \ }
 }	 |
 j d d  \ } } } | j d d  \ } } WnE |  j j t d  | |  |  j j sd t d  g f Sw n X|  j d | d | d | d | d	 |	  } n* | d k st |   |  j d |  } Wn t j j k
 r}} |  j j t j j |  |  j j sd t d  g f Sq t j j k
 r|  j j t j j t d  |  j j d | |  j j d  |  j |  |  j j sd t d  g f Sq Xt } |  j |  q Wt  |  j  | k rXt  |  j  | } d t d d |  | g f S| sqd t d  g f Sd t d  g f S(   ss  Attempt 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-nRO   s
   install-naRl   i   s   Bad %s argument %s.s2   Not tolerating missing names on install, stopping.R   s   install-nevrat   -i   t   :R   R   R   R  t   patterns   No package %s%s%s available.R   R   s   %d package to installs   %d packages to installs   Nothing to doi    (    Rp   R+  R   t   endswithR   R_   t   re_remote_urlR   R   R   t   installLocalR  R  t   rsplitR'   R   R   R   t   skip_missing_names_on_installRo   t   AssertionErrorR   t   GroupInstallErrorRT   RU   RV   t   InstallErrorR   R   R  R)   R   (   R   t   userlistR   t   repoidt   oldcountR   R   R  t   nt   at   nevrt   evt   rR   R   t   change(    (    s   /usr/share/yum-cli/cli.pyt   installPkgs  st    ! 

	i    c   	   
   C   s  t  |  j  } t  |  d k r. |  j   nDxA| D]9} | j d  r t j j |  sn t j j	 |  r |  j
 | d d } |  j |  q5 n  y |  j d | d |  } Wn@ t j j t j j f k
 r |  j |  d t d  g f SX|  j |  | s5 |  j |  |  j j sn|  j d d	 d
 | g d t  } | j rk| j rkd t d  g f Sqnq5 q5 Wt  |  j  | k rt  |  j  | } d t d d |  | g f Sd t d  g f Sd S(   s  Take 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
        i    s   .rpmt
   updateonlyi   R  t	   update_tos1   Not tolerating missing names on update, stopping.R  R  R   Rx  i   s   %d package marked for updates   %d packages marked for updates   No packages marked for updateN(   Rp   R+  R  R  R   R_   R  R   R   R   R  R  R   t   UpdateMissingNameErrorR  R  R   R   t   skip_missing_names_on_updateRy  R   R{  Rz  R   (	   R   R  R   R  R  R|   R  R  R  (    (    s   /usr/share/yum-cli/cli.pyt
   updatePkgs  s2    !!c         C   s  d } | rH | d d k rH | d } | d } | d k rH d } qH n  g  } i  } x0 t  |  j j d |   D] } | | | j <qp Wg  } |  j j r |  j j d d  } n  xC | D]; \ } } | d | k r q n  | j |  j	 d |   q Wx5 | D]- \ } } | d | k r q n  | | d =q Wi  }	 g  }
 | ry |  j
 j d | j    }
 Wqt j j k
 rg  }
 qXn  x0 |
 D]( } | j | k rqn  | |	 | j <qWx| D]} | |	 k rqn  | | } |	 | } | j |  r| d k r
qn  x |  j j | g  D] } |  j |  re| j |  re| j |  j d	 |   q n  | j } t } xc |  j
 j | j  D]L } d
 | k rd | k r| j | j k r| j | j k rt } PqqW| rq n  | j |  j d | j   q Wqn  |  j |  rt } xc |  j j | j g  D]I } | j |  rXt } q:| j |  r:| j |  j d	 |   q:q:W| rqn  | j |  j d | j   q| j |  r| j \ } } } } } | j |  j	 d | d | d | d |   q| j \ } } } } } | j |  j  d | d | d | d |   qW| r}d t! d d t" |   t" |  g f Sd t# d  g f Sd S(   s  Upgrade or downgrade packages to match the latest versions
        available in the enabled repositories.

        :param userlist: list of names or wildcards specifying
           packages to synchronize with the repositories.  If the
           first string in *userlist* is "full", packages will also be
           reinstalled if their checksums do not match the checksums
           in the repositories.  If *userlist* is an empty list or
           only contains "full", every installed package will be
           synchronized
        :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
        t   diffi    t   fullt	   differenti   R   t   newestt   pkgtupR5  t   checksum_typet   checksum_dataR  RO   R   R   t   reli   s2   %d package marked for distribution synchronizations3   %d packages marked for distribution synchronizations3   No packages marked for distribution synchronizationN(   R  R  R  ($   R   R   R   RO   R   t	   obsoletest   upt   getObsoletesTuplest   extendR  t   pkgSackt   returnNewestByNamet   keysR   R   t   PackageSackErrort   verEQt   searchNamest   allowedMultipleInstallst   removet
   yumdb_infoR   t   searchPkgTupleR  R  R  t   pkgIdR)   RI  t   verGTR  t   verLTt	   downgradeR   Rp   R   (   R   R  t   levelt   dupdatest   ipkgsR   R  t
   obsoletingRz  t   apkgsRu  t   ipkgnamet   ipkgt   apkgt   napkgt   nayit   foundR  R  R   R   R  (    (    s   /usr/share/yum-cli/cli.pyt   distroSyncPkgsO  s    

"

	 	 ./)R  c         C   s1  g  } x| D]} | rG |  j  d |  } | r | j |  q q n  t rP nh| d k rq |  j  d |  } nG| d k r y | j d d  \ } } Wn& |  j j t d	  | |  q n X|  j  d | d
 |  } n | d k ryO | j d d  \ }	 } |	 j d d  \ } }
 } |
 j d d  \ } } Wn& |  j j t d	  | |  q n X|  j  d | d | d | d | d
 |  } n* | d  k st |   |  j  d |  } | s|  j	 | d t d t
 n  | j |  q W| rd t d d t |   t |  g f Sd t d  g f Sd S(!   s  Take user commands and populate a transaction wrapper with
        packages to be erased.

        :param userlist: a list of names or wildcards specifying
           packages to erase
        :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
        R5  s   erase-ns   remove-nRO   s   erase-nas	   remove-naRl   i   s   Bad %s argument %s.R   s   erase-nevras   remove-nevraR  i   R  R   R   R   t   eraseR  R  R  R  s   %d package marked for removals   %d packages marked for removali    s   No Packages marked for removalN(   s   erase-ns   remove-n(   s   erase-nas	   remove-na(   s   erase-nevras   remove-nevra(   R  s   remove(   R  R  R   R  R'   R   R   Ro   R  R  R)   R   Rp   (   R   R  t   posR   t   all_rmsR   t   rmsR  R  R  R  R  R   R   (    (    s   /usr/share/yum-cli/cli.pyt	   erasePkgs  sJ     

-)c      
   C   sZ  t  |  j  } t } x | D] } | j d  rh t j j |  sU t j j	 |  rh |  j
 |  q n  y |  j d |  Wn` t j j k
 r |  j j t j j t d  |  j j d | |  j j d  |  j |  q Xt } q Wt  |  j  | k r.t  |  j  | } d t d d |  | g f S| sGd	 t d
  g f Sd t d
  g f S(   s  Attempt to take the user specified list of packages or
        wildcards and downgrade them. If a complete version number if
        specified, attempt to downgrade them to the specified version

        :param userlist: a list of names or wildcards specifying
           packages to downgrade
        :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   .rpmR  s   No package %s%s%s available.R   R   i   s   %d package to downgrades   %d packages to downgradei   s   Nothing to doi    (   Rp   R+  R   R  R   R_   R  R   R   R   t   downgradeLocalR  R   t   DowngradeErrorR'   RT   RU   RV   R   R   R   R  R)   R   (   R   R  R  R   R   R  (    (    s   /usr/share/yum-cli/cli.pyt   downgradePkgs  s,    !	
c         C   s*  t  |  j  } t } x| D]} | j d  rw t j j |  sU t j j	 |  rw |  j
 |  } |  j |  q n  y |  j d |  } Wnt j j k
 r |  j | d t q t j j k
 r^} x | j D] } d } d | j k r| j j } t d  | } n  t d  }	 |  j j t j j |	 |  j j d | |  j j d	 |  q Wq t j j k
 r} t st d
   |  j j t j j |  q Xt } |  j |  q Wt  |  j  | k rt  |  j  | }
 d t d d |
  |
 g f S| sd t d  g f Sd t d  g f S(   s  Attempt to take the user specified list of packages or
        wildcards and reinstall them.

        :param userlist: a list of names or wildcards specifying
           packages to reinstall
        :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   .rpmR  R  R   t	   from_repos
    (from %s)s)   Installed package %s%s%s%s not available.R   R   s"   Shouldn't happen, but just in casei   s   %d package to reinstalls   %d packages to reinstalli   s   Nothing to doi    (   Rp   R+  R   R  R   R_   R  R   R   R   t   reinstallLocalR  RI  R   t   ReinstallRemoveErrorR  t   ReinstallInstallErrort   failed_pkgsR  R  R   R'   RT   RU   RV   R   R   t   ReinstallErrorR  R)   R   (   R   R  R  R   R   R  R   R  t   xmsgR   R  (    (    s   /usr/share/yum-cli/cli.pyt   reinstallPkgs$  sB    !c         C   s   t  |  d k r% d t d  g f St } xc | D][ } | j d  si |  j j t j j d |  q2 n  |  j	 | d | } | r2 t
 } q2 q2 W| r d t d  g f Sd t d  g f S(	   s  Install or update rpms provided on the file system in a
        local directory (i.e. not from a repository).

        :param filelist: a list of names specifying local rpms
        :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
        i    s   No packages provideds   .rpms,   Skipping: %s, filename does not end in .rpm.R  i   s   Package(s) to installs   Nothing to do(   Rp   R   R   R  R'   RT   R   RU   RV   R  R)   (   R   t   filelistR  t
   installingR   R  (    (    s   /usr/share/yum-cli/cli.pyt   localInstall[  s    
c   	      C   sM  d d d d d d d d g } d } t  } t  } t |  d	 k r | rn | d	 d k rn t } | j d	  q | r | d	 d k r t } | j d	  q | d	 | k r | j d	  } q n  |  j d
 | d | d t d |  } |  j j r| j | j 7_ n  | r%| j | _	 | j
 | _ n  | r7g  | _ n  | rIg  | _
 n  | S(   s  Return a :class:`yum.misc.GenericHolder` object containing
        lists of package objects that match the given names or wildcards.

        :param extcmds: a list of names or wildcards specifying
           packages to list
        :param installed_available: whether the available package list
           is present as .hidden_available when doing all, available,
           or installed
        :param repoid: a repoid that all packages should belong to

        :return: a :class:`yum.misc.GenericHolder` instance with the
           following lists defined::

             available = list of packageObjects
             installed = list of packageObjects
             updates = tuples of packageObjects (updating, installed)
             extras = list of packageObjects
             obsoletes = tuples of packageObjects (obsoleting, installed)
             recent = list of packageObjects
        R{  Rz  R  t   extrast   updatest   recentR  s   distro-extrasi    R  R   Rx  R  (   R   Rp   R)   t   popRy  R   t   showdupesfromreposR{  t   reinstall_availablet   hidden_availableRz  t   hidden_installed(	   R   R   t   installed_availableR  t   specialR  t   done_hidden_availablet   done_hidden_installedt   ypl(    (    s   /usr/share/yum-cli/cli.pyt   returnPkgLists~  s4    c            sU  d d d d g }  j  j } t t      t   } t   } t   } t   }     f d   } t    d k r   d d k r   j d  n  j d d g   d	 | d
 t }	 x |	 D] \ }
  }  | k r-| rt |  t    k r Pn  d GHn t   } | t	 d    } n  | j
 |
  | j    j |
 |    q W j |   d	 | d
 t }	 t   } t |  t    k rd GHt    d k rt	 d  } n t	 d  } |  j j d  j j d f GHg  }	 n  x |	 D] \ }
  } t   t |  k r/qn  | rSt   t |  k  rSqn   | k r| rmd GHn  | t	 d    } | j   n   j |
 |    qW| rt |  t    k rd GHt	 d   j j d  j j d f GHn  x6   D]. } | | k r  j j t	 d  |  q q W| sKd t	 d  g f Sd |	 f S(   sE  Search for simple text tags in a package object. This is a
        cli wrapper method for the module search function.

        :param args: list of names or wildcards to search for.
           Normally this method will begin by searching the package
           names and summaries, and will only search urls and
           descriptions if that fails.  However, if the first string
           in *args* is "all", this method will always search
           everything
        :return: a tuple where the first item is an exit code, and
           the second item is a generator if the search is a
           successful, and a list of error messages otherwise

        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
        RO   Ri   t   descriptiont   urlc            sD   g    D] } |  k r | ^ q }  j  |  d j |   GHd  S(   Ns   , (   t
   fmtSectionR   (   t   textR   t	   used_keys(   R   R  R   (    s   /usr/share/yum-cli/cli.pyt   _print_match_section  s    %i   i    R  t   showdupsR  R   s   N/S matched: %ssE     Name and summary matches %sonly%s, use "search all" for everything.sJ     Full name and summary matches %sonly%s, use "search all" for everything.R   R   s   Matched: %ssG     Name and summary matches %smostly%s, use "search all" for everything.s!   Warning: No matches found for: %ss   No matches found(   R   R  R}  R   R|  Rp   R  t   searchGeneratorR)   R   R  R  t   matchcallbackR   R   R&   R   (   R   R   t
   searchlistt   dupst   okeyst   akeyst   mkeysR  R   t   matchingR5  t   matched_valueR   R   (    (   R   R  R   s   /usr/share/yum-cli/cli.pyt   search  sn    				"		#	, c      	   C   s  g  } x | D] } | j  d  rq t j j |  sF t j j |  rq t j j |  |  j	 |  } | j
 |  q |  j j r | j |  j j d | g d t   q y) | j |  j j d | g d t   Wq t j j k
 r q Xq W|  j |  } |  j |  d g  f S(   s  Print out a formatted list of dependencies for a list of
        packages.  This is a cli wrapper method for
        :class:`yum.YumBase.findDeps`.

        :param args: a list of names or wildcards specifying packages
           that should have their dependenices printed
        :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   .rpmR   Rx  i    (   R  R   R_   R  R   R   R   t   packagest   YumUrlPackageR6  Rq   R   R  R  R  R   R)   R  R   R  t   findDepst   depListOutput(   R   R   Ru  R   t   thispkgt   results(    (    s   /usr/share/yum-cli/cli.pyt   deplist  s"    !c   	      C   sE  |  j  j } t |  j  _ |  j } |  j | d | d t } t |  d k rt t j t	 j
 d j d   } g  } xx | D]p } | s q~ n  t j j |  s~ t j j |  r q~ n  x1 | D]) } | s q n  | j d | | f  q Wq~ W|  j | d | d t } n  | |  j  _ t |  d k r;d d g f Sd g  f S(   s  Print 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
        t   callbackt   callback_has_matchfori    t   PATHR  s   %s/%ss   No matches found(   R   R  R)   t   matchcallback_verboset   searchPackageProvidesRp   R|  R   R   R   t   environRo   R   R_   t   re_filenamet   re_globRq   (	   R   R   t   old_sdupR*  R	  t   pathst   nargsR   R   (    (    s   /usr/share/yum-cli/cli.pyt   providesA  s.    		#$c         C   sL  t    } x| D] } y |  j |  } Wn t j j k
 rH d } n4 X|  j j d |  |  j j d | j | j	 f  y |  j
 |  } Wn- t j j k
 r | s| j |  qq X| s |  j j d |  n  | j |  s |  j j d | j | j	 f  q q W| rB|  j j t d  d j t |    n  d g  f S(   s  Print information about a package that provides the given
        dependency.  Only one package will be printed per dependency.

        :param args: a list of strings specifying dependencies 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
        s     %s:s   %s %ss"   Error: No packages found for:
  %ss   
  i    N(   R|  t   returnInstalledPackageByDepR   R   R   RS   R'   R,  t   envrat   ui_from_repot   returnPackageByDepR  R  R&   R   R   R   R   (   R   R   t	   not_foundR   R  R   (    (    s   /usr/share/yum-cli/cli.pyt   resolveDepClil  s.    	
c   "      C   sY  d } } } } } g  } } }	 }
 } |  j  t d  d j g  |  j j   D] } | j ^ qQ   } |  j j t j	 j
 |  t d  |  j j } |  j j t j	 j |  d | k rb|  j   \ } } |  j   \ } } |  j   \ } }	 |  j   \ } }
 |  j   \ } } |  j j d  | | | | | } | | |	 |
 | } x | D] } |  j j |  q]W|  j d d g  } t j | d	  } g  g  g  g  f } |  j j } t } x | D] } t j j |  } t j j |  r(| | k r	d
 } q.| | j rd } q.d } n d } t j j  |  } | sLqn  | | j! | | f  | d k  r| d/ k rt" } qqWt d  | g } d0 } d d d d g } x t# |  D] \ } } g  } d }  xW t$ | | d d   d t D]6 \ } } | j! d |  j% |  | f  |  | 7}  qW| r>d n d }! | d |  j% |   t |  |! f g 7} | | 7} |  | | <qW| t d  |  j% t& |   g 7} d j |  } |  j j t j	 j |  | s|  j j' d k r| g  f S|  j% t& | d    }  |  d d k r/|  d  d }  n  t d   |  } |  j j t j	 j
 |  | g  f Sd! | k r|  j j t d"   |  j   \ } } n  d# | k r|  j j t d$   |  j   \ } } n  d% | k r|  j j t d&   |  j   \ } }	 n  d' | k sd% | k rJ|  j j t d(   |  j   \ } }
 n  d) | k sbd% | k r|  j j t d*   |  j(   \ } } n  d+ | k r|  j j t d,   |  j   \ } } n  d- | k r|  j j t d.   |  j j d  n  | | | | | } | | |	 |
 | } x' | D] } |  j j t j	 j
 |  q,W| g  f S(1   s  Remove data from the yum cache directory.  What data is
        removed depends on the options supplied by the user.

        :param userlist: a list of options.  The following are valid
           options::

             expire-cache = Eliminate the local data saying when the
               metadata and mirror lists were downloaded for each
               repository.
             packages = Eliminate any cached packages
             headers = Eliminate the header files, which old versions
               of yum used for dependency resolution
             metadata = Eliminate all of the files which yum uses to
               determine the remote availability of packages
             dbcache = Eliminate the sqlite cache used for faster
               access to metadata
             rpmdb = Eliminate any cached datat from the local rpmdb
             plugins = Tell any enabled plugins to eliminate their
               cached data
             all = do all of the above
        :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
        i    s   Cleaning repos: R   s9   Operating on %s (see CLEAN OPTIONS in yum(8) for details)R  RG  t   basearchR   s   /*i   i   i   i@   i   s"   Disk usage under %s after cleanup:s   enabled reposs   disabled reposs   untracked reposs
   other dataR\   c         S   s   |  d S(   Ni    (    (   R]   (    (    s   /usr/share/yum-cli/cli.pyR^     s    t   reverses
     %-5s  %sR  R   s
   %-5s  %s%ss   %-5s  totals   
i   it   bytess@   Other repos take up %s of disk space (use --verbose for details)t   headerss   Cleaning up headersR  s   Cleaning up packagest   metadatas   Cleaning up xml metadatat   dbcaches   Cleaning up database caches   expire-caches!   Cleaning up expire-cache metadataR   s   Cleaning up cached rpmdb dataR   s   Cleaning up pluginsi   (   s   enabled reposs   disabled reposs   untracked reposs
   other data()   R~  R   R   R   R   t   idR'   RT   R   RU   RV   R   t   cachedirt   DEBUG_3t   cleanPackagest   cleanHeaderst   cleanMetadatat   cleanSqlitet
   cleanRpmDBR   R   R&   R   t   getCachedirGlobt   globR)   R   R   t   basenamet   isdirt   enabledR_   t
   disk_usageRq   R   t	   enumerateR   t   format_numbert   sumR   t   cleanExpireCache("   R   R  t   hdrcodet   pkgcodet   xmlcodet   dbcodet   expccodet
   pkgresultst
   hdrresultst
   xmlresultst	   dbresultst   expcresultsR]   R   t   rpmcodet
   rpmresultst   codeR  t	   cacheglobR  t   tableR   t   emptyR   R   t   colRg   t   linesR(  t   totalst   headert   rowst   totalt   colon(    (    s   /usr/share/yum-cli/cli.pyt   cleanCli  s    1				 	#
&
	
c         C   s   |  j  |  S(   s  Print out a list of groups that match the given names or
        wildcards.

        :param extcmds: a list of names or wildcards specifying
           groups to list
        :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        
        (   t   _returnGroupLists(   R   R  (    (    s   /usr/share/yum-cli/cli.pyt   returnGroupLists/  s    c      
      s?  i d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d	 6d
 d 6d
 d 6d
 d
 6d
 d 6d d 6d d 6d d 6d d 6d d 6d d 6}  j  j t j j  } i t d 6d  d 6d  d 6d  d
 6d  d 6d  d 6| d 6 | } xg | rJ| d } t } | j d  r| d } t } n  | | k r,Pn  |  | | <| j	 d  q W| sZd  } n   d d  k r d d  k rt  d <t  d <n   d d  k r d
 d  k r d d  k rt  d <t  d
 <n   d }  j
 d | d | d t  }	 |	 \ }
 } } }  d s,g  } g  } n   d sEg  }
 g  } n   d s^g  } g  } n  g         f d   } | t d  |  | t d  |  g  } x: |
 D]2 } | j rqn   d
 sqn  | j |  qW| t d  |  g  } x: |
 D]2 } | j sqn   d s*qn  | j |  qW| t d  |  g  } x: | D]2 } | j rpq[n   d
 sq[n  | j |  q[W| t d  |  g  } x: | D]2 } | j sqn   d sqn  | j |  qW| t d   |    s, j j t d!  d" j |   d g  f Sd t d#  g f S($   NR[   t   langt   languaget	   languagest   langst   envt   environmentt   environmentst   envsR   t   packageR  Ru  t   availR{  t   instRz  R+  t   idsi    t   noi   R   t   uservisiblet   return_evgrpsc            s   | s
 d  S  j  |    rF  j j t j j d |  t |   d  S j j t j j |   xi | D]a } d | j }  d r | d | j 7} n  | j	 r | d | j	 7} n   j j
 d |  qf Wd  S(   Ns   %s %us      %sR+  s    (%s)s    [%s]s   %s(   Rq   R'   RT   R   RU   RV   Rp   t   ui_namet   compsidt   langonlyR,  (   t   sectt   groupsR  R   (   R   R   Ri   t   wts(    s   /usr/share/yum-cli/cli.pyt   _out_grp  s    
	s   Installed Environment Groups:s   Available Environment Groups:s   Installed Groups:s   Installed Language Groups:s   Available Groups:s   Available Language Groups:s)   Warning: no environments/groups match: %ss   , t   Done(   R'   R.  R   RU   R-  R   RS   R)   RD  R  t   doGroupListsR   Rh  Rq   R&   R_  R   (   R   R  Ri   t   wts_mapt   verbt	   ouserlistR   t   valt   uvt   dGLRz  R{  t   ievgrpst   evgrpsRl  Rj  R  (    (   R   R   Ri   Rk  s   /usr/share/yum-cli/cli.pyRU  ?  s    



	

		 
0

	
	
		 
 	 
 	 
 	 
 
c         C   s   |  j  | d t S(   s  Print a summary of the groups that match the given names or
        wildcards.

        :param userlist: a list of names or wildcards specifying the
           groups to summarise. If *userlist* is an empty list, all
           installed and available packages will be summarised
        :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
        Ri   (   RU  R)   (   R   R  (    (    s   /usr/share/yum-cli/cli.pyt   returnGroupSummary  s    c         C   s  x | D] } t  } t } t } | j d  rA | d } t  } n" | j d  rc | d } t  } n  | r x0 |  j j |  D] } |  j |  t } q| Wn  | r x0 |  j j |  D] } |  j |  t } q Wn  | s |  j j	 t
 d  |  q q Wd g  f S(   s  Print complete information about the groups that match the
        given names or wildcards.

        :param userlist: a list of names or wildcards specifying the
           groups to print information about
        :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   @^i   R  i   s-   Warning: group/environment %s does not exist.i    (   R   R)   RD  t   compst   return_environmentst   displayGrpsInEnvironmentst   return_groupst   displayPkgsInGroupsR&   R_  R   (   R   R  t   strngt   group_matchedt   pkg_grpt   grp_grpt   evgroupR  (    (    s   /usr/share/yum-cli/cli.pyt   returnGroupInfo  s*    
	
	 c         C   s  g  } | r |  j  j d k r x. |  j j D]  } | j |  j d |   q, Wx1 |  j j D]  } | j |  j d |   q] Wn  t } x| D]} t } t }	 | j	 d  r t }	 | d } n" | j	 d  r t } | d } n  t }
 g  } | r|  j
 j |  } n  xs | D]k } t }
 y |  j | j d | } Wn3 t j j k
 rr|  j j t d  |  qqX| j |  qWg  } |	 r|  j
 j |  } n  xs | D]k } t }
 y |  j | j d | } Wn3 t j j k
 r	|  j j t d  |  qqX| j |  qW|
 s@|  j j t d	  |  q n  t } q W| s|  j  j d k r{|  j j t d
   n  d } | rd } n  | rd } n  | t d  g f Sd t d d t |   t |  g f Sd S(   s|  Mark the packages in the given groups for installation.

        :param grouplist: a list of names or wildcards specifying
           groups to be installed
        :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
        t   objectss   @^R  i   i   t   upgrades-   Warning: Environment group %s does not exist.s)   Warning: Package group %s does not exist.s!   Warning: group %s does not exist.s0   Maybe run: yum groups mark install (see man yum)i    sA   No packages in any requested group available to install or updates   %d package to Installs   %d packages to InstallN(   R   t   group_commandt   igroupsR]  R  t   _at_groupupgradeRj  R   R)   RD  Rx  Ry  t   selectEnvironmentt   environmentidR   R   t   GroupsErrorR&   R   R   R{  t   selectGroupt   groupidR_  R   Rp   (   R   t	   grouplistR  t	   pkgs_usedt   ievgrpt   igrpR   t   group_stringR  R  R~  Rj  R  R  t   exit_status(    (    s   /usr/share/yum-cli/cli.pyt   installGroups  sl    !
		c   	      C   s   g  } x| D]~} t  } t  } | j d  rA t } | d } n" | j d  rc t } | d } n  g  } | r |  j j |  } | s |  j j t d  |  q n  xN | D]F } y |  j | j	  } Wn t
 j j k
 r q q X| j |  q Wg  } | r:|  j j |  } | s:|  j j t d  |  q:n  xN | D]F } y |  j | j  } Wn t
 j j k
 ryqAqAX| j |  qAWq W| s|  j j d k r|  j j t d   n  d	 t d
  g f Sd t d d t |   t |  g f Sd S(   su  Mark the packages in the given groups for removal.

        :param grouplist: a list of names or wildcards specifying
           groups to be removed
        :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   @^i   R  i   s   No environment named %s existss   No group named %s existsR  s/   Maybe run: yum groups mark remove (see man yum)i    s!   No packages to remove from groupss   %d package to removes   %d packages to removeN(   R)   RD  R   Rx  Ry  R&   R   R   t   environmentRemoveR  R   R   R  R  R{  t   groupRemoveR  R   R  R   Rp   (	   R   R  R  R  R  R  Rj  R  R  (    (    s   /usr/share/yum-cli/cli.pyt   removeGroupsM  sJ    c         C   sv   |  j  j s |  j  j r) |  j  j r) t S|  j  j r9 t Sx6 |  j j   D]% } | j	 sj | j
 |  j k rI t SqI Wt S(   N(   R   R1  R  R0  R   t   alwayspromptR)   R+  R3  t   isDepRO   R   (   R   RZ  (    (    s   /usr/share/yum-cli/cli.pyR<    s    %	c         C   s   t  j j |  j j    d S(   s/   Print out an explanation of command line usage.N(   R   t   stdoutR   R   t   format_help(   R   (    (    s   /usr/share/yum-cli/cli.pyRg     s    c         C   s   t  j j |  j j    d S(   s,   Print out an explanation of the shell usage.N(   R   R  R   R   t	   get_usage(   R   (    (    s   /usr/share/yum-cli/cli.pyt
   shellUsage  s    c         C   s  |  j  j } |  j j d |  rG |  j j t j j t	 d  |  t
 S|  j j d | j  } g  } xj | D]b } t | j  t | j  k r | j |  ql |  j j t j j t	 d  | j | j  ql ql Wt |  d k rtx | D] } | j |  r/| j | k r(| j | j k r,t Sqmt Sq | j |  rBt
 S| j |  r | rm|  j |  rmt Sq q Wn) |  j j t j j t	 d  | j  t St
 S(   s:   check if the package is reasonably installable, true/falseR5  s)   Package %s is already installed, skippingRO   s#   Discarding non-comparable pkg %s.%si    s;   No other %s installed, adding to list for potential install(   R   t   exactarchlistR   t   containsR'   RT   R   RU   R-  R   R   RN  RO   R   R   Rq   Rp   R  R)   R  R  R  t   DEBUG_1(   R   R   t   ematchR  t   installedByKeyt
   comparablet   instpo(    (    s   /usr/share/yum-cli/cli.pyt   _installable  s8    %N(/   R   R   R   R   R+   RS   RZ   Rj   R   R   R   R)   R   R   R   R  R  R  Rn  R?  R  R   R  R  R  R  R  R  R  R  R  R  R  R  R  R$  RT  RV  RU  Rw  R  R  R  R<  Rg   R  R  (    (    (    s   /usr/share/yum-cli/cli.pyR   K   sT   	*			&		&9					%		!	
+	'W>	p9	,	7#3	l	$	+	+				(T	<			R   c           B   sh   e  Z d  Z d   Z d   Z d   Z e d    Z d
 d  Z	 d   Z
 d   Z d   Z d	   Z RS(   s\   Subclass that makes some minor tweaks to make OptionParser do things the
    "yum way".
    c         K   s   d | k r# | d |  _  | d =n	 t |  _  t j |  |  t j d  |  _ | |  _ t |  t	 d   |  _
 |  j |  j
  |  j   d  S(   NR  s   yum.clis   Plugin Options(   t   _utilsR   R    R   R#   R%   R&   R   R   R   t   plugin_option_groupt   add_option_groupt   _addYumBasicOptions(   R   R   t   kwargs(    (    s   /usr/share/yum-cli/cli.pyR     s    
		c         C   s4   |  j    |  j j t d  |  t j d  d S(   s   Output an error message, and exit the program.  This method
        is overridden so that error output goes to the logger.

        :param msg: the error message to output
        s   Command line error: %si   N(   t   print_usageR&   R   R   R   R   (   R   R   (    (    s   /usr/share/yum-cli/cli.pyR_    s    
c         C   sw   y t  d d |  } WnJ t k
 rb } |  j j   t j t d  d | f IJt j d  n X|  j d |  d S(   s   Parse only command line options that affect basic yum
        setup.

        :param args: a list of command line options to parse
        :return: a dictionary containing the values of command line
           options
        s   --nopluginss	   --versions   -qs   -vs   --quiets	   --verboses   -cs   --configs   -ds   --debuglevels   -es   --errorlevels   --installroots   --disableplugins   --enableplugins   --releasevers   --setopts$   

%s: %s option requires an arguments   Command line errori   R   i    (   s   --nopluginss	   --versions   -qs   -vs   --quiets	   --verbose(   s   -cs   --configs   -ds   --debuglevels   -es   --errorlevels   --installroots   --disableplugins   --enableplugins   --releasevers   --setopt(	   t   _filtercmdlineR   R   Rg   R   R   R   R   t
   parse_args(   R   R   R   (    (    s   /usr/share/yum-cli/cli.pyR     s        c         C   s:   g  } x- |  D]% } | j  | j d d  j    q W| S(   sR    Split all strings in seq, at "," and whitespace.
            Returns a new list. t   ,R   (   R  t   replaceRo   (   t   seqR"  R   (    (    s   /usr/share/yum-cli/cli.pyR   	  s    #c         C   s  | s |  j    \ } } n |  j  d |  \ } } |  j j j | |  y| j sd |  j j j rv t |  j j _ n  | j r d |  j j _ n  | j	 r d |  j j _	 n  | j
 |  j j _ | j |  j j _ | j |  j j d <| j |  j j d <|  j | j  |  j j d <|  j | j  |  j j d <|  j | j  |  j j d <|  j | j  |  j j d <|  j j j rt j   d	 k rd |  j j _ n! |  j j   sd |  j j _ n  | j rd |  j j _ n  | j rd |  j j _ n  | j r|  j |  | j |  j j _ n  | j r7t |  j j _  n  | j! rRt |  j j _! n  | j" d k rst$ t% d   n | j" d k r|  j j j" d
 k rN|  j j& j' d |  j j j"  qNn i
 d
 d 6d
 d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6} | j( | j" | j"  | _" | j" d
 k rN|  j j& j' d | j"  n  |  j | j)  |  j j _* |  j | j+  |  j j _, |  j | j-  |  j _. x |  j j. D]{ } y/ |  j j j- } | j/ |  | |  j j _- Wqt0 j1 j2 k
 r#} |  j3 j4 |  |  j j5   t6 j7 d  qXqW| j8 d k	 rL| j8 |  j j _8 n  |  j j9   |  j j:   x | j; D] \ } }	 yH | d k r|  j j; j< |	  n" | d k r|  j j; j= |	  n  Wqpt0 j1 j2 k
 r	} |  j3 j4 |  |  j j5   t6 j7 d  qpXqpW| j> rLt |  j _? x& |  j j; j@   D] }
 t |
 _? q6Wn  WnF t$ k
 r} |  j3 j4 t% d  |  |  j j5   t6 j7 d  n X| | f S(   s  Parse command line options.

        :param args: the command line arguments entered by the user
        :return: (opts, cmds)  opts is a dictionary containing
           the values of command line options.  cmds is a list of the
           command line arguments that were not parsed as options.
           For example, if args is ["install", "foo", "--verbose"],
           cmds will be ["install", "foo"].
        R   i   t   securityt   bugfixt   advst   bzst   cvest   sevsi    t   autot   alwayst   nevert   ttys   if-ttyt   yesRc  t   ont   offs)   --color takes one of: auto, always, nevert   colort   1t   trueR   t   falses   --enablerepos   --disablerepos   Options error: %sN(
   NR  s   alwaysR  R  s   if-ttys   yess   noR  R  (A   R  R   R   t
   setCmdLinet   tolerantR   R)   t   recheck_installed_requiresR1  R0  t   dlonlyR  t   dldirt   downloaddirR  t   updateinfo_filtersR  R   R  R  R  R  t	   usercacheR   t   geteuidR   t   setCacheDirt	   cacheonlyR  R   t   _checkAbsInstallRoott
   skipbrokent   skip_brokenR  R  RS   R   R   R   t   reinitt   gett   disableexcludest   disable_excludest   disableincludest   disable_includest   excludet   cmdline_excludesRq   R   R   RM   R&   R   Rg   R   R   t   rpmverbosityt   setupProgressCallbackst   setupKeyImportCallbacksR   t
   enableRepot   disableRepot
   nogpgcheckt   _override_sigchecksR   (   R   R   R   R   t   _remapR  t   excludelistR   R   t   repoexpR   (    (    s   /usr/share/yum-cli/cli.pyR   	  s    
		"						%	c         C   sQ   | j  s d  S| j  d d k r$ d  S|  j j t d  | j   t j d  d  S(   Ni    R   s*   --installroot must be an absolute path: %si   (   R   R&   R   R   R   R   (   R   R   (    (    s   /usr/share/yum-cli/cli.pyR  	  s    	
c         C   s   |  j  |  | j r | j j d  r t j | j d | j t j  re | j d | j | _ nA | j d k r t j | j d t j  r | j d | _ q n  | j } n d } | S(   s(  Return the root location to use for the yum operation.
        This location can be changed by using the --installroot
        option.

        :param opts: a dictionary containing the values of the command
           line options
        :return: a string representing the root location
        R   s   /etc/yum/yum.confs   /etc/yum.conf(   R  R   t   lstripR   t   accessR   t   R_OK(   R   R   R   (    (    s   /usr/share/yum-cli/cli.pyR   	  s    	#c         O   s   |  j  j   |  j   d  S(   N(   R   Rg   R   (   R   R   t   valuet   parserR   R  (    (    s   /usr/share/yum-cli/cli.pyt   _wrapOptParseUsage	  s    c         C   s  d   } |  j  r1 t |  d  } |  j |  n |  } d | _ | j d d d d d |  j d t d	  d
 | _ | j d d d d d t d  | j d d d d d d d t d  | j d d d d d d d t d  d d | j d d d d d d  d d  d t d!  d d" | j d# d$ d d% d d  d t d&  d d  d d' | j d( d d) d d d t d*  | j d+ d d) d d d t | j d, d- d d. d d  d t d/  d d  d d0 | j d1 d2 d d  d t d3  d d4 | j d5 d6 d d7 d d d t d8  | j d9 d: d d; d d d t d<  | j d= d> d d? d d d t d@  | j dA d dB d d d t dC  | j dD d dB d d d t | j dE d d d t dF  | j dG d t dH  d dI | j dJ d d d dK d | d dL d g  d t dM  d dN | j dO d d d dK d | d dL d g  d t dP  d dN | j dQ dR d g  d dS d t dT  d dU | j d1 dV d g  d dS d t dW  d dN | j d1 dX d g  d dS d t dY  d dN | j dZ d d d t d[  | j d\ d d d t d]  | j d^ d d d t d_  | j d1 d` d da d g  d dS d t db  d dc | j d1 dd d de d g  d dS d t df  d dc | j dg d d d dh d t di  | j d1 dj d dk d d  d t dl  | j d1 dm d dn d d  d t do  | j dp d dq d d d t dr  | j ds d dt d d  d t du  | j d1 dv d dw d g  d dS d t dx  | j dy d d d t dz  | j d{ d d d t d|  | j d} d~ d d d g  d dS d t d  | j d d g  d dS d t d  | j d d g  d dS d t d  | j d d d g  d d d dS d t d  d  S(   Nc         S   s*   t  d |  j  } | j | | f  d S(   s   Callback for the enablerepo and disablerepo option. 
            
            Combines the values given for these options while preserving order
            from command line.
            s   parser.values.%sN(   t   evalt   destRq   (   t   optobjR   R  R  R  (    (    s   /usr/share/yum-cli/cli.pyt
   repo_optcb	  s    s   Yum Base Optionst   resolves   -hs   --helpt   actionR  t   helps   show this help message and exitR_  s   -ts
   --tolerantt
   store_trues   be tolerant of errorss   -Cs   --cacheonlyR  R  s2   run entirely from system cache, don't update caches   -cs   --configR   t   defaults   /etc/yum/yum.confs   config file locationt   metavars   [config file]s   -Rs   --randomwaitR   t   typeR  s   maximum command wait times	   [minutes]s   -ds   --debuglevelR   s   debugging output levels   [debug level]s   --showduplicatesR  s2   show duplicates, in repos, in list/search commandss   --show-duplicatess   -es   --errorlevelR   s   error output levels   [error level]R   s   --rpmverbositys   debugging output level for rpms   [debug level name]s   -qs   --quietR   s   quiet operations   -vs	   --verboseR   s   verbose operations   -ys   --assumeyesR1  s   answer yes for all questionss
   --assumenoR0  s   answer no for all questionss   --nodepss	   --versions   show Yum version and exits   --installroots   set install roots   [path]s   --enablerepot   stringR   s3   enable one or more repositories (wildcards allowed)s   [repo]s   --disablerepos4   disable one or more repositories (wildcards allowed)s   -xs	   --excludeRq   s"   exclude package(s) by name or globs	   [package]s   --disableexcludess7   disable exclude from main, for a repo or for everythings   --disableincludess0   disable includepkgs for a repo or for everythings   --obsoletess*   enable obsoletes processing during updatess   --nopluginss   disable Yum pluginss   --nogpgchecks   disable gpg signature checkings   --disablepluginR   s   disable plugins by names   [plugin]s   --enablepluginR   s   enable plugins by names   --skip-brokenR  s&   skip packages with depsolving problemss   --colorR  s   control whether color is useds   --releaseverR   s5   set value of $releasever in yum config and repo filess   --downloadonlyR  s   don't update, just downloads   --downloaddirR  s2   specifies an alternate directory to store packagess   --setoptRw   s%   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   --bzss7   Include packages needed to fix the given BZ, in updatess   --cvess8   Include packages needed to fix the given CVE, in updatess   --sec-severitys   --secseverityR  sD   Include security relevant packages matching the severity, in updates(	   R  R   R  t   conflict_handlert
   add_optionR  R   RS   R   (   R   R  R  (    (    s   /usr/share/yum-cli/cli.pyR  	  s    						N(   R   R   R   R   R_  R   t   staticmethodR   RS   R   R  R   R  R  (    (    (    s   /usr/share/yum-cli/cli.pyR     s   		
			
		c         C   sf  g  } t  |  } xMt |  d k ra| j d  } d | k ry | j d d  \ } } | | k r^| j |  q^q | d k r | j |  q | |  k r | j |  q | | k rt |  d k  r t |  n  | j d  } | d d k rt |  n  | j | | g  q x? | D]7 } t |  d k r#| j |  r#| j |  q#q#Wq W| S(   s  Keep 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.
    i    Rk   i   s   --R  i   (   t   listRp   R  Ro   Rq   R   R  RD  (   t	   novaloptst   valoptsR   t   outR  R   R   t   next(    (    s   /usr/share/yum-cli/cli.pyR  7
  s.    !(/   R   R   R   R   R   R   R#   R  t   optparseR    R   R   t   rpmRO  R4  RL  R   R!   R   R   t
   yum.Errorst   yum.logginglevelst   yum.misct   yum.pluginst   rpmUtils.archR   R   R   t   yum.rpmtransR   R   R,   t   yum.i18nR   R	   R
   t   yum.packagesR   R   R   R   R   R    R"   R   R   R  (    (    (    s   /usr/share/yum-cli/cli.pyt   <module>   sP   	
         `