ó
Qº’Nc           @   s0  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d Z	 d Z
 e	 e	 d „ Z e	 d „ Z e	 d „ Z e	 d „ Z e d k r,e j ƒ  d	 k sÞ d
 GHe j d ƒ n  d e j d	 <e j d e j d d d d ƒ e j d e j d	 ƒ e j j e
 ƒ rne
 Z e
 d Z e j d e e f ƒ e j e e ƒ n  e j j e	 ƒ se j d ƒ e j d	 ƒ n  e j j e	 ƒ d	 k rße j d ƒ e j e	 ƒ e j d	 ƒ n  e	 d e j d ƒ Z e j d e ƒ e j  e	 e ƒ e j j d ƒ r`d e! e	 ƒ j" ƒ  k r`e j d e	 ƒ e d ƒ n  e j j d ƒ r©d e! e	 ƒ j" ƒ  k r©e j d e	 ƒ e d ƒ n  e j# d  d! d" d# g d$ e j$ ƒj% ƒ  d	 Z& e j d% e& ƒ e& r,e j' e& d& ƒ d	 k r,e ƒ  se ƒ  q)e j d' ƒ q,n  d S((   iÿÿÿÿNs   /etc/X11/xorg.confs   /etc/X11/XF86Config-4c         C   s¶  t  j d ƒ g  } t } x_t |  ƒ D]Q} | j ƒ  } | j ƒ  j d ƒ r¶ | j ƒ  j d ƒ d j ƒ  j d ƒ r¶ t  j d ƒ | j	 d ƒ | j	 d ƒ | j	 d | ƒ t
 } q& | j ƒ  j d	 ƒ rë | rë | j	 d | ƒ t } q& | j ƒ  j d
 ƒ r?t  j d | ƒ | j	 d ƒ | j	 d ƒ | j	 d | ƒ q& | rjt  j d | ƒ | j	 d | ƒ q& | j	 | ƒ q& Wt | d d ƒ j d j | ƒ ƒ t j | d | ƒ t
 S(   Nt   remove_input_devicest   sectiont   #i    s   "inputdevice"s   found 'InputDevice' sectionsL   # commented out by update-manager, HAL is now used and auto-detects devices
sA   # Keyboard settings are now read from /etc/default/console-setup
t
   endsectiont   inputdevices   commenting out '%s' s   .newt   wt    (   t   loggingt   debugt   Falset   opent   stript   lowert
   startswitht   splitt   endswitht   appendt   Truet   writet   joint   ost   rename(   t   xorg_sourcet   xorg_destinationt   contentt   in_input_devicest   rawt   line(    (    sD   /usr/lib/python2.7/dist-packages/DistUpgrade/xorg_fix_proprietary.pyR       s6    (		#c         C   s1  t  j j | ƒ s' t j d | ƒ d Sg  } x‘ t | ƒ D]ƒ } | j d ƒ d j ƒ  } | j ƒ  j	 d ƒ r° | j
 d |  ƒ r° t j d | ƒ d | } t j d	 | ƒ n  | j | ƒ q: Wt | ƒ j ƒ  | k r-t j d
 | |  | f ƒ t | d d ƒ j d j | ƒ ƒ t  j | d | ƒ n  d S(   se   
    this removes old_driver driver from the xorg.conf and subsitutes
    it with the new_driver
    s   file %s not foundNR   i    t   drivers   "%s"s   line '%s' founds   	Driver	"%s"
s   replacing with '%s's   saveing new %s (%s -> %s)s	   .xorg_fixR   R   (   R   t   patht   existsR   t   warningR
   R   R   R   R   R   R   R   t	   readlinest   infoR   R   R   (   t
   old_drivert
   new_drivert   xorgR   R   t   s(    (    sD   /usr/lib/python2.7/dist-packages/DistUpgrade/xorg_fix_proprietary.pyt   replace_driver_from_xorg5   s     
#c         C   s.  t  j j | ƒ s' t j d | ƒ d Sg  } x‘ t | ƒ D]ƒ } | j d ƒ d j ƒ  } | j ƒ  j	 d ƒ r° | j
 d |  ƒ r° t j d | ƒ d | } t j d	 | ƒ n  | j | ƒ q: Wt | ƒ j ƒ  | k r*t j d
 | |  f ƒ t | d d ƒ j d j | ƒ ƒ t  j | d | ƒ n  d S(   s3   
    this comments out a driver from xorg.conf
    s   file %s not foundNR   i    R   s   "%s"s   line '%s' founds   #%ss   replacing with '%s's   saveing new %s (commenting %s)s	   .xorg_fixR   R   (   R   R   R   R   R   R
   R   R   R   R   R   R   R   R    R!   R   R   R   (   R"   R$   R   R   R%   (    (    sD   /usr/lib/python2.7/dist-packages/DistUpgrade/xorg_fix_proprietary.pyt   comment_out_driver_from_xorgN   s     
#c         C   s>   d „  } t  t | t |  ƒ ƒ ƒ } t j d | ƒ | d k S(   s*    check if we have a multiseat xorg config c         S   s/   |  j  ƒ  j d ƒ o. |  j  ƒ  j ƒ  j d ƒ S(   NR   s   "serverlayout"(   R   R   R   R   (   R   (    (    sD   /usr/lib/python2.7/dist-packages/DistUpgrade/xorg_fix_proprietary.pyt   is_serverlayout_lineh   s    s   is_multiseat: lines %ii   (   t   lent   filterR
   R   R   (   R   R(   t   msl(    (    sD   /usr/lib/python2.7/dist-packages/DistUpgrade/xorg_fix_proprietary.pyt   is_multiseatf   s    	t   __main__i    s   Need to run as rooti   s   /usr/bin/update-managert   levelt   filenames$   /var/log/dist-upgrade/xorg_fixup.logt   filemodeR   s
   %s runnings	   .obsoletes   renaming obsolete %s -> %ss   No xorg.conf, exitings    xorg.conf is zero size, removings   .dist-upgrade-s
   %Y%m%d%H%Ms   creating backup '%s's*   /usr/lib/xorg/modules/drivers/fglrx_drv.sot   fglrxs   Removing fglrx from %ss+   /usr/lib/xorg/modules/drivers/nvidia_drv.sot   nvidias   Removing nvidia from %ss
   dpkg-querys   -Ws   -f=${Version}s   xserver-xorg-coret   stdouts!   xserver-xorg-core version is '%s's   2:1.5.0s   multiseat setup, ignoring((   t   aptt   sysR   t   os.pathR   t   timet   shutilt
   subprocesst   apt_pkgt	   XORG_CONFt   OBSOLETE_XORG_CONFR    R&   R'   R,   t   __name__t   getuidt   exitt   argvt   basicConfigt   DEBUGR!   R   R   t   oldt   newR   t   getsizet   removet   strftimet   backupR   t   copyR
   t   readt   Popent   PIPEt   communicatet   vert   VersionCompare(    (    (    sD   /usr/lib/python2.7/dist-packages/DistUpgrade/xorg_fix_proprietary.pyt   <module>   sh   	
.	
