Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julian-klode/bc96cccf69b756f46004928e64b21e9b to your computer and use it in GitHub Desktop.
Save julian-klode/bc96cccf69b756f46004928e64b21e9b to your computer and use it in GitHub Desktop.
diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py
index 0692ef90c..27a45d796 100644
--- a/DistUpgrade/DistUpgradeCache.py
+++ b/DistUpgrade/DistUpgradeCache.py
@@ -449,6 +449,23 @@ class MyCache(apt.Cache):
if pkg in self:
self._depcache.mark_delete(self[pkg]._pkg, True)
+ def _do_not_install(self, pkgname, reason):
+ if (pkgname in self
+ and not self[pkgname].is_installed
+ and self[pkgname].marked_install):
+ self.mark_remove(pkgname, reason)
+
+ def do_not_install_rule(self):
+ """ run after the dist-upgrade to ensure that certain
+ packages are not newly installed """
+ # We handle provides here, so we can mark e.g. mail-transport-agent as something we do not
+ # want a release upgrade to pull in by depends.
+ for pkgname in self.config.getlist("Distro", "DoNotInstallPkgs"):
+ if pkgname in self:
+ self._do_not_install(pkgname, "Distro KeepInstalledPkgs rule")
+ for _, _, provver in in self[pkgname].provides_list:
+ self._do_not_install(provver.parent_pkg.name, "Distro KeepInstalledPkgs rule")
+
def _keep_installed(self, pkgname, reason):
if (pkgname in self
and self[pkgname].is_installed
@@ -631,6 +648,9 @@ class MyCache(apt.Cache):
# check that everything in priority required is installed
self.checkPriority()
+ # see if our KeepInstalled rules are honored
+ self.do_not_install_rule()
+
# see if our KeepInstalled rules are honored
self.keep_installed_rule()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment