~ubuntu-branches/ubuntu/saucy/jockey/saucy

« back to all changes in this revision

Viewing changes to data/handlers/fglrx.py

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Milone
  • Date: 2011-07-05 11:44:19 UTC
  • Revision ID: james.westby@ubuntu.com-20110705114419-xa9zylsa5junko23
Tags: 0.9.2-0ubuntu8
data/handlers/fglrx.py: Add support for multi-arch to the fglrx handler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import XKit.xorgparser
10
10
from jockey.xorg_driver import XorgDriverHandler
11
11
from NvidiaDetector.alternatives import Alternatives
 
12
from NvidiaDetector.alternatives import MultiArchUtils
12
13
import subprocess
13
14
 
14
15
# dummy stub for xgettext
26
27
                'potential of some ATI graphics cards, as well as provide '
27
28
                '2D acceleration of newer cards.'))
28
29
 
29
 
        self._alternatives = Alternatives('gl_conf')
 
30
        (self._alternatives, self._other_alternatives) = self._get_alternatives()
30
31
        self.needs_kernel_headers = True
31
32
 
 
33
    def _get_alternatives(self):
 
34
        '''Get multi-arch alternatives names'''
 
35
        arch_utils = MultiArchUtils()
 
36
        main_name = arch_utils.get_main_alternative_name()
 
37
        other_name = arch_utils.get_other_alternative_name()
 
38
        return Alternatives(main_name), Alternatives(other_name)
 
39
 
32
40
    def available(self):
33
41
        # we don't offer fglrx in a life CD environment, as we will run out of
34
42
        # RAM trying to download and install all the packages in the RAM disk.
72
80
        # Set the alternative to FGLRX
73
81
        fglrx_alternative = self._alternatives.get_alternative_by_name(self.package)
74
82
        self._alternatives.set_alternative(fglrx_alternative)
 
83
        other_fglrx_alternative = self._other_alternatives.get_alternative_by_name(self.package)
 
84
        self._other_alternatives.set_alternative(other_fglrx_alternative)
75
85
        subprocess.call(['update-initramfs', '-u'])
76
86
        subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]])
77
87
 
79
89
        # See if fglrx is the current alternative
80
90
        target_alternative = self._alternatives.get_alternative_by_name(self.package)
81
91
        current_alternative = self._alternatives.get_current_alternative()
82
 
        
 
92
        other_target_alternative = self._other_alternatives.get_alternative_by_name(self.package)
 
93
        other_current_alternative = self._other_alternatives.get_current_alternative()
 
94
 
 
95
        logging.debug('fglrx.enabled(%s): target_alt %s current_alt %s other target alt %s other current alt %s',
 
96
                self.module, target_alternative, current_alternative,
 
97
                other_target_alternative, other_current_alternative)
 
98
 
83
99
        if current_alternative is None:
84
100
            logging.debug('current alternative of %s is None, not enabled', self.module)
85
101
            return False
86
 
        if current_alternative != target_alternative:
 
102
        if current_alternative != target_alternative or \
 
103
           other_current_alternative != other_target_alternative:
87
104
            logging.debug('%s is not the alternative in use', self.module)
88
105
            return False
89
106
 
94
111
        XorgDriverHandler.disable(self)
95
112
        #kernel_source = 'fglrx-kernel-source'
96
113
        #self.backend.remove_package(kernel_source)
97
 
        
 
114
 
98
115
        # Set the alternative back to open drivers
99
116
        open_drivers = self._alternatives.get_open_drivers_alternative()
100
 
        self._alternatives.set_alternative(open_drivers)
 
117
        logging.debug('fglrx.disable(%s): open_drivers: %s', self.module, open_drivers)
 
118
        if open_drivers:
 
119
            self._alternatives.set_alternative(open_drivers)
 
120
        other_open_drivers = self._other_alternatives.get_open_drivers_alternative()
 
121
        logging.debug('fglrx.disable(%s): other_open_drivers: %s', self.module, other_open_drivers)
 
122
        if other_open_drivers:
 
123
            self._other_alternatives.set_alternative(other_open_drivers)
101
124
        subprocess.call(['update-initramfs', '-u'])
102
125
        subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]])
103
126