diff -u jockey-0.3.3/data/handlers/b43.py jockey-0.3.3/data/handlers/b43.py --- jockey-0.3.3/data/handlers/b43.py +++ jockey-0.3.3/data/handlers/b43.py @@ -5,6 +5,7 @@ import re, os.path, logging from glob import glob +from jockey.oslib import OSLib from jockey.handlers import ModulePackageHandler, KernelModuleHandler class B43Handler(ModulePackageHandler): @@ -25,0 +27,17 @@ + + def used(self): + '''Return if the handler is currently in use.''' + + return KernelModuleHandler.used(self) and \ + len(glob('/lib/firmware/b43/*.fw')) > 0 + + def enable(self): + '''Remove blacklist produced by BroadcomWLHandler.''' + + bl_file = '/etc/modprobe.d/blacklist-bcm43' + if os.path.exists(bl_file): + os.unlink(bl_file) + OSLib.inst._load_module_blacklist() + subprocess.call(['/usr/sbin/update-initramfs', '-u']) + + ModulePackageHandler.enable(self) diff -u jockey-0.3.3/tests/oslib.py jockey-0.3.3/tests/oslib.py --- jockey-0.3.3/tests/oslib.py +++ jockey-0.3.3/tests/oslib.py @@ -76,6 +76,32 @@ os.unlink(OSLib.inst.module_blacklist_file) OSLib.inst._load_module_blacklist() + def test_module_blacklist_load_thirdparty(self): + '''module blacklist loading of other files in modprobe.d/.''' + + path = os.path.join(os.path.dirname(OSLib.inst.module_blacklist_file), + 'blacklist-custom') + f = open(path, 'w') + try: + f.write('''blacklist vanilla +# FOO BAR + + blacklist cherry # we do not like red fruits +# blacklist mint +''') + f.close() + + OSLib.inst._load_module_blacklist() + + self.assert_(OSLib.inst.module_blacklisted('vanilla')) + self.assert_(OSLib.inst.module_blacklisted('cherry')) + self.failIf(OSLib.inst.module_blacklisted('chocolate')) + self.failIf(OSLib.inst.module_blacklisted('mint')) + self.failIf(OSLib.inst.module_blacklisted('vanilla3d')) + finally: + os.unlink(path) + OSLib.inst._load_module_blacklist() + def test_is_admin(self): '''is_admin()''' diff -u jockey-0.3.3/debian/changelog jockey-0.3.3/debian/changelog --- jockey-0.3.3/debian/changelog +++ jockey-0.3.3/debian/changelog @@ -1,3 +1,27 @@ +jockey (0.3.3-0ubuntu8.1) hardy-proposed; urgency=low + + Fix configuration of "b43" vs. the new "wl" wifi driver. (LP: #263097) + + * jockey/oslib.py: Check all /etc/modprobe.d/blacklist* files in + module_blacklisted(). The new Broadcom wl driver generates + blacklist-bcm43, which Jockey needs to evaluate in order to handle the + enabling/disabling properly. (Cherrypicked from trunk, r296) + * tests/sandbox.py: Provide temporary module_blacklist_file in + AllAvailOSLib, so that handlers which modify blacklists do not die with + EPERM during tests. (Cherrypicked from trunk, r297) + * Add data/handlers/broadcom_wl.py: Handler for the alternative Broadcom + 'wl' module. Enabling this will automatically blacklist b43 and bcm43xx. + * data/handlers/b43.py: Remove the blacklist generated by enabling wl when + enabling b43. + * data/handlers/b43.py: Do not show the handler as "in use" if no firmware + is present. + * jockey/ui.py, jockey-{gtk,kde}: Cowboy ui_download_start() to take an + alternative title for the progress window, so that we can abuse it for + other progress dialogs. + * broadcom_wl.py: Spawn a progress dialog while update-initramfs is running. + + -- Martin Pitt Tue, 30 Sep 2008 19:30:12 +0200 + jockey (0.3.3-0ubuntu8) hardy-proposed; urgency=low * fglrx.py: Do not override already installed third-party fglrx driver with diff -u jockey-0.3.3/jockey/ui.py jockey-0.3.3/jockey/ui.py --- jockey-0.3.3/jockey/ui.py +++ jockey-0.3.3/jockey/ui.py @@ -667,7 +667,7 @@ ''' raise NotImplementedError, 'subclasses need to implement this' - def ui_download_start(self, url, total_size): + def ui_download_start(self, url, total_size, title=None): '''Create a progress dialog for a download of given URL. total_size specifes the number of bytes to download, or -1 if it cannot diff -u jockey-0.3.3/jockey/oslib.py jockey-0.3.3/jockey/oslib.py --- jockey-0.3.3/jockey/oslib.py +++ jockey-0.3.3/jockey/oslib.py @@ -18,6 +18,7 @@ '''Encapsulate operations which are Linux distribution specific.''' import fcntl, os, subprocess, sys, logging, sys, time +from glob import glob class OSLib: '''Encapsulation of operating system/Linux distribution specific operations.''' @@ -327,7 +328,8 @@ def module_blacklisted(self, module): '''Check if a module is on the modprobe blacklist.''' - return module in self._module_blacklist + return module in self._module_blacklist or \ + module in self._module_blacklist_system def blacklist_module(self, module, blacklist): '''Add or remove a kernel module from the modprobe blacklist. @@ -346,12 +348,24 @@ self._save_module_blacklist() def _load_module_blacklist(self): - '''Initialize self._module_blacklist.''' + '''Initialize self._module_blacklist{,_system}.''' self._module_blacklist = set() + self._module_blacklist_system = set() + + self._read_blacklist_file(self.module_blacklist_file, self._module_blacklist) + + # read other blacklist files (which we will not touch, but evaluate) + for f in glob('%s/blacklist*' % os.path.dirname(self.module_blacklist_file)): + if f != self.module_blacklist_file: + self._read_blacklist_file(f, self._module_blacklist_system) + + @classmethod + def _read_blacklist_file(klass, path, blacklist_set): + '''Read a blacklist file and add modules to blacklist_set.''' try: - f = open(self.module_blacklist_file) + f = open(path) except IOError: return @@ -366,7 +380,7 @@ module = line[len('blacklist'):].strip() if module: - self._module_blacklist.add(module) + blacklist_set.add(module) finally: f.close() only in patch2: unchanged: --- jockey-0.3.3.orig/kde/jockey-kde +++ jockey-0.3.3/kde/jockey-kde @@ -226,7 +226,7 @@ QApplication.processEvents() - def ui_download_start(self, url, total_size): + def ui_download_start(self, url, total_size, title=None): '''Create a progress dialog for a download of given URL. total_size specifes the number of bytes to download, or -1 if it cannot @@ -244,7 +244,7 @@ self.dlui.progressBar.setMaximum(total_size) # set translations - self.dlui.downloadLabel.setText(self.string_download_progress_title) + self.dlui.downloadLabel.setText(title or self.string_download_progress_title) self.dlui.firmwareName.setText(url) self.dlui.show() only in patch2: unchanged: --- jockey-0.3.3.orig/gtk/jockey-gtk +++ jockey-0.3.3/gtk/jockey-gtk @@ -187,7 +187,7 @@ while gtk.events_pending(): gtk.main_iteration(False) - def ui_download_start(self, url, total_size): + def ui_download_start(self, url, total_size, title=None): '''Create a progress dialog for a download of given URL. total_size specifes the number of bytes to download, or -1 if it cannot @@ -196,7 +196,7 @@ ''' self.w('progress_download').set_fraction(0) self.w('label_download_url').set_label(url) - self.w('window_download_progress').set_title(self.string_download_progress_title) + self.w('window_download_progress').set_title(title or self.string_download_progress_title) self.w('window_download_progress').show() self.cancel_download = False @@ -206,7 +206,11 @@ This should return True to cancel the current download, and False otherwise. ''' - self.w('progress_download').set_fraction(float(current_size)/total_size) + if current_size < 0 or total_size < 0: + self.w('progress_download').set_pulse_step(0.1) + self.w('progress_download').pulse() + else: + self.w('progress_download').set_fraction(float(current_size)/total_size) return self.cancel_download def ui_download_finish(self): only in patch2: unchanged: --- jockey-0.3.3.orig/data/handlers/broadcom_wl.py +++ jockey-0.3.3/data/handlers/broadcom_wl.py @@ -0,0 +1,78 @@ +# (c) 2008 Canonical Ltd. +# Author: Martin Pitt +# License: GPL v2 or later + +import re, os.path, logging, subprocess, time +from glob import glob + +from jockey.oslib import OSLib +from jockey.handlers import KernelModuleHandler + +class BroadcomWLHandler(KernelModuleHandler): + '''Handler for Broadcom Wifi chipsets which use the wl module.''' + + def __init__(self, ui): + self.bl_file = os.path.join(os.path.dirname( + OSLib.inst.module_blacklist_file), 'blacklist-bcm43') + if KernelModuleHandler.module_loaded('b44'): + raise SystemError, 'BroadcomWLHandler: would break b44, disabling myself' + + KernelModuleHandler.__init__(self, ui, 'wl', + name=ui._('Broadcom STA wireless driver')) + + def enabled(self): + km = KernelModuleHandler.enabled(self) + bcm = OSLib.inst.module_blacklisted('bcm43xx') + b43 = OSLib.inst.module_blacklisted('b43') + b43_legacy = OSLib.inst.module_blacklisted('b43_legacy') + logging.debug('BroadcomWLHandler enabled(): kmod %s, bcm43xx: %s, b43: %s, b43_legacy: %s' % ( + km and 'enabled' or 'disabled', + bcm and 'blacklisted' or 'enabled', + b43 and 'blacklisted' or 'enabled', + b43_legacy and 'blacklisted' or 'enabled')) + + return km and bcm and b43 and b43_legacy + + def used(self): + '''Return if the handler is currently in use.''' + + return KernelModuleHandler.used(self) and self.enabled() + + def enable(self): + '''Disable b43 drivers, so that wl can become active.''' + + if not os.path.exists(self.bl_file): + f = open(self.bl_file, 'w') + f.write('''blacklist bcm43xx +blacklist b43 +blacklist b43_legacy +blacklist ssb +''') + f.close() + OSLib.inst._load_module_blacklist() + self._update_initramfs() + + KernelModuleHandler.enable(self) + OSLib.inst.ui_notify_reboot(self.ui) + + def disable(self): + '''Unblacklist b43 drivers again, so that they trump wl.''' + + if os.path.exists(self.bl_file): + os.unlink(self.bl_file) + OSLib.inst._load_module_blacklist() + self._update_initramfs() + + KernelModuleHandler.disable(self) + OSLib.inst.ui_notify_reboot(self.ui) + + def _update_initramfs(self): + self.ui.ui_download_start(self.name(), -1, self.ui._('Updating system')) + self.ui.ui_idle() + initramfs = subprocess.Popen(['/usr/sbin/update-initramfs', '-u']) + while initramfs.poll() == None: + self.ui.ui_download_progress(-1, -1) + self.ui.ui_idle() + time.sleep(0.2) + self.ui.ui_download_finish() + self.ui.ui_idle() only in patch2: unchanged: --- jockey-0.3.3.orig/tests/sandbox.py +++ jockey-0.3.3/tests/sandbox.py @@ -534,6 +534,8 @@ self.reboot_flag = False self._make_modinfo() self.xorg_conf_path = os.path.join(self.workdir, 'xorg.conf') + self.module_blacklist_file = os.path.join(self.workdir, + 'module-blacklist') def package_description(self, package): '''Return a tuple (short_description, long_description) for a package. @@ -685,7 +687,7 @@ return self.notification_stack.pop() - def ui_download_start(self, url, total_size): + def ui_download_start(self, url, total_size, title=None): '''Create a progress dialog for a download of given URL. total_size specifes the number of bytes to download, or -1 if it cannot @@ -704,8 +706,8 @@ assert self.cur_download[0] assert self.cur_download[1] is not None assert self.cur_download[2] is not None - assert current_size > self.cur_download[1] - assert total_size == self.cur_download[2] + assert current_size > self.cur_download[1] or current_size == -1 + assert total_size == self.cur_download[2] or total_size == -1 self.cur_download[1] = current_size