Esempio n. 1
0
 def enabled(self):
     if self.xorg_conf:
         if self.xorg_driver:
             if self.xorg_conf.isDriverEnabled(self.xorg_driver) == False:
                 logging.debug('XorgDriverHandler(%s, %s, %s).enabled(): considering xorg driver disabled',
                     self.module, self.package, self.xorg_driver)
                 return False
         
             logging.debug('XorgDriverHandler(%s, %s, %s).enabled(): xorg.conf driver matches',
                     self.module, self.package, self.xorg_driver)
         else:
             logging.debug('XorgDriverHandler(%s, %s).enabled(): No X.org driver set, not checking')
     else:
         logging.debug('%s: xkit object does not exist!', self.module)
         return False
     return KernelModuleHandler.enabled(self)
Esempio n. 2
0
 def enabled(self):
     if self.xorg_conf:
         if self.xorg_driver:
             if self.xorg_conf.is_driver_enabled(self.xorg_driver) == False:
                 logging.debug('XorgDriverHandler(%s, %s, %s).enabled(): considering xorg driver disabled',
                     self.module, self.package, self.xorg_driver)
                 return False
         
             logging.debug('XorgDriverHandler(%s, %s, %s).enabled(): xorg.conf driver matches',
                     self.module, self.package, self.xorg_driver)
         else:
             logging.debug('XorgDriverHandler(%s, %s).enabled(): No X.org driver set, not checking')
     else:
         logging.debug('%s: xkit object does not exist!', self.module)
         return False
     return KernelModuleHandler.enabled(self)
Esempio n. 3
0
    def enable(self):
        if not self.xorg_conf:
            logging.error('XorgDriverHandler.enable(): invalid xorg.conf, skipping')
            return False

        KernelModuleHandler.enable(self)

        # do not mangle xorg.conf if package installation has been aborted or
        # module is not available (e. g. because DKMS did not build it)
        if not KernelModuleHandler.enabled(self):
            logging.error('XorgDriverHandler.enable(): package or module not installed, aborting')
            return False
        
        # see if the same proprietary driver is in use
        # in the xorg.conf. If so do not create a backup
        has_proprietary = False
        if self.xorg_driver:
            it = 0
            for section in self.xorg_conf.globaldict['Device']:
                try:
                    driver = self.xorg_conf.getDriver('Device', it)
                    if driver == self.xorg_driver:
                        has_proprietary = True
                        break
                except XKit.xorgparser.OptionException:
                    # no driver is specified
                    pass
                it += 1
        
        # backup the current xorg.conf
        if os.path.exists(OSLib.inst.xorg_conf_path):
            if not has_proprietary:
                open(self.old_conf, 'w').write(open(OSLib.inst.xorg_conf_path).read())
        else:
            open(self.no_conf, 'w')
        
        relevant_devices = []
        
        if self.xorg_driver or self.extra_conf_options:
            if len(self.xorg_conf.globaldict['Device']) == 0:
                # Create a new Device section. "device" = position of the section
                device = self.xorg_conf.makeSection('Device', identifier='Default Device')
                relevant_devices.append(device)
                # Set the driver
                if self.xorg_driver:
                    self.xorg_conf.setDriver('Device', self.xorg_driver, device)
            else:
                # Get the relevant sections by checking the ServerLayout section
                # in case of multiple screens layouts or modify all the Device
                # sections
                devices = self.xorg_conf.getDevicesInUse()
                if len(devices) > 0:
                    relevant_devices = devices
                else:
                    relevant_devices = self.xorg_conf.globaldict['Device'].keys()
                if self.xorg_driver:
                    for device in relevant_devices:
                        self.xorg_conf.setDriver('Device', self.xorg_driver, device)
            logging.debug('XorgDriverHandler device sections (%s)' % (
                str(self.xorg_conf.globaldict['Device'])))
        
        module_sections = self.xorg_conf.globaldict['Module']
        have_modules = len(module_sections) > 0
        
        if have_modules:
            for section in module_sections:
                for mod in self.remove_modules:
                    self.xorg_conf.removeOption('Module', 'Load', value=mod, position=section)
        
        if self.add_modules:
            if not have_modules:
                module_section = self.xorg_conf.makeSection('Module')
            else:
                module_section = 0 #the 1st module section
            
            for mod in self.add_modules:
                if not self._mod_enabled(mod):
                    self.xorg_conf.addOption('Module', 'Load', mod, optiontype=None, position=module_section, reference=True)
        
        if self.disable_modules:
            for mod in self.disable_modules:
                if not self._mod_disabled(mod):
                    self.xorg_conf.addOption('Module', 'Disable', mod, optiontype=None, position=module_section, reference=True)
        
        for device_section in relevant_devices:
            for k, v in self.extra_conf_options.iteritems():
                self.xorg_conf.addOption('Device', k, v, optiontype='Option', position=device_section)
        
        self.enable_config_hook()
        
        self.xorg_conf.writeFile(OSLib.inst.xorg_conf_path)

        return False
Esempio n. 4
0
    def enable(self):
        if not self.xorg_conf:
            logging.error(
                'XorgDriverHandler.enable(): invalid xorg.conf, skipping')
            return False

        KernelModuleHandler.enable(self)

        # do not mangle xorg.conf if package installation has been aborted or
        # module is not available (e. g. because DKMS did not build it)
        if not KernelModuleHandler.enabled(self):
            logging.error(
                'XorgDriverHandler.enable(): package or module not installed, aborting'
            )
            return False

        # see if the same proprietary driver is in use
        # in the xorg.conf. If so do not create a backup
        has_proprietary = False
        if self.xorg_driver:
            it = 0
            for section in self.xorg_conf.globaldict['Device']:
                try:
                    driver = self.xorg_conf.getDriver('Device', it)
                    if driver == self.xorg_driver:
                        has_proprietary = True
                        break
                except XKit.xorgparser.OptionException:
                    # no driver is specified
                    pass
                it += 1

        # backup the current xorg.conf
        if os.path.exists(OSLib.inst.xorg_conf_path):
            if not has_proprietary:
                open(self.old_conf,
                     'w').write(open(OSLib.inst.xorg_conf_path).read())
        else:
            open(self.no_conf, 'w')

        relevant_devices = []

        if self.xorg_driver or self.extra_conf_options:
            if len(self.xorg_conf.globaldict['Device']) == 0:
                # Create a new Device section. "device" = position of the section
                device = self.xorg_conf.makeSection(
                    'Device', identifier='Default Device')
                relevant_devices.append(device)
                # Set the driver
                if self.xorg_driver:
                    self.xorg_conf.setDriver('Device', self.xorg_driver,
                                             device)
            else:
                # Get the relevant sections by checking the ServerLayout section
                # in case of multiple screens layouts or modify all the Device
                # sections
                devices = self.xorg_conf.getDevicesInUse()
                if len(devices) > 0:
                    relevant_devices = devices
                else:
                    relevant_devices = self.xorg_conf.globaldict[
                        'Device'].keys()
                if self.xorg_driver:
                    for device in relevant_devices:
                        self.xorg_conf.setDriver('Device', self.xorg_driver,
                                                 device)
            logging.debug('XorgDriverHandler device sections (%s)' %
                          (str(self.xorg_conf.globaldict['Device'])))

        module_sections = self.xorg_conf.globaldict['Module']
        have_modules = len(module_sections) > 0

        if have_modules:
            for section in module_sections:
                for mod in self.remove_modules:
                    self.xorg_conf.removeOption('Module',
                                                'Load',
                                                value=mod,
                                                position=section)

        if self.add_modules:
            if not have_modules:
                module_section = self.xorg_conf.makeSection('Module')
            else:
                module_section = 0  #the 1st module section

            for mod in self.add_modules:
                if not self._mod_enabled(mod):
                    self.xorg_conf.addOption('Module',
                                             'Load',
                                             mod,
                                             optiontype=None,
                                             position=module_section,
                                             reference=True)

        if self.disable_modules:
            for mod in self.disable_modules:
                if not self._mod_disabled(mod):
                    self.xorg_conf.addOption('Module',
                                             'Disable',
                                             mod,
                                             optiontype=None,
                                             position=module_section,
                                             reference=True)

        for device_section in relevant_devices:
            for k, v in self.extra_conf_options.iteritems():
                self.xorg_conf.addOption('Device',
                                         k,
                                         v,
                                         optiontype='Option',
                                         position=device_section)

        self.enable_config_hook()

        self.xorg_conf.writeFile(OSLib.inst.xorg_conf_path)

        return False