From b3cf95cf422246b74df0b3176cabb9a11f824a98 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 18 Jan 2006 16:20:30 +0100 Subject: * refactored more stuff into the cache (out of the controler) --- DistUpgrade/DistUpgradeCache.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'DistUpgrade/DistUpgradeCache.py') diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py index 3687ac80..dd552b73 100644 --- a/DistUpgrade/DistUpgradeCache.py +++ b/DistUpgrade/DistUpgradeCache.py @@ -191,7 +191,7 @@ class MyCache(apt.Cache): return True return False - def _tryMarkObsoleteForRemoval(self, pkgname, remove_candidates): + def _tryMarkObsoleteForRemoval(self, pkgname, remove_candidates, foreign_pkgs): # this is a delete candidate, only actually delete, # if it dosn't remove other packages depending on it # that are not obsolete as well @@ -199,8 +199,38 @@ class MyCache(apt.Cache): self[pkgname].markDelete() for pkg in self.getChanges(): if pkg.name not in remove_candidates or \ - pkg.name in self.foreign_pkgs or \ + pkg.name in foreign_pkgs or \ self._inRemovalBlacklist(pkg.name): self.restore_snapshot() return False return True + + def _getObsoletesPkgs(self): + " get all package names that are not downloadable " + obsolete_pkgs =set() + for pkg in self: + if pkg.isInstalled: + if not self.downloadable(pkg): + obsolete_pkgs.add(pkg.name) + return obsolete_pkgs + + def _getForeignPkgs(self, allowed_origin, fromDist, toDist): + """ get all packages that are installed from a foreign repo + (and are actually downloadable) + """ + foreign_pkgs =set() + for pkg in self: + if pkg.isInstalled and self.downloadable(pkg): + # assume it is foreign and see if it is from the + # official archive + foreign=True + for origin in pkg.candidateOrigin: + if fromDist in origin.archive and \ + origin.origin == allowed_origin: + foreign = False + if toDist in origin.archive and \ + origin.origin == allowed_origin: + foreign = False + if foreign: + foreign_pkgs.add(pkg.name) + return foreign_pkgs -- cgit v1.2.3