Created
September 5, 2024 12:18
-
-
Save julian-klode/41cb598d06b5530ad320dace35c1f75d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/DistUpgrade/DistUpgradeController.py b/DistUpgrade/DistUpgradeController.py | |
index 43d3624eb..79d4ae6b4 100644 | |
--- a/DistUpgrade/DistUpgradeController.py | |
+++ b/DistUpgrade/DistUpgradeController.py | |
@@ -2025,7 +2025,24 @@ class DistUpgradeController(object): | |
# resolve them by keeping back the obsolete packages. | |
self.cache._startAptResolverLog() | |
pr = apt.ProblemResolver(self.cache) | |
- pr.resolve_by_keep() | |
+ | |
+ # Manually keep dependencies of now-broken packages | |
+ while self.cache.broken_count > 0: | |
+ logging.info("Resolving %d broken dependencies", self.cache.broken_count) | |
+ pr.resolve_by_keep() | |
+ # There is a bug in resolve_by_keep() where it doesn't undo purge | |
+ # requests, so let's do it ourselves. | |
+ with self.cache.actiongroup(): | |
+ for package in self.cache: | |
+ if package.is_inst_broken: | |
+ for dep in package.installed.get_dependencies("PreDepends", "Depends"): | |
+ for target_version in dep.installed_target_versions: | |
+ if target_version.package.marked_delete: | |
+ logging.debug("Keeping %s due to %s", target_version.package, dep) | |
+ target_version.package.mark_keep() | |
+ if not target_version.package.marked_keep: | |
+ logging.error("Could not keep %s", target_version.package) | |
+ | |
self.cache._stopAptResolverLog() | |
# resolve_by_keep() will revert any unsafe removals, so we need to list them here again. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment