ó
È”Mc           @   s©   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z m Z m	 Z	 d  d l
 Td  d l Z d  d l Z d  d l Z d  d l Z d e f d „  ƒ  YZ d	 „  Z d S(
   iÿÿÿÿ(   t   RPMPackageListLoader(   t   getFileDigest(   t   PackageChannel(   t	   SUCCEEDEDt   FAILEDt   NEVER(   t   *Nt   APTRPMChannelc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         G   so   t  t |  ƒ j | Œ  | |  _ | |  _ | rb d j g  | D] } | j ƒ  s; | ^ q; ƒ |  _ n	 d  |  _ d  S(   Nt    (	   t   superR   t   __init__t   _baseurlt   _compst   joint   isspacet   _fingerprintt   None(   t   selft   baseurlt   compst   fingerprintt   argst   x(    (    s:   /usr/lib/python2.7/dist-packages/smart/channels/apt_rpm.pyR
   "   s    		!c         C   s   t  j |  j d ƒ g S(   Ns   base/release(   t	   posixpathR   R   (   R   (    (    s:   /usr/lib/python2.7/dist-packages/smart/channels/apt_rpm.pyt   getCacheCompareURLs,   s    c         C   s   t  |  j ƒ d d S(   Ni   i   (   t   lenR   (   R   (    (    s:   /usr/lib/python2.7/dist-packages/smart/channels/apt_rpm.pyt   getFetchSteps/   s    c   ,   	   C   sœ  | j  ƒ  | j t j |  j d ƒ ƒ } | j d | ƒ | j ƒ  } | r¼ | j |  j ƒ  d ƒ | j	 ƒ  | j
 ƒ  t k r¸ t d ƒ |  d | j ƒ  | f g } t d j | ƒ ‚ n  t St | j ƒ  ƒ } | |  j k r| j |  j ƒ  d ƒ | j	 ƒ  t S|  j ƒ  i  } t } t }	 x¯ t | j ƒ  ƒ D]› }
 |
 j d ƒ rPt }	 Pq1| sq|
 j d ƒ rÌt } qÌq1|
 j d	 ƒ s‰t } q1y |
 j ƒ  \ } } } Wn t k
 rµq1X| t | ƒ f | | <q1W|  j r:t j ƒ  \ } } t j ƒ  \ } } t j | d
 ƒ } t j | d
 ƒ } y{|	 s@t t d ƒ |  ‚ n  | } x? t | j ƒ  ƒ D]+ }
 |
 j d ƒ rw| } n  | j |
 ƒ qYW| j  ƒ  | j  ƒ  t! j" d | | f ƒ \ } } t } t } d  } xƒ | j$ ƒ  D]u }
 |
 j d ƒ rÚ|
 d j ƒ  } | d } | d k r"| d } qO| d k r7t } qO| d k rOt } qOqÚqÚW| rot t d ƒ |  ‚ n  | s…| |  j k r›t t d ƒ |  ‚ n  Wn~ t k
 r} | j |  j ƒ  d ƒ | j	 ƒ  | j  ƒ  | j  ƒ  t j% | ƒ t j% | ƒ | j
 ƒ  t k r‚  q7t Sq:Xt j% | ƒ t j% | ƒ n  | j  ƒ  g  } g  } xµ|  j& D]ª} d | }  t j |  j |  ƒ }! |  d | k r¬|  }" |  d 7}  |! d 7}! nb |  d | k rÙ|  }" |  d 7}  |! d 7}! n5 |  | k rt' j( t d ƒ | |  f ƒ qZn d  }" i | d 6t d 6}# | |  \ |# d <|# d <|" r[| |" \ |# d <|# d <n  | j) | j |! |#  ƒ d | }$ |$ | k ràt j |  j |$ ƒ }! i | d 6}# | |$ \ |# d <|# d <| j) | j |! |#  ƒ qZ| j d ƒ | j	 ƒ  | j) d  ƒ qZW| j d | ƒ g  }% x#t* t+ | ƒ ƒ D]}& | |& }' | |& }( |' j, ƒ  t- k rd  }) |( rÜ|( j, ƒ  t- k rÜyD x= t |( j ƒ  ƒ D]) }
 |
 j d  ƒ r‘t |
 d! ƒ }) Pq‘q‘WWqÜt. t f k
 rØqÜXn  |' j ƒ  }* t/ |* |  j |) ƒ }+ |+ j0 |  ƒ |  j1 j) |+ ƒ q1|% j) d" |' j ƒ  |' j ƒ  f ƒ q1W|% r| j
 ƒ  t k r‹|% j2 d t d ƒ |  ƒ t d j |% ƒ ‚ n  t S| |  _ t S(#   Ns   base/releaset   progressi   s&   Failed acquiring information for '%s':s   %s: %ss   
s
   -----BEGINs   MD5Sum:t    t   ws.   Channel '%s' has fingerprint but is not signeds<   gpg --batch --no-secmem-warning --status-fd 1 --verify %s %ss   [GNUPG:]i   i    t   VALIDSIGt   GOODSIGt   BADSIGs   Channel '%s' has bad signatures$   Channel '%s' signed with unknown keys   base/pkglist.s   .bz2s   .gzs6   Component '%s' is not in release file for channel '%s't	   componentt   uncompt   md5t   sizet
   uncomp_md5t   uncomp_sizes   base/release.s   PackageCount:i   u   %s: %s(3   t   resett   enqueueR   R   R   t   runt   getFailedReasont   addR   t   showt
   getCachingR   t   _t   getURLt   Errort   FalseR   t   getTargetPatht   _digestt   Truet   removeLoaderst   opent
   startswitht   splitt
   ValueErrort   intR   t   tempfilet   mkstempt   ost   fdopent   writet   closet   commandst   getstatusoutputR   t
   splitlinest   unlinkR   t   ifacet   warningt   appendt   rangeR   t	   getStatusR   t   IOErrorR    t
   setChannelt   _loaderst   insert(,   R   t   fetcherR   t   itemt   failedt   linest   digestt   md5sumt   insidemd5sumt   hassignaturet   lineR#   R$   t   patht   rfdt   rnamet   sfdt   snamet   rfilet   sfilet   filet   statust   outputt   badsigt   goodsigt   validsigt   tokenst   firstt   et   pkgitemst   relitemst   compt   pkglistt   urlt   upkglistt   infot   releaset
   errorlinest   it   pkgitemt   relitemt   countt	   localpatht   loader(    (    s:   /usr/lib/python2.7/dist-packages/smart/channels/apt_rpm.pyt   fetch2   s"   



		
	


	










	(   t   __name__t
   __module__R
   R   R   Rv   (    (    (    s:   /usr/lib/python2.7/dist-packages/smart/channels/apt_rpm.pyR       s   	
		c         C   sH   t  | d | d j ƒ  | d | d |  | d | d | d | d ƒ	 S(	   NR   t
   componentsR   t   typet   namet   manualt	   removablet   priority(   R   R8   (   t   aliast   data(    (    s:   /usr/lib/python2.7/dist-packages/smart/channels/apt_rpm.pyt   createÝ   s    
(   t   smart.backends.rpm.headerR    t   smart.util.filetoolsR   t   smart.channelR   t   smart.constR   R   R   t   smartR   R;   RA   R=   R   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/smart/channels/apt_rpm.pyt   <module>   s   
½