summaryrefslogtreecommitdiff
path: root/apt-pkg/cacheset.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-07-13 03:36:59 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-08-10 17:27:18 +0200
commit9112f77703c39d46e2e0471c48c8a5e1f93f4abf (patch)
tree63d990155a5e3e3f77daeabcc36529394e08fc9b /apt-pkg/cacheset.cc
parent6cfadda161ce19e6c8076d0aa118f8f436805a6a (diff)
show or-groups in not-installed recommends and suggests lists
Further abstracting our new ShowList allows to use it for containers of strings as well giving us the option to implement an or-groups display for the recommends and suggests lists which is a nice trick given that it also helps with migrating the last remaining other cases of old ShowList.
Diffstat (limited to 'apt-pkg/cacheset.cc')
-rw-r--r--apt-pkg/cacheset.cc110
1 files changed, 110 insertions, 0 deletions
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index a4e330a0a..f5cf52159 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -582,6 +582,116 @@ bool VersionContainerInterface::FromPackage(VersionContainerInterface * const vc
return found;
}
/*}}}*/
+// FromDependency - versions satisfying a given dependency /*{{{*/
+bool VersionContainerInterface::FromDependency(VersionContainerInterface * const vci,
+ pkgCacheFile &Cache,
+ pkgCache::DepIterator const &D,
+ CacheSetHelper::VerSelector const selector,
+ CacheSetHelper &helper)
+{
+ bool found = false;
+ switch(selector) {
+ case CacheSetHelper::ALL:
+ {
+ pkgCache::PkgIterator const T = D.TargetPkg();
+ for (pkgCache::VerIterator Ver = T.VersionList(); Ver.end() == false; ++Ver)
+ {
+ if (D.IsSatisfied(Ver) == true)
+ {
+ vci->insert(Ver);
+ found = true;
+ }
+ for (pkgCache::PrvIterator Prv = T.ProvidesList(); Prv.end() != true; ++Prv)
+ {
+ pkgCache::VerIterator const V = Prv.OwnerVer();
+ if (unlikely(V.end() == true) || D.IsSatisfied(Prv) == false)
+ continue;
+ vci->insert(V);
+ found = true;
+ }
+ }
+ return found;
+ }
+ case CacheSetHelper::CANDANDINST:
+ {
+ found = FromDependency(vci, Cache, D, CacheSetHelper::CANDIDATE, helper);
+ found &= FromDependency(vci, Cache, D, CacheSetHelper::INSTALLED, helper);
+ return found;
+ }
+ case CacheSetHelper::CANDIDATE:
+ {
+ pkgCache::PkgIterator const T = D.TargetPkg();
+ pkgCache::VerIterator const Cand = Cache[T].CandidateVerIter(Cache);
+ if (Cand.end() == false && D.IsSatisfied(Cand) == true)
+ {
+ vci->insert(Cand);
+ found = true;
+ }
+ for (pkgCache::PrvIterator Prv = T.ProvidesList(); Prv.end() != true; ++Prv)
+ {
+ pkgCache::VerIterator const V = Prv.OwnerVer();
+ pkgCache::VerIterator const Cand = Cache[Prv.OwnerPkg()].CandidateVerIter(Cache);
+ if (Cand.end() == true || V != Cand || D.IsSatisfied(Prv) == false)
+ continue;
+ vci->insert(Cand);
+ found = true;
+ }
+ return found;
+ }
+ case CacheSetHelper::INSTALLED:
+ {
+ pkgCache::PkgIterator const T = D.TargetPkg();
+ pkgCache::VerIterator const Cand = T.CurrentVer();
+ if (Cand.end() == false && D.IsSatisfied(Cand) == true)
+ {
+ vci->insert(Cand);
+ found = true;
+ }
+ for (pkgCache::PrvIterator Prv = T.ProvidesList(); Prv.end() != true; ++Prv)
+ {
+ pkgCache::VerIterator const V = Prv.OwnerVer();
+ pkgCache::VerIterator const Cand = Prv.OwnerPkg().CurrentVer();
+ if (Cand.end() == true || V != Cand || D.IsSatisfied(Prv) == false)
+ continue;
+ vci->insert(Cand);
+ found = true;
+ }
+ return found;
+ }
+ case CacheSetHelper::CANDINST:
+ return FromDependency(vci, Cache, D, CacheSetHelper::CANDIDATE, helper) ||
+ FromDependency(vci, Cache, D, CacheSetHelper::INSTALLED, helper);
+ case CacheSetHelper::INSTCAND:
+ return FromDependency(vci, Cache, D, CacheSetHelper::INSTALLED, helper) ||
+ FromDependency(vci, Cache, D, CacheSetHelper::CANDIDATE, helper);
+ case CacheSetHelper::NEWEST:
+ {
+ pkgCache::PkgIterator const T = D.TargetPkg();
+ pkgCache::VerIterator const Cand = T.VersionList();
+ if (Cand.end() == false && D.IsSatisfied(Cand) == true)
+ {
+ vci->insert(Cand);
+ found = true;
+ }
+ for (pkgCache::PrvIterator Prv = T.ProvidesList(); Prv.end() != true; ++Prv)
+ {
+ pkgCache::VerIterator const V = Prv.OwnerVer();
+ pkgCache::VerIterator const Cand = Prv.OwnerPkg().VersionList();
+ if (Cand.end() == true || V != Cand || D.IsSatisfied(Prv) == false)
+ continue;
+ vci->insert(Cand);
+ found = true;
+ }
+ return found;
+ }
+ case CacheSetHelper::RELEASE:
+ case CacheSetHelper::VERSIONNUMBER:
+ // both make no sense here, so always false
+ return false;
+ }
+ return found;
+}
+ /*}}}*/
// getCandidateVer - Returns the candidate version of the given package /*{{{*/
pkgCache::VerIterator VersionContainerInterface::getCandidateVer(pkgCacheFile &Cache,
pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {