ó
È”Mc           @   sÅ   d  d l  m Z m Z m Z m Z m Z d  d l m Z d  d l m	 Z	 d  d l
 Td  d l Z d  d l Z d  d l Z d  d l Z e d ƒ Z e d ƒ Z e d ƒ Z d	 „  Z d
 „  Z d „  Z d S(   iÿÿÿÿ(   t   Transactiont   PolicyUpgradet   UPGRADEt   INSTALLt   REMOVE(   t   OptionParser(   t   Package(   t   *Ns%   smart upgrade [options] [package] ...sC  
This command will upgrade one or more packages which
are currently installed in the system. If no packages
are given, all installed packages will be checked.

If pkgname is prefixed by a '+', it will be installed
even if it was not currently installed in the system.
If pkgname is prefixed with a '-', it will be removed.
s“   
smart upgrade
smart upgrade pkgname
smart upgrade '*kgnam*'
smart upgrade pkgname-1.0
smart upgrade pkgname-1.0-1
smart upgrade pkgname1 pkgname2
c       	   C   s†  t  d t d t d t ƒ }  t |  _ |  j d d d d t d ƒ ƒ|  j d	 d d d t d
 ƒ ƒ|  j d d d d t d ƒ ƒ|  j d d d d t d ƒ ƒ|  j d d d d t d ƒ ƒ|  j d d d d t d ƒ ƒ|  j d d d d t d ƒ ƒ|  j d d d d t d ƒ ƒ|  j d d d d d  d t d ƒ ƒ|  j d d d d d t d ƒ ƒ|  j d d d d t d ƒ ƒ|  S(    Nt   usaget   descriptiont   exampless	   --steppedt   actiont
   store_truet   helps   split operation in stepss   --urlss+   dump needed urls and don't commit operations
   --metalinks,   dump metalink xml and don't commit operations
   --downloads,   download packages and don't commit operations   --updates3   update channel information before trying to upgrades   --checks+   just check if there are upgrades to be dones   --check-updatesE   check if there are upgrades to be done, and update the known upgradess	   --explains:   include additional information about changes,when possibles   --flagt   storet   defaults+   check only upgrades with the given flag sets   -ys   --yess   do not ask for confirmations   --dumpsD   dump package names and versions to stderr but don't commit operation(	   R   t   USAGEt   DESCRIPTIONt   EXAMPLESt   Falset   allow_interspersed_argst
   add_optiont   _t   None(   t   parser(    (    s:   /usr/lib/python2.7/dist-packages/smart/commands/upgrade.pyt   option_parser5   s6    		c         C   s+   t  ƒ  } | j |  ƒ \ } } | | _ | S(   N(   R   t
   parse_argst   args(   t   argvR   t   optsR   (    (    s:   /usr/lib/python2.7/dist-packages/smart/commands/upgrade.pyt   parse_optionsV   s    		c         C   s  | j  r" t j d t d t ƒn  | j s: t j d ƒ rl d d l m } | j g  ƒ } | j |  | ƒ n
 |  j	 ƒ  |  j
 ƒ  } t | t ƒ } | j r\x| j D]±} t } | j d ƒ rÒ | d } t } n  | j d ƒ rô | d } t } n  |  j | ƒ \ } }	 }
 |	 s|
 r¯i  } x~ |
 D]v \ } } t | t ƒ re| j sU| t k r›t | | <q›q%x3 | j D]( } | j sŠ| t k rot | | <qoqoWq%W| s¯|
 2q¯n  |
 r÷t t d	 ƒ | d
 j g  | D] } d t | ƒ ^ qÑƒ f ‚ qt t d ƒ | ‚ n  t } t } xv |	 D]n } t | t ƒ r | j sJ| t k r…| j sit j | j | ƒ r…| j | | ƒ | j } n  t } q q W| s(x |	 D]‚ } t | t ƒ sŸxj | j D]\ } | j sÙ| t k r| j søt j | j | ƒ r| j } | j | | ƒ n  t } q¾WqŸqŸWn  | r¤ | t k r¤ t  j! t d ƒ | ƒ q¤ q¤ WnR xO | j" ƒ  D]A } | j ri| j s—t j | j | ƒ ri| j | t ƒ qiqiWt  j# t d ƒ ƒ | j$ ƒ  | rÚ| j% sã| j& r:t' j( j) d ƒ } t' j( j* | ƒ r/t+ | ƒ } t, j- | ƒ } | j. ƒ  n d  } | j0 ƒ  } | j1 ƒ  } | j& r¹t' j( j2 | ƒ } t' j( j3 | ƒ sŠt' j4 | ƒ n  t+ | d ƒ } t, j5 | | d ƒ | j. ƒ  n  | sÖt  j# t d ƒ ƒ d S| r$xE | D]# } | j | ƒ | | k rãPqãqãWt  j# t d ƒ ƒ d Sn  t  j# t d ƒ ƒ nÒ | sVt  j# t d ƒ ƒ n¶ t  j6 ƒ  | j7 } | j8 rƒ|  j9 | ƒ n‰ | j: rœ|  j; | ƒ np | j5 r»|  j< | d t ƒnQ | j= rÚ|  j> | d | ƒn2 | j? rù|  j@ | d | ƒn |  jA | d | ƒd  S(   Ns   explain-changesetst   softs   auto-updateiÿÿÿÿ(   t   updatet   +i   t   -s)   '%s' matches no packages. Suggestions:
%ss   
s       s   '%s' matches no packagess"   '%s' matches no installed packagess   Computing transaction...s   ~/.smart/upgradecheckt   wi   s"   No interesting upgrades available.s   There are pending upgrades!s!   There are new upgrades available!t   installt   confirm(B   t   explaint   sysconft   sett   TrueR    t   gett   smart.commandsR   t   maint   reloadChannelst   getCacheR    R   R   R   t
   startswithR   R   t   searcht
   isinstanceR   t	   installedt   packagest   ErrorR   t   joint   strR   t   flagt   pkgconft   testFlagt   enqueuet   ifacet   warningt   getPackagest
   showStatust   runt   checkt   check_updatet   ost   patht
   expandusert   isfilet   opent   cPicklet   loadt   closeR   t   getChangeSett   getPersistentStatet   dirnamet   isdirt   makedirst   dumpt
   hideStatust   yest   urlst   dumpTransactionURLst   metalinkt   dumpTransactionMetalinkt   dumpTransactionPackagest   downloadt   downloadTransactiont   steppedt   commitTransactionSteppedt   commitTransaction(   t   ctrlR   R    t
   updateoptst   cachet   transt   argt   opt   ratiot   resultst   suggestionst   dctt   rt   objt   pkgt   xt   foundanyt   foundinstalledt	   checkfilet   filet
   checkstatet	   changesett   stateRL   t   entryR%   (    (    s:   /usr/lib/python2.7/dist-packages/smart/commands/upgrade.pyR,   \   sÆ    	
	
	
	
644	!(
	

					(   t   smart.transactionR    R   R   R   R   t   smart.optionR   t   smart.cacheR   t   smartRG   t   stringt   reRB   R   R   R   R   R   R   R,   (    (    (    s:   /usr/lib/python2.7/dist-packages/smart/commands/upgrade.pyt   <module>   s   (
			!	