summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/apt/cache.py b/apt/cache.py
index bbf2165b..3fd1e996 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -182,6 +182,51 @@ class Cache(object):
finally:
os.close(lock)
+ def isVirtualPackage(self, name):
+ """
+ Return True if the package of the given name is a virtual package
+ """
+ try:
+ virtual_pkg = self._cache[name]
+ except KeyError:
+ return False
+ if len(virtual_pkg.VersionList) == 0:
+ return True
+ return False
+
+ def getProvidingPackages(self, virtual):
+ """
+ Return a list of packages which provide the virtual package of the
+ specified name
+ """
+ providers = []
+ try:
+ vp = self._cache[virtual]
+ if len(vp.VersionList) != 0:
+ return providers
+ except KeyError:
+ return providers
+ for pkg in self:
+ v = self._depcache.GetCandidateVer(pkg._pkg)
+ if v == None:
+ continue
+ for p in v.ProvidesList:
+ #print virtual
+ #print p[0]
+ if virtual == p[0]:
+ # we found a pkg that provides this virtual
+ # pkg, check if the proivdes is any good
+ providers.append(pkg)
+ #cand = self._cache[pkg.name]
+ #candver = self._cache._depcache.GetCandidateVer(cand._pkg)
+ #instver = cand._pkg.CurrentVer
+ #res = apt_pkg.CheckDep(candver.VerStr,oper,ver)
+ #if res == True:
+ # self._dbg(1,"we can use %s" % pkg.name)
+ # or_found = True
+ # break
+ return providers
+
def update(self, fetchProgress=None):
" run the equivalent of apt-get update "
lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock"
@@ -232,6 +277,10 @@ class Cache(object):
fetcher.Shutdown()
return (res == pm.ResultCompleted)
+ def clear(self):
+ """ Unmark all changes """
+ self._depcache.Init()
+
# cache changes
def cachePostChange(self):
" called internally if the cache has changed, emit a signal then "