ó
N_c           @   s]  d  d l  Z d  d l Z d  d l m Z m Z d  d l Td  d l m Z d  d l	 Z
 d  d l Z d  d l Z d" Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d d „ Z# d d „ Z$ d d  „ Z% g  d! „ Z& d S(#   iÿÿÿÿN(   t   _t   P_(   t   *(   t   INFO_1t   securityt   bugfixt   enhancementt   recommendedt
   newpackagec         C   s=   t  j j |  d |  d |  d f | d | d | d f ƒ S(   s-    Compare two "std." tuples, (n, a, e, v, r). i   i   i   (   t   rpmUtilst	   miscutilst
   compareEVR(   t   tup1t   tup2(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _rpm_tup_vercmp   s    !c         C   s   |  s
 g  S|  S(   sj    Sometimes refs == None, if so return the empty list here. 
        So we don't have to check everywhere. (    (   t   refs(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _ysp_safe_refs   s    c         C   sÛ   xÔ |  D]Ì } t  j  | | ƒ r# | St  j  | d | ƒ r= | S| } | j d ƒ p^ | j d ƒ sn d | } n  xb t | d ƒ D]P } | d d  k r› q n  t  j  | d | ƒ rµ | St  j  | d | ƒ r | Sq Wq Wd  S(   Nt	   update_ids   CVE-R   t
   referencest   id(   t   fnmatcht
   startswithR   t   None(   t   sec_cmdst   pkgnamet   noticet   it   cveit   ref(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _match_sec_cmd#   s     c         C   sZ   xS t  | ƒ D]E } | d | k r) q n  | d | k r? q n  t |  | | d <| SWd S(   s#    Check if the given ID is a match. t   typeR   N(   R   t   TrueR   (   t   used_mapR   t   ref_typet   ref_idsR   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _has_id6   s    c         C   s•  t  |  j | | ƒ } | r- t | d | <t S|  j r_ | d |  j k r_ t | d | d <t S|  j r¡ | d d k r¡ | d |  j k r¡ t | d | d <t S|  j rÊ t | | d d	 |  j ƒ rÊ t S|  j ró t | | d d
 |  j ƒ ró t S|  j r1| d d k r1|  j s-d | k s-| d r1t S|  j	 rN| d d k rNt S|  j pŠ|  j pŠ|  j pŠ|  j pŠ|  j	 pŠ|  j pŠ|  j s‘t St
 S(   s;    Do the package filtering for should_show and should_keep. t   cmdR   R   R   R   t   severityt   sevR   t   cvet   bugzillaR   (   R   R   R   t   advisoryR%   R'   R#   t   bzR   t   bugfixest   False(   t   optsR   R   R    t   rcmd(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _ysp_should_filter_pkgA   s2    %%$c         C   sY   |  t  k r# | d |  k r# | Sn  x/ t | d ƒ D] } | d |  k rP q4 n  | SWd  S(   NR   R   (   t   _update_info_types_R   (   t   rnamet   mdR   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _ysp_has_info_md`   s    c         C   s5   |  j  p3 |  j p3 |  j p3 |  j p3 |  j p3 |  j S(   N(   R   R+   R)   R*   R'   R%   (   R-   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _no_optionsi   s    c         C   s—   t  j ƒ  } g  | _ |  j d g  ƒ | _ |  j d g  ƒ | _ |  j d g  ƒ | _ |  j d g  ƒ | _ |  j d t ƒ | _	 |  j d t ƒ | _
 | S(   Nt   advst   bzst   cvest   sevsR   R   (   t   misct   GenericHolderR   t   getR)   R*   R'   R%   R,   R+   R   (   t   updateinfo_filtersR-   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _updateinfofilter2optsm   s    	c         C   sk  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 6} i t  d 6t  d 6} xÌ |  D]Ä } | j d d ƒ } d } d | k rä | j d d ƒ \ } } n! | | k rù | } n | } d } | | k rqŸ n  | | } | d k r?| | | | <n# | j | g  ƒ | j d ƒ | | <| SWd  S(   NR5   R)   t
   advisoriesR6   R*   R7   R'   R8   s   security-severitys   security-severitiesR%   t
   severitiesR&   R   t   secR   R+   t   bugst    t   ,t   =i   t   true(   s   securitys   bugfix(   R,   t   replacet   splitR;   (   t   argst   T_mapt   filterst   arg0t   Tt   arg1(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _args2filters{   sF    

	
#c         C   s’   d „  } t  |  ƒ } | d  k	 r- | | _ n  x^ d d g D]P } t | | ƒ } t | | ƒ } t t | ƒ t | ƒ Bƒ } t | | | ƒ q: W| S(   Nc         S   s/   d } t  j | |  ƒ } | r+ | j d ƒ S|  S(   Ns   ^(RH[BES]A\-\d+\:\d+)(\-\d+)?$i   (   t   ret   matcht   group(   t   id_t   patternRP   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   strip_respin±   s
    R   R)   (   R=   R   R   t   getattrt   mapt   listt   sett   setattr(   RJ   R   RT   R-   t   attrt   oldlistt   strippedt   newlist(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _ysp_gen_opts°   s    	c         C   sá   i i  d 6i  d 6i  d 6i  d 6i  d 6} t  r3 | Sx |  j D] } t | d | <q= Wx |  j D] } t | d | <q_ Wx |  j D] } t | d | <q Wx |  j D] } t | d | <q£ Wx |  j D] } t | d | <qÅ W| S(   NR(   R'   R   R$   R&   (   R   R   R,   R)   R*   R'   R%   (   R-   R    R   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _ysp_gen_used_mapÒ   s    )c         C   s  x1 |  d D]% } |  d | s | d | ƒ q q Wx1 |  d D]% } |  d | s? | d | ƒ q? q? Wx1 |  d D]% } |  d | ss | d | ƒ qs qs Wx1 |  d D]% } |  d | s§ | d | ƒ q§ q§ Wx1 |  d	 D]% } |  d	 | sÛ | d
 | ƒ qÛ qÛ Wd  S(   NR$   s$   No update information found for "%s"R   s2   Advisory "%s" not found applicable for this systemR(   s,   BZ "%s" not found applicable for this systemR'   s-   CVE "%s" not found applicable for this systemR&   s2   Severity "%s" not found applicable for this system(    (   R    t   msgR   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _ysp_chk_used_mapâ   s    c         C   s\   i  } xO | D]G } | d | k rF t  | | d | ƒ d k rF q n  | | | d <q W| S(   Ni    (   R   (   t   baset   pkgtupst   name2tupt   pkgtup(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _get_name2pkgtupô   s    c         C   s(   t  d „  |  j j ƒ  ƒ } t |  | ƒ S(   s?    Get the pkgtups for all installed pkgs. which have an update. c         S   s   |  d S(   Ni   (    (   t   x(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   <lambda>ÿ   s    (   RV   t   upt   getUpdatesTuplesRf   (   Rb   t   oupdates(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _get_name2oldpkgtupý   s    c         C   s   t  |  |  j j ƒ  ƒ S(   s)    Get the pkgtups for all installed pkgs. (   Rf   t   rpmdbt   simplePkgList(   Rb   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _get_name2instpkgtup  s    c         C   sF   g  |  j  j ƒ  D]# } | d | d d d d f ^ q } t |  | ƒ S(   sa    Get the pkgtups for all installed pkgs. and munge that to be the
        first possible pkgtup. i    i   t   0(   Rm   Rn   Rf   (   Rb   t   ptt   ofirst(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _get_name2allpkgtup  s    9c         C   sF   g  |  j  j ƒ  D]# } | d | d d d d f ^ q } t |  | ƒ S(   sa    Get the pkgtups for all available pkgs. and munge that to be the
        first possible pkgtup. i    i   Rp   (   t   pkgSackRn   Rf   (   Rb   Rq   Rr   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _get_name2aallpkgtup	  s    9c         C   sG   | d } x6 | j  | ƒ D]% \ } } t |  | | | ƒ r t Sq Wt S(   sA    Do we want to keep this package to satisfy the security limits. i    (   t   get_applicable_noticesR/   R   R,   (   R-   Re   t   md_infoR    t   nameR   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _ysp_should_keep_pkg  s
    
c         C   s~   t  } xq |  D]i } y | j j d ƒ } Wn
 q n X| j d t j j | j d ƒ } t j j | ƒ s t	 } Pq q W| S(   Nt
   updateinfot   /i   (
   R   t   repoXMLt   getDatat   cachedirt   ost   patht   basenamet   locationt   existsR,   (   t   repost   dledt   repot   dataR€   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _repos_downloaded"  s    $c   
   	   C   s  t  j |  j ƒ } | d d  k r& d  St } xà | j | ƒ D]Ï \ } } | s< | d d k rd q< n  t } |  j j | ƒ } | sˆ q< n  | d } d } | d d k r¹ d | d } n  d | d | | d	 | d
 | d f }	 | t	 d ƒ | ƒ | t	 d ƒ |	 ƒ Pq< Wd  S(   Ni    R   R   t    i   Rp   s   %s:s   %s-%s%s-%s.%si   i   i   s,   Security: %s is an installed security updates-   Security: %s is the currently running version(
   R9   t   get_running_kernel_pkgtupt   tsR   R,   Rv   R   Rm   t   searchPkgTupleR    (
   t   ybRw   R`   t   kern_pkgtupt	   found_secRe   R   t   ipkgt   et   rpkg(    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   _check_running_kernel2  s*    
c            s  ‡  ‡ f d †  } | d k r* ˆ  j } n  t | ƒ } t | ƒ rF d Sˆ  j } d } d } t | ƒ } ˆ  j ‰ ˆ j ƒ  } t ƒ  }	 t t	 t
 g ƒ }
 t ƒ  } x0 | D]( } | j |
 k r¨ | j | j ƒ q¨ q¨ Wt ˆ  ƒ } xŽ | D]† } | j |
 k r	| d 7} n  | j j } | | k sç t | | | | | ƒ rAqç n  | j |
 k r]| d 7} n  |	 j | j ƒ qç W| } t } xá | r`t } xÎ | D]Æ } | j |	 k r x® | j D]G \ } } | |	 k r²| | k rã| d 7} n  |	 j | ƒ t } q²q²Wq“xV | j D]K \ } } | |	 k r
| | k r;| d 7} n  |	 j | j ƒ t } Pq
q
Wq“Wq€Wx* | D]" } | j |	 k rh| | ƒ qhqhWt | ‡  f d †  ƒ | r×ˆ  j j t t d ƒ | | | | f ƒ n ˆ  j j t t d ƒ | ƒ | | | f S(	   sJ   
    Remove packages from the transaction, using the updateinfo data.
    c            s@   ˆ  j  j t t d ƒ |  j |  j j f ƒ ˆ j |  j ƒ d S(   s)    Deletes a package within a transaction. s$    --> %s from %s removed (updateinfo)N(   t   verbose_loggert   logR   R    t   pot   ui_from_repot   removeRe   (   t   tspkg(   Rb   t   tsinfo(    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   ysp_del_pkgQ  s    	i    i   c            s   ˆ  j  j d |  ƒ S(   Ns   %s(   R”   t   warn(   Rg   (   Rb   (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyRh   —  s    sD   %d package(s) needed (+%d related) for security, out of %d availables6   No packages needed for security; %d packages availableN(   i    i    i    (   R   R<   R^   R4   t   upinfoR_   t   tsInfot
   getMembersRX   t   TS_INSTALL_STATESt   TS_ERASEt   output_statet   addR–   Rl   Rx   Ry   R   R,   t	   relatedtoRa   R”   R•   R   R    (   Rb   RJ   R›   R-   Rw   t   tott   cntR    t   tspkgst	   keep_pkgst   count_statest
   count_pkgsR™   Rd   Rx   t   scntt   mini_depsolve_againR’   t   reason(    (   Rb   Rš   s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   remove_txmbrsL  sp    					-c            sâ  d ‡  f d † } | d k r* ˆ  j } n  t | ƒ } t | ƒ rF d Sˆ  j } t | ƒ } t t ˆ  j d d ƒ j	 ˆ  j d d ƒ j
 ƒ ƒ } ˆ  j j ƒ  } t ˆ  ƒ } g  }	 xS | D]K }
 |
 j } | | k sì t | | | | | ƒ r· |	 j |
 j ƒ q· q· q· W|	 rEx6 ˆ  j d d d |	 d	 t ƒ j D] } | | ƒ q.Wn  t t ˆ  j d d ƒ j	 ˆ  j d d ƒ j
 ƒ ƒ } t | ‡  f d
 †  ƒ | r»ˆ  j j t t d ƒ | | f ƒ n ˆ  j j t t d | ƒ ƒ | | f S(   sM   
    Exclude all packages to do with updates, using the updateinfo data.
    Rz   c            s@   ˆ  j  j t t d ƒ |  |  j | f ƒ |  j j j |  ƒ d S(   s7    Deletes a package from all trees that yum knows about s    --> %s from %s excluded (%s)N(   R”   R•   R   R    t   repoidR†   t   sackt
   delPackage(   t   pkgR­   (   Rb   (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyR›   ¥  s    	i    t	   pkgnarrowt   updatest	   obsoletest	   availablet   patternst   showdupsc            s   ˆ  j  j d |  ƒ S(   Ns   %s(   R”   Rœ   (   Rg   (   Rb   (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyRh   Ë  s    s6   %d package(s) needed for security, out of %d availables6   No packages needed for security; %d packages availableN(   i    i    (   R   R<   R^   R4   R   R_   t   lenRX   t   doPackageListsR´   Rµ   Rt   t   returnPackagesRl   Rx   Ry   t   appendR   R¶   Ra   R”   R•   R   R    (   Rb   RJ   R›   R-   Rw   R    R¥   t   pkgsRd   t   pkgs_to_delR²   Rx   t   pR¦   (    (   Rb   s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   exclude_updates   s:    		
(&c            sO  d ‡  f d † } | d k r* ˆ  j } n  t | ƒ } t | ƒ rF d	 Sˆ  j } t | ƒ } ˆ  j j ƒ  } t ˆ  ƒ } d } d }	 xa | D]Y }
 | d 7} |
 j	 } | | k sÈ t
 | | | | | ƒ rØ | |
 ƒ q‰ n  |	 d 7}	 q‰ Wt | ‡  f d †  ƒ |	 r(ˆ  j j t t d ƒ |	 | f ƒ n ˆ  j j t t d | ƒ ƒ |	 | f S(
   s:   
    Exclude all packages, using the updateinfo data.
    Rz   c            s@   ˆ  j  j t t d ƒ |  |  j | f ƒ |  j j j |  ƒ d S(   s7    Deletes a package from all trees that yum knows about s    --> %s from %s excluded (%s)N(   R”   R•   R   R    R¯   R†   R°   R±   (   R²   R­   (   Rb   (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyR›   Ù  s    	i    i   c            s   ˆ  j  j d |  ƒ S(   Ns   %s(   R”   Rœ   (   Rg   (   Rb   (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyRh   ù  s    s6   %d package(s) needed for security, out of %d availables6   No packages needed for security; %d packages availableN(   i    i    (   R   R<   R^   R4   R   R_   Rt   R»   Ru   Rx   Ry   Ra   R”   R•   R   R    (   Rb   RJ   R›   R-   Rw   R    R½   Rd   R¥   R¦   R²   Rx   (    (   Rb   s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   exclude_allÔ  s2    	
	
&c         C   s4  g  } t  |  j ƒ } t |  j ƒ } t | ƒ } t d „  |  j j ƒ  ƒ } xâ t | ƒ D]Ô } |  j j	 | ƒ } | rƒ | j
 ƒ  n  x¦ | D]ž \ }	 }
 |	 d } | r¿ t | | |
 ƒ r¿ qŠ n  | râ t | | |
 | ƒ râ qŠ n  | j |  j d |	 d d |	 d d |	 d d |	 d	 d
 |	 d ƒ ƒ PqŠ WqX W| S(   sÑ   Mark the specified items to be updated, in the minimal way.
    :param extcmds: the user specified arguments
    :return: a list of transaction members added to the
       transaction set by this function
    c         S   s   |  d S(   Ni   (    (   Rg   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyRh     s    i    Rx   t   archi   t   epochi   t   versioni   t   releasei   (   R_   R<   R^   R4   RV   Ri   Rj   t   sortedR   Rv   t   reverseR   R/   t   extendt   update(   Rb   t   extcmdst   txmbrsR    R-   t   ndataRk   t	   oldpkgtupR‡   Re   R   Rx   (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   update_minimal  s*    
#
	(   s   securitys   bugfixR   R   R   ('   t   os.pathR   RO   t   yum.i18nR    R   t   yum.constantst   yum.logginglevelsR   t   rpmUtils.miscutilsR	   R9   R   R0   R   R   R   R#   R/   R3   R4   R=   RN   R   R^   R_   Ra   Rf   Rl   Ro   Rs   Ru   Ry   Rˆ   R“   R®   RÀ   RÁ   RÎ   (    (    (    s2   /usr/lib/python2.7/site-packages/yum/updateinfo.pyt   <module>   sB   
 										5"											T4.