ó
ß™xTc           @   s÷   d  Z  d d l m Z d d l Td d l m Z d d l j Z d d l	 Z	 d d l
 Z
 d d l Z d d l Z e j e j e j e ƒ ƒ ƒ Z e e j k r² e j j e ƒ n  e j d „ Z e d k ró e e j d ƒ só e j d ƒ qó n  d S(	   sr   
Create a graphical Mac installer for a complete installation of CCTBX or
Phenix (or any other derived software).
iÿÿÿÿ(   t   division(   t   *(   t   OptionParserNc      
   C   s  t  j d k r d GHt Sd t j d <t j d t j ƒ  ƒ } t ƒ  } | j	 d d d d	 d
 d d d t j
 ƒ  ƒ| j	 d d d d	 d
 d d d d ƒ| j	 d d d d	 d
 d d d | ƒ| j	 d d d d	 d
 d d d d  ƒ| j	 d d d d	 d
 d d d d  ƒ| j	 d d d d	 d
 d d d d ƒ| j	 d d d  d	 d
 d d! d t ƒ  ƒ| j	 d" d d# d	 d$ d d% ƒ| j	 d& d d' d	 d$ d d( ƒ| j |  ƒ \ } }  t j ƒ  d) } d* } | d+ k rÐd, } n  | d- t ƒ  7} t |  ƒ d. k rüd/ GHt S|  d0 } | j d1 ƒ sd2 GHt St j | ƒ s6d3 GHt St j | ƒ } | d4 k rZd5 } n  d6 }	 t j |	 ƒ r‘| j s�d7 GHt St j |	 ƒ n  t j |	 ƒ d8 | j j ƒ  | j f }
 |
 d9 | j } |
 d: } d; | j |
 f } t j d< ƒ t d= d> ƒ } | j d? i | j d@ 6| j d 6| dA 6| dB 6ƒ g  } xe t j  | ƒ D]T } | j! dC ƒ rMt j" | | ƒ } t j | ƒ s‰qMn  | j# dD | d. ƒ qMqMWdE | j } t | d> ƒ } | j dF dG j" | ƒ ƒ | j$ ƒ  t j | ƒ d. } t j" d6 | ƒ } t j | ƒ t j% | | ƒ g  } | j& d  k	 r´| j& j! dH ƒ rut j' | j& dI ƒ | j# dJ dK ƒ q´| j& j! dL ƒ s�t( ‚ t j' | j& dM ƒ | j# dN dK ƒ n  | j) d  k	 ræt j' | j) dO ƒ | j# dP ƒ n  t dQ d> ƒ } | j dR i | j d@ 6| j d 6| dS 6| dT 6| j dU 6dG j" | ƒ dV 6ƒ | j$ ƒ  dW dX d6 dY | dZ | | g } t* | | ƒ d[ d\ dQ d] d< d^ d_ d | j | g
 } t* | | ƒ t j | ƒ sÀt( ‚ | j+ s| d` IJda db dc dd | | de g } t* | | ƒ t j, | de ƒ st( ‚ n  t- S(f   Nt   darwins9   ERROR: this program can only be run on Macintosh systems.t   truet   COPYFILE_DISABLEs   %Y-%m-%ds	   --tmp_dirt   destt   tmp_dirt   actiont   storet   helps   Temporary (staging) directoryt   defaults   --package_namet   package_names   Package namet   CCTBXs	   --versiont   versions   Software versions   --license_filet   license_files   License files   --backgroundt
   backgrounds   Background images   --organizationt   organizations   Organization (domain name)s   org.phenix-onlines   --machine_typet   machine_types   Machine type (OS/architecture)s   --overwritet	   overwritet
   store_trues   Overwrite temporary filess   --no_compressiont   no_compressions   Skip final compression stepiÿÿÿÿs   64-bit Intel Macst   x86_64s
   Intel Macss    (OS %s or later)i   s+   Usage: create_mac_pkg [options] PROGRAM_DIRi    t   /s   ERROR: absolute path requireds   ERROR: '%s' is not a directorys   /Applicationss   the Applications foldert   pkg_roots?   ERROR: pkg_root already exists - run with --overwrite to ignores   %s-%ss   -%s.pkgs   .pkgs   %s.%st	   resourcess   resources/welcome.txtt   ws,  This package contains %(package)s version %(version)s compiled for %(arch)s. It will install the full command-line suite and graphical launcher(s) to %(dest_name)s.  If you need to install %(package)s to a different location, you must use the command-line installer (also available from our website).t   packaget   archt	   dest_names   .apps)    <dict>
    <key>BundleHasStrictIdentifier</key>
    <true/>
    <key>BundleIsRelocatable</key>
    <true/>
    <key>BundleIsVersionChecked</key>
    <true/>
    <key>BundleOverwriteAction</key>
    <string>upgrade</string>
    <key>RootRelativeBundlePath</key>
    <string>%s</string>
  </dict>
s   %s.plistsÁ   <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
%s
</array>
</plist>
s   
s   .jpgs   resources/background.jpgs9   <background file="background.jpg" mime-type="image/jpeg" s,   alignment="topleft" scaling="proportional"/>s   .pngs   resources/background.pngs8   <background file="background.png" mime-type="image/png" s   resources/license.txts;   <license    file="license.txt"    mime-type="text/plain" />s   distribution.xmlsP  <?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
    <title>%(package)s %(version)s</title>
    <organization>%(org)s</organization>
    <domains enable_localSystem="true"/>
    <options customize="never" require-scripts="true" rootVolumeOnly="true" />
    <!-- Define documents displayed at various steps -->
    <welcome    file="welcome.txt"    mime-type="text/plain" />
    %(misc_files)s
    <pkg-ref id="%(pkg_id)s"
             version="0"
             auth="root">%(base_pkg)s</pkg-ref>
    <choices-outline>
        <line choice="%(pkg_id)s"/>
    </choices-outline>
    <choice
        id="%(pkg_id)s"
        visible="false"
        title="%(package)s"
        description="%(package)s"
        start_selected="true">
      <pkg-ref id="%(pkg_id)s"/>
    </choice>
</installer-gui-script>
t   pkg_idt   base_pkgt   orgt
   misc_filest   pkgbuilds   --roots   --identifiers   --component-plistt   productbuilds   --distributions   --resourcess   --package-patht   .s     compressing installer. . .t   dittos   -cs   -ks   -rsrcs   .zip(.   t   syst   platformt   Falset   ost   environt   timet   strftimet	   localtimeR   t
   add_optiont   getcwdt   NoneR   t
   parse_argst   unamet   get_os_versiont   lent
   startswitht   opt   isdirt   dirnamet   existsR   t   shutilt   rmtreet   mkdirR   t   lowerR   R   t   opent   writet   listdirt   endswitht   joint   appendt   closet   moveR   t   copyfilet   AssertionErrorR   t   callR   t   isfilet   True(   t   argst   outt	   datestampt   parsert   optionst	   arch_typet   system_typet   program_dirR   R   t	   base_namet   pkg_nameR   R   t   welcomet   app_bundle_xmlt	   file_namet	   full_patht
   plist_filet   plistt   rel_patht   pkg_pathR!   t   distfilet   pkg_argst   product_argst   zip_args(    (    sN   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/create_mac_pkg.pyt   run   sö    		
		

 




				
t   __main__i   (   t   __doc__t
   __future__R    t   installer_utilst   optparseR   t   os.patht   pathR6   R:   R+   R&   R)   t   abspathR8   t   __file__t   libtbx_pathRC   t   stdoutRa   t   __name__t   argvt   exit(    (    (    sN   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/auto_build/create_mac_pkg.pyt   <module>   s   
!¹