mò
Î©ìPc        
   @   s,  d  k  Z  d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z e a	 d „  Z
 d f  d „  ƒ  YZ d „  Z d e j o¨d  k Z e ƒ  Z d d d d	 d
 d d d d d g
 Z y& e i e  i d d e ƒ \ Z Z Wn" e i j
 o Z e e ƒ n Xh  Z x  e D] Z e d e e d <qWe Z e i d ƒ o e d e _ n e d ƒ e i d ƒ o e e d ƒ e _ n e d ƒ e i d ƒ o e e d ƒ e _ n e d ƒ e i d ƒ o e e d ƒ e _ n e d ƒ e i d ƒ o e d e _ n e d ƒ e i d ƒ o e d e _ n e d ƒ e i d ƒ o e d e _ n e d  ƒ e i d! ƒ o e d! e _ n e d" ƒ e i d# ƒ o e d# e _  n e i d$ ƒ o e! e d% ƒ e _" n e i# ƒ  Z$ x& e% d e& e$ ƒ ƒ D] Z' e$ e' GHqWe  i( d ƒ n d  S(&   Nc         C   s   t  d  j o t i ƒ  a  t  i d ƒ n t i |  t i ƒ } t  i
 | ƒ } t i | ƒ d | d | d | d | d f S(   Niÿÿÿÿs   %s-%s-%s.%s.rpmt   namet   versiont   releaset   arch(   t   _tst   Nonet   rpmt   TransactionSett
   setVSFlagst   ost   opent   pkgfilet   O_RDONLYt   fdt   hdrFromFdnot   ht   close(   R   R   R   (    (    t&   /usr/lib/anaconda-runtime/splittree.pyt   nvra!   s     t   Timberc           B   st   t  Z d  Z d „  Z e d „ Z e e d „ Z d „  Z d „  Z d „  Z	 d d „ Z
 d	 „  Z d
 „  Z d „  Z RS(   s   Split trees like no otherc         C   s÷   d d d |  _ d d d |  _ d d d |  _ d |  _ d |  _ d |  _ d |  _ d |  _	 d |  _
 d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ d |  _ g  |  _ g  |  _ g  |  _ d |  _ d d	 d
 d d d d g |  _ g  |  _ d S(   s  self.release_str : the name and version of the product"
     
self.package_order_file : the location of the file which has
the package ordering
        
self.arch : the arch the tree is intended for
        
self.real_arch : the arch found in the unified tree's
.discinfo file
        
self.dist_dir : the loaction of the unified tree

self.src_dir : the location of the unified SRPM dir
        
self.start_time : the timestamp that's in .discinfo files
        
self.dir_info : The info other than start_time that goes
into the .discinfo files. The info should already exist
after running buildinstall in the unified tree
        
self.total_discs : total number of discs
        
self.total_bin_discs : total number of discs with RPMs
        
self.total_srpm_discs : total number of discs with SRPMs
        
self.reverse_sort_srpms : sort the srpms in reverse order to
fit. Usually only needed if we share a disc between SRPMs
and RPMs. Set to 1 to turn on.

self.reserve_size : Additional size needed to be reserved on the first disc.
f640.0f1024.0i   f1.2f10.0i    t   anacondas   beta_eula.txtt   EULAt   READMEt   GPLs   RPM-GPG-KEYs   RPM-GPG-KEY-betas   RPM-GPG-KEY-fedoraN(   t   selft   target_sizet   fudge_factort
   comps_sizet   reserve_sizeR   t   release_strt   package_order_fileR   t	   real_archt   dist_dirt   src_dirt
   start_timet   dir_infot   total_discst	   bin_discst	   src_discst   product_patht   bin_listt   src_listt   shared_listt   reverse_sort_srpmst   common_filest   logfile(   R   (    (    R   t   __init__/   s.    ! 																	c         C   s›   | oM t i d | d ƒ } | i ƒ  } | i ƒ  t t	 i
 | ƒ d ƒ } | SnD t i d | d ƒ } | i ƒ  } | i ƒ  t	 i
 | ƒ d } | Sd S(   s#   Gets the size as reported by du -sLs   du -sL --block-size=1 %st   ri    s
   du -sLh %sN(   t	   blocksizeR	   t   popent   patht   pt   readt   thesizeR   t   longt   stringt   split(   R   R2   R0   R5   R3   (    (    R   t   getSizej   s     

c         C   sŠ   | o |  i i d | | f ƒ n | o |  i i d | | f ƒ n |  i d |  i | f ƒ } |  i i d |  i	 | | f ƒ d S(   s   appends to self.logfiles   First package on disc%d: %ss   Last package on disc%d : %ss	   %s-disc%ds   %s-disc%d size: %sN(
   t   firstpkgR   R-   t   appendt   disct   lastpkgR9   R    t   discsizeR   (   R   R<   R:   R=   R>   (    (    R   t   reportSizes|   s     c         C   sš  t  i i d |  i ƒ p t d ‚ n |  i p· t d |  i d ƒ } | i	 ƒ  d  |  _ | i	 ƒ  d  |  _
 | i	 ƒ  d  |  _ |  i |  i j o t d ‚ n | i	 ƒ  | i	 ƒ  d  | i	 ƒ  d  | i	 ƒ  d  g |  _ | i ƒ  n t d |  i | f d ƒ } | i d |  i ƒ | i |  i
 d	 ƒ | i |  i d	 ƒ | i d | ƒ x8 t d
 t |  i ƒ ƒ D] } | i |  i | d	 ƒ qjW| i ƒ  d S(   s.   creates the .discinfo files in the split treess   %s/.discinfosK   CRITICAL ERROR : .discinfo doesn't exist in the unified tree, not splittingR/   iÿÿÿÿs<   CRITICAL ERROR : self.real_arch is not the same as self.archs   %s-disc%d/.discinfot   ws   %s
s   
i    N(   R	   R2   t   existsR   R    t   RuntimeErrorR"   R
   t   filet   readlineR   R   R   R#   R   t
   discnumbert   discinfo_filet   writet   ranget   lent   i(   R   RE   RF   RJ   RC   (    (    R   t   createDiscInfo‰   s,     

0 c   	      C   sg   x` | D]X } d | | f } d | | f } y t i | | ƒ Wq t j
 o \ } } q Xq Wd S(   si   Creates hardlinks from files in the unified dir to files in the split dirs. This is not for RPMs or SRPMss   %s/%sN(   t   filelistRC   R!   t   srct   dest_dirt   destR	   t   linkt   OSErrort   errnot   msg(	   R   R!   RN   RL   RM   RO   RR   RS   RC   (    (    R   t	   linkFiles¬   s      c   	   
   C   s  |  i |  i j p |  i |  i j o t d ‚ n t d |  i d ƒ |  _ t |  i |  i d |  i d ƒ |  _ t |  i |  i d |  i d ƒ |  _ x_t |  i d |  i d d ƒ D]<} | d j oÖt
 i d |  i d ƒ } | i ƒ  } | i ƒ  t i | ƒ } t
 i d |  i d ƒ } | i ƒ  } | i ƒ  t i | ƒ } g  } x= t d t | ƒ ƒ D]& } t i | | |  i d ƒ | | <qgWx> t d t | ƒ ƒ D]' } t
 i d	 |  i | | | f ƒ q§Wx¬ t d t | ƒ ƒ D]• } t i | | |  i d ƒ | | <yQ t
 i t
 i i d
 |  i | | f ƒ t
 i i d	 |  i | | | f ƒ ƒ Wqèt j
 o \ } } qèXqèWt
 i d |  i | |  i f ƒ nG t
 i d |  i | |  i f ƒ |  i  |  i d |  i | f |  i! ƒ |  i" | ƒ q¼ W|  i d j o} xz t |  i d |  i d d ƒ D]S } t
 i d |  i | f ƒ |  i  |  i d |  i | f |  i! ƒ |  i" | ƒ q.Wn d S(   s²   Figures out which discs are for RPMs, which are for SRPMs,
        and which are shared. Also creates links for files on disc1
        and files which are common across all discssL   CRITICAL ERROR : Number of discs specified exceeds the total number of discsi   i    iÿÿÿÿs%   find %s/ -type f -not -name .discinfoR/   s1   find %s/ -type d -not -name RPMS -not -name SRPMSt    s   %s-disc%d/%ss   %s/%ss   %s-disc%d/%s/RPMSs	   %s-disc%ds   %s-disc%d/SRPMSN(#   R   R%   R$   R&   RB   RH   R(   R)   R*   RJ   R	   R1   R    R3   R4   RL   R   R7   R8   t   dirlistt   dont_createRI   t   jt   replacet   makedirsRP   R2   t   normpathRQ   RR   RS   R'   RT   R,   RK   (	   R   RV   RX   RJ   RR   RW   RL   R3   RS   (    (    R   t   createSplitDirs¹   sX     &''" 

 $ %  &+	$ &" 
i   c      	   C   s|  h  } t i i d |  i |  i f ƒ o d |  i f } n d |  i f } t i d |  i | f ƒ } | i
 ƒ  x~ | D]v } t i i d |  i | | f ƒ }	 t d |  i | | f ƒ } | i | ƒ o | | i | ƒ qz | g | | <qz Wg  } t |  i d ƒ } xH | i ƒ  D]: } t i | ƒ } | d d !d	 j o | i | ƒ qqW| i ƒ  d
 } d } |  i d } xÑ| D]É} | i | ƒ p qn x©| | D]} |  i  d |  i | f d d ƒ} |  i  d |  i | | f d d ƒ}	 |	 | } | d j o |  i# |  i$ |  i% } n
 |  i# } | d } | d j o
 | } n | | j o® |  i( | d | d | ƒyf |  i i) | d ƒ }
 |  i |
 } t i+ d |  i | | f d |  i | | | f ƒ d } | } WqF| d } |  i, i d | ƒ q©qFXq©t i+ d |  i | | f d |  i | | | f ƒ | } q©WqW| d j o |  i( | d | d | ƒn d S(   s,   Creates links in the split dirs for the RPMss
   %s/%s/RPMSs   %s/RPMSs   %ss   %s/%ss   %s/%s/%sR/   i    i   s   warning:RU   s	   %s-disc%sR0   i   R:   R=   s   %s-disc%d/%s/%ss4   No more discs to put packages, overflowing on disc%dN(.   t   packagesR	   R2   t   isdirR   R    R'   t   pkgdirt   listdirt   rpmlistt   sortt   filenamet   getsizet   filesizeR   t   pkg_nvrt   has_keyR;   t   orderedlistR
   R   RC   t	   readlinesR7   t   rstripR   t   lastpackaget
   packagenumR(   R<   t   rpm_nvrt	   file_nameR9   t   curusedt   newsizeR   R   R   t   maxsizet   firstpackageR?   t   indext   nextdiscRP   R-   t
   reportSize(   R   Ru   Rn   R<   RC   Rr   Rf   Rc   Rq   Re   Rt   Rk   Rp   R]   Rh   Rm   Ra   R_   Ro   Rl   (    (    R   t	   splitRPMSø   st     #
 " 
  "%
	



c         C   sx   g  } x] t d t |  i ƒ ƒ D]C } | i |  i d |  i |  i | f d d ƒ|  i | g ƒ q W| i	 ƒ  | d S(   s,   Returns the least full tree to use for SRPMSi    s	   %s-disc%dR0   i   N(
   t   sizesRH   RI   R   R)   RJ   R;   R9   R    Rb   (   R   RJ   Rw   (    (    R   t   getLeastUsedTreeU  s      A
c         C   sò  g  } |  i } xS t i d |  i ƒ D]; } |  i d |  i | f d d ƒ} | i
 | | g ƒ q& W| i ƒ  | i ƒ  xAt d t | ƒ ƒ D]*} xÚ |  i D]Ï } |  i d |  i | f d d ƒ|  i j o t |  i ƒ d j  o' |  i i
 d | | d | f ƒ Pqn|  i d	 |  i | | f ƒ } |  i i
 d
 |  i | | f ƒ |  i i |  i i | ƒ ƒ qŸ qŸ Wt i d |  i | | d f d |  i |  i ƒ  d | | d f ƒ q Wx. t d t | ƒ ƒ D] } |  i | | ƒ qÓWd S(   s›   Puts the srpms onto the SRPM split discs. The packages are
        ordered by size, and placed one by one on the disc with the
        most space availables   %ss   %s/%sR0   i   i    s	   %s-disc%si   s   Overflowing %s on disc%ds	   %s-disc%ds   %s-disc%d size: %ss   %s-disc%d/SRPMS/%sN(   t	   srpm_listR   R)   t   srpm_disc_listR	   R`   R!   t   srpmR9   t	   srpm_sizeR;   Rb   t   reverseRH   RI   RJ   R<   R    R   R-   R>   R   t   popRs   RP   Rx   R?   (   R   Ry   RJ   R>   R|   Rz   R<   R{   (    (    R   t
   splitSRPMS`  s2     	 "

 
 ,"  $- c         C   s9   |  i ƒ  |  i ƒ  |  i d j o |  i ƒ  n |  i S(   s   Just runs everythingi    N(   R   R\   Rv   R&   R   R-   (   R   (    (    R   t   main„  s     

(   t   __name__t
   __module__t   __doc__R.   R   R9   R?   RK   RT   R\   Rv   Rx   R   R€   (    (    (    R   R   -   s    	;	#		?]		$c         C   s&   |  GHd t i d GHt i d ƒ d  S(   Nsä   Usage: %s --arch=i386 --total-discs=8 --bin-discs=4 --src-discs=4 --release-string="distro name" --pkgorderfile=/tmp/pkgorder.12345 --distdir=/usr/src/someunifiedtree --srcdir=/usr/src/someunifiedtree/SRPMS --productpath=producti    i   (   t   theerrort   syst   argvt   exit(   R„   (    (    R   t   usageŽ  s    t   __main__s   arch=s   total-discs=s
   bin-discs=s
   src-discs=s   release-string=s   pkgorderfile=s   distdir=s   srcdir=s   productpath=s   reserve-size=i   RU   i    s   --archs   You forgot to specify --archs   --total-discss#   You forgot to specify --total-discss   --bin-discss!   You forgot to specify --bin-discss   --src-discss!   You forgot to specify --src-discss   --release-strings&   You forgot to specify --release-strings   --pkgorderfiles$   You forgot to specify --pkgorderfiles	   --distdirs   You forgot to specify --distdirs   --srcdirs   You forgot to specify --srcdirs   --productpaths   --reserve-sizes   --reserve_size()   R…   R	   t   os.pathR7   t   getoptt   timet   typesR   R   R   R   R   Rˆ   R   t   timbert   theargsR†   t   optionst   argst   errort   myoptsRJ   Rg   R   t   intR$   R%   R&   R   R   R    R!   R'   t   floatR   R€   R-   RH   RI   t   logentryR‡   (   R   R   RŽ   R   Rˆ   R‹   R7   R‘   R…   R-   R   RJ   RŒ   R–   R’   R	   R   R“   R   (    (    R   t   ?   sv   								 	ÿ b			$& 







 