ó
È”Mc           @   sˆ  d  d l  m Z d  d l m Z d  d l m Z y d  d l m Z WnI e k
 r y d  d l	 m Z Wn! e k
 r‹ d  d l
 m Z n Xn Xd  d l m Z m Z m Z m Z d  d l m Z m Z d  d l Td  d l Z d  d l Z d  d l Z d  d	 l m Z d
 Z e d Z e d Z e d Z e d Z d Z e d Z e d Z  e d Z! e d Z" d e e f d „  ƒ  YZ# d „  Z$ d S(   iÿÿÿÿ(   t   RPMMetaDataLoader(   t   RPMUpdateInfo(   t   getFileDigest(   t   ElementTree(   t	   SUCCEEDEDt   FAILEDt   NEVERt   ALWAYS(   t   PackageChannelt   MirrorsChannel(   t   *N(   t   expats%   {http://linux.duke.edu/metadata/repo}t   datat   locationt   checksums   open-checksums   {http://www.metalinker.org/}t   filest   filet	   resourcest   urlt   RPMMetaDataChannelc           B   sh   e  Z i  Z d  Z d	 Z d	 d	 d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z RS(
   t    c         G   sM   t  t |  ƒ j | Œ  | |  _ | |  _ | rI d j | j ƒ  ƒ |  _ n  d  S(   NR   (   t   superR   t   __init__t   _baseurlt   _mirrorlistt   joint   splitt   _fingerprint(   t   selft   baseurlt
   mirrorlistt   fingerprintt   args(    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyR   ?   s
    		c         C   s   t  j |  j d ƒ g S(   Ns   repodata/repomd.xml(   t	   posixpathR   R   (   R   (    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyt   getCacheCompareURLsF   s    c         C   s   |  j  r d Sd Sd  S(   Ni   i   (   R   (   R   (    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyt   getFetchStepsI   s    	c   
      C   sú  |  j  j ƒ  y t j | ƒ j ƒ  } WnC t j t f k
 rk } t j	 t
 d ƒ ƒ t j t | ƒ ƒ d  SXd  } x| j ƒ  D]s} | j t k r© | j d ƒ } q n | j t k r¾ q n  x1| j ƒ  D]#} | j t k ræ qË n  | j d ƒ } | j d ƒ } | d k r.| d k r.| d k r.qË n  | j }	 |	 rË |	 j d ƒ ra|	 j d d	 ƒ }	 n2 | r“|	 j d
 | ƒ r“|	 j d
 | d	 ƒ }	 n  |  j |  j  k rØ|	 |  j  |  j k rë|  j  |  j j |	 ƒ qëqî|	 g |  j  |  j <qË qË Wq Wd  S(   Ns8   Could not load meta link. Continuing with base URL only.t   namet   typet
   preferencet   httpt   ftpR   s   /repodata/repomd.xmlR   t   /(   t   _mirrorst   clearR   t   parset   getrootR   t   errort   SyntaxErrort   ifacet   warningt   _t   debugt   unicodet   Nonet   getiteratort   tagt   FILEt   gett	   RESOURCESt   getchildrent   URLt   textt   endswitht   replaceR   t   append(
   R   t   metalinkfilet   roott   et   filenamet   nodet   subnodeR%   R&   t   mirror(    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyt   loadMetalinkO   s>    $	c         C   s  |  j  j ƒ  y t | d ƒ } Wn: t k
 r\ } t j t d ƒ ƒ t j t | ƒ ƒ d  SXx§ | D]Ÿ } | d k rƒ |  j	 | ƒ S| d d k rd | j
 ƒ  } | r|  j |  j  k rê | |  j  |  j k rý |  j  |  j j | ƒ qý q | g |  j  |  j <qqd qd Wd  S(   Nt   rs:   Could not load mirror list. Continuing with base URL only.s'   <?xml version="1.0" encoding="utf-8"?>
i    t   #(   R*   R+   t   opent   IOErrorR0   R1   R2   R3   R4   RH   t   stripR   R@   (   R   t   mirrorlistfileR   RC   t   lineRG   (    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyt   loadMirrorss   s"    c         C   sQ  i  } y t  j | ƒ j ƒ  } Wn; t j t f k
 r\ } t t d ƒ | t | ƒ f ‚ n Xxí | j	 ƒ  D]ß } | j
 t k r… qj n  | j d ƒ } i  | | <x¨ | j	 ƒ  D]š } | j
 t k ré t j |  j | j d ƒ ƒ | | d <n  | j
 t k r| j | | | j d ƒ <n  | j
 t k r« | j | | d | j d ƒ <q« q« Wqj W| S(   Ns   Invalid XML file:
  %s
  %sR%   t   hrefR   t   uncomp_(   R   R,   R-   R   R.   R/   t   ErrorR2   t   strR;   R7   t   DATAR9   t   LOCATIONR!   R   R   t   CHECKSUMR=   t   OPENCHECKSUM(   R   t   metadatafilet   infoRB   RC   RE   R%   RF   (    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyt   loadMetadata‰   s&    
))c         C   sD   d d l  m } | j ƒ  j | ƒ } | | | | ƒ } | j | ƒ S(   Niÿÿÿÿ(   t	   FetchItem(   t   smart.fetcherR\   t   getMirrorSystemR9   t   getLocalPath(   R   t   fetcherR   R\   RG   t   item(    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyR_   £   s    c   "      C   s<  | j  ƒ  |  j r¯ |  j } | j | ƒ } | j d | ƒ | j ƒ  t k r | j |  j ƒ  d ƒ | j ƒ  t	 k r¢ t
 j t d ƒ ƒ q¢ n |  j | j ƒ  ƒ | j  ƒ  n | j d ƒ t j |  j d ƒ } t j |  j d ƒ } i  } |  j | | ƒ } t j j | ƒ r:y |  j | ƒ } Wq:t k
 r6q:Xn  | j | ƒ } |  j rd| j | ƒ }	 n  | j d | ƒ | j ƒ  t k rô| j |  j ƒ  d ƒ | j ƒ  t	 k rðt d ƒ |  d | j ƒ  | j ƒ  f g }
 t d j |
 ƒ ‚ n  t S|  j rH|	 j ƒ  t k r1t t d	 ƒ |  |	 j ƒ  f ‚ n  t j d
 |	 j ƒ  | j ƒ  f ƒ \ } } t } t } d  } xƒ | j ƒ  D]u } | j  d ƒ r{| d j! ƒ  } | d } | d k rÃ| d } qð| d k rØt" } qð| d k rðt" } qðq{q{W| rt t d ƒ |  ‚ n  | s/|  j rH| |  j k rHt t d ƒ |  ‚ qHn  t# | j ƒ  ƒ } | |  j$ k rz| j d ƒ t" S|  j% ƒ  |  j | j ƒ  ƒ } d | k rÇd | k rÇt t d ƒ |  ‚ n  d | k rà| d } n
 | d } d | k r| d } n
 | d } | j  ƒ  | j | d d | j& d ƒ d | j& d ƒ d | j& d ƒ d | j& d ƒ d | j& d ƒ d | j& d ƒ d t" ƒ} | j | d d | j& d ƒ d | j& d ƒ d | j& d ƒ d | j& d ƒ d | j& d ƒ d | j& d ƒ d t" ƒ} d  | k ru| j | d  d d | d  j& d ƒ d | d  j& d ƒ d | d  j& d ƒ d | d  j& d ƒ d t" ƒ} n  | j d | ƒ | j ƒ  t' k ro| j ƒ  t' k ro| j ƒ  } | j ƒ  } t( | | |  j ƒ } | j) |  ƒ |  j* j+ | ƒ d  | k rJ| j ƒ  t' k r@| j ƒ  } t, | ƒ } | j- ƒ  | j. ƒ  qlt
 j t d! ƒ | j ƒ  | j ƒ  f ƒ qJnÛ | j ƒ  t' k rÒ| j ƒ  t k rÒ| j ƒ  t/ k rÒt
 j t d" ƒ | j ƒ  | j ƒ  f ƒ t S| j ƒ  t	 k rF| j ƒ  t k rÿ| } n | } t d# ƒ |  d | j ƒ  | j ƒ  f g }
 t d j |
 ƒ ‚ n t S| j0 ƒ  } xÖ d d d$ d d d% g D]¼ } | | k ro| | d }  |  r+| | d | | d k r+|  j | |  ƒ } t j j | ƒ råt j1 | ƒ n  | j2 | ƒ }! |! j | ƒ } t j j | ƒ r(t j1 | ƒ q(q+qoqoW| |  _$ t" S(&   Nt   progressi   s:   Could not load mirror list. Continuing with base URL only.s   repodata/repomd.xmls   repodata/repomd.xml.ascs'   Failed acquiring release file for '%s':u   %s: %ss   
s=   Download of repomd.xml.asc failed for secure channel '%s': %ss<   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 keyt   primaryt   primary_lzmas=   Primary information not found in repository metadata for '%s't   filelists_lzmat	   filelistsR   t   md5t
   uncomp_md5t   shat
   uncomp_shat   sha256t   uncomp_sha256t   uncompt
   updateinfosc   Failed to download. You must fetch channel information to acquire needed update information.
%s: %ssZ   Failed to download. You must fetch channel information to acquire needed filelists.
%s: %ss&   Failed acquiring information for '%s':t   othert
   other_lzma(3   t   resetR   t   enqueuet   runt	   getStatusR   t   addR#   t
   getCachingR   R0   R1   R2   RP   t   getTargetPathR!   R   R   R_   t   ost   patht   existsR[   RS   R   t   getURLt   getFailedReasont   Falset   commandst   getstatusoutputR5   t
   splitlinest
   startswithR   t   TrueR   t   _digestt   removeLoadersR9   R   R    t
   setChannelt   _loadersR@   R   t   loadt   setErrataFlagsR   t   getUncompressort   unlinkt
   getHandler("   R   R`   Rb   R   Ra   t   repomdt   reposigt   oldinfoR|   t   gpgitemt   linest   statust   outputt   badsigt   goodsigt   validsigRO   t   tokenst   firstt   digestRZ   Rf   Ri   t   flitemt   uiitemt	   localpatht   filelistspatht   loadert   erratat
   faileditemt   uncompressorR%   R   t   handler(    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyt   fetch©   s    
					"
	




		$	
 		"	N(   t   __name__t
   __module__R*   R   R5   R   R   R"   R#   RH   RP   R[   R_   R¥   (    (    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyR   7   s   			$			c         C   sB   t  | d | d | d | d |  | d | d | d | d ƒ	 S(	   NR   R   R   R%   R$   t   manualt	   removablet   priority(   R   (   t   aliasR   (    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyt   createZ  s    
(%   t   smart.backends.rpm.metadataR    t   smart.backends.rpm.updateinfoR   t   smart.util.filetoolsR   t	   xml.etreeR   t   ImportErrort   elementtreet   smart.util.elementtreet   smart.constR   R   R   R   t   smart.channelR   R	   t   smartR!   R   R{   t   xml.parsersR   t   NSRU   RV   RW   RX   t   MLt   FILESR8   R:   R<   R   R¬   (    (    (    s9   /usr/lib/python2.7/dist-packages/smart/channels/rpm_md.pyt   <module>   s:   "








ÿ $