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
diff --git a/DistUpgrade/DistUpgradeQuirks.py b/DistUpgrade/DistUpgradeQuirks.py
index c6be753..4754b94 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,51 @@ 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 driver = 'nvidia-driver-{}'.format(version)
1458 if driver in cache and cache[driver].is_installed:
1459 logging.debug("package {} detected, exit.".format(driver))
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 summary = _("NVIDIA driver metapackage unavailable")
1477 msg = _("Your system has the package libnvidia-gl-%s installed "
1478 "but the corresponding metapackage nvidia-driver-%s is "
1479 "not installed and is not available to be installed. "
1480 "The upgrade process was not able to automatically fix "
1481 "this issue and consequently the upgrade will now exit." %
1482 (version_to_fix, version_to_fix))
1483 self._view.error(summary, msg)
1484 self.controller.abort()
1485 return
1486 logging.debug("Installing missing nvidia driver metapackage {}".format(missing_metapackage))
1487 cache[missing_metapackage].mark_install()
1488 cache.commit(None, None)
diff --git a/debian/changelog b/debian/changelog
index 9ca24a5..128717e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
1ubuntu-release-upgrader (1:22.04.13) UNRELEASED; urgency=medium
2
3 * Add a quirk to resolve an issue where the nvidia driver would get
4 suggested for autoremoval. (LP: #1955047)
5
6 -- Simon Chopin <schopin@ubuntu.com> Tue, 02 Aug 2022 15:45:26 +0200
7
1ubuntu-release-upgrader (1:22.04.12) jammy; urgency=medium8ubuntu-release-upgrader (1:22.04.12) jammy; urgency=medium
29
3 [ Brian Murray ]10 [ Brian Murray ]

Subscribers

People subscribed via source and target branches