Merge ubuntu-release-upgrader:nvidia-quirk-abort into ubuntu-release-upgrader:ubuntu/jammy

Proposed by Brian Murray
Status: Merged
Approved by: Steve Langasek
Approved revision: 63ceabe06f465c3308bd78e10d938e3633ceb5af
Merged at revision: 742e630c7cae0a6dbe18fee75a584e910bc16f75
Proposed branch: ubuntu-release-upgrader:nvidia-quirk-abort
Merge into: ubuntu-release-upgrader:ubuntu/jammy
Diff against target: 79 lines (+56/-0)
2 files modified
DistUpgrade/DistUpgradeQuirks.py (+49/-0)
debian/changelog (+7/-0)
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Review via email: mp+427736@code.launchpad.net

This proposal supersedes a proposal from 2022-08-02.

Description of the change

This builds upon the work in https://code.launchpad.net/~schopin/ubuntu-release-upgrader/+git/ubuntu-release-upgrader/+merge/427718 but exits the release upgrade process if the nvidia driver metapackage can not be installed.

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
Revision history for this message
Brian Murray (brian-murray) wrote :

I've made the changes suggested.

Revision history for this message
Steve Langasek (vorlon) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/DistUpgrade/DistUpgradeQuirks.py b/DistUpgrade/DistUpgradeQuirks.py
2index c6be753..4754b94 100644
3--- a/DistUpgrade/DistUpgradeQuirks.py
4+++ b/DistUpgrade/DistUpgradeQuirks.py
5@@ -122,6 +122,7 @@ class DistUpgradeQuirks(object):
6
7 cache = self.controller.cache
8 self._test_and_warn_if_ros_installed(cache)
9+ self._fix_missing_nvidia_metapackage()
10
11 if 'snapd' not in cache:
12 logging.debug("package required for Quirk not in cache")
13@@ -1437,3 +1438,51 @@ class DistUpgradeQuirks(object):
14 "%s: %s; %s",
15 netplan_config_filename, exc, failure_action)
16 return
17+
18+ def _fix_missing_nvidia_metapackage(self):
19+ # LP: #1955047
20+ # Desktop installs for 20.04.3 on systems with nvidia graphics don't have the
21+ # driver metapackage installed
22+ logging.debug("running Quirks._test_and_fix_missing_nvidia_metapackage")
23+ try:
24+ from NvidiaDetector.nvidiadetector import NvidiaDetection
25+ except (ImportError) as e:
26+ logging.error("NvidiaDetection can not be imported %s" % e)
27+ return
28+ nv = NvidiaDetection()
29+ versions = nv.drivers.keys()
30+ cache = self.controller.cache
31+ # Early exit if there's a driver metapackage installed
32+ for version in versions:
33+ driver = 'nvidia-driver-{}'.format(version)
34+ if driver in cache and cache[driver].is_installed:
35+ logging.debug("package {} detected, exit.".format(driver))
36+ return
37+ version_to_fix = None
38+ # If we find an autoremovable libnvidia-gl package, this probably means the user
39+ # hit LP: #1955047
40+ for version in versions:
41+ nvidia_gl = 'libnvidia-gl-{}'.format(version)
42+ if nvidia_gl in cache and cache[nvidia_gl].is_installed and cache[nvidia_gl].is_auto_removable:
43+ version_to_fix = version
44+ logging.debug("Found autoremovable package {}, assuming we're missing nvidia-driver-{}".format(nvidia_gl, version))
45+ break
46+ if version_to_fix is None:
47+ logging.debug("No autoremovable libnvidia-gl found, exiting.")
48+ return
49+ missing_metapackage = "nvidia-driver-{}".format(version_to_fix)
50+ if missing_metapackage not in cache:
51+ logging.error("Package {} not available in the APT cache!".format(missing_metapackage))
52+ summary = _("NVIDIA driver metapackage unavailable")
53+ msg = _("Your system has the package libnvidia-gl-%s installed "
54+ "but the corresponding metapackage nvidia-driver-%s is "
55+ "not installed and is not available to be installed. "
56+ "The upgrade process was not able to automatically fix "
57+ "this issue and consequently the upgrade will now exit." %
58+ (version_to_fix, version_to_fix))
59+ self._view.error(summary, msg)
60+ self.controller.abort()
61+ return
62+ logging.debug("Installing missing nvidia driver metapackage {}".format(missing_metapackage))
63+ cache[missing_metapackage].mark_install()
64+ cache.commit(None, None)
65diff --git a/debian/changelog b/debian/changelog
66index 9ca24a5..128717e 100644
67--- a/debian/changelog
68+++ b/debian/changelog
69@@ -1,3 +1,10 @@
70+ubuntu-release-upgrader (1:22.04.13) UNRELEASED; urgency=medium
71+
72+ * Add a quirk to resolve an issue where the nvidia driver would get
73+ suggested for autoremoval. (LP: #1955047)
74+
75+ -- Simon Chopin <schopin@ubuntu.com> Tue, 02 Aug 2022 15:45:26 +0200
76+
77 ubuntu-release-upgrader (1:22.04.12) jammy; urgency=medium
78
79 [ Brian Murray ]

Subscribers

People subscribed via source and target branches