[Merge] ubuntu-release-upgrader:nvidia-quirk-abort into ubuntu-release-upgrader:ubuntu/jammy
Brian Murray
mp+427736 at code.launchpad.net
Tue Aug 2 20:22:34 UTC 2022
I've made the changes suggested.
Diff comments:
> diff --git a/DistUpgrade/DistUpgradeQuirks.py b/DistUpgrade/DistUpgradeQuirks.py
> index c6be753..1b5fa97 100644
> --- a/DistUpgrade/DistUpgradeQuirks.py
> +++ b/DistUpgrade/DistUpgradeQuirks.py
> @@ -1437,3 +1438,51 @@ class DistUpgradeQuirks(object):
> "%s: %s; %s",
> netplan_config_filename, exc, failure_action)
> return
> +
> + def _fix_missing_nvidia_metapackage(self):
> + # LP: #1955047
> + # Desktop installs for 20.04.3 on systems with nvidia graphics don't have the
> + # driver metapackage installed
> + logging.debug("running Quirks._test_and_fix_missing_nvidia_metapackage")
> + try:
> + from NvidiaDetector.nvidiadetector import NvidiaDetection
> + except (ImportError) as e:
> + logging.error("NvidiaDetection can not be imported %s" % e)
> + return
> + nv = NvidiaDetection()
> + versions = nv.drivers.keys()
> + cache = self.controller.cache
> + # Early exit if there's a driver metapackage installed
> + for version in versions:
> + driver = 'nvidia-driver-{}'.format(version)
> + if driver in cache and cache[driver].is_installed:
> + logging.debug("package {} detected, exit.".format(driver))
> + return
> + version_to_fix = None
> + # If we find an autoremovable libnvidia-gl package, this probably means the user
> + # hit LP: #1955047
> + for version in versions:
> + nvidia_gl = 'libnvidia-gl-{}'.format(version)
> + if nvidia_gl in cache and cache[nvidia_gl].is_installed and cache[nvidia_gl].is_auto_removable:
> + version_to_fix = version
> + logging.debug("Found autoremovable package {}, assuming we're missing nvidia-driver-{}".format(nvidia_gl, version))
> + break
> + if version_to_fix is None:
> + logging.debug("No autoremovable libnvidia-gl found, exiting.")
> + return
> + missing_metapackage = "nvidia-driver-{}".format(version_to_fix)
> + if missing_metapackage not in cache:
> + logging.error("Package {} not available in the APT cache!".format(missing_metapackage))
> + summary = _("NVIDIA driver metapackage unavailable")
> + msg = _("Your system has the package libnvidia-gl-%s installed "
> + "but the corresponding metapackage nvidia-driver-%s is "
> + "not installed and is not available to be installed. "
> + "The upgrade process was not able to automatically fix "
> + "this issue and subsequently the upgrade will now exit." %
> + (version, version))
Yes, thanks.
> + self._view.error(summary, msg)
> + self.controller.abort()
> + return
> + logging.debug("Installing missing nvidia driver metapackage {}".format(missing_metapackage))
> + cache[missing_metapackage].mark_install()
> + cache.commit(None, None)
--
https://code.launchpad.net/~ubuntu-core-dev/ubuntu-release-upgrader/+git/ubuntu-release-upgrader/+merge/427736
Your team Ubuntu Core Development Team is subscribed to branch ubuntu-release-upgrader:ubuntu/jammy.
More information about the Ubuntu-reviews
mailing list