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
diff --git a/DistUpgrade/DistUpgradeQuirks.py b/DistUpgrade/DistUpgradeQuirks.py
index c6be753..f60e3c0 100644
--- a/DistUpgrade/DistUpgradeQuirks.py
+++ b/DistUpgrade/DistUpgradeQuirks.py
@@ -122,6 +122,7 @@ class DistUpgradeQuirks(object):
122122
123 cache = self.controller.cache123 cache = self.controller.cache
124 self._test_and_warn_if_ros_installed(cache)124 self._test_and_warn_if_ros_installed(cache)
125 self._fix_missing_nvidia_metapackage()
125126
126 if 'snapd' not in cache:127 if 'snapd' not in cache:
127 logging.debug("package required for Quirk not in cache")128 logging.debug("package required for Quirk not in cache")
@@ -1437,3 +1438,42 @@ class DistUpgradeQuirks(object):
1437 "%s: %s; %s",1438 "%s: %s; %s",
1438 netplan_config_filename, exc, failure_action)1439 netplan_config_filename, exc, failure_action)
1439 return1440 return
1441
1442 def _fix_missing_nvidia_metapackage(self):
1443 # LP: #1955047
1444 # Desktop installs for 20.04.3 on systems with nvidia graphics don't have the
1445 # driver metapackage installed
1446 logging.debug("running Quirks._test_and_fix_missing_nvidia_metapackage")
1447 try:
1448 from NvidiaDetector.nvidiadetector import NvidiaDetection
1449 except (ImportError) as e:
1450 logging.error("NvidiaDetection can not be imported %s" % e)
1451 return
1452 nv = NvidiaDetection()
1453 versions = nv.drivers.keys()
1454 cache = self.controller.cache
1455 # Early exit if there's a driver metapackage installed
1456 for version in versions:
1457 desktop = 'nvidia-driver-{}'.format(version)
1458 if desktop in cache and cache[desktop].is_installed:
1459 logging.debug("package {} detected, exit.".format(desktop))
1460 return;
1461 version_to_fix = None
1462 # If we find an autoremovable libnvidia-gl package, this probably means the user
1463 # hit LP: #1955047
1464 for version in versions:
1465 nvidia_gl = 'libnvidia-gl-{}'.format(version)
1466 if nvidia_gl in cache and cache[nvidia_gl].is_installed and cache[nvidia_gl].is_auto_removable:
1467 version_to_fix = version
1468 logging.debug("Found autoremovable package {}, assuming we're missing nvidia-driver-{}".format(nvidia_gl, version))
1469 break
1470 if version_to_fix is None:
1471 logging.debug("No autoremovable libnvidia-gl found, exiting.")
1472 return
1473 missing_metapackage = "nvidia-driver-{}".format(version_to_fix)
1474 if missing_metapackage not in cache:
1475 logging.error("Package {} not available in the APT cache!".format(missing_metapackage))
1476 return
1477 logging.debug("Installing missing nvidia driver metapackage {}".format(missing_metapackage))
1478 cache[missing_metapackage].mark_install()
1479 cache.commit(None, None)
diff --git a/debian/changelog b/debian/changelog
index 9ca24a5..6f3ba43 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
1ubuntu-release-upgrader (1:22.04.13) UNRELEASED; urgency=medium
2
3 * quirk: fix nvidia driver autoremoval issue (LP: #1955047)
4
5 -- Simon Chopin <schopin@ubuntu.com> Tue, 02 Aug 2022 15:45:26 +0200
6
1ubuntu-release-upgrader (1:22.04.12) jammy; urgency=medium7ubuntu-release-upgrader (1:22.04.12) jammy; urgency=medium
28
3 [ Brian Murray ]9 [ Brian Murray ]

Subscribers

People subscribed via source and target branches