summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt/package.py11
-rw-r--r--tests/apt-test.py14
2 files changed, 22 insertions, 3 deletions
diff --git a/apt/package.py b/apt/package.py
index 806cb0c3..0ee6aff8 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -125,9 +125,17 @@ class Package(object):
self._pcache.CachePreChange()
self._depcache.MarkKeep(self._pkg)
self._pcache.CachePostChange()
- def MarkDelete(self):
+ def MarkDelete(self, autoFix=True):
self._pcache.CachePreChange()
self._depcache.MarkDelete(self._pkg)
+ # try to fix broken stuffsta
+ if autoFix and self._depcache.BrokenCount > 0:
+ Fix = apt_pkg.GetPkgProblemResolver(self._depcache)
+ Fix.Clear(self._pkg)
+ Fix.Protect(self._pkg)
+ Fix.Remove(self._pkg)
+ Fix.InstallProtect()
+ Fix.Resolve()
self._pcache.CachePostChange()
def MarkInstall(self, autoFix=True):
self._pcache.CachePreChange()
@@ -185,3 +193,4 @@ if __name__ == "__main__":
print "Description (formated) :\n%s" % pkg.Description(True)
print "InstalledSize: %s " % pkg.InstalledSize()
print "PackageSize: %s " % pkg.PackageSize()
+
diff --git a/tests/apt-test.py b/tests/apt-test.py
index 6ae9f702..45ecad98 100644
--- a/tests/apt-test.py
+++ b/tests/apt-test.py
@@ -9,6 +9,16 @@ if __name__ == "__main__":
if pkg.IsUpgradable():
pkg.MarkInstall()
for pkg in cache.GetChanges():
- print pkg.Name()
+ #print pkg.Name()
+ pass
print "Broken: %s " % cache._depcache.BrokenCount
-
+ print "InstCount: %s " % cache._depcache.InstCount
+
+ # get a new cache
+ cache = apt.Cache(progress)
+ for name in cache.keys():
+ import random
+ if random.randint(0,1) == 1:
+ cache[name].MarkDelete()
+ print "Broken: %s " % cache._depcache.BrokenCount
+ print "DelCount: %s " % cache._depcache.DelCount