summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-08-24 13:36:38 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-08-24 13:36:38 +0200
commiteb48d80c9a845bbb687790331c0a7c71a3365973 (patch)
treea40401cbbb2242d8982ff1a56dffe412c61b778b /apt/cache.py
parent543bd48fbc582b2ef663cd8bcd387a11939e78b4 (diff)
parent353d2494c234d87cb63affd07a927d1030fa9721 (diff)
downloadpython-apt-eb48d80c9a845bbb687790331c0a7c71a3365973.tar.gz
merged from debian-sid
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py47
1 files changed, 40 insertions, 7 deletions
diff --git a/apt/cache.py b/apt/cache.py
index c1e2428c..756f9ba9 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -91,7 +91,6 @@ class Cache(object):
for f in files:
if not os.path.exists(rootdir+f):
open(rootdir+f,"w")
-
def _runCallbacks(self, name):
""" internal helper to run a callback """
@@ -270,7 +269,7 @@ class Cache(object):
providers.append(pkg)
return providers
- def update(self, fetchProgress=None):
+ def update(self, fetchProgress=None, pulseInterval=0):
" run the equivalent of apt-get update "
lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock"
lock = apt_pkg.GetLock(lockfile)
@@ -280,7 +279,7 @@ class Cache(object):
try:
if fetchProgress is None:
fetchProgress = apt.progress.FetchProgress()
- return self._cache.Update(fetchProgress, self._list)
+ return self._cache.Update(fetchProgress, self._list, pulseInterval)
finally:
os.close(lock)
@@ -345,22 +344,56 @@ class Cache(object):
@property
def broken_count(self):
"""Return the number of packages with broken dependencies."""
- return self._depcache.broken_count
+ return self._depcache.BrokenCount
@property
def delete_count(self):
"""Return the number of packages marked for deletion."""
- return self._depcache.del_count
+ return self._depcache.DelCount
@property
def install_count(self):
"""Return the number of packages marked for installation."""
- return self._depcache.inst_count
+ return self._depcache.InstCount
@property
def keep_count(self):
"""Return the number of packages marked as keep."""
- return self._depcache.keep_count
+ return self._depcache.KeepCount
+
+
+class ProblemResolver(object):
+ """Resolve problems due to dependencies and conflicts.
+
+ The first argument 'cache' is an instance of apt.Cache.
+ """
+
+ def __init__(self, cache):
+ self._resolver = apt_pkg.GetPkgProblemResolver(cache._depcache)
+
+ def clear(self, package):
+ """Reset the package to the default state."""
+ self._resolver.Clear(package._pkg)
+
+ def install_protect(self):
+ """mark protected packages for install or removal."""
+ self._resolver.InstallProtect()
+
+ def protect(self, package):
+ """Protect a package so it won't be removed."""
+ self._resolver.Protect(package._pkg)
+
+ def remove(self, package):
+ """Mark a package for removal."""
+ self._resolver.Remove(package._pkg)
+
+ def resolve(self):
+ """Resolve dependencies, try to remove packages where needed."""
+ self._resolver.Resolve()
+
+ def resolve_by_keep(self):
+ """Resolve dependencies, do not try to remove packages."""
+ self._resolver.ResolveByKeep()
# ----------------------------- experimental interface