diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-01-12 12:49:33 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-01-12 12:49:33 +0100 |
| commit | 4a786f397ec4a4845e58c51288bba1217451f541 (patch) | |
| tree | 4dc2065051bc252fe8a16a0f7bd25f764dda3f4d /DistUpgrade | |
| parent | 6a7d3c4fdea2f85b100bbccaabb41637450e78e6 (diff) | |
| download | python-apt-4a786f397ec4a4845e58c51288bba1217451f541.tar.gz | |
* added a "removal_blacklist.txt" that contains regexp for packagenames that should never get removed
Diffstat (limited to 'DistUpgrade')
| -rw-r--r-- | DistUpgrade/DistUpgradeControler.py | 46 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeViewGtk.py | 2 | ||||
| -rw-r--r-- | DistUpgrade/removal_blacklist.txt | 6 |
3 files changed, 41 insertions, 13 deletions
diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 58d8fb16..3b5a1ac9 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -108,6 +108,13 @@ class DistUpgradeControler(object): # be added before the dist-upgrade (e.g. missing ubuntu-desktop) self.missing_pkgs = [] + # a list of regexp that are not allowed to be removed + self.removal_blacklist = [] + for line in open("removal_blacklist.txt").readlines(): + line = line.strip() + if not line == "" or line.startswith("#"): + self.removal_blacklist.append(line) + def openCache(self): self.cache = MyCache(self._view.getOpCacheProgress()) @@ -375,6 +382,26 @@ class DistUpgradeControler(object): return False return True + def _inRemovalBlacklist(self, pkgname): + for expr in self.removal_blacklist: + if re.compile(expr).match(pkgname): + return True + return False + + def _tryMarkObsoleteForRemoval(self, pkgname, removal_canidates): + # this is a delete candidate, only actually delete, + # if it dosn't remove other packages depending on it + # that are not obsolete as well + self.cache.create_snapshot() + self.cache[pkgname].markDelete() + for pkg in self.cache.getChanges(): + if pkg.name not in remove_candidates or \ + pkg.name in self.foreign_pkgs or \ + pkg.name in self._inRemovalBlacklist(pkg.name): + self.cache.restore_snapshot() + return False + return True + def doPostUpgrade(self): self.openCache() # check out what packages are cruft now @@ -391,19 +418,14 @@ class DistUpgradeControler(object): logging.debug("Start checking for obsolete pkgs") for pkgname in remove_candidates: if pkgname not in self.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 - self.cache.create_snapshot() - self.cache[pkgname].markDelete() - for pkg in self.cache.getChanges(): - if pkg.name not in remove_candidates or \ - pkg.name in self.foreign_pkgs: - logging.debug("'%s' scheduled for remove but not in remove_candiates, skipping", pkg.name) - self.cache.restore_snapshot() + if not self._tryMarkObsoleteForRemoval(pkgname, + removal_candidates): + logging.debug("'%s' scheduled for remove but not in remove_candiates, skipping", pkg.name) logging.debug("Finish checking for obsolete pkgs") - if self._view.confirmChanges(_("Remove obsolete Packages?"), - self.cache.getChanges(), 0): + changes = self.cache.getChanges() + if len(changes) > 0 and \ + self._view.confirmChanges(_("Remove obsolete Packages?"), + changes, 0): fprogress = self._view.getFetchProgress() iprogress = self._view.getInstallProgress() self.cache.commit(fprogress,iprogress) diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py index 32286e7d..c39efbe6 100644 --- a/DistUpgrade/DistUpgradeViewGtk.py +++ b/DistUpgrade/DistUpgradeViewGtk.py @@ -109,8 +109,8 @@ class GtkInstallProgressAdapter(InstallProgress): # setup the child waiting reaper = vte.reaper_get() reaper.connect("child-exited", self.child_exited) - self.finished = False def startUpdate(self): + self.finished = False # FIXME: add support for the timeout # of the terminal (to display something useful then) # -> longer term, move this code into python-apt diff --git a/DistUpgrade/removal_blacklist.txt b/DistUpgrade/removal_blacklist.txt new file mode 100644 index 00000000..eeacd38c --- /dev/null +++ b/DistUpgrade/removal_blacklist.txt @@ -0,0 +1,6 @@ +# blacklist of packages that should never be removed +ubuntu-desktop +kubuntu-destkop +edubuntu-desktop +ubuntu-base +linux-image-.*
\ No newline at end of file |
