diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-01-11 18:48:12 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-01-11 18:48:12 +0100 |
| commit | 4e79e7a7b6c57b458bf97d6c5083989054a2ca75 (patch) | |
| tree | 0b62d0e8cc179268e705903725f44a48e7786629 | |
| parent | 425b2d6407817598f9a6c9c606762a96d8407e5e (diff) | |
| download | python-apt-4e79e7a7b6c57b458bf97d6c5083989054a2ca75.tar.gz | |
* be careful about remove obsolete, only remove if no other package (outside
of obsoletes) gets deleted
| -rw-r--r-- | DistUpgrade/DistUpgradeControler.py | 44 | ||||
| -rw-r--r-- | DistUpgrade/DistUpgradeView.py | 1 |
2 files changed, 39 insertions, 6 deletions
diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py index 4cfd85d7..9888bf85 100644 --- a/DistUpgrade/DistUpgradeControler.py +++ b/DistUpgrade/DistUpgradeControler.py @@ -36,12 +36,13 @@ class MyCache(apt.Cache): # init def __init__(self, progress=None): apt.Cache.__init__(self, progress) + self.to_install = [] + self.to_remove = [] # turn on debuging apt_pkg.Config.Set("Debug::pkgProblemResolver","true") fd = os.open(os.path.expanduser("~/dist-upgrade-apt.log"), os.O_RDWR|os.O_CREAT|os.O_TRUNC) os.dup2(fd,1) os.dup2(fd,2) - # properties @property @@ -68,6 +69,27 @@ class MyCache(apt.Cache): """ try to fix broken dependencies on the system, may throw SystemError when it can't""" return self._depcache.FixBroken() + def create_snapshot(self): + """ create a snapshot of the current changes """ + self.to_install = [] + self.to_remove = [] + for name in self.getChanges(): + pkg = self[name] + if pkg.markedInstall or pkg.markedUpgrade: + self.to_install.append(name) + if pkg.markedDelete: + self.to_remove.append(name) + def restore_snapshot(self): + """ restore a snapshot """ + for pkg in self: + pkg.markKeep() + for name in self.to_remove: + pkg = self[name] + pkg.markDelete() + for name in self.to_install: + pkg = self[name] + pkg.markInstall() + class DistUpgradeControler(object): def __init__(self, distUpgradeView): @@ -78,8 +100,8 @@ class DistUpgradeControler(object): # some constants here self.fromDist = "hoary" self.toDist = "breezy" - self.fromDist = "breezy" - self.toDist = "dapper" + #self.fromDist = "breezy" + #self.toDist = "dapper" self.origin = "Ubuntu" @@ -105,7 +127,8 @@ class DistUpgradeControler(object): return False # now check for ubuntu-base - if not self.cache["ubuntu-base"].isInstalled: + if not self.cache.has_key("ubuntu-base") or \ + not self.cache["ubuntu-base"].isInstalled: self.missing_pkgs.append("ubuntu-base") # now check for ubuntu-desktop, kubuntu-desktop, edubuntu-desktop @@ -364,10 +387,19 @@ class DistUpgradeControler(object): # mark packages that are now obsolete (and where not obsolete # before) to be deleted. make sure to not delete any foreign - # (that is, not from ubuntu) packages - for pkgname in (now_obsolete - self.obsolete_pkgs): + # (that is, not from ubuntu) packages + remove_candidates = now_obsolete - self.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 change in self.cache.getChanges(): + if change not in remove_candidates or \ + change in self.foreign_pkgs: + self.cache.restore_snapshot() if self._view.confirmChanges(_("Remove obsolete Packages?"), self.cache.getChanges(), 0): fprogress = self._view.getFetchProgress() diff --git a/DistUpgrade/DistUpgradeView.py b/DistUpgrade/DistUpgradeView.py index f45932f6..ba223a1b 100644 --- a/DistUpgrade/DistUpgradeView.py +++ b/DistUpgrade/DistUpgradeView.py @@ -64,3 +64,4 @@ class DistUpgradeView(object): def error(self, summary, msg, extended_msg=None): " display a error " pass + |
