
N_c           @   sr  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 m	 Z	 m
 Z
 d d l Z d d l m Z m Z d d l m Z d d l Z d d l m Z d d l m Z d d l Td d l Z d d l Z d d l Z e j d	 e j  d d
 l m Z d d l m Z m Z y e  d d  d k s;t!  Wn d   Z" d   Z  n Xi e j# d 6e j$ e j# Bd 6e j% d 6e j% e j$ Bd 6e j$ d 6d e& 6Z' i  Z( x e' D] Z) e) e( e' e) <qWd f  d     YZ* d f  d     YZ+ d f  d     YZ, d f  d     YZ- d e. f d     YZ/ d  e. f d!     YZ0 d" e. f d#     YZ1 d$ e. f d%     YZ2 d S(&   s'   
Dependency resolution module for yum.
iN(   t   archDifferencet   canCoinstall(   t   uniquet   version_tuple_to_string(   t   TransactionMember(   t   ListPackageSack(   t
   PackageEVR(   t   *t   ignore(   t   proxy(   t   _t   _rpm_ver_atleasti   i   c         G   s*   x# | D] } |  | k r | }  q q W|  S(   N(    (   t   xt   argst   y(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   min1   s     c         G   s*   x# | D] } |  | k  r | }  q q W|  S(   N(    (   R   R   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   max5   s     t   GTt   GEt   LTt   LEt   EQi    t   _wrap_ayum_getPkgSackc           B   s    e  Z d  Z d   Z d   Z RS(   s    This is a wrapper for calling YumBase.pkgSack because
        otherwise we take a real reference through the bound method and
        that is d00m (this applies to YumBase and TransactionInfo, hence why
        we have a separate class). c         C   s   t  |  |  _ d  S(   N(   t   weakreft   ayum(   t   selfR   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   __init__I   s    c         C   s
   |  j  j S(   N(   R   t   pkgSack(   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   __call__K   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   D   s   	t   _wrap_ayum_installc           B   s    e  Z d  Z d   Z d   Z RS(   s    This is a wrapper for calling YumBase.install because
        otherwise we take a real reference through the bound method and
        that is d00m (this applies to YumBase and TransactionInfo, hence why
        we have a separate class). c         C   s   t  |  |  _ d  S(   N(   R   R   (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   S   s    c         O   s   |  j  j | |   S(   N(   R   t   install(   R   R   t   kwargs(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   U   s    (   R   R   R   R   R   (    (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR    N   s   	t   _wrap_ayum_removec           B   s    e  Z d  Z d   Z d   Z RS(   s    This is a wrapper for calling YumBase.remove because
        otherwise we take a real reference through the bound method and
        that is d00m (this applies to YumBase and TransactionInfo, hence why
        we have a separate class). c         C   s   t  |  |  _ d  S(   N(   R   R   (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   \   s    c         O   s   |  j  j | |   S(   N(   R   t   remove(   R   R   R"   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   ^   s    (   R   R   R   R   R   (    (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR#   W   s   	t   _wrap_ayum_updatec           B   s    e  Z d  Z d   Z d   Z RS(   s    This is a wrapper for calling YumBase.update because
        otherwise we take a real reference through the bound method and
        that is d00m (this applies to YumBase and TransactionInfo, hence why
        we have a separate class). c         C   s   t  |  |  _ d  S(   N(   R   R   (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   e   s    c         O   s   |  j  j | |   S(   N(   R   t   update(   R   R   R"   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   g   s    (   R   R   R   R   R   (    (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR%   `   s   	t   Depsolvec           B   sg  e  Z d  Z d   Z d   Z e d  Z e d  Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d d 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 d   Z d   Z e e d  Z d   Z e d    Z  d   Z! d   Z" d    Z# d!   Z$ d"   Z% d#   Z& e& Z' d% d$  Z) RS(&   s#   A class for resolving dependencies.c         C   sy   d  |  _ d  |  _ d  |  _ t |  _ t j d  |  _ t j d  |  _	 g  |  _
 g  |  _ d  |  _ d  |  _ t |  _ d  S(   Ns   yum.Depsolves   yum.verbose.Depsolve(   t   Nonet   _tst   _tsInfot
   dsCallbackt   Falset   use_txmbr_in_callbackt   loggingt	   getLoggert   loggert   verbose_loggert   patht   loopst   installedFileRequirest   installedUnresolvedFileRequirest   _missing_requires(   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   m   s    								c         C   s)   t  j t d  t j d d |  j   S(   s.   Sets up the transaction set before it is used.s5   doTsSetup() will go away in a future version of Yum.
t
   stackleveli   (   t   warningst   warnR
   t   Errorst   YumFutureDeprecationWarningt   _getTs(   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt	   doTsSetup}   s    c         C   s   |  j  d k rc |  j d k rc | r_ |  j  j d k r_ t |   } |  j  j |  j d |  n  d S|  j j s t	 j
 t d   n  |  j |  |  j   d S(   s   setup all the transaction set storage items we'll need
           This can't happen in __init__ b/c we don't know our installroot
           yetNs4   Setting up TransactionSets before config class is up(   R*   R(   R)   R   R   t   setDatabasest   rpmdbt   conft   installrootR:   t   YumBaseErrorR
   t
   _getTsInfot   initActionTs(   R   t   remove_onlyt   pkgSackCtor(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR<      s    c         C   s   |  j  d k r |  j   |  _  | r3 d } d } n d } t |   } |  j  j |  j | |  |  j j |  j  _ t |   |  j  _	 t
 |   |  j  _ t |   |  j  _ n  |  j  S(   s    remove_only param. says if we are going to do _only_ remove(s) in
            the transaction. If so we don't need to setup the remote repos. N(   R*   R(   t   _transactionDataFactoryR   R>   R?   R@   t   installonlypkgsR    t   install_methodR%   t   update_methodR#   t   remove_method(   R   RE   R   RF   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyRC      s    	c         C   s   | |  _  d  S(   N(   R*   (   R   t   value(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt
   _setTsInfo   s    c         C   s   d  |  _ d  S(   N(   R(   R*   (   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt
   _delTsInfo   s    c         C   s   |  j  s |  j   n  |  j  S(   N(   R)   RD   (   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _getActionTs   s    	c         C   st  |  j  j r5 t j d  } t j d |  j  j  n  t j j |  j  j  |  _ i t j	 d 6t j
 d 6t j d 6t j d 6t j d 6t j d 6} t t d	  r t j | d
 <n  |  j j d  xP |  j  j D]B } | | k r |  j j | |  q |  j j t d  |  q W|  j  j s9|  j t j t j  n  d } x |  j j D] } | | O} qLW|  j j |  d S(   s>   Set up the transaction set that will be used for all the work.s   %_install_langss   %define _install_langs t	   noscriptst
   notriggerst   nodocst   testt   justdbt	   repackaget   RPMTRANS_FLAG_NOCONTEXTSt
   nocontextsi    s!   Invalid tsflag in config file: %sN(   R@   t   override_install_langst   rpmt   expandMacrot   rpmUtilst   transactiont   TransactionWrapperRA   R)   t   RPMTRANS_FLAG_NOSCRIPTSt   RPMTRANS_FLAG_NOTRIGGERSt   RPMTRANS_FLAG_NODOCSt   RPMTRANS_FLAG_TESTt   RPMTRANS_FLAG_JUSTDBt   RPMTRANS_FLAG_REPACKAGEt   hasattrRV   t   setFlagst   tsflagst	   addTsFlagR0   t   criticalR
   t   diskspacecheckt   _add_prob_flagst   RPMPROB_FILTER_DISKSPACEt   RPMPROB_FILTER_DISKNODESt   tsInfot   probFilterFlagst   setProbFilter(   R   t   old_install_langst   ts_flags_to_rpmt   flagt
   probfilter(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyRD      s2    	



c         C   sD   |  j  j t j t d  |  t |  j j | | | f   } | S(   s  Search the packageSacks for what provides the specified
        feature or file.
      
        :param name: a string specifying the file or feature to search
           for
        :param flags: flags related to the search
        :param version: the version to search for
        :return: a :class:`ListPackagaSack` containing the packages
           that match the arguments, and may be empty
        s   Searching pkgSack for dep: %s(   R1   t   logt   logginglevelst   DEBUG_1R
   R   R   t   searchProvides(   R   t   namet   flagst   versiont   defSack(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   whatProvides   s    !c         C   sM   t  |  j j  } | j | k r% t Sx! | j D] } | | k r/ t Sq/ Wt S(   s  Return whether the given package object can be installed
        multiple times with different versions.  For example, this
        would be true of kernels and kernel modules.

        :param po: the package object that this function will
           determine whether can be install multiple times
        :return: a boolean specifying whether *po* can be installed
           multiple times
        (   t   setR@   RH   Rx   t   Truet   provides_namesR,   (   R   t   pot   iopkgst   prov(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   allowedMultipleInstalls   s    
i    i   c         C   sG  |  j  r |  j  j   n  i  } |  j j d k r> |  j   n  | r x |  j D] } | j   } | d k ru d } n  | j   | j   | | j   | j	   f } | j
   d k r d } n | j
   d k r d } n  d | | | f <qN Wn  xQ|  j j   D]@} |  j j t j t d  |  | j d k r| j d f | k rNq n  | j j   }	 t j j |	  r| j j   }
 n |  j | j  | j j   }
 | j d k r|  j | j  r|  j j t j t d  | j  d | _ t | _ qn  |  j  r| } n |
 |	 f } |  j j! |
 | | j  |  j j t j" t d	  | j | j  |  j  r?| j } | d k r| j# rd
 } n  |  j  j$ | j |  q?q | j d k r | j | j f | k rq n  |  j j% | j j&  |  j  r| j' rq n  |  j  j$ | j d  n  |  j j t j" t d  | j  q q Wd S(   sx   Populate the transaction set.

        :param test: unused
        :param keepold: whether to keep old packages
        t   0i   t   ii   t   es
   Member: %st   us   %s converted to installs   Adding Package %s in mode %st   ds   Removing Package %sN(   R   R   (   R   ((   R+   t   transactionPopulationt   tsR(   RD   t   Et   Nt   At   Vt   Rt   TypeRm   t
   getMembersR1   Rt   Ru   t   DEBUG_3R
   t   ts_statet   pkgtupR   t   localPkgt   osR2   t   existst   returnHeaderFromPackaget   downloadHeadert   returnLocalHeaderR   t   DEBUG_2t
   TS_INSTALLt   output_stateR-   t
   addInstallRv   t
   downgradest   pkgAddedt   addEraset   idxt   downgraded_by(   R   RS   t   keepoldt   ts_elemt   tet   epocht   pkginfot   modet   txmbrt   rpmfilet   hdrt   cbkeyt   dscb_ts_state(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt
   populateTs   sj    	 	-										c         C   sO   |  j  s d St |  j  d  r5 |  j  j | |  n |  j  j | j |  d S(   sW    Call the callback for processing requires, call the nicest one
            available. Nt	   procReqPo(   R+   Rd   R   t   procReqRx   (   R   R   t   niceformatneed(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _dscb_procReqE  s
    	c         C   s+  g  } | \ } } } t  j j | | |  } |  j j t j t d  | |  |  j | |  yx | j	 j
 d k r |  j | | |  \ } }	 n |  j | | |  \ } }	 |	 r |  j j | |  j | d f  n  WnD t j k
 r}
 |  j j | |  j t |
  f  d } d }	 n X| |	 | f S(   s   processes a Requires dep from the resolveDeps functions, returns a tuple
           of (CheckDeps, missingdep, conflicts, errors) the last item is an array
           of error messagess   %s requires: %st	   installedii   i    (   R[   t	   miscutilst   formatRequireR1   Rt   Ru   Rv   R
   R   t   repot   idt   _requiringFromTransactiont   _requiringFromInstalledt   po_with_problemst   addt   _working_poR:   t   DepErrort   str(   R   R   t   requirementt	   errormsgst   neednameRy   t   needversionR   t	   CheckDepst
   missingdepR   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _processReqP  s     "'"
c         C   s   |  t  | t |  f S(   N(   Ry   R   (   t   rnt   rft   rv(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _prco_req_nfv2reqs  s    c         C   s   |  j  | d | d | d  S(   Ni    i   i   (   R   (   R   t   req(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _prco_req2reqw  s    c         C   s   t  |  _ t |  j d  rR |  j j | |  } | d  k	 rR |  j j | |  Sn  | \ } } } t j j | | |  } t	 d  | | f S(   Nt   format_missing_requiress   %s requires %s(
   R~   R6   Rd   R+   R   R(   R[   R   R   R
   (   R   t   reqPot   reqTupt   msgR   t	   needflagsR   t   ui_req(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _err_missing_requiresz  s    		c   %         s  d } d } |  j  j  j t  r. | | f S j \ } } } }	 }
   \ } } } t j j | | |  } d# } d# } g  } | | | f |  j k r |  j	 j
 t j t d   |  j | | | f } | g } n |  j j d |  r#|  j  j d |  } xX | D] } | j | j  qWn7 |  j	 j
 t j t d  |  |  j j | | |  } x| D]} | |  _ d | j } | j \ } } } } } |  j	 j
 t j t d  |  |  j  j d | d | d | d	 | d
 |  } | d# k r| |  j j k r|  j  j d | d |  } n  | d# k rS| |  j j k rS|  j  j d |  } n  | d# k rt d   |  j  j | | | | |   rd } qn  | d# k	 ra| } | |  j | | | f <|  j	 j
 t j t d  | | |  PqaqaW|  j	 j
 t j t d  | |  | d$ k r|  j	 j
 t j t d    |  j j } d |  j _ |  j d  d   } | |  j _ t    f d  } | |  s|  j d  d   } | | d t s|  j     } |  j	 j
 t j t d    |  j    |  Sn  d } n  | d% k r]|  j	 j
 t j t d    |  j d  d   } t }  | s|  j     } |  j	 j
 t j t d   |  n | | t j j |  f }! xE | D]= } | j  t! k r| j j" d |!  rt }  Pqt }  qqW| r;|  r;|  j     } |  j	 j
 t j t d   |  n  |  sT|  j    |  Sd } n  | d& k r|  j	 j
 t j t d   |  |  j# d   } x | D] } | j$ d |  qWd } n  | d' k r|  j d | d | d |	 d |
 d   }" |  j  j  j t  } |" r| r| d j  t% k rd|  j	 j
 t j t d    | d j& d  ny |  j	 j
 t j t d!    xW | d j' D]H }#   t( |  j) |# j* d   k rt | |  j |#   |  d f SqWt } | | f S|  j	 j
 t j t d"  |  |  j    |  S| d# k r| |	 |
 d# f }$ |  j+ d# k r_|  j    |  S|  j     } |  j	 j
 t j |  d } d } | j |  n  | | f S((   sb   processes the dependency resolution for a dep where the requiring 
           package is installedi    s3   Needed Require has already been looked up, cheatingRx   s4   Needed Require is not a package name. Looking up: %ss   %s.%s %s:%s-%ss   Potential Provider: %st   archR   t   vert   relc         S   s   |  j  S(   N(   t   obsoleted_by(   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   <lambda>  s    R   s!   Mode is %s for provider of %s: %ss   Mode for pkg providing %s: %st   uds"   Trying to update %s to resolve depR   t   requiringPoc            st   xm |  D]e } | s% | j   j  k r   \ } } } | t | t j j |  f } | | j j k rl t Sq q Wt S(   N(	   Rx   t   _rflagsR[   R   t   stringToVersionR   t   requiresR~   R,   (   t   txmbrst   obsR   t   nt   ft   vt   creq(   R   R   (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _check_update_worked  s    
R   s&   No update paths found for %s. Failure!i   t   ods=   No update paths found for %s. Failure due to requirement: %s!R   s+   Update for %s. Doesn't fix requirement: %s!R   s/   TSINFO: %s package requiring %s marked as eraseR   Rz   t   releases-   TSINFO: Obsoleting %s with %s to resolve dep.s#   TSINFO: Updating %s to resolve dep.s*   Cannot find an update path for dep for: %sN(   R   (   R   (   R   (   R   R   (,   Rm   t   getMembersWithStateR   t   TS_REMOVE_STATESR[   R   R   R(   t   cheaterlookupR1   Rt   Ru   R   R
   R?   t   containst
   matchNaevrt   appendR   t   getProvidesR   t   getModeR@   t   exactarchlistt   filtert	   obsoletesR&   R,   R~   R   R   R   R   t   TS_INSTALL_STATESt	   checkPrcoR$   t   setAsDept   TS_OBSOLETEDR   t
   updated_byt   mapR   t
   returnPrcoR   (%   R   R   R   t	   errorlistt	   checkdepsR   Rx   R   R   R   R   R   R   R   R   t   needmodet   needpot	   providerst
   cheater_poR   R   t   inst_pot   inst_strt   i_nt   i_at   i_et   i_vt   i_rt   thismodet   origobsR   R   t   fixedt
   req_lookupt
   newupdatest   pkgt   reqpkg(    (   R   R   s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR     s    
		!
	%%	
	!	!%
c         C   s   |  j  d  k r t S| d k r( d  } n  t |  t j t j t j f k rj t j	 j
 |  \ } } } n0 t |  t j t j f k r | \ } } } n  |  j  } | j d | | | | | f f  r |  j j t d  | |  t St S(   Ni    t   providess"   Quick matched %s to require for %s(   t	   _last_reqR(   R,   t   typet   typest
   StringTypet   NoneTypet   UnicodeTypeR[   R   R   t	   TupleTypet   ListTypeR   R1   t   debugR
   R~   (   R   Rx   Ry   Rz   t   r_et   r_vt   r_rR   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _quickWhatProvides8  s    	$	$c   %      C   s  | j  \ } } } } } | \ }	 }
 } d } d } i  } |  j |	 |
 |  rX | | f S|  j |	 |
 |  } x| j   D]} |  j j d |  r |  j j t j	 t
 d  |  | j |  qz n  g  } |  j |  sz |  j j d | j  } x | D] } t | j | j j  s | j j |  rdt
 d  | } |  j j t j	 |  | j |  q q| j j |  r| j | j  g   j | j   qq q W|  j j d | j  } xo | D]d } | j |  rt | j | j  rt
 d  | } |  j j t j	 |  | j |  qqqWqz qz Wt |  d k rnd } |  j | |  } | j |  | | f Sx | j   D] } | j  \ } } } } } |  j j d | d | d	 | d
 | d |  } | d k r{|  j j t j	 t
 d  |  | |  _ | | f Sq{Wg  } x | j   D] } |  j d | d | j d	 | j d | j d | j   } | j! |  x6 | D]. } | | j k rkt" } | |  _ | | f SqkWqW| j   } t |  d k r| d }  n& |  j# | | d |	 }! |! d d }  |  j j d |   r<d } d } |  j | |  } | j |  | | f S|  j j d |  j d |  j  }" t |"  d k r|  j j$ t
 d  |  | f  |  j j% |  |" d  } | j& d |  d |" d j' k r|" d j' j( | _( n	 d | _( t" } |  |  _ n |  j j$ t
 d  |  |  t) j* |	 t+ |
  |  }# |  j, |  d |# }$ x_ |$ D]W } | j& d |  d | _( | j |  _ | j  | k rQt- |  j j. | | j   qQqQW|$ sd } d } |  j | |  } | j |  n d } | | f S(   sk   processes the dependency resolution for a dep where requiring 
           package is in the transaction seti    R   sB   %s is in providing packages but it is already installed, removing.Rx   s8   Potential resolving package %s has newer instance in ts.s<   Potential resolving package %s has newer instance installed.i   R   R   R   R   R   R   s#   %s already in ts, skipping this oneR   Rz   R   s#   TSINFO: Marking %s as update for %st   reasont   deps$   TSINFO: Marking %s as install for %st   provides_for(   R   R   (/   R   R  R|   t   returnPackagesR?   R   R1   Rt   Ru   R   R
   t
   delPackageR   Rm   R   Rx   R   R   R   t   verGTt   verLTt
   setdefaultR   t   searchNevrat   lenR   R   R  t   returnNewestByNameR&   R   Rz   R   t   extendR~   t   _compare_providersR  t	   addUpdateR   t
   yumdb_infoR  t   misct   string_to_prco_tupleR   R!   R   R$   (%   R   R   R   R   Rx   R   R   Rz   R   R   R   R   R   R   t   upgradedt   provSackR  t   tspkgst   tspkgR   t   dbpkgst   dbpkgR   t   aR   R   t   rt   pkgmodet   resultst   tresultsR   t   pkgst   bestt
   pkgresultst   instt   reqtupleR   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   J  s    
)%
-			
!		!c         C   sO   |  j  s d St |  j  d  r5 |  j  j | |  n |  j  j | j |  d S(   sW    Call the callback for processing requires, call the nicest one
            available. Nt   procConflictPo(   R+   Rd   R<  t   procConflictRx   (   R   R   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _dscb_procConflict  s
    	c         C   s*  t  } g  } | \ } } } | j \ }	 }
 } } } t j j | | |  } |  j | |  t |  j  } | t j	 @r |  j
 d | j  |  j j | j t  } t |  j  | k r'| r'| | f Sn] | t j @r'|  j
 d |	  |  j j | j t  } t |  j  | k r'| r'| | f Sn  |  j
 d | j  |  j j | j t  } t |  j  | k rw| rw| | f S|  j
 d |	  |  j j | j t  } t |  j  | k r| r| | f Sd |	 t |  f } | j |  |  j j t j |  t } |  j j | | | d f  | | f S(   s6   processes a Conflict dep from the resolveDeps() methodRx   s   %s conflicts with %si(   R~   R   R[   R   R   R>  R$  Rm   RY   t   RPMSENSE_LESSR&   Rx   R   R   t   RPMSENSE_GREATERR   R   R1   Rt   Ru   Rv   R,   R   R   (   R   R   t   conflictt   conflicting_poR   R   R   Ry   R   Rx   R   R   R   R   R   t   lengthR   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _processConflict  s>    

c         C   s7   x0 |  j  D]% } | j r
 |  j  j | j  q
 q
 Wd  S(   N(   Rm   t   isDepR$   R   (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _undoDepInstalls&  s    	c         C   s   d } d d l  } d d l } | j |  } | j |  j  } | j   d GH| j j |  } | j   | j	 d d  | j
 d  | S(   s  Call :func:`resolveDeps`, and profile the call using the
        hotshot profiler.

        :return: a tuple containing the result code and a list of
           result strings.  This is simply the return value of
           :func:`resolveDeps` being passed up.
        s   anaconda.prof.0iNs   done running depcheckt   timet   callsi   (   t   hotshott   hotshot.statst   Profilet   runcallt   resolveDepst   closet   statst   loadt
   strip_dirst
   sort_statst   print_stats(   R   t   fnRI  t   proft   rcRO  (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   prof_resolveDeps,  s    

c         C   s   d d l  } d d l } | j   } | j |  j  } | j d  d GH| j d  } | j   | j d  | j	 d  | S(   s  Call :func:`resolveDeps`, and profile the call using the
        cprof profiler.

        :return: a tuple containing the result code and a list of
           result strings.  This is simply the return value of
           :func:`resolveDeps` being passed up.
        iNt   yumprofs   done running depcheckRG  i   (
   t   cProfilet   pstatsRK  RL  RM  t
   dump_statst   StatsRQ  RR  RS  (   R   RY  RZ  RU  RV  t   p(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   cprof_resolveDeps@  s    
c         C   s  t  |  j  s" d t d  g f St   |  _ d |  _ d |  _ |  j j d t	  t
 } | } | } d } g  } |  j r |  j j   n  d } x#t
 r| |  j j p d k r d t d  g t |  f S| d 7} t
 } x[ | r;i  |  _ |  j r	|  j j   n  |  j |  \ } }	 }
 } | |	 O} | |
 O} q Wd |  _ | rt	 } xI |  j   D]; \ } } |  j | |  \ } } } | | O} | | 7} q^W| r|  j r|  j j   n  |  j j t j t d   q qn  d |  _ | rt	 } xG |  j   D]9 } |  j |   \ } } | | O} | | 7} | rPqqWt
 rm|  j   rmt
 } t
 } d |  _ qmn  | r|  j r|  j j   n  |  j j t j t d   q qn  Pq Wxo |  j j   D]^ } |  j | j  r| j  d k r|  j j t j! t d	  | j  d
 | _  t" | _# qqW|  j rn|  j j$ sM|  j j%   qn| rn| rn|  j j%   qnn  |  j j t j t d   t	 |  j _& t  |  d k r^t |  } t   } x |  j D] \ } } } | | f | k rqn  | j' | | f  |  j j t j( d | | j) f  | j* d d  } |  j j t j( d |  qWd | f St  |  j  sd t d  g f Sd t d  g f S(   s1  Resolve dependencies for the packages in the current
        trasaction set.
        
        :param full_check: whether to also check removes and installs,
           as well as dependencies
        :param skipping_broken: if this is true, a message saying that
           dependency solving has finished successfully will not be output.
           This is useful since if there are broken packages that are
           being skipped, :func:`resolveDeps` will need to be called
           multiple times before dependency solving is completely finished
        i    s   Success - empty transactiont   hardii   s   Depsolving loop limit reached.s   Restarting LoopR   s   %s converted to installR   s   Dependency Process endings.   SKIPBROKEN: %s from %s has depsolving problemss   
s   
  --> s   SKIPBROKEN:  --> %si   s   Success - deps resolvedN(+   R$  Rm   R
   R}   R   R(   R   R  t   resetResolvedR,   R~   R+   t   startR@   t   depsolve_loop_limitR   R   t   tscheckt   _resolveRequirest   _checkFileRequiresR   t   restartLoopR1   Rt   Ru   Rv   t   _checkConflictsRD  t   _checkObsoletesR   R   R   R   R   R   R   t   skip_brokent   endt   changedR   t   DEBUG_4t   repoidt   replace(   R   t
   full_checkt   skipping_brokenR   t   CheckRemovest   CheckInstallsR   t   errorst   depsolve_loop_countt   checkinstallst   checkremovest   missingR   R  t   checkdepR   RA  R   t   donet   wpot   err(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyRM  T  s    			 	
			 
	
	 		

	 		
			
c      
   C   si  t  } t  } t  } t  } x>|  j j   D]-} |  j r | j r | j } | j r[ d } n  | d k ry | j ry d } n  | d k r | j t k r d } q | j	 s d } q n  |  j j
 | j |  n  |  j j t j t d  | f  | j	 r| j r| j d d |  _ n | j |  _ | j t k | j j d  k k r]|  j |  } t } n |  j |  } t } t  }	 x | D] \ }
 } | j r|  j |
 |  } |  j j t j |  | j |  |  j j |
 |  j | d f  d	 }	 qn  |  j |
 |  \ } } } | | O} | | 7} |	 | O}	 qW|	 sK|  j j  |  n  | |	 O} q( W| | | | f S(
   NR   R   R3  t   oR   s   Checking deps for %si    ii   (!   R,   Rm   t   getUnresolvedMembersR+   R   R   t	   reinstallR   t   TS_OBSOLETINGt   updatesR   R   R1   Rt   Ru   R   R
   t	   relatedtoR   R   R   t   stateR(   t   _checkInstallR~   t   _checkRemoveR   R   R   R   R   R   t   markAsResolved(   R   Rs  t   any_missingR   Rr  Rq  R   R   t	   thisneedst   missing_in_pkgR   R  R   Rx  Rw  R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyRd    sX    						!		 

c         C   s   i d d 6d d 6d d 6d d 6d	 d
 6d d 6} | j |  d d  } d } |  d j d  r |  d j d  s |  d j d  r d } n  | | f S(   s8   Get a sort key for a package requires from most "narrow" to least,
            this tries to ensure that if we have two reqs like
            "libfoo = 1.2.3-4" and "foo-api" (which is also provided by
            libxyz-foo) that we'll get just libfoo.
            There are other similar cases this "handles".i   R   i   R   i   R   i   R   i   R   ic   i
   i    t   libs   ()s	   ()(64bit)N(   R(   t   gett
   startswitht   endswith(   R   t   mappert	   flagscoret	   namescore(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _sort_req_key  s    0&	c   
      C   s  | j  j d  } g  } |  j j sQ x* | j D] } | j | j d   q. Wn  t |  } g  } x&t | d |  j D]} | d j	 d  r qy n  | | k r qy n  |  j
 j t j t d  | |  |  j j |   } | r | j  j d |  r | j | j  |  j |  f  qy n  xe | D]] } | j | j k rEq'n  x< |  j j d | j d	 t  D] }	 |	 j | j  d
 t qdWq'Wqy W| S(   NR   t   strong_requirest   keyi    s   rpmlib(s%   looking for %s as a requirement of %sR  R   t   output_statest   relonly(   R   R   R@   t   recheck_installed_requiresR  R&  R}   t   sortedR  R  R1   Rt   Ru   R   R
   Rm   R   t   inPrcoRangeR   R   Rx   R   R   R   R   R~   (
   R   R   t
   txmbr_reqst   oldreqst   oldpot   retR   t   provsR   t   member(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR  *  s0    ""c         C   sA  | j  } | j d  } i  } x6 | j | j D]$ } x | j D] } d | | <q? Wq/ Wg  } x| D]} | d j d  r qd n  | | k r qd n  x|  j j |   j   D]\ }	 }
 |  j	 j
 rW| j rW| j t k rW|  j } | rt | d  r| j | j  |
  n. | r@t | d  r@| j | j  |	 |
  n  |  j j | j  g  S|  j	 j r| j r| j t k r|  j } | rt | d  r| j |	 |
  n. | rt | d  r| j | j  |	 |
  n  |  j j | j  g  S|  j	 j rZ| j t k rZ|  j } | rCt | d  rC| j | j  |	 |
  n  |  j j | j  g  Sx |
 D] } t } x- | j D]" } | j d |  rwt } PqwqwW| rqan  x- | j D]" } | j d |  rt } PqqW| rqan  | \ } } } |  j j | | |  sa| j |	 |  j | | |  f  qaqaWq Wqd W| S(   NR  i   i    s   rpmlib(t   repoPkgRemoveReqt	   removeReqt   groupRemoveReq(   R   R   R   R   R  R  Rm   t   getRequirest	   iteritemsR@   t   repopkgsremove_leaf_onlyt   repopkgR   t   TS_ERASER+   Rd   R  R  R$   R   t   groupremove_leaf_onlyt   groupsR  t   remove_leaf_onlyR,   R   R~   R   R   R   (   R   R   R   R  t
   newpoprovst   newpoR]  R  R   R  t   hitst   cbt   hitt   foundR   R   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR  R  sp    	%			  1c      
   C   s  t    } t    } i  } g  } |  j d  k rQ |  j j   \ |  _ |  _ |  _ n  g  } x| |  j j   D]k \ } } |  j j	 | d t
 r | j |  qg | j |  x' | D] } | j | g   j |  q Wqg Wx | D] } |  j | =q W| |  j 8} x|  j j	 d t  D]}	 g  } x |	 j j D] \ }
 } } |
 j d  r-| j |
  |
 |  j k rt } x6 |	 j D]+ } | j d |
 d  d f  rwt } PqwqwW| rq-qn  |
 | k r| j |
  n  | j |
  | j |
 g   j |	 j j  q-q-W| |  j |	 j j <qWg  } x |  j D]u } g  } x@ |  j | D]1 } |  j j	 | d t
 riqEn  | j |  qEW| s| j |  q+n  | |  j | <q+Wx | D] } |  j | =qW|  j } x| D]} | |  j k rqn  |  j j |  } | r7| j | g   j g  | D] } | j ^ q qn  |  j j |  } | r| j | g   j g  | D] } | j ^ qh qn  | t j j |  k rt j j |  } |  j j |  } | r| j | g   j g  | D] } | j ^ q qqn  xh | | D]\ } |  j j	 | t  } | r:| d j } n |  j |  } | j | | d d f f  q	WqW|  j j  |  j |  j |  j |  | S(   NR  t   /R   i    t    (   NNN(!   R}   R4   R(   R?   t   fileRequiresDataR5   t   installedFileProvidersR  R*   R   R   R   R&   R"  R   R   R   R  R,   R  R   R~   R   R   Rm   t   getOldProvidesR&  t   getNewProvidesR   R2   t   realpatht   getInstalledPackageObjectt   transactionCacheFileRequires(   R   t   fileRequirest   nfileRequirest   reverselookupR  t   todelR   t   filest   filenameR   Rx   Rr   t   evrt   already_brokenR  t   fnamet
   niFP_fnamet   iFPt   oprovR   t   nprovR  (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyRe    s    		$!	&	///	$c      
   C   s1  g  } g  } x|  j  j   D] } |  j j | j d t rC q n  | j d  } | s^ q n  | j |  x | D] } | \ } } } x |  j j | | |  D]e }	 |	 j d | j d k r |	 j d | j d k r q n  | j | |  j	 | | |  |	 f  q Wqr Wq Wx |  j j d t
  D] }
 |
 j } t } x |
 j j d  D] } | st| j |
 j  t } n  | \ } } } x |  j j | | |  D]e }	 |	 j d | j d k r|	 j d | j d k rqn  | j | |  j	 | | |  |	 f  qWqOWq'Wt d  r| S|  j  j |  | S(   NR  t	   conflictsi    i   i   i	   (   i   i	   i    (   R?   t   returnConflictPackagesRm   R   R   R   R   R   R  R   R   R   R,   R~   R   R   t    transactionCacheConflictPackages(   R   R  t   cpkgsR   R  RA  R3  R   R   RB  R   Ry  (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyRg    sB    4		4c            sN  g  } t  }   f d   } x  j j   D] }   j j | j d t rR q+ n  | j d  } | sm q+ n  | j |  x | D] \ } } } x   j j	 d |  D]n }	 |	 j
 j | g  s q n  | j |	 j
 g  r q n  t d  }
   j j |
 |	 |  | |	  t } q Wq Wq+ Wx  j j d  d t D] } t  } x | j
 j D] } | sw| j | j
  t } n  x   j j	 d |  D] }	 |	 j t k rqn  |	 j
 | j
 k rqn  |	 j
 j | j
 g  sqn  | j
 j |	 j
 g  rqn  t d  }
   j j |
 |	 |  | |	  t } qWqRWq9W  j j |  | S(   Nc            sY     j  j |  j    j j |  j    j j |  j    j pE i  j |  j d   d  S(   N(
   Rm   R$   R   R   R  R   t   upR4   t   popR(   (   t   otxmbr(   R   (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _do_obs?  s    R  R   Rx   s.   Removing %s due to obsoletes from installed %ss$   Removing %s due to obsoletes from %s(   R,   R?   t   returnObsoletePackagesRm   R   R   R   R   R   R   R   t   obsoletedByR
   R1   t   warningR~   R(   R   t   obsoletes_namesR   t    transactionCacheObsoletePackages(   R   t   opkgsR  R  R   R   t   obs_nameR   R   R  R   R   Ry  t   obs_n(    (   R   s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyRh  :  sR    	
	
c         C   sl   |  j  j d |  } x! | D] } | j t k r t Sq Wt |  d k rO t S|  j j d |  sh t St S(   s   Return whether the given package in installed.

        :param pkgname: the name of the package
        :return: whether the package in installed
        Rx   i    (	   Rm   R   R   R   R~   R$  R,   R?   R   (   R   t   pkgnamet   lstR   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   isPackageInstalledu  s    c             s#   j  j t j t d  t |   d d  } d   } d   }  f d   } d   } i  }	 xI | D]A }
 |
 j |	 k r |	 |
 j j |
 j k r qi n  |
 |	 |
 j <qi W|	 j   } i  } t	   } x | D] }
 d | |
 <q W j
 j d	 d
 | d | x | j   D] }
  j j d |
 j  } | rt |  d } | j |
  rc| |
 c d 7<q| j |
  r| |
 c d 7<q| j |
  r| |
 c d 8<qqqW| j   } i  } x| D]} x| D]} | | k rqn  | j | k r j j | j  d  | | j <n  | | j sG| j | | j d  rZ| | c d 8<n  t } | j | g  rt } | | c d 8< j  j t j t d  | | f  n  | r| j  j j f } n  j j f } xw | D]o } | | | |  } | s	qn   j  j t j t d | | | | f   | | k r| | c d 7<qqWqW| | |  r j  j t j t d | | f   | | c d 7<n  | | |  r j  j t j t d | | f   | j |  n   j | j  r7 j  j t j t d | j | f   | | c d 7<n  | r| | j | j  } | d k r j  j t j t d | | | f   | | c | d 7<qqqW| d" k	 rt | j    } i    xS | D]K } | | | k rqn  | | |  } | d" k ri    Pn  |   | <qWt     d k r j  j t j t d  t |   t   d   f d   } xc t! |  D]R }   |   | d k rPn   j  j t j t d  |  | | c d 7<qWqn  t | j    } i  } x. | D]& } | | | k rqn  d | | <qWt  |  d k r+x9 | D]1 } t" |  }  j# |  } t  |  | | <q=Wt$ | j    }  j  j t j t d  |  x | D]y } | | | k r j  j t j t d  |  | | c d 7<q| | }  j  j t j t d  | | f  qWn  t | j    } xQ | D]I } | | | k r`qDn  | | c d 7<| | c t  | j  d 7<qDWt | j    t$ | j    d } x | D] } | | c | 8<qWt | j%   d d   d  t }  j  j t j t d! t |    | S(#   so   take the list of pkgs and score them based on the requesting package
           return a dictionary of po=scores"   Running compare_providers() for %si   c         S   s`   t  t |   t |   } x5 t |  D]' } |  | | | k r( t | |  Sq( Wt | |  S(   N(   R   R$  t   rangeR   (   R   R   t   minlent   numt   off(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _common_prefix_len  s
    c         S   s6   t  |  d  s t St  | d  s& t S|  j | j k S(   Nt	   sourcerpm(   Rd   R,   R  (   R   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _common_sourcerpm  s
    c         S   s>   | d  k r t Sx' | j D] } |  j d |  r t Sq Wt S(   NR  (   R(   R,   R  R   R~   (   R   R   t   ydep(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _conflict_req  s    c            s   t  | |  j  }   j j rQ | d k rQ   j j t j t d  |  | Sn  t  | | j  } | d k r | | k r   j j t j t d  |  | S| | k r d  S|  S(   Ni    s   better arch in po %s(	   R    R   t   multilibR1   Rt   Ru   Rl  R
   R(   (   R   R   t   req_compare_archt   x_distt   y_dist(   R   (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _compare_arch_distance  s    c   	      S   s   d } xx |  j D]m } | \ } } \ } } } | | k r@ q n  | d k rR q n  | d k	 rb d S| pk d | | pw d f } q W| S(   s)   This converts a package into a specific version tuple for the
            required provide. The provide _must_ be '=' and epoch=None and
            release=None == '0'.
               If there is 0 or 2+ matches, return None.
               If the req does not == the provide name, return None. R   R   N(   R(   R  (	   R  t   provnameR  R   R   R   R   R   R3  (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   _pkg2prov_version  s    i    t   compare_providerst   providers_dictt   reqpoRx   ii   i  i   i   s   %s obsoletes %ss-   archdist compared %s to %s on %s
  Winner: %ss   common sourcerpm %s and %si   s   conflict req %s and %ss#   base package %s is installed for %ss%   common prefix of %s between %s and %ss   provides vercmp: %sR  c            s   t    |    S(   N(   R   (   R   (   t   prov_depsolve(    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR   f  s    s    Winner: %ss   requires minimal: %ds    Loser(with %d): %sc         S   s   |  d |  d f S(   Ni   i    (    (   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR     s    t   reverses   Best Order: %sN(&   R1   Rt   Ru   Rl  R
   R   R   R   t   valuesR}   t   pluginst   runt   keysR?   R#  Rx   R  R!  t   verEQR   R   R%  R,   R  R~   R   t   bestarchR   R  t   base_package_nameR(   R   R$  t   reversedR   R  R   t   items(    R   R7  R  R   R  R  R  R  R  t   unique_nevra_pkgsR  R9  t   penalizet	   rpmdbpkgst   newestt   lposR   t   nextpot	   obsoletedt   archest   thisarcht   rest   cplt   bestnumR  t   winnert   rec_depsolvet
   fake_txmbrt   reqsR  t   shiftt	   bestorder(    (   R  R   s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR'    s   				#)		

!&N(*   R   R   R   R   R=   R,   R<   RC   RM   RN   RO   RD   R|   R   R   R   R   t   staticmethodR   R   R   R   R  R   R>  RD  RF  RW  R^  R~   RM  Rd  R  R  R  Re  Rg  Rh  R  t   _isPackageInstalledR(   R'  (    (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR'   j   sH   						&		F		#							)			{	>	(	M	s	(	;	t   DepCheckc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s-  Object that :class:`YumDepsolver` uses to see what things are
    needed to close the transaction set. The attributes requires and
    conflicts are lists of requires and conflicts in the current
    transaction set. Each item in the lists is a :class:`Requires` or
    :class:`Conflicts` object.
    c         C   s   g  |  _  g  |  _ d  S(   N(   R   R  (   R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR     s    	c         C   s#   t  | |  } |  j j |  d S(   s  Create and add a :class:`Requires` object to the list of
        requires.

        :param po: the package object involved in the requires
        :param req_tuple_list: a list of required by *po* that are
           un-closed in the transaction set
        N(   t   RequiresR   R   (   R   R   t   req_tuple_listt   reqobj(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   addRequires  s    	c         C   s#   t  | |  } |  j j |  d S(   s  Create and add a :class:`Conflicts` object to the list of
        conflicts.

        :param conflict_po_list: a list of conflicting package objects
        :param conflict_item: what the conflict between the members of
           *conflict_po_list is.
        N(   t	   ConflictsR  R   (   R   t   conflict_po_listt   conflict_itemt   confobj(    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   addConflicts  s    (   R   R   R   R   R  R  (    (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR
    s   		R  c           B   s   e  Z d  Z d   Z RS(   sT   A pure data class for holding a package and the list of things
    it requires.
    c         C   s   | |  _  | |  _ d  S(   N(   R  R   (   R   R  R   (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR     s    	(   R   R   R   R   (    (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR    s   R  c           B   s   e  Z d  Z d   Z RS(   s]   A pure data class for holding a list packages and what the
    conflict between them is.
    c         C   s   | |  _  | |  _ d  S(   N(   t   pkglistRA  (   R   R  RA  (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR     s    	(   R   R   R   R   (    (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyR    s   (3   R   t   os.pathR   R  R.   t   rpmUtils.transactionR[   t   rpmUtils.miscutilst   rpmUtils.archR    R   R*  R   R   t   transactioninfoR   RY   t   packageSackR   t   packagesR   t	   constantsRu   R:   R8   t   simplefilterR;   R   R	   t   yumR
   R   R   t   AssertionErrorR   R@  t   RPMSENSE_EQUALR?  R(   Ry   R   R   R   R    R#   R%   t   objectR'   R
  R  R  (    (    (    s0   /usr/lib/python2.7/site-packages/yum/depsolve.pyt   <module>   s^   
	



		
      L"	