Merge ~schopin/ubuntu-release-upgrader:nvidia-quirk into ubuntu-release-upgrader:ubuntu/jammy

Proposed by Simon Chopin
Status: Merged
Merged at revision: 9a45503daefb3ec95fc97b9e7df7f3427f46a8e1
Proposed branch: ~schopin/ubuntu-release-upgrader:nvidia-quirk
Merge into: ubuntu-release-upgrader:ubuntu/jammy
Diff against target: 69 lines (+46/-0)
2 files modified
DistUpgrade/DistUpgradeQuirks.py (+40/-0)
debian/changelog (+6/-0)
Reviewer Review Type Date Requested Status
Brian Murray Needs Fixing
Julian Andres Klode Approve
Review via email: mp+427718@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Simon Chopin (schopin) wrote :

This has been tested on proper hardware, worked as expected when upgrading from a fresh 22.04.3 install, while not doing anything when upgrading from Impish or from a server install.

Revision history for this message
Julian Andres Klode (juliank) :
review: Needs Fixing
Revision history for this message
Julian Andres Klode (juliank) wrote :

Approving this as it should not cause terrible breakage at least even if something else called commit on the same cache, but this should be investigated further and resolved differently I suppose.

review: Approve
Revision history for this message
Brian Murray (brian-murray) wrote :

I see one typo, which I'm happy to fix, but there is a more serious question about what to do when the driver metapackage isn't available in the cache.

review: Needs Fixing
Revision history for this message
Steve Langasek (vorlon) wrote :

If the driver metapackage is not available in the cache, I think the preference should be to abort and tell the user to fix their sources - rather than proceeding with the upgrade and breaking their desktop setup.

That's also the more conservative option, because affected users will be held back and we can iterate further improvements on the upgrader as necessary - rather than them being upgraded and broken.

Revision history for this message
Brian Murray (brian-murray) wrote (last edit ):

> If the driver metapackage is not available in the cache, I think the
> preference should be to abort and tell the user to fix their sources - rather
> than proceeding with the upgrade and breaking their desktop setup.
>
> That's also the more conservative option, because affected users will be held
> back and we can iterate further improvements on the upgrader as necessary -
> rather than them being upgraded and broken.

I've gone ahead and created a new merge proposal building on this but it exits if the driver metapackage is not available.

https://code.launchpad.net/~ubuntu-core-dev/ubuntu-release-upgrader/+git/ubuntu-release-upgrader/+merge/427736

Revision history for this message
Nick Rosbrook (enr0n) :

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..f60e3c0 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,42 @@ 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+ desktop = 'nvidia-driver-{}'.format(version)
34+ if desktop in cache and cache[desktop].is_installed:
35+ logging.debug("package {} detected, exit.".format(desktop))
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+ return
53+ logging.debug("Installing missing nvidia driver metapackage {}".format(missing_metapackage))
54+ cache[missing_metapackage].mark_install()
55+ cache.commit(None, None)
56diff --git a/debian/changelog b/debian/changelog
57index 9ca24a5..6f3ba43 100644
58--- a/debian/changelog
59+++ b/debian/changelog
60@@ -1,3 +1,9 @@
61+ubuntu-release-upgrader (1:22.04.13) UNRELEASED; urgency=medium
62+
63+ * quirk: fix nvidia driver autoremoval issue (LP: #1955047)
64+
65+ -- Simon Chopin <schopin@ubuntu.com> Tue, 02 Aug 2022 15:45:26 +0200
66+
67 ubuntu-release-upgrader (1:22.04.12) jammy; urgency=medium
68
69 [ Brian Murray ]

Subscribers

People subscribed via source and target branches