
Nc           @   s  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  d l	 Z	 d  d l
 Z
 d  d l Z d  d l m Z m Z d  d l m Z d  d l m Z m Z d  d l m Z d  d l m Z d e f d     YZ d S(	   iN(   t   PIPEt   Popen(   t   md5(   t   lsmodt   get_arch(   t   gettext(   t   PluginManagert   DistUpgradeQuirksc           B   s  e  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  d   Z! d    Z" d!   Z# d"   Z$ d#   Z% d$   Z& d% d&  Z' d'   Z( d(   Z) d)   Z* d*   Z+ d+   Z, d,   Z- d-   Z. d.   Z/ d/   Z0 d0   Z1 d1   Z2 d2   Z3 d3   Z4 d4   Z5 d5   Z6 d6   Z7 d7   Z8 d8   Z9 d% d9  Z: d:   Z; d;   Z< d<   Z= d= d>  Z> d?   Z? d@   Z@ dA   ZA dB dC  ZB dM dD  ZD dE   ZE dF   ZF dG   ZG dH   ZH dI dJ  ZI dK   ZJ dL   ZK RS(N   s   
    This class collects the various quirks handlers that can
    be hooked into to fix/work around issues that the individual
    releases have
    c         C   sq   | |  _  | j |  _ | |  _ t d d g d t j   d j   |  _ t   |  _	 t
 |  j  d g  |  _ d  S(   Nt   unames   -rt   stdouti    s	   ./plugins(   t
   controllert   _viewt   configR   R    t   communicatet   stripR   R   t   archR   t   plugin_manager(   t   selfR
   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   __init__0   s    		+c         C   s  |  j  j r t j d  d Sx | d |  j j d d  | f d |  j j d d  | f g D]> } x5 |  j j |  D]! } t j d |  | j	   qx Wq_ Wd	 | } t
 |  | d  } | d k	 r t j d
 |  |   n  d |  j j d d  | f } t
 |  | d  } | d k	 r<t j d
 |  |   n  d |  j j d d  | f } t
 |  | d  } | d k	 rt j d
 |  |   n  d S(   s  
        Run the specific quirks handler, the follow handlers are supported:
        - PreCacheOpen: run *before* the apt cache is opened the first time
                        to set options that affect the cache
        - PostInitialUpdate: run *before* the sources.list is rewritten but
                             after a initial apt-get update
        - PostDistUpgradeCache: run *after* the dist-upgrade was calculated
                                in the cache
        - StartUpgrade: before the first package gets installed (but the
                        download is finished)
        - PostUpgrade: run *after* the upgrade is finished successfully and 
                       packages got installed
        - PostCleanup: run *after* the cleanup (orphaned etc) is finished
        s)   not running quirks in partialUpgrade modeNs   %s%st   Sourcest   Tos	   from_%s%st   Froms   running quirks plugin %ss   %ss   quirks: running %s(   R
   t   _partialUpgradet   loggingt   infoR   t   getR   t   get_pluginst   debugt   do_cleanup_cruftt   getattrt   None(   R   t
   quirksNamet	   conditiont   plugint   funcnamet   func(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   run<   s2    &


c         C   s   t  j d  d S(   s3    run before the apt cache is opened the first time s   running Quirks.PreCacheOpenN(   R   R   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   PreCacheOpeno   s    c         C   sn   t  j d  t j j j d  d k rj t  j d  t j j j d d  t j j j d t d   n  d  S(   Ns"   running Quirks.oneiricPreCacheOpens   Apt::Architecturet   amd64s5   multiarch: enabling i386 as a additional architectures   Apt::Architectures::t   i386s   APT::Cache-Starti0   i   i   i   (   R   R   t   aptt   apt_pkgR   t   findt   sett   str(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   oneiricPreCacheOpens   s
    c         C   s   t  j d  d S(   s    run after cleanup s   running Quirks.PostCleanupN(   R   R   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   PostCleanup   s    c         C   s%   t  j d  |  j   |  j   d S(   s5    this works around quirks for dapper->hardy upgrades s,   running Controller.from_dapperQuirks handlerN(   R   R   t   _rewriteFstabt   _checkAdminGroup(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   from_dapperPostUpgrade   s    
c         C   s   t  j d  |  j   d S(   s4    this applies rules for the hardy->intrepid upgrade s)   running Controller.intrepidQuirks handlerN(   R   R   t   _addRelatimeToFstab(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   intrepidPostUpgrade   s    c         C   s   t  j d  d S(   s@    this function works around quirks in the feisty->gutsy upgrade s&   running Controller.gutsyQuirks handlerN(   R   R   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   gutsyPostUpgrade   s    c         C   s%   t  j d  |  j   |  j   d S(   s?    this function works around quirks in the edgy->feisty upgrade s'   running Controller.feistyQuirks handlerN(   R   R   R/   R0   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   feistyPostUpgrade   s    
c         C   s%   t  j d  |  j   |  j   d S(   sA    this function works around quirks in the jaunty->karmic upgrade s,   running Controller.karmicPostUpgrade handlerN(   R   R   t   _ntfsFstabFixupt   _checkLanguageSupport(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   karmicPostUpgrade   s    
c         C   s5   t  j d t j   j j  |  j   |  j   d S(   s    Quirks that are run before the sources.list is updated to the
            new distribution when upgrading from a lucid system (either
            to maverick or the new LTS)
        s
   running %sN(   R   R   t   syst	   _getframet   f_codet   co_namet   _test_and_fail_on_non_i686t   _test_and_warn_on_i8xx(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   from_lucidPostInitialUpdate   s    
c         C   s   |  j    d  S(   N(   R>   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   oneiricPostInitialUpdate   s    c         C   s?   t  j d t j   j j  |  j   |  j   |  j   d S(   sA    quirks that are run before the sources.list is updated to lucid s
   running %sN(	   R   R   R9   R:   R;   R<   t   _test_and_fail_on_non_arm_v6t   _test_and_warn_if_vservert'   _test_and_warn_on_dropped_fglrx_support(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   lucidPostInitialUpdate   s    

c         C   s,   |  j    |  j   |  j   |  j   d  S(   N(   t   hardyPostDistUpgradeCachet   gutsyPostDistUpgradeCachet   feistyPostDistUpgradeCachet   edgyPostDistUpgradeCache(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   from_dapperPostDistUpgradeCache   s    


c         C   s   t  j d t j   j j  |  j   |  j   |  j   ry t  j	 d  |  j
 j	 t d  t d   |  j j   n  |  j   |  j   |  j   |  j   d S(   s:    this function works around quirks in upgrades from hardy s
   running %ss   evms in use in /etc/fstabs   evms in uses   Your system uses the 'evms' volume manager in /proc/mounts. The 'evms' software is no longer supported, please switch it off and run the upgrade again when this is done.N(   R   R   R9   R:   R;   R<   t   _kernel386TransitionCheckt   _kubuntuDesktopTransitiont   _usesEvmsInMountst   errorR   t   _R
   t   abortt   _checkAndInstallBroadcomt"   _dealWithLanguageSupportTransitiont   _test_and_warn_on_old_nvidiat#   _test_and_warn_on_nvidia_and_no_sse(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   from_hardyPostDistUpgradeCache   s    




c         C   s   |  j    d S(   so   
        this function works around quirks in the 
        maverick -> natty cache upgrade calculation
        N(   t%   _add_kdegames_card_extra_if_installed(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   nattyPostDistUpgradeCache   s    c         C   s   |  j    |  j   d S(   sg   
        this function works around quirks in the 
        lucid->maverick upgrade calculation
        N(   t   _add_extras_repositoryt   _gutenprint_fixup(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   maverickPostDistUpgradeCache   s    
c         C   s,   |  j    |  j   |  j   |  j   d S(   sg    
        this function works around quirks in the 
        jaunty->karmic upgrade calculation
        N(   RP   RQ   RJ   t   _mysqlClusterCheck(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   karmicPostDistUpgradeCache   s    


c         C   sM  t  j d t j   j j  xu d g D]j } |  j j j |  r' |  j j | j	 r' |  j j | j
 r' t  j d |  |  j j | j   q' q' Wx d d g D] } |  j j j |  r |  j j | j	 r |  j j | j
 r t  j d |  |  j j j d  r.t  j d  |  j j d j   n  |  j j | j   q q Wd	 S(
   si    
        this function works around quirks in the 
        intrepid->jaunty upgrade calculation
        s
   running %ss   pidgin-libnotifys   forcing '%s' upgradet   gwenviewt   digikams   forcing libkipi '%s' upgradet   libkipi0s   removing  libkipi0)N(   R   R   R9   R:   R;   R<   R
   t   cachet   has_keyt   is_installedt   marked_upgradet   mark_upgradet   mark_delete(   R   t   pkg(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   jauntyPostDistUpgradeCache   s     c         C   s   t  j d t j   j j  d } d } |  j j j |  r |  j j | j	 r |  j j j |  r |  j j j
 | d  n  d S(   s]    
        this function works around quirks in the 
        hardy->intrepid upgrade 
        s
   running %ss   kdelibs4-devs   kdelibs5-devs'   kdelibs4-dev -> kdelibs5-dev transitionN(   R   R   R9   R:   R;   R<   R
   R_   R`   Ra   t   mark_install(   R   t   frompt   to(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   intrepidPostDistUpgradeCache  s    c         C   sD  t  j d t j   j j  |  j j j d  r |  j j d j	 r |  j j d j
 r xM d D]E } |  j j j |  r` |  j j | j	 r` |  j j | j   q` q` W|  j j d j   n  |  j   |  j j d d  d k r@xX |  j j D]G } | j j d  r | j	 r | j
 r |  j j j | j d  q q Wn  d	 S(
   sc    
        this function works around quirks in the 
        {dapper,gutsy}->hardy upgrade 
        s
   running %st   nautiluss   link-monitor-applett   Optionst   withNetworkt   Trues   language-support-s   extra language-support- kickN(   R   R   R9   R:   R;   R<   R
   R_   R`   Ra   Rb   Rd   Rg   t   _checkAndRemoveEvmsR   R   t   namet
   startswith(   R   t   brokenRe   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRE     s    (
	
c         C   s  t  j d t j   j j  y |  j j d  \ } } } | d k s_ | d k s_ | d k r d } |  j j	 | j
 p |  j j	 | j s t  j d |  |  j j	 | j   q n  Wn$ t k
 r } t  j d |  n Xy x t t j t d	   D] } | d
 k s | j d  r!q n  y" | j   \ } } }	 }
 } } Wn' t k
 rl} t  j d |  q n Xd |	 k r t  j d |  |  j j	 d j   Pq q WWn$ t k
 r} t  j d |  n Xd S(   s@    this function works around quirks in the feisty->gutsy upgrade s
   running %st   -t
   lowlatencyt   686t   k7s   linux-image-generics   Selecting new kernel '%s's2   problem while transitioning lowlatency kernel (%s)s   /proc/mountst    t   #s   can't parse line '%s't   nfss=   found nfs mount in line '%s', marking nfs-common for install s
   nfs-commons9   problem while transitioning util-linux -> nfs-common (%s)N(   R   R   R9   R:   R;   R<   R   t   splitR
   R_   Ra   t   marked_installRg   t	   Exceptiont   warningt   mapt   stringR   t   openRq   RM   (   R   t   versiont   buildt   flavourt   kernelt   et   linet   devicet   mount_pointt   fstypet   optionst   at   b(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRF   7  s6    &"c         C   s   t  j d t j   j j  x d g D] \ } } |  j j j |  r' |  j j j |  r' |  j j | j	 r |  j j | j
 r y$ |  j j j | d | | f  Wq t k
 r } t  j d | | | f  q Xq q' q' Wd S(   s?    this function works around quirks in the edgy->feisty upgrade s
   running %ss   ndiswrapper-utils-1.8s   ndiswrapper-utils-1.9s   %s->%s quirk upgrade rules#   Failed to apply %s->%s install (%s)N(   s   ndiswrapper-utils-1.8s   ndiswrapper-utils-1.9(   R   R   R9   R:   R;   R<   R
   R_   R`   Ra   R{   Rg   t   SystemErrorR}   (   R   t   frRi   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRG   W  s    *'$c         C   s  t  j d t j   j j  xN|  j j D]@} | j j	 d  r | j
 r | j r d | j t d  } |  j j j |  r |  j j | j r |  j j | j r y |  j j j | d  Wq t k
 r } t  j d | | f  q Xq n  | j j	 d  r* | j
 r* | j r* y |  j j j | j d  Wqjt k
 rf} t  j d | j | f  qjXq* q* Wx d	 d
 d g D] } |  j j j |  r~|  j j | j
 r~|  j j | j r~|  j j | j r~y |  j j j | d |  Wq!t k
 r} t  j d | | f  q!Xq~q~W|  j j j d  r|  j j d } | j | j k rd | j k rx | j j D] } d | j k rxxn | j D]` \ } } |  j j j j |  } | r| j rt  j d  |  j j j j | j |  PqqWqxqxWqn  x d g D] \ }	 }
 |  j j j |	  r|  j j j |
  r|  j j |	 j
 r|  j j |
 j ry$ |  j j j |
 d |	 |
 f  Wqt k
 r} t  j d |	 |
 | f  qXqqqWd S(   s?    this function works around quirks in the dapper->edgy upgrade s
   running %ss
   python2.4-s   python-s   python2.4->python upgrade rules2   Failed to apply python2.4->python install: %s (%s)s   xserver-xorg-input-s   xserver-xorg-input fixup rules   Failed to apply fixup: %s (%s)t   hpijst   bzrt   tomboys   %s quirk upgrade rules   Failed to apply %s install (%s)s   libgl1-mesa-dris   +cvs2006s   ~2006s@   Forcing downgrade of libgl1-mesa-dri for xgl.compz.info installss   xserver-xorg-driver-alls   xserver-xorg-video-alls   %s->%s quirk upgrade rules#   Failed to apply %s->%s install (%s)N(   s   xserver-xorg-driver-alls   xserver-xorg-video-all(   R   R   R9   R:   R;   R<   R
   R_   Rp   Rq   Ra   Rb   t   lenR`   t   candidateDownloadableR{   Rg   R   t   isUpgradablet   candidateVersiont   installedVersiont   _pkgt   VersionListt   VerStrt   FileListt   _listt	   FindIndext	   IsTrustedR   t	   _depcachet   SetCandidateVer(   R   Re   t   basepkgR   t   pkgnamet   vert   VerFileItert   indext	   indexfileR   Ri   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRH   d  s^    	
!	
%('"*'$c         C   s   t  j d t j   j j  |  j j j d  r |  j j d j	 r |  j j j d  r |  j j d j	 r t  j d  |  j j j
 d  |  j j j d  n  d S(   sA    this function works around quirks in the breezy->dapper upgrade s
   running %ss
   nvidia-glxs   nvidia-settingss+   nvidia-settings and nvidia-glx is installedN(   R   R   R9   R:   R;   R<   R
   R_   R`   Ra   t   mark_removeRg   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   dapperPostDistUpgradeCache  s    ((c         C   sT   |  j    |  j   |  j   |  j   |  j   |  j   |  j   |  j   d  S(   N(   t   _applyPatchest   _removeOldApportCrashest   _removeBadMaintainerScriptst   _killUpdateNotifiert   _killKBluetootht   _killScreensavert   _pokeScreensavert   _stopDocvertConverter(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   StartUpgrade  s    






c         C   s   t  j d  |  j j } t j j d  r t j j d  r d } t j j |  sf t j |  n  t  j d |  t j	 d |  t j
 t j j | d  d  n  t j j j d  d	 k r |  j d
 d  n  d  S(   Ns   oneiric StartUpgrade quirkss   /usr/sbin/update-grubs%   /etc/kernel/postinst.d/zz-update-grubs   /etc/kernel/postinst.ds   copying zz-update-grub into %ss   zz-update-grubi  s   Apt::ArchitectureR&   t   foreign_archR'   (   R   R   R
   R_   t   ost   patht   existst   makedirst   shutilt   copyt   chmodt   joinR(   R)   R   R*   t   _enable_multiarch(   R   R_   t	   targetdir(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   oneiricStartUpgrade  s    "c         C   s   t  j d  |  j   d  S(   Ns   from_hardyStartUpgrade quirks(   R   R   t   _stopApparmor(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   from_hardyStartUpgrade  s    c         C   st   |  j    d } t j j |  rp d } t t |  j    j   | k rp t j	 d |  t j
 |  qp n  d  S(   Ns   /var/lib/dpkg/info/hal.postinstt    146145275900af343d990a4dea968d7cs   removing bad script '%s'(   t   _createPycentralPkgRemoveR   R   R   R   R   t   readt	   hexdigestR   R   t   unlink(   R   t   apt   md5sum(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   jauntyStartUpgrade  s    
$c         C   s   d t  j k r d t  j k r t j d d t  j d d d g d t j j   d } d	 | k r t j d d t  j d d d
 g  q n  t S(   Nt   DISPLAYt	   SUDO_USERt   sudos   -us   ./theme-switch-helper.pys   -gR	   i    t   Cruxs
   --defaults(   R   t   environt
   subprocessR   R    R   t   callRn   (   R   t   out(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   dapperStartUpgrade  s    c         C   s   t    } y" t j d d g d t j } Wn t k
 r? | SXxA | j   d j d  D]& } | rZ | j | j   d  qZ qZ W| S(   s8    return a set of pci ids of the system (using lspci -n) t   lspcis   -nR	   i    s   
i   (   R+   R   R   R    t   OSErrorR   Rz   t   add(   R   R   t   pR   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   _get_pci_ids  s    	" c         C   s   d d d d d d d g } |  j    } t |  j |  r| |  j j t d  t d	   } | t k r| |  j j   q| n  d  S(
   Ns	   8086:7121s	   8086:7125s	   8086:1132s	   8086:3577s	   8086:2562s	   8086:3582s	   8086:2572sB   Your graphics hardware may not be fully supported in Ubuntu 11.04.s   The support in Ubuntu 11.04 for your intel graphics hardware is limited and you may encounter problems after the upgrade. Do you want to continue with the upgrade?(	   R   R+   t   intersectionR   t   askYesNoQuestionRN   t   FalseR
   RO   (   R   t   I8XX_PCI_IDSR   t   res(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR>     s    			c         C   s   |  j  j } x d d d g D] } | j |  r | | j r |  j d  r t j d |  |  j   s t j d  |  j	 j
 t d  t d   } | t k r |  j  j   n  |  j  j | j   q q q Wd	 S(
   s    The current 
        s   nvidia-glx-180s   nvidia-glx-185s   nvidia-glx-195t   nvidias   found %s video drivers7   nvidia driver that needs SSE but cpu has no SSE supportsh   Upgrading may reduce desktop effects, and performance in games and other graphically intensive programs.s   This computer is currently using the NVIDIA 'nvidia' graphics driver. No version of this driver is available that works with your video card in Ubuntu 10.04 LTS.

Do you want to continue?N(   R
   R_   R`   R{   t   _checkVideoDriverR   R   t   _cpuHasSSESupportR}   R   R   RN   R   RO   t	   mark_keep(   R   R_   R   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRS     s    c         C   s   |  j  j } x d d g D] } | j |  r | | j r |  j d  r t j d |  |  j j t	 d  t	 d   } | t
 k r |  j  j   n  |  j  j | j   q q Wd S(   s?    nvidia-glx-71 and -96 are no longer in the archive since 8.10 s   nvidia-glx-71s   nvidia-glx-96R   s   found %s video driversh   Upgrading may reduce desktop effects, and performance in games and other graphically intensive programs.s   This computer is currently using the NVIDIA 'nvidia' graphics driver. No version of this driver is available that works with your video card in Ubuntu 10.04 LTS.

Do you want to continue?N(   R
   R_   R`   R{   R   R   R   R   R   RN   R   RO   R   (   R   R_   R   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRR   %  s    c         C   s   |  j  d  r |  j d  r |  j j t d  t d   } | t k r\ |  j j   n  t j	 d  |  j j
 j d d  } | j d  | j d  | j d	  | j d
  | j d  | j d  |  j j
 j d d d j |   n  d S(   si   
        Some cards are no longer supported by fglrx. Check if that
        is the case and warn
        t   fglrxsh   Upgrading may reduce desktop effects, and performance in games and other graphically intensive programs.s   This computer is currently using the AMD 'fglrx' graphics driver. No version of this driver is available that works with your hardware in Ubuntu 10.04 LTS.

Do you want to continue?sC   remove xorg-driver-fglrx,xorg-driver-fglrx-envy,fglrx-kernel-sourcet   Distrot   PostUpgradePurges   xorg-driver-fglrxs   xorg-driver-fglrx-envys   fglrx-kernel-sources   fglrx-amdcccles   xorg-driver-fglrx-devt   libamdxvba1t   ,N(   R   t   _supportInModaliasesR   R   RN   R   R
   RO   R   R   R   t   getlistt   appendR+   R   (   R   R   t   l(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRC   @  s    c         C   sw   |  j  d k rs t j d  |  j   ss t j d  t d  } t d  } |  j j | |  |  j j   qs n  d S(   s   
        Test and fail if the cpu is not i686 or more or if its a newer
        CPU but does not have the cmov feature (LP: #587186)
        R'   s   checking for i586 CPUs   not a i686 or no cmovs   No i686 CPUs   Your system uses an i586 CPU or a CPU that does not have the 'cmov' extension. All packages were built with optimizations requiring i686 as the minimal architecture. It is not possible to upgrade your system to a new Ubuntu release with this hardware.N(	   R   R   R   t   _cpu_is_i686_and_has_cmovRM   RN   R   R
   RO   (   R   t   summaryt   msg(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR=   a  s    s   /proc/cpuinfoc         C   s   t  j j |  s' t j d |  t St |  j   } t j	 d | t j
  rb t j d  t St j	 d | t j
  } | r d | j d  j   k r t j d | j d   t j d  t Sn  t S(	   Ns   cannot open %s ?!?s   ^cpu family\s*:\s*[345]\s*s    found cpu family [345], no i686+s   ^flags\s*:\s*(.*)t   cmovi   s   found flags '%s's   can not find cmov in flags(   R   R   R   R   RM   Rn   R   R   t   ret   searcht	   MULTILINER   R   t   groupRz   (   R   t   cpuinfo_patht   cpuinfot   match(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   v  s    c         C   sS   |  j  d k rO |  j   sO |  j j t d  t d   } |  j j   qO n  d S(   s    
        Test and fail if the cpu is not a arm v6 or greater,
        from 9.10 on we do no longer support those CPUs
        t   armels   No ARMv6 CPUs   Your system uses an ARM CPU that is older than the ARMv6 architecture. All packages in karmic were built with optimizations requiring ARMv6 as the minimal architecture. It is not possible to upgrade your system to a new Ubuntu release with this hardware.N(   R   t   _checkArmCPUR   RM   RN   R
   RO   (   R   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRA     s
    c         C   sy   y t  j d d  Wn^ t j d  |  j j t d  t d   } | t k rd |  j j	   n  |  j j
   n Xd S(   sd   
        upstart and vserver environments are not a good match, warn
        if we find one
        i   i    s   no init founds   No init availables  Your system appears to be a virtualised environment without an init daemon, e.g. Linux-VServer. Ubuntu 10.04 LTS cannot function within this type of environment, requiring an update to your virtual machine configuration first.

Are you sure you want to continue?N(   R   t   killR   t   warnR   R   RN   R   R
   RO   t   processEvents(   R   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRB     s    		c         C   s   t  } d } d } |  j j | d  r| t } xL |  j j | d  D]2 } | |  j j j |  oq |  j j | j M} qC Wn  | r t j	 d | | f  |  j j | j
   n  d S(   sy   
        check if a key depends of kubuntu-kde4-desktop is installed
        and transition in this case as well
        s   kubuntu-kde4-desktops   kubuntu-desktopt   KeyDependenciess(   transitioning %s to %s (via key depends)N(   R   R   R   Rn   R
   R_   R`   Ra   R   R   Rg   (   R   t
   deps_foundt   frompkgt   topkgRe   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRK     s    c         C   sA  t  j d  |  j j j d  r=|  j j d j r=t j d d d d d d g  } t  j d	 |  | d
 k r$t  j d  x d D] } |  j j j | d  |  j j j	 } xh d d g D]Z } | j r | j
 | j  r t  j d | j  t } t } | j | j | |  q q Wq Wq=|  j j j d d  n  d S(   si   
        check if ndb clustering is used and do not upgrade mysql
        if it is (LP: #450837)
        RZ   s   mysql-servert   egreps   -qs   -is   -rs7   ^[^#]*ndb.connectstring|^[:space:]*\[[:space:]*ndb_mgmds   /etc/mysql/s   egrep returned %si    s.   mysql clustering in use, do not upgrade to 5.1s   mysql-clients   clustering in uses   mysql-server-5.0s   mysql-client-5.0s   marking '%s' manual installeds   no clustering in useN(   s   mysql-servers   mysql-client(   R   R   R
   R_   R`   Ra   R   R   R   R   t   IsAutoInstalledR   Rp   R   Rn   t   Mark_installRc   (   R   t   retRe   t   depcachet   autoInstDepst   fromUser(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRZ     s(    $c         C   sb   t  j d  t j j d  s0 t  j d  t St d  } t j	 d | j
   t j  r^ t St S(   sE   
        parse /proc/cpuinfo and search for ARMv6 or greater
        s   checking for ARM CPU versions   /proc/cpuinfos   cannot open /proc/cpuinfo ?!?s   ^Processor\s*:\s*ARMv[45](   R   R   R   R   R   RM   R   R   R   R   R   R   Rn   (   R   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR     s    c      	   C   s   t  j d  x |  j j D] } |  j j j } | j j d  r | j r x | j D] } xx | j	 D]m } |  j j | j } | j rd | j
 | j  rd t  j d | j  t } t } | j | j | |  qd qd WqT Wq q Wd S(   s   
        In karmic the language-support-translations-* metapackages
        are gone and the direct dependencies will get marked for
        auto removal - mark them as manual instead
        s*   language-support-translations-* transitions   language-support-translationss   marking '%s' manual installedN(   R   R   R
   R_   R   Rp   Rq   Ra   t   installedDependenciest   or_dependenciesR   R   R   Rn   Rg   (   R   Re   R   t   dp_ort   dpnamet   dpR   R  (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRQ     s    	c         C   s  t  j j d  s# t j d  d St j d g d t j } x | j   d j	   D] } |  j
 j j |  rU |  j
 j | j rU t j d |  d } d	 } xU d D]J } t  j j t  j j | |   r t j t  j j | |  |  d Sq WqU qU Wd S(   s   
        check if the language support is fully installed and if
        not generate a update-notifier note on next login
        s   /usr/bin/check-language-supports#   no check-language-support availableNs   check-language-supportR	   i    s%   language support package '%s' missings   /usr/share/language-support/s   /var/lib/update-notifier/user.ds&   incomplete-language-support-gnome.notes#   incomplete-language-support-qt.note(   s&   incomplete-language-support-gnome.notes#   incomplete-language-support-qt.note(   R   R   R   R   R   R   R   R    R   Rz   R
   R_   R`   Ra   R   R   R   (   R   R   R   t   baset   target(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR7     s    
!c         C   s9   t  j d  d t   k r5 |  j j j d d  n  d S(   sr   
        check for the 'wl' kernel module and install bcmwl-kernel-source
        if the module is loaded
        s   checking for 'wl' modulet   wls   bcmwl-kernel-sources   'wl' module found in lsmodN(   R   R   R   R
   R_   Rg   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRP     s    c         C   s9   t  j j d  r5 t j d  t j d d g  n  d S(   s,    /etc/init.d/apparmor stop (see bug #559433)s   /etc/init.d/apparmors   /etc/init.d/apparmor stopt   stopN(   R   R   R   R   R   R   R   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   "  s    c         C   s9   t  j j d  r5 t j d  t j d d g  n  d S(   s5    /etc/init.d/docvert-converter stop (see bug #450569)s   /etc/init.d/docvert-converters"   /etc/init.d/docvert-converter stopR
  N(   R   R   R   R   R   R   R   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   '  s    c         C   s<   t  j j d  r8 t j d  t j d d d g  n  d S(   s   kill update-notifiers   /usr/bin/killalls   killing update-notifiert   killalls   -qs   update-notifierN(   R   R   R   R   R   R   R   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   ,  s    c         C   s?   t  j j d  r; t j d  t j d d d d g  n  d S(   s3   killall kblueplugd kbluetooth (riddel requested it)s   /usr/bin/killalls   killing kblueplugd kbluetooth4R  s   -qt
   kblueplugdt   kbluetooth4N(   R   R   R   R   R   R   R   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   2  s    c         C   s<   t  j j d  r8 t j d  t j d d d g  n  d S(   s   killall gnome-screensaver s   /usr/bin/killalls   killing gnome-screensaverR  s   -qs   gnome-screensaverN(   R   R   R   R   R   R   R   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   7  s    c         C   si   t  j j d  re t j d  y, t j d d t |  _ t	 j
 |  j  Wqe t j d  qe Xn  d  S(   Ns   /usr/bin/xdg-screensavers#   setup poke timer for the scrensavers=   while true; do /usr/bin/xdg-screensaver reset; sleep 30; donet   shells    failed to setup screensaver poke(   R   R   R   R   R   R   R   Rn   t   _poket   atexitt   registert   _stopPokeScreensavert	   exception(   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   <  s    c         C   sQ   |  j  rM y  |  j  j   |  j  j   } Wn t j d  n Xd  |  _  | Sd  S(   Ns   failed to stop screensaver poke(   R  t	   terminatet   waitR   R  R   (   R   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR  F  s    		c         C   sT   d d g } xA | D]9 } t  j j |  r t j d |  t  j |  q q Wd S(   s4    remove bad/broken maintainer scripts (last resort) s'   /var/lib/dpkg/info/apache2-common.prerms'   /var/lib/dpkg/info/pango-libthai.postrms   removing bad script '%s'N(   R   R   R   R   R   R   (   R   t   bad_scriptsR   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   O  s    	c         C   s@   t  j d  t j j d  s/ t j d  n  t d d  d S(   s   
        intrepid->jaunty, create /var/lib/pycentral/pkgremove flag file
        to help python-central so that it removes all preinst links
        on upgrade
        s   adding pkgremove files   /var/lib/pycentral/s   /var/lib/pycentrals   /var/lib/pycentral/pkgremovet   wN(   R   R   R   R   R   R   R   (   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   [  s    c         C   sg   y< x5 t  j  d  D]$ } t j d |  t j |  q WWn$ t k
 rb } t j d |  n Xd S(   s    remove old apport crash files s   /var/crash/*.crashs   removing old crash file '%s's+   error during unlink of old crash files (%s)N(   t   globR   R   R   R   R|   R}   (   R   t   fR   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   f  s    c         C   sP   t  j j |  s t Sx3 t |  D]% } | j d  r# d | k r# t Sq# Wt S(   s5    helper that checks if the given cpu has sse support t   flagss    sse(   R   R   R   R   R   Rq   Rn   (   R   R   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   o  s    c         C   s   t  j d  x t d  D] } | j   } | d k s | j d  rM q n  y" | j   \ } } } } } } Wn% t k
 r t  j d |  q n Xd | k r t  j d |  t Sq Wt	 S(   s'    check if evms is used in /proc/mounts s   running _usesEvmsInMountss   /proc/mountsRw   Rx   s   can't parse line '%s't   evmss)   found evms device in line '%s', skipping (
   R   R   R   R   Rq   Rz   R|   RM   Rn   R   (   R   R   R   R   R   R   R   R   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRL   x  s    "c      	   C   s   t  j d  |  j   r t Sxh d d d d d d d d	 d
 g	 D]E } |  j j j |  r? |  j j | j r? |  j j | j   q? q? Wt	 S(   s/    check if evms is in use and if not, remove it s   running _checkAndRemoveEvmsR  s   libevms-2.5s   libevms-devs   evms-ncursess   evms-has   evms-bootdebugs   evms-guis   evms-clis   linux-patch-evms(
   R   R   RL   R   R
   R_   R`   Ra   Rd   Rn   (   R   Re   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRo     s    (c      	   C   s  t  j d  t } g  } x#t d  D]} | j   } | d k sS | j d  rf | j |  q& n  y" | j   \ } } } } } }	 Wn2 t k
 r t  j	 d |  | j |  q& n Xd | k s d | k r.d | k r.d	 | k r.t  j d
 |  | j
 | d |  } t  j d |  t } n  | j |  q& W| rt  j d  t d d  }
 |
 j d j |   |
 j d  |
 j   t j d d  n  t S(   s=    add the relatime option to ext2/ext3 filesystems on upgrade t   _addRelatimes
   /etc/fstabRw   Rx   s   can't parse line '%s't   ext2t   ext3t   noatimet   relatimes   adding 'relatime' to line '%s' s   %s,relatimes   replaced line is '%s' s   writing new /etc/fstabs   /etc/fstab.intrepidR  s   
(   R   R   R   R   R   Rq   R   Rz   R|   RM   t   replaceRn   t   writeR   t   closeR   t   rename(   R   t   replacedt   linesR   R   R   R   R   R   R   R  (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR2     s>    "	
s
   /etc/fstabc         C   s  t  j d  t } g  } x#t |  D]} | j   } | d k sS | j d  rf | j |  q& n  y" | j   \ } } } } }	 }
 Wn2 t k
 r t  j	 d |  | j |  q& n Xd | k r.|
 d k r.t  j d |  | d d k r| d  d	 } n t  j	 d
  t  j d |  t
 } n  | j |  q& W| rd } t  j d  t | | d  } | j d j |   | j d  | j   t j | | |  n  t
 S(   s-   change PASS 1 to 0 for ntfs entries (#441242)R6   Rw   Rx   s   can't parse line '%s't   ntfst   1s%   changing PASS for ntfs to 0 for '%s' it   0s   unexpected value in lines   replaced line is '%s' s   .jauntys   writing new /etc/fstabR  s   
(   R   R   R   R   R   Rq   R   Rz   R|   RM   Rn   R"  R   R#  R   R$  (   R   t   fstabR%  R&  R   R   R   R   R   t   fdumpt   fpasst   suffixR  (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR6     s>    "	
c         C   s  t  j d  d } g  } x5t d  D]'} | j   } | d k sS | j d  rf | j |  q& n  y" | j   \ } } } } } }	 Wn2 t k
 r t  j d |  | j |  q& n Xd | k r@| d k r@t	 j
 j d  r@t	 j
 j d  | k r@t  j d	 |  | j | d  } t  j d
 |  | d 7} n  | j |  q& W| d k rt  j d  t j d d  t d d  }
 |
 j d j |   |
 j d  |
 j   n  t S(   s>    convert /dev/{hd?,scd0} to /dev/cdrom for the feisty upgrade s   _rewriteFstab()i    s
   /etc/fstabRw   Rx   s   can't parse line '%s't   iso9660s
   /dev/cdroms   replacing '%s' s   replaced line is '%s' i   s   writing new /etc/fstabs   /etc/fstab.edgyR  s   
(   R   R   R   R   Rq   R   Rz   R|   RM   R   R   R   t   realpathR!  R   R   R"  R   R#  Rn   (   R   R%  R&  R   R   R   R   R   R   R   R  (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR/     s>    "
c         C   s/  t  j d  d d l } y | j d  j } Wn: t k
 rk } t  j d |  t j d d d g  n Xy | j d  j } Wn% t k
 r } t  j d |  d SXt	 j
 j d	  r+t	 j
 d	 | k r+t	 j
 d	 } t  j d
 |  d d d d | g } t j |  } t  j d | | f  n  d S(   s6    check if the current sudo user is in the admin group R0   iNt   admins   System has no admin group (%s)t   addgroups   --systems"   adding the admin group failed (%s)R   s"   SUDO_USER=%s is not in admin groupt   usermods   -as   -Gs   cmd: %s returned %i(   R   R   t   grpt   getgrnamt   gr_memt   KeyErrorR}   R   R   R   R   R`   R   (   R   R3  t   admin_groupR   t
   admin_usert   cmdR   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR0     s&    c         C   s|   d } t  j j |  s t SxY t |  D]K } | j d  d j   } | j   j d  r) | j	 d |  r) t
 Sq) Wt S(   s2    check if the given driver is in use in xorg.conf s   /etc/X11/xorg.confRx   i    t   drivers   "%s"(   R   R   R   R   R   Rz   R   t   lowerRq   t   endswithRn   (   R   Rp   t   XORGR   t   s(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   ,  s    s	   ./patchesc   	      C   s  t  j j |  s# t j d  d Sxt  j |  D]} d | k r\ t j d |  q3 n  t j d |  t j | d d  \ } } } | j d d  } t j d	 | | | f  t  j j |  s t j d
 |  q3 n  t	 j
   } | j t |  j    | j   | k r.t j d |  q3 n) | j   | k rWt j d |  q3 n  d d l m } y4 | | t  j j | |  |  t j d |  Wq3 t k
 rt j d |  q3 Xq3 Wd S(   s   
        helper that applies the patches in patchdir. the format is
        _path_to_file.md5sum
        
        and it will apply the diff to that file if the md5sum
        matches
        s   no patchdirNt   .s   skipping '%s' (no '.')s'   check if patch '%s' needs to be appliedi   RN   t   /s   target for '%s' is '%s' -> '%s's   target '%s' does not exists%   already at target hash, skipping '%s's(   unexpected target md5sum, skipping: '%s'i(   t   patchs   applied '%s' successfullys   ed failed for '%s'(   R   R   R   R   R   t   listdirR   t   rsplitR!  t   hashlibR   t   updateR   R   R   R   t   DistUpgradePatcherRA  R   R   R|   R  (	   R   t   patchdirR  t   encoded_pathR   t   result_md5sumR   R   RA  (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   9  s:    	c   	      C   s  | s |  j    } n  | |  j j k s; |  j j | j rL t j d  t S|  j j | } x |  j | j j  D] \ } } xr | D]j } t	 j
 d |  } | r d | j d  | j d  f } | j   | k r t j d |  t Sq q Wqr Wt j d |  t S(   s    
        Check if pkgname will work on this hardware

        This helper will check with the modaliasesdir if the given 
        pkg will work on this hardware (or the hardware given
        via the lspci argument)
        s   can not find '%s' in caches   pci:v0000(.+)d0000(.+)sv.*s   %s:%si   i   s%   found system pciid '%s' in modaliasess4   checking for %s support in modaliases but none found(   R   R
   R_   t	   candidateR   R   R   t!   _parse_modaliases_from_pkg_headert   recordR   R   R   R;  R   Rn   (	   R   R   R   Re   t   modulet
   pciid_listt   pciidt   mt   matchid(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   h  s"    	""c         C   s   d | k r g  Sg  } x | d j  d  D]k } | j d  } | sK q* n  | j  d  \ } } | j | g  | j  d  D] } | j   ^ qy f  q* W| S(   sB    return a list of (module1, (pciid, ...), (module2, (pciid, ...)))t
   Modaliasest   )s   , t   (R   (   Rz   R   R   (   R   t	   pkgrecordt   modulesRP  RM  t   pciidst   x(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRK    s    9c         C   s   t  j d  x d d g D] } |  j j j |  r |  j j | j r |  j j j   } d d g } xI | D]> } | | k rm t  j d  |  j j j | d  r d Sqm qm Wq q Wd S(	   s~    test if the current kernel is 386 and if the system is 
            capable of using a generic one instead (#353534)
        RJ   s	   linux-386s   linux-image-386s   linux-generics   linux-image-genericsC   386 kernel installed, but generic kernel  will work on this machines   386 -> generic transitionN(   R   R   R
   R_   R`   Ra   t   getKernelsFromBaseInstallerRg   (   R   R   t   working_kernelst
   upgrade_to(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRJ     s    c         C   s  t  j d  |  j j } d | k r6 t  j d  d  S| d j pM | d j sa t  j d  d  Sy d d  l } | j j   } xg | D]& } d | j	 k r t  j d  Pq q Wt  j
 d  | j d	 d
 |  j j d g d  | j   Wn t  j d  n Xd  S(   NRW   s   ubuntu-extras-keyrings-   no ubuntu-extras-keyring, no need to add repos2   ubuntu-extras-keyring not installed/marked_installis   extras.ubuntu.coms*   found extras.ubuntu.com, no need to add its/   no extras.ubuntu.com, adding it to sources.listt   debs   http://extras.ubuntu.com/ubuntut   mains!   Third party developers repositorys   error adding extras.ubuntu.com(   R   R   R
   R_   R{   t	   installedt   aptsources.sourceslistt   sourceslistt   SourcesListt   uriR   R   t   toDistt   saveR  (   R   R_   t
   aptsourcest   sourcest   entry(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRW     s.    c         C   sp   yU |  j  j } d | k rT | d j rT d | k rT t j d  | j d d  n  Wn t j d  n Xd S(   s    foomatic-db-gutenprint get removed during the upgrade,
            replace it with the compressed ijsgutenprint-ppds
            (context is foomatic-db vs foomatic-db-compressed-ppds)
        s   foomatic-db-gutenprints   ijsgutenprint-ppdss   installing ijsgutenprint-ppdss1   foomatic-db-gutenprint -> ijsgutenprint-ppds rules   _gutenprint_fixup failedN(   R
   R_   t   marked_deleteR   R   Rg   R  (   R   R_   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRX     s    R'   c         C   s^   d } t  j j |  sZ y t  j d  Wn t k
 r< n Xt | d  j d |  n  d S(   s5    enable multiarch via /etc/dpkg/dpkg.cfg.d/multiarch s   /etc/dpkg/dpkg.cfg.d/multiarchs   /etc/dpkg/dpkg.cfg.d/R  s   foreign-architecture %s
N(   R   R   R   R   R   R   R"  (   R   R   t   cfg(    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR     s    c         C   st   yY |  j  j } d | k p$ d | k s+ d S| d j sE | d j rX | j d d  n  Wn t j d  n Xd S(   s    test if kdegames-card-data is installed and if so,
            add kdegames-card-data-extra so that users do not 
            loose functionality (LP: #745396)
        s   kdegames-card-datas   kdegames-card-data-extraNs,   kdegames-card-data -> k-c-d-extra transitions,   _add_kdegames_card_extra_if_installed failed(   R
   R_   Ra   R{   Rg   R   R  (   R   R_   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyRU     s    c         C   sZ   d d l  } |  j j sV | j j j d  sV t j d  | j j j d d  qV n  d S(   s^    ensure that on a desktop install recommends are installed 
            (LP: #759262)
        iNs   Apt::Install-RecommendssF   Apt::Install-Recommends was disabled, enabling it just for the upgradeR(  (	   R(   R
   t
   serverModeR)   R   t   find_bR   R   R+   (   R   R(   (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt+   ensure_recommends_are_installed_on_desktops  s
    N(L   t   __name__t
   __module__t   __doc__R   R$   R%   R-   R.   R1   R3   R4   R5   R8   R?   R@   RD   RI   RT   RV   RY   R[   Rf   Rj   RE   RF   RG   RH   R   R   R   R   R   R   R   R>   RS   RR   RC   R=   R   RA   RB   RK   RZ   R   RQ   R7   RP   R   R   R   R   R   R   R  R   R   R   R   RL   Ro   R2   R6   R/   R0   R   R   R   R   RK  RJ   RW   RX   R   RU   Rl  (    (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyR   )   s   		3									
											 		=	
											!					 				
						
										$&	/		/				
	(   R(   R  R  R   R   t   os.pathR   RD  R   R   R9   R   R    R   R   t   utilsR   R   t   DistUpgradeGettextR   RN   t   computerjanitor.pluginR   t   objectR   (    (    (    sA   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeQuirks.pyt   <module>   s"   