Merge ~albertomilone/ubuntu/+source/software-properties:apt-pkg-transition into ubuntu/+source/software-properties:ubuntu/devel
- Git
- lp:~albertomilone/ubuntu/+source/software-properties
- apt-pkg-transition
- Merge into ubuntu/devel
Status: | Needs review |
---|---|
Proposed branch: | ~albertomilone/ubuntu/+source/software-properties:apt-pkg-transition |
Merge into: | ubuntu/+source/software-properties:ubuntu/devel |
Diff against target: |
406 lines (+121/-80) 3 files modified
softwareproperties/SoftwareProperties.py (+24/-12) softwareproperties/gtk/SoftwarePropertiesGtk.py (+49/-35) softwareproperties/qt/SoftwarePropertiesQt.py (+48/-33) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastien Bacher (community) | Approve | ||
Julian Andres Klode (community) | Needs Fixing | ||
git-ubuntu import | Pending | ||
Review via email: mp+416950@code.launchpad.net |
Commit message
This makes software-
Description of the change
Julian Andres Klode (juliank) wrote : | # |
I found a couple of spots worth fixing/considering in the diff
- 68577e2... by Alberto Milone
-
softwarepropert
ies/SoftwarePro perties. py: import apt only on demand - 66473bd... by Alberto Milone
-
Do without a couple of tries, and make get_package_id return the installed package when available
Alberto Milone (albertomilone) wrote : | # |
I have just pushed a couple of commits which should fix the problems reported by Julian and Matthew. Thanks
Sebastien Bacher (seb128) wrote : | # |
Thanks, I've merged and uploaded but I can't close that one since it's targetting the wrong Vcs, for reference the git repository is reference in debian/control and https:/
I've also updated the depends on ubuntu-
Alberto Milone (albertomilone) wrote : | # |
I understand. Sorry about that. Thanks
Unmerged commits
- 66473bd... by Alberto Milone
-
Do without a couple of tries, and make get_package_id return the installed package when available
- 68577e2... by Alberto Milone
-
softwarepropert
ies/SoftwarePro perties. py: import apt only on demand - ada2244... by Alberto Milone
-
Use apt_pkg instead of apt, as in ubuntu-
drivers- common Fixes LP: #1964880
Preview Diff
1 | diff --git a/softwareproperties/SoftwareProperties.py b/softwareproperties/SoftwareProperties.py | |||
2 | index 3e94731..7fc9862 100644 | |||
3 | --- a/softwareproperties/SoftwareProperties.py | |||
4 | +++ b/softwareproperties/SoftwareProperties.py | |||
5 | @@ -26,7 +26,6 @@ | |||
6 | 26 | from __future__ import absolute_import, print_function | 26 | from __future__ import absolute_import, print_function |
7 | 27 | 27 | ||
8 | 28 | import apt_pkg | 28 | import apt_pkg |
9 | 29 | import apt | ||
10 | 30 | import copy | 29 | import copy |
11 | 31 | from hashlib import md5 | 30 | from hashlib import md5 |
12 | 32 | import re | 31 | import re |
13 | @@ -828,22 +827,35 @@ class SoftwareProperties(object): | |||
14 | 828 | except: | 827 | except: |
15 | 829 | return False | 828 | return False |
16 | 830 | 829 | ||
18 | 831 | def get_package_id(self, ver): | 830 | def get_package_id(self, apt_cache, pkg): |
19 | 832 | """ Return the PackageKit package id """ | 831 | """ Return the PackageKit package id """ |
23 | 833 | assert isinstance(ver, apt.package.Version) | 832 | assert isinstance(pkg, apt_pkg.Package) |
24 | 834 | return "%s;%s;%s;" % (ver.package.shortname, ver.version, | 833 | cur_ver = pkg.current_ver |
25 | 835 | ver.package.architecture()) | 834 | if cur_ver: |
26 | 835 | ver = cur_ver.ver_str | ||
27 | 836 | arch = cur_ver.arch | ||
28 | 837 | else: | ||
29 | 838 | depcache = apt_pkg.DepCache(apt_cache) | ||
30 | 839 | candidate = depcache.get_candidate_ver(pkg) | ||
31 | 840 | ver = candidate.ver_str | ||
32 | 841 | arch = candidate.arch | ||
33 | 842 | return "%s;%s;%s;" % (pkg.name, ver, arch) | ||
34 | 836 | 843 | ||
35 | 837 | @staticmethod | 844 | @staticmethod |
37 | 838 | def get_dependencies(apt_cache, package_name, pattern=None): | 845 | def get_dependencies(apt_cache, package, pattern=None): |
38 | 839 | """ Get the package dependencies, which can be filtered out by a pattern """ | 846 | """ Get the package dependencies, which can be filtered out by a pattern """ |
39 | 847 | depcache = apt_pkg.DepCache(apt_cache) | ||
40 | 848 | candidate = depcache.get_candidate_ver(package) | ||
41 | 849 | |||
42 | 840 | dependencies = [] | 850 | dependencies = [] |
49 | 841 | for or_group in apt_cache[package_name].candidate.dependencies: | 851 | try: |
50 | 842 | for dep in or_group: | 852 | for dep_list in candidate.depends_list_str.get('Depends'): |
51 | 843 | if dep.rawtype in ["Depends", "PreDepends"]: | 853 | for dep_name, dep_ver, dep_op in dep_list: |
52 | 844 | dependencies.append(dep.name) | 854 | if dep_name.find(pattern) != -1: |
53 | 845 | if pattern: | 855 | dependencies.append(apt_cache[dep_name]) |
54 | 846 | dependencies = [ x for x in dependencies if x.find(pattern) != -1 ] | 856 | except (KeyError, TypeError): |
55 | 857 | return [] | ||
56 | 858 | |||
57 | 847 | return dependencies | 859 | return dependencies |
58 | 848 | 860 | ||
59 | 849 | 861 | ||
60 | diff --git a/softwareproperties/gtk/SoftwarePropertiesGtk.py b/softwareproperties/gtk/SoftwarePropertiesGtk.py | |||
61 | index 9b797ac..01e3d28 100644 | |||
62 | --- a/softwareproperties/gtk/SoftwarePropertiesGtk.py | |||
63 | +++ b/softwareproperties/gtk/SoftwarePropertiesGtk.py | |||
64 | @@ -26,7 +26,6 @@ | |||
65 | 26 | 26 | ||
66 | 27 | from __future__ import absolute_import, print_function | 27 | from __future__ import absolute_import, print_function |
67 | 28 | 28 | ||
68 | 29 | import apt | ||
69 | 30 | import apt_pkg | 29 | import apt_pkg |
70 | 31 | import datetime | 30 | import datetime |
71 | 32 | import dbus | 31 | import dbus |
72 | @@ -228,7 +227,9 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
73 | 228 | # used to store the handlers of callbacks | 227 | # used to store the handlers of callbacks |
74 | 229 | self.handlers = {} | 228 | self.handlers = {} |
75 | 230 | 229 | ||
77 | 231 | self.apt_cache = {} | 230 | # Initialise and store the apt cache |
78 | 231 | self.init_apt_cache() | ||
79 | 232 | |||
80 | 232 | self.pk_task = None | 233 | self.pk_task = None |
81 | 233 | 234 | ||
82 | 234 | # Put some life into the user interface: | 235 | # Put some life into the user interface: |
83 | @@ -290,6 +291,17 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
84 | 290 | self.handlers[self.combobox_release_upgrades] = \ | 291 | self.handlers[self.combobox_release_upgrades] = \ |
85 | 291 | self.combobox_release_upgrades.connect("changed", | 292 | self.combobox_release_upgrades.connect("changed", |
86 | 292 | self.on_combobox_release_upgrades_changed) | 293 | self.on_combobox_release_upgrades_changed) |
87 | 294 | def init_apt_cache(self): | ||
88 | 295 | apt_pkg.init_config() | ||
89 | 296 | apt_pkg.init_system() | ||
90 | 297 | self.apt_cache = apt_pkg.Cache(None) | ||
91 | 298 | self.depcache = apt_pkg.DepCache(self.apt_cache) | ||
92 | 299 | self.records = apt_pkg.PackageRecords(self.apt_cache) | ||
93 | 300 | |||
94 | 301 | def update_apt_cache(self): | ||
95 | 302 | self.apt_cache = apt_pkg.Cache(None) | ||
96 | 303 | self.depcache = apt_pkg.DepCache(self.apt_cache) | ||
97 | 304 | self.records = apt_pkg.PackageRecords(self.apt_cache) | ||
98 | 293 | 305 | ||
99 | 294 | def init_auto_update(self): | 306 | def init_auto_update(self): |
100 | 295 | """ Set up the widgets that allow to configure the update automation """ | 307 | """ Set up the widgets that allow to configure the update automation """ |
101 | @@ -983,7 +995,7 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
102 | 983 | # dbus events | 995 | # dbus events |
103 | 984 | def on_config_modified(self): | 996 | def on_config_modified(self): |
104 | 985 | """The config was changed and now needs to be saved and reloaded""" | 997 | """The config was changed and now needs to be saved and reloaded""" |
106 | 986 | apt.apt_pkg.init_config() | 998 | apt_pkg.init_config() |
107 | 987 | self.button_revert.set_sensitive(True) | 999 | self.button_revert.set_sensitive(True) |
108 | 988 | 1000 | ||
109 | 989 | def on_keys_modified(self): | 1001 | def on_keys_modified(self): |
110 | @@ -1226,7 +1238,7 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
111 | 1226 | if not installs_pending: | 1238 | if not installs_pending: |
112 | 1227 | self.progress_bar.set_visible(False) | 1239 | self.progress_bar.set_visible(False) |
113 | 1228 | self.clear_changes() | 1240 | self.clear_changes() |
115 | 1229 | self.apt_cache = apt.Cache() | 1241 | self.update_apt_cache() |
116 | 1230 | self.set_driver_action_status() | 1242 | self.set_driver_action_status() |
117 | 1231 | self.update_label_and_icons_from_status() | 1243 | self.update_label_and_icons_from_status() |
118 | 1232 | self.button_driver_revert.set_visible(True) | 1244 | self.button_driver_revert.set_visible(True) |
119 | @@ -1239,19 +1251,20 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
120 | 1239 | installs = [] | 1251 | installs = [] |
121 | 1240 | removals = [] | 1252 | removals = [] |
122 | 1241 | 1253 | ||
123 | 1254 | has_nvidia = False | ||
124 | 1242 | for pkg in self.driver_changes: | 1255 | for pkg in self.driver_changes: |
127 | 1243 | if pkg.is_installed: | 1256 | if pkg.current_ver: |
128 | 1244 | removals.append(self.get_package_id(pkg.installed)) | 1257 | removals.append(self.get_package_id(self.apt_cache, pkg)) |
129 | 1245 | # The main NVIDIA package is only a metapackage. | 1258 | # The main NVIDIA package is only a metapackage. |
130 | 1246 | # We need to collect its dependencies, so that | 1259 | # We need to collect its dependencies, so that |
131 | 1247 | # we can uninstall the driver properly. | 1260 | # we can uninstall the driver properly. |
137 | 1248 | if 'nvidia' in pkg.shortname: | 1261 | if 'nvidia' in pkg.name: |
138 | 1249 | for dep in self.get_dependencies(self.apt_cache, pkg.shortname, 'nvidia'): | 1262 | has_nvidia = True |
139 | 1250 | dep_pkg = self.apt_cache[dep] | 1263 | for dep in self.get_dependencies(self.apt_cache, pkg, 'nvidia'): |
140 | 1251 | if dep_pkg.is_installed: | 1264 | if dep.current_ver: |
141 | 1252 | removals.append(self.get_package_id(dep_pkg.installed)) | 1265 | removals.append(self.get_package_id(self.apt_cache, dep)) |
142 | 1253 | else: | 1266 | else: |
144 | 1254 | installs.append(self.get_package_id(pkg.candidate)) | 1267 | installs.append(self.get_package_id(self.apt_cache, pkg)) |
145 | 1255 | 1268 | ||
146 | 1256 | self.cancellable = Gio.Cancellable() | 1269 | self.cancellable = Gio.Cancellable() |
147 | 1257 | try: | 1270 | try: |
148 | @@ -1269,6 +1282,11 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
149 | 1269 | installs_pending # callback data | 1282 | installs_pending # callback data |
150 | 1270 | ) | 1283 | ) |
151 | 1271 | if installs: | 1284 | if installs: |
152 | 1285 | if has_nvidia: | ||
153 | 1286 | to_install = [] | ||
154 | 1287 | for item in installs: | ||
155 | 1288 | name = item.split(';')[0] | ||
156 | 1289 | to_install.append(name) | ||
157 | 1272 | self.pk_task.install_packages_async(installs, | 1290 | self.pk_task.install_packages_async(installs, |
158 | 1273 | self.cancellable, # cancellable | 1291 | self.cancellable, # cancellable |
159 | 1274 | self.on_driver_changes_progress, | 1292 | self.on_driver_changes_progress, |
160 | @@ -1376,7 +1394,6 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
161 | 1376 | # WARNING: This is run in a separate thread. | 1394 | # WARNING: This is run in a separate thread. |
162 | 1377 | self.detect_called = True | 1395 | self.detect_called = True |
163 | 1378 | try: | 1396 | try: |
164 | 1379 | self.apt_cache = apt.Cache() | ||
165 | 1380 | self.devices = detect.system_device_drivers(self.apt_cache) | 1397 | self.devices = detect.system_device_drivers(self.apt_cache) |
166 | 1381 | except: | 1398 | except: |
167 | 1382 | # Catch all exceptions and feed them to apport. | 1399 | # Catch all exceptions and feed them to apport. |
168 | @@ -1395,22 +1412,16 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
169 | 1395 | return | 1412 | return |
170 | 1396 | 1413 | ||
171 | 1397 | pkg = None | 1414 | pkg = None |
188 | 1398 | try: | 1415 | if pkg_name: |
189 | 1399 | if pkg_name: | 1416 | pkg = self.apt_cache[pkg_name] |
190 | 1400 | pkg = self.apt_cache[pkg_name] | 1417 | # Add the matching linux modules package when available |
191 | 1401 | # If the package depends on dkms | 1418 | try: |
192 | 1402 | # we need to install the correct linux metapackage | 1419 | modules_package = detect.get_linux_modules_metapackage(self.apt_cache, pkg_name) |
193 | 1403 | # so that users get the latest headers | 1420 | modules_package_obj = self.apt_cache[modules_package] |
194 | 1404 | if 'dkms' in pkg.candidate.record['Depends']: | 1421 | if modules_package and not modules_package_obj.current_ver: |
195 | 1405 | linux_meta = detect.get_linux(self.apt_cache) | 1422 | self.driver_changes.append(modules_package_obj) |
196 | 1406 | if (linux_meta and | 1423 | except KeyError: |
197 | 1407 | linux_meta not in self.driver_changes): | 1424 | pass |
182 | 1408 | # Install the linux metapackage | ||
183 | 1409 | lmp = self.apt_cache[linux_meta] | ||
184 | 1410 | if not lmp.is_installed: | ||
185 | 1411 | self.driver_changes.append(lmp) | ||
186 | 1412 | except (AttributeError, KeyError): | ||
187 | 1413 | pass | ||
198 | 1414 | 1425 | ||
199 | 1415 | if button.get_active(): | 1426 | if button.get_active(): |
200 | 1416 | if pkg in self.driver_changes: | 1427 | if pkg in self.driver_changes: |
201 | @@ -1430,7 +1441,7 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
202 | 1430 | 1441 | ||
203 | 1431 | if (pkg is not None | 1442 | if (pkg is not None |
204 | 1432 | and pkg not in self.driver_changes | 1443 | and pkg not in self.driver_changes |
206 | 1433 | and pkg.is_installed): | 1444 | and pkg.current_ver): |
207 | 1434 | self.driver_changes.append(pkg) | 1445 | self.driver_changes.append(pkg) |
208 | 1435 | 1446 | ||
209 | 1436 | self.button_driver_revert.set_sensitive(bool(self.driver_changes)) | 1447 | self.button_driver_revert.set_sensitive(bool(self.driver_changes)) |
210 | @@ -1492,11 +1503,14 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
211 | 1492 | 1503 | ||
212 | 1493 | try: | 1504 | try: |
213 | 1494 | pkg = self.apt_cache[pkg_driver_name] | 1505 | pkg = self.apt_cache[pkg_driver_name] |
217 | 1495 | installed = pkg.is_installed | 1506 | installed = pkg.current_ver |
218 | 1496 | if pkg.candidate is not None: | 1507 | candidate = self.depcache.get_candidate_ver(pkg) |
219 | 1497 | description = _("Using {} from {}").format(pkg.candidate.summary, pkg.shortname) | 1508 | |
220 | 1509 | if candidate is not None: | ||
221 | 1510 | self.records.lookup(candidate.file_list[0]) | ||
222 | 1511 | description = _("Using {} from {}").format(self.records.short_desc, pkg_driver_name) | ||
223 | 1498 | else: | 1512 | else: |
225 | 1499 | description = _("Using {}").format(pkg.shortname) | 1513 | description = _("Using {}").format(pkg_driver_name) |
226 | 1500 | except KeyError: | 1514 | except KeyError: |
227 | 1501 | print("WARNING: a driver ({}) doesn't have any available package associated: {}".format(pkg_driver_name, current_driver)) | 1515 | print("WARNING: a driver ({}) doesn't have any available package associated: {}".format(pkg_driver_name, current_driver)) |
228 | 1502 | continue | 1516 | continue |
229 | @@ -1626,7 +1640,7 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp): | |||
230 | 1626 | for device in self.devices: | 1640 | for device in self.devices: |
231 | 1627 | for pkg_name in self.devices[device]['drivers']: | 1641 | for pkg_name in self.devices[device]['drivers']: |
232 | 1628 | pkg = self.apt_cache[pkg_name] | 1642 | pkg = self.apt_cache[pkg_name] |
234 | 1629 | if not self.devices[device]['drivers'][pkg_name]['free'] and pkg.is_installed: | 1643 | if not self.devices[device]['drivers'][pkg_name]['free'] and pkg.current_ver: |
235 | 1630 | self.nonfree_drivers = self.nonfree_drivers + 1 | 1644 | self.nonfree_drivers = self.nonfree_drivers + 1 |
236 | 1631 | 1645 | ||
237 | 1632 | if self.nonfree_drivers > 0: | 1646 | if self.nonfree_drivers > 0: |
238 | diff --git a/softwareproperties/qt/SoftwarePropertiesQt.py b/softwareproperties/qt/SoftwarePropertiesQt.py | |||
239 | index 332bf06..e9e5818 100644 | |||
240 | --- a/softwareproperties/qt/SoftwarePropertiesQt.py | |||
241 | +++ b/softwareproperties/qt/SoftwarePropertiesQt.py | |||
242 | @@ -55,7 +55,6 @@ from .CdromProgress import CdromProgress | |||
243 | 55 | 55 | ||
244 | 56 | from UbuntuDrivers import detect | 56 | from UbuntuDrivers import detect |
245 | 57 | import sys | 57 | import sys |
246 | 58 | import apt | ||
247 | 59 | from functools import partial | 58 | from functools import partial |
248 | 60 | import aptsources.distro | 59 | import aptsources.distro |
249 | 61 | import logging | 60 | import logging |
250 | @@ -345,6 +344,18 @@ class SoftwarePropertiesQt(SoftwareProperties): | |||
251 | 345 | self.userinterface.combobox_server.addItem(_("Other...")) | 344 | self.userinterface.combobox_server.addItem(_("Other...")) |
252 | 346 | self.other_mirrors_index = self.userinterface.combobox_server.count() - 1 | 345 | self.other_mirrors_index = self.userinterface.combobox_server.count() - 1 |
253 | 347 | 346 | ||
254 | 347 | def init_apt_cache(self): | ||
255 | 348 | apt_pkg.init_config() | ||
256 | 349 | apt_pkg.init_system() | ||
257 | 350 | self.apt_cache = apt_pkg.Cache(None) | ||
258 | 351 | self.depcache = apt_pkg.DepCache(self.apt_cache) | ||
259 | 352 | self.records = apt_pkg.PackageRecords(self.apt_cache) | ||
260 | 353 | |||
261 | 354 | def update_apt_cache(self): | ||
262 | 355 | self.apt_cache = apt_pkg.Cache(None) | ||
263 | 356 | self.depcache = apt_pkg.DepCache(self.apt_cache) | ||
264 | 357 | self.records = apt_pkg.PackageRecords(self.apt_cache) | ||
265 | 358 | |||
266 | 348 | def show_distro(self): | 359 | def show_distro(self): |
267 | 349 | """ | 360 | """ |
268 | 350 | Represent the distro information in the user interface | 361 | Represent the distro information in the user interface |
269 | @@ -736,7 +747,7 @@ class SoftwarePropertiesQt(SoftwareProperties): | |||
270 | 736 | 747 | ||
271 | 737 | def on_restore_clicked(self): | 748 | def on_restore_clicked(self): |
272 | 738 | """Restore the original keys""" | 749 | """Restore the original keys""" |
274 | 739 | self.apt_key.update() | 750 | self.update_apt_cache() |
275 | 740 | self.show_keys() | 751 | self.show_keys() |
276 | 741 | 752 | ||
277 | 742 | def on_pktask_progress(self, progress, ptype, udata=(None,)): | 753 | def on_pktask_progress(self, progress, ptype, udata=(None,)): |
278 | @@ -859,7 +870,7 @@ class SoftwarePropertiesQt(SoftwareProperties): | |||
279 | 859 | if not installs_pending: | 870 | if not installs_pending: |
280 | 860 | self.progress_bar.setVisible(False) | 871 | self.progress_bar.setVisible(False) |
281 | 861 | self.clear_changes() | 872 | self.clear_changes() |
283 | 862 | self.apt_cache = apt.Cache() | 873 | self.update_apt_cache() |
284 | 863 | self.set_driver_action_status() | 874 | self.set_driver_action_status() |
285 | 864 | self.update_label_and_icons_from_status() | 875 | self.update_label_and_icons_from_status() |
286 | 865 | self.button_driver_revert.setVisible(True) | 876 | self.button_driver_revert.setVisible(True) |
287 | @@ -885,19 +896,20 @@ class SoftwarePropertiesQt(SoftwareProperties): | |||
288 | 885 | installs = [] | 896 | installs = [] |
289 | 886 | removals = [] | 897 | removals = [] |
290 | 887 | 898 | ||
291 | 899 | has_nvidia = False | ||
292 | 888 | for pkg in self.driver_changes: | 900 | for pkg in self.driver_changes: |
295 | 889 | if pkg.is_installed: | 901 | if pkg.current_ver: |
296 | 890 | removals.append(self.get_package_id(pkg.installed)) | 902 | removals.append(self.get_package_id(self.apt_cache, pkg)) |
297 | 891 | # The main NVIDIA package is only a metapackage. | 903 | # The main NVIDIA package is only a metapackage. |
298 | 892 | # We need to collect its dependencies, so that | 904 | # We need to collect its dependencies, so that |
299 | 893 | # we can uninstall the driver properly. | 905 | # we can uninstall the driver properly. |
305 | 894 | if 'nvidia' in pkg.shortname: | 906 | if 'nvidia' in pkg.name: |
306 | 895 | for dep in self.get_dependencies(self.apt_cache, pkg.shortname, 'nvidia'): | 907 | has_nvidia = True |
307 | 896 | dep_pkg = self.apt_cache[dep] | 908 | for dep in self.get_dependencies(self.apt_cache, pkg, 'nvidia'): |
308 | 897 | if dep_pkg.is_installed: | 909 | if dep.current_ver: |
309 | 898 | removals.append(self.get_package_id(dep_pkg.installed)) | 910 | removals.append(self.get_package_id(self.apt_cache, dep)) |
310 | 899 | else: | 911 | else: |
312 | 900 | installs.append(self.get_package_id(pkg.candidate)) | 912 | installs.append(self.get_package_id(self.apt_cache, pkg)) |
313 | 901 | 913 | ||
314 | 902 | self.cancellable = Gio.Cancellable() | 914 | self.cancellable = Gio.Cancellable() |
315 | 903 | try: | 915 | try: |
316 | @@ -915,6 +927,11 @@ class SoftwarePropertiesQt(SoftwareProperties): | |||
317 | 915 | installs_pending # callback data | 927 | installs_pending # callback data |
318 | 916 | ) | 928 | ) |
319 | 917 | if installs: | 929 | if installs: |
320 | 930 | if has_nvidia: | ||
321 | 931 | to_install = [] | ||
322 | 932 | for item in installs: | ||
323 | 933 | name = item.split(';')[0] | ||
324 | 934 | to_install.append(name) | ||
325 | 918 | self.pk_task.install_packages_async(installs, | 935 | self.pk_task.install_packages_async(installs, |
326 | 919 | self.cancellable, # cancellable | 936 | self.cancellable, # cancellable |
327 | 920 | self.on_driver_changes_progress, | 937 | self.on_driver_changes_progress, |
328 | @@ -1019,8 +1036,8 @@ class SoftwarePropertiesQt(SoftwareProperties): | |||
329 | 1019 | def detect_drivers(self): | 1036 | def detect_drivers(self): |
330 | 1020 | # WARNING: This is run in a separate thread. | 1037 | # WARNING: This is run in a separate thread. |
331 | 1021 | self.detect_called = True | 1038 | self.detect_called = True |
332 | 1039 | self.init_apt_cache() | ||
333 | 1022 | try: | 1040 | try: |
334 | 1023 | self.apt_cache = apt.Cache() | ||
335 | 1024 | self.devices = detect.system_device_drivers(self.apt_cache) | 1041 | self.devices = detect.system_device_drivers(self.apt_cache) |
336 | 1025 | except: | 1042 | except: |
337 | 1026 | # Catch all exceptions and feed them to apport. | 1043 | # Catch all exceptions and feed them to apport. |
338 | @@ -1039,21 +1056,17 @@ class SoftwarePropertiesQt(SoftwareProperties): | |||
339 | 1039 | return | 1056 | return |
340 | 1040 | 1057 | ||
341 | 1041 | pkg = None | 1058 | pkg = None |
357 | 1042 | try: | 1059 | |
358 | 1043 | if pkg_name: | 1060 | if pkg_name: |
359 | 1044 | pkg = self.apt_cache[pkg_name] | 1061 | pkg = self.apt_cache[pkg_name] |
360 | 1045 | # If the package depends on dkms | 1062 | # Add the matching linux modules package when available |
361 | 1046 | # we need to install the correct linux metapackage | 1063 | try: |
362 | 1047 | # so that users get the latest headers | 1064 | modules_package = detect.get_linux_modules_metapackage(self.apt_cache, pkg_name) |
363 | 1048 | if 'dkms' in pkg.candidate.record['Depends']: | 1065 | modules_package_obj = self.apt_cache[modules_package] |
364 | 1049 | linux_meta = detect.get_linux(self.apt_cache) | 1066 | if modules_package and not modules_package_obj.current_ver: |
365 | 1050 | if (linux_meta and linux_meta not in self.driver_changes): | 1067 | self.driver_changes.append(modules_package_obj) |
366 | 1051 | # Install the linux metapackage | 1068 | except KeyError: |
367 | 1052 | lmp = self.apt_cache[linux_meta] | 1069 | pass |
353 | 1053 | if not lmp.is_installed: | ||
354 | 1054 | self.driver_changes.append(lmp) | ||
355 | 1055 | except KeyError: | ||
356 | 1056 | pass | ||
368 | 1057 | 1070 | ||
369 | 1058 | if button.isChecked(): | 1071 | if button.isChecked(): |
370 | 1059 | if pkg in self.driver_changes: | 1072 | if pkg in self.driver_changes: |
371 | @@ -1069,7 +1082,7 @@ class SoftwarePropertiesQt(SoftwareProperties): | |||
372 | 1069 | if modalias not in self.orig_selection: | 1082 | if modalias not in self.orig_selection: |
373 | 1070 | self.orig_selection[modalias] = button | 1083 | self.orig_selection[modalias] = button |
374 | 1071 | 1084 | ||
376 | 1072 | if (pkg is not None and pkg not in self.driver_changes and pkg.is_installed): | 1085 | if (pkg is not None and pkg not in self.driver_changes and pkg.current_ver): |
377 | 1073 | self.driver_changes.append(pkg) | 1086 | self.driver_changes.append(pkg) |
378 | 1074 | 1087 | ||
379 | 1075 | self.button_driver_revert.setEnabled(bool(self.driver_changes)) | 1088 | self.button_driver_revert.setEnabled(bool(self.driver_changes)) |
380 | @@ -1137,11 +1150,13 @@ None if not applicable | |||
381 | 1137 | 1150 | ||
382 | 1138 | try: | 1151 | try: |
383 | 1139 | pkg = self.apt_cache[pkg_driver_name] | 1152 | pkg = self.apt_cache[pkg_driver_name] |
387 | 1140 | installed = pkg.is_installed | 1153 | installed = pkg.current_ver or False |
388 | 1141 | if pkg.candidate is not None: | 1154 | candidate = self.depcache.get_candidate_ver(pkg) |
389 | 1142 | description = _("Using {} from {}").format(pkg.candidate.summary, pkg.shortname) | 1155 | if candidate is not None: |
390 | 1156 | self.records.lookup(candidate.file_list[0]) | ||
391 | 1157 | description = _("Using {} from {}").format(self.records.short_desc, pkg_driver_name) | ||
392 | 1143 | else: | 1158 | else: |
394 | 1144 | description = _("Using {}").format(pkg.shortname) | 1159 | description = _("Using {}").format(pkg_driver_name) |
395 | 1145 | except KeyError: | 1160 | except KeyError: |
396 | 1146 | print("WARNING: a driver ({}) doesn't have any available package associated: {}".format(pkg_driver_name, current_driver)) | 1161 | print("WARNING: a driver ({}) doesn't have any available package associated: {}".format(pkg_driver_name, current_driver)) |
397 | 1147 | continue | 1162 | continue |
398 | @@ -1277,7 +1292,7 @@ licence=licence) | |||
399 | 1277 | for device in self.devices: | 1292 | for device in self.devices: |
400 | 1278 | for pkg_name in self.devices[device]['drivers']: | 1293 | for pkg_name in self.devices[device]['drivers']: |
401 | 1279 | pkg = self.apt_cache[pkg_name] | 1294 | pkg = self.apt_cache[pkg_name] |
403 | 1280 | if not self.devices[device]['drivers'][pkg_name]['free'] and pkg.is_installed: | 1295 | if not self.devices[device]['drivers'][pkg_name]['free'] and pkg.current_ver: |
404 | 1281 | self.nonfree_drivers = self.nonfree_drivers + 1 | 1296 | self.nonfree_drivers = self.nonfree_drivers + 1 |
405 | 1282 | 1297 | ||
406 | 1283 | if self.nonfree_drivers > 0: | 1298 | if self.nonfree_drivers > 0: |
Hi Alberto,
I tried to build and test your patch, but it fails on the pyflakes3 test:
$ python3 tests/test_ pyflakes. py Work/lp1964880/ alberto/ software- properties/ softwarepropert ies/SoftwarePro perties. py:29:1 'apt' imported but unused Work/lp1964880/ alberto/ software- properties/ softwarepropert ies/SoftwarePro perties. py:753: 9 redefinition of unused 'apt' from line 29 ======= ======= ======= ======= ======= ======= ======= ======= ======= clean (__main_ _.TestPyflakesC lean) ------- ------- ------- ------- ------- ------- ------- ------- ------- matthew/ Work/lp1964880/ alberto/ software- properties/ tests/test_ pyflakes. py", line 21, in test_pyflakes3_ clean assertEqual( subprocess. check_call( ['pyflakes3' ] + self.paths), 0) python3. 10/subprocess. py", line 369, in check_call ror(retcode, cmd)
/home/matthew/
/home/matthew/
E
=======
ERROR: test_pyflakes3_
-------
Traceback (most recent call last):
File "/home/
self.
File "/usr/lib/
raise CalledProcessEr