Ñò
JTúLc           @   sE  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k l	 Z	 d f  d „  ƒ  YZ
 d „  Z d f  d „  ƒ  YZ d f  d	 „  ƒ  YZ e d
 j o‚ e ƒ  Z e i d ƒ e i d ƒ e i d ƒ e i d ƒ e i d ƒ e i d ƒ d GHe i i e ƒ d GHe i d ƒ n d S(   iÿÿÿÿN(   t   ST_SIZEt   Versionc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s7   A class for holding parsed package version information.c         C   s   | |  _  | |  _ d  S(   N(   t   epocht   version(   t   selfR   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   __init__/   s    	c   
      C   sM  |  i  } | i  } x4t i d | ƒ } | i ƒ  \ } } t i d | ƒ } | i ƒ  \ } } | | j o d S| | j  o d St i d | ƒ i ƒ  \ } } t i d | ƒ i ƒ  \ }	 } | d j o t | ƒ } n d } |	 d j o t |	 ƒ }	 n d }	 | |	 j o d S| |	 j  o d S| d j o | d j o d Sq d  S(   Ns   ([^0-9]*)(.*)i   iÿÿÿÿs   ([0-9]*)(.*)t    i    (   R   t   ret   matcht   groupst   int(
   R   t   reft   selfversiont
   refversiont   selfmt	   selfalphat   refmt   refalphat   selfnumt   refnum(    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   _versioncompare3   s2    		c         C   sA   |  i  | i  j o d S|  i  | i  j  o d S|  i | ƒ Sd  S(   Ni   iÿÿÿÿ(   R   R   (   R   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   compareV   s
    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyR   -   s   		#c         C   sN   d } t  i d |  ƒ } | o" | i ƒ  \ } }  t | ƒ } n t | |  ƒ S(   Ni    s   ([0-9]*):(.*)(   R   R   R	   R
   R   (   t
   versionstrR   t   mt   epochstr(    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   parse_version^   s    t   Packagec           B   s1  e  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 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d  „  Z# RS("   sN   A class for creating objects to manipulate (e.g. create) ipkg
       packages.c         C   sÖ  d  |  _ d |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ g  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d |  _ | oót | d ƒ } | i d ƒ } | i ƒ  | d j o d |  _ n t | d ƒ } t i ƒ  } x+ | i d ƒ } | p Pn | i | ƒ q$| i ƒ  t i d  d j o | i ƒ  |  _ n( t i t d	 „  | i  ƒ  ƒ d
 ƒ |  _ t! i" | ƒ } | t# |  _ t! i$ i% | ƒ |  _ |  i o t! i& d | d d ƒ } n t! i& d | d d ƒ } | i' ƒ  } xý | p Pn t i( | ƒ } t) i* d | ƒ }	 |	 oº t i+ |	 i, d ƒ ƒ }
 |	 i, d ƒ } xN | i' ƒ  } | p Pn | d d j o Pn t i( | ƒ } | d | } q‡|
 d j o | |  _ q#|  i- i. |
 ƒ o | |  i- |
 <q#q)| i' ƒ  } q)| i ƒ  |  i o t! i& d | d d ƒ } n t! i& d | d d ƒ } x4 | i' ƒ  } | p Pn |  i i/ t i( | ƒ ƒ qu| i ƒ  n d  |  _0 d  |  _1 d  |  _2 d  S(   Nt   nonei    t   ri   s   !<ari   i   t   2c         S   s   d  t  |  ƒ S(   s   %02x(   t   ord(   t   x(    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   <lambda>•   s    R   s   ar p s4    control.tar.gz | tar --wildcards -xzOf - '*control's	   tar xfzO s7    '*control.tar.gz' | tar --wildcards -xzOf - '*control's   ([\w-]*?):\s*(.*)i   t    s   
t   filenames    data.tar.gz | tar tfz -s    '*data.tar.gz' | tar tfz -(3   t   Nonet   packageR   t   parsed_versiont   architecturet
   maintainert   sourcet   descriptiont   dependst   providest   replacest	   conflictst
   recommendst   suggestst   sectiont   filename_headert	   file_listt   md5t   sizet   installed_sizeR%   t   isdebt   opent   readt   closet   newt   updatet   syst	   hexdigestt   stringt   joint   mapt   digestt   ost   statR    t   patht   basenamet   popent   readlinet   rstripR   R   t   lowert   groupt   __dict__t   has_keyt   appendt   scratch_dirt   file_dirt   meta_dir(   R   t   fnt   ft   magict   sumt   dataRF   t   controlt   linet	   linepartst   namet   value(    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyR   j   sž    																					
 
'
   

 		c         C   s)  d d  k  } | i ƒ  } x
| p Pn t i | ƒ } t i d | ƒ } | oÇ t i | i d ƒ ƒ } | i d ƒ } x? | i ƒ  } | p Pn | d d j o Pn | d | } qy | d j o t | ƒ |  _	 n% |  i
 i | ƒ o | |  i
 | <n | d d j o d  Sq | i ƒ  } q d  S(	   Niÿÿÿÿs   ([\w-]*?):\s*(.*)i   i   i    R$   s   
R7   (   RE   RJ   RA   RK   R   R   RL   RM   R
   R7   RN   RO   (   R   RY   RE   RZ   R[   R\   R]   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   read_controlÃ   s4       	c         C   ss   d t  i ƒ  t  i ƒ  f |  _ d |  i |  _ d |  i |  _ t i |  i ƒ t i |  i ƒ t i |  i ƒ d  S(   Ns	   %s/%sipkgs   %s/filess   %s/meta(   t   tempfilet
   gettempdirt   gettempprefixRQ   RR   RS   RE   t   mkdir(   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   _setup_scratch_areaÞ   s    c         C   s   | |  _  d  S(   N(   R'   (   R   R'   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_packageè   s    c         C   s   |  i  S(   N(   R'   (   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_packageë   s    c         C   s   | |  _  t | ƒ |  _ d  S(   N(   R   R   R(   (   R   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_versionî   s    	c         C   s   |  i  S(   N(   R   (   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_versionò   s    c         C   s   | |  _  d  S(   N(   R)   (   R   R)   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_architectureõ   s    c         C   s   |  i  S(   N(   R)   (   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_architectureø   s    c         C   s   | |  _  d  S(   N(   R*   (   R   R*   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_maintainerû   s    c         C   s   |  i  S(   N(   R*   (   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_maintainerþ   s    c         C   s   | |  _  d  S(   N(   R+   (   R   R+   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt
   set_source  s    c         C   s   |  i  S(   N(   R+   (   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt
   get_source  s    c         C   s   | |  _  d  S(   N(   R,   (   R   R,   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_description  s    c         C   s   |  i  S(   N(   R,   (   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_description
  s    c         C   s   | |  _  d  S(   N(   R-   (   R   R-   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_depends  s    c         C   s   |  i  S(   N(   R-   (   R   R-   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_depends  s    c         C   s   | |  _  d  S(   N(   R.   (   R   R.   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_provides  s    c         C   s   |  i  S(   N(   R.   (   R   R.   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_provides  s    c         C   s   | |  _  d  S(   N(   R/   (   R   R/   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_replaces  s    c         C   s   |  i  S(   N(   R/   (   R   R/   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_replaces  s    c         C   s   | |  _  d  S(   N(   R0   (   R   R0   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_conflicts  s    c         C   s   |  i  S(   N(   R0   (   R   R0   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_conflicts"  s    c         C   s   | |  _  d  S(   N(   R2   (   R   R2   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_suggests%  s    c         C   s   |  i  S(   N(   R2   (   R   R2   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_suggests(  s    c         C   s   | |  _  d  S(   N(   R3   (   R   R3   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   set_section+  s    c         C   s   |  i  S(   N(   R3   (   R   R3   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_section.  s    c         C   s   |  i  S(   N(   R5   (   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   get_file_list1  s    c   	      C   s¯  |  i  ƒ  } t d |  i d ƒ } | i | ƒ |  i ƒ  d |  i |  i f } t i | ƒ \ } } } x | i ƒ  d j o qj W| i	 ƒ  | i	 ƒ  | i	 ƒ  d } |  i
 ou d |  i |  i f } t i | ƒ \ } } } x | i ƒ  d j o qá W| i	 ƒ  | i	 ƒ  | i	 ƒ  | d } n d |  i |  i |  i f } d	 |  i | | | f } t i | ƒ \ } } } x | i ƒ  d j o quW| i	 ƒ  | i	 ƒ  | i	 ƒ  d  S(
   Ns
   %s/controlt   ws*   cd %s ; tar cvfz %s/control.tar.gz controlR   s   control.tar.gzs   cd %s ; tar cvfz %s/data.tar.gzs    data.tar.gzs   %s_%s_%s.ipks   cd %s ; tar cvfz %s/%s %s(   t   render_controlR:   RS   t   writeRc   RQ   RE   t   popen3RJ   R<   R5   RR   R'   R   R)   (	   R   t   dirnamet   buft   filet   cmdt   cmd_outt   cmd_int   cmd_errt   bits(    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   write_package4  sJ    
	 



	 


	
 

c         C   s‡   |  i  p d |  i GHn | i  p d | i GHn |  i p t |  i  ƒ |  _ n | i p t | i  ƒ | _ n |  i i | i ƒ S(   s(   Compare package versions of self and refs   No version for package %s(   R   R'   R(   R   R   (   R   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   compare_versionf  s    



c         C   s/  d } |  i  o | d |  i  } n |  i o | d |  i } n |  i o | d |  i } n |  i o | d |  i } n |  i o | d |  i } n |  i o | d |  i } n |  i o | d |  i } n |  i o | d	 |  i } n |  i o | d
 |  i } n |  i	 o | d |  i	 } n |  i
 o | d |  i
 } n |  i o | d |  i } n |  i o | d t |  i ƒ } n |  i o | d t |  i ƒ } n |  i o | d |  i } n |  i o | d |  i } n |  i o | d |  i } n | d } | S(   NR   s   Package: %s
s   Version: %s
s   Depends: %s
s   Provides: %s
s   Replaces: %s
s   Conflicts: %s
s   Suggests: %s
s   Recommends: %s
s   Section: %s
s   Architecture: %s
s   Maintainer: %s
s   MD5Sum: %s
s	   Size: %d
s   InstalledSize: %d
s   Filename: %s
s   Source: %s
s   Description: %s
s   
(   R'   R   R-   R.   R/   R0   R2   R1   R3   R)   R*   R6   R7   R
   R8   R%   R+   R,   (   R   t   out(    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   __repr__r  sJ    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c         C   s   d  S(   N(    (   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   __del__  s    N($   R   R   R   R&   R   R^   Rc   Rd   Re   Rf   Rg   Rh   Ri   Rj   Rk   Rl   Rm   Rn   Ro   Rp   Rq   Rr   Rs   Rt   Ru   Rv   Rw   Rx   Ry   Rz   R{   R|   R‰   RŠ   RŒ   R   (    (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyR   g   sB   Y		
																										2		t   Packagesc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s:   A currently unimplemented wrapper around the ipkg utility.c         C   s   h  |  _  d  S(   N(   t   packages(   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyR   ”  s    	c         C   s}   | i  } | i } d | | f } |  i i | ƒ p | |  i | <n | i |  i | ƒ d j o | |  i | <d Sd Sd  S(   Ns   %s:%si    i   (   R'   R)   R   RO   RŠ   (   R   t   pkgR'   t   archR\   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   add_package˜  s    		c         C   sX   t  | d ƒ } x8 t ƒ  } | i | ƒ | i ƒ  o |  i | ƒ q Pq | i ƒ  d  S(   NR   (   R:   R   R^   Re   R’   R<   (   R   RT   RU   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   read_packages_file¥  s    	
c         C   sW   t  | d ƒ } |  i i ƒ  } | i ƒ  x( | D]  } | i |  i | i ƒ  ƒ q/ Wd  S(   NR}   (   R:   R   t   keyst   sortR   RŒ   (   R   RT   RU   t   namesR\   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   write_packages_file±  s    
 c         C   s   |  i  i ƒ  S(   N(   R   R”   (   R   (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyR”   ¹  s    c         C   s   |  i  | S(   N(   R   (   R   t   key(    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   __getitem__¼  s    (	   R   R   R   R   R’   R“   R—   R”   R™   (    (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyRŽ   ’  s   					t   __main__t   FooBars   0.1-fam1t   arms!   Testing <testing@testing.testing>t   libcs   A test of the APIs.t   <t   >s   /tmp(   R_   RE   R?   t   globR6   R   RA   t   commandsRF   R    R   R   R   RŽ   R   R'   Rd   Rf   Rh   Rj   Rp   Rn   t   stdoutR   R‰   (    (    (    s*   /home/obiwan/src/ipkg-utils-050831/ipkg.pyt   <module>#   s2   1		ÿ ,-	