]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/cacheset.cc
use a=experimental instead n=experimental in pin documentation
[apt.git] / apt-pkg / cacheset.cc
index 76a7e717e7799a3eb183d69c156d162ca20477cb..af607a197763318eee1560d6af0c664d0a01a9f7 100644 (file)
@@ -37,7 +37,6 @@
 #include <apti18n.h>
                                                                        /*}}}*/
 namespace APT {
-
 // PackageFrom - selecting the appropriate method for package selection        /*{{{*/
 bool CacheSetHelper::PackageFrom(enum PkgSelector const select, PackageContainerInterface * const pci,
       pkgCacheFile &Cache, std::string const &pattern) {
@@ -583,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) {
@@ -613,19 +722,14 @@ void CacheSetHelper::canNotFindPackage(enum PkgSelector const select,
       PackageContainerInterface * const pci, pkgCacheFile &Cache,
       std::string const &pattern) {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case REGEX: canNotFindRegEx(pci, Cache, pattern); break;
        case TASK: canNotFindTask(pci, Cache, pattern); break;
        case FNMATCH: canNotFindFnmatch(pci, Cache, pattern); break;
        case PACKAGENAME: canNotFindPackage(pci, Cache, pattern); break;
        case STRING: canNotFindPackage(pci, Cache, pattern); break;
        case UNKNOWN: break;
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+APT_IGNORE_DEPRECATED_POP
        }
 }
 // canNotFindTask - handle the case no package is found for a task     /*{{{*/
@@ -663,19 +767,14 @@ pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
 void CacheSetHelper::canNotFindVersion(enum VerSelector const select, VersionContainerInterface * const vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg)
 {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case ALL: canNotFindAllVer(vci, Cache, Pkg); break;
        case INSTCAND: canNotFindInstCandVer(vci, Cache, Pkg); break;
        case CANDINST: canNotFindCandInstVer(vci, Cache, Pkg); break;
        case NEWEST: canNotFindNewestVer(Cache, Pkg); break;
        case CANDIDATE: canNotFindCandidateVer(Cache, Pkg); break;
        case INSTALLED: canNotFindInstalledVer(Cache, Pkg); break;
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+APT_IGNORE_DEPRECATED_POP
        case CANDANDINST: canNotGetCandInstVer(Cache, Pkg); break;
        case RELEASE:
        case VERSIONNUMBER:
@@ -706,16 +805,11 @@ void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const /*v
 // canNotGetVersion - for package by selector                          /*{{{*/
 pkgCache::VerIterator CacheSetHelper::canNotGetVersion(enum VerSelector const select, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case NEWEST: return canNotFindNewestVer(Cache, Pkg);
        case CANDIDATE: return canNotFindCandidateVer(Cache, Pkg);
        case INSTALLED: return canNotFindInstalledVer(Cache, Pkg);
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+APT_IGNORE_DEPRECATED_POP
        case CANDINST: return canNotGetCandInstVer(Cache, Pkg);
        case INSTCAND: return canNotGetInstCandVer(Cache, Pkg);
        case ALL:
@@ -769,19 +863,14 @@ pkgCache::VerIterator CacheSetHelper::canNotGetCandInstVer(pkgCacheFile &Cache,
                                                                        /*}}}*/
                                                                        /*}}}*/
 // showPackageSelection - by selector and given pattern                        /*{{{*/
-APT_CONST void CacheSetHelper::showPackageSelection(pkgCache::PkgIterator const &pkg, enum PkgSelector const select,
+void CacheSetHelper::showPackageSelection(pkgCache::PkgIterator const &pkg, enum PkgSelector const select,
                                       std::string const &pattern) {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case REGEX: showRegExSelection(pkg, pattern); break;
        case TASK: showTaskSelection(pkg, pattern); break;
        case FNMATCH: showFnmatchSelection(pkg, pattern); break;
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-#endif
+APT_IGNORE_DEPRECATED_POP
        case PACKAGENAME: /* no suprises here */ break;
        case STRING: /* handled by the special cases */ break;
        case UNKNOWN: break;
@@ -804,23 +893,17 @@ APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const
                                                                        /*}}}*/
                                                                        /*}}}*/
 // showVersionSelection                                                        /*{{{*/
-APT_CONST void CacheSetHelper::showVersionSelection(pkgCache::PkgIterator const &Pkg,
+void CacheSetHelper::showVersionSelection(pkgCache::PkgIterator const &Pkg,
       pkgCache::VerIterator const &Ver, enum VerSelector const select, std::string const &pattern) {
        switch (select) {
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic push
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_PUSH
        case RELEASE:
                showSelectedVersion(Pkg, Ver, pattern, true);
                break;
        case VERSIONNUMBER:
                showSelectedVersion(Pkg, Ver, pattern, false);
                break;
-#if __GNUC__ >= 4
-       #pragma GCC diagnostic pop
-       #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+APT_IGNORE_DEPRECATED_POP
        case NEWEST:
        case CANDIDATE:
        case INSTALLED:
@@ -838,4 +921,28 @@ APT_CONST void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &
                                         bool const /*verIsRel*/) {
 }
                                                                        /*}}}*/
+
+CacheSetHelper::CacheSetHelper(bool const ShowError, GlobalError::MsgType ErrorType) :
+   ShowError(ShowError), ErrorType(ErrorType), d(NULL) {}
+CacheSetHelper::~CacheSetHelper() {}
+
+PackageContainerInterface::PackageContainerInterface() : ConstructedBy(CacheSetHelper::UNKNOWN), d(NULL) {}
+PackageContainerInterface::PackageContainerInterface(CacheSetHelper::PkgSelector const by) : ConstructedBy(by), d(NULL) {}
+PackageContainerInterface& PackageContainerInterface::operator=(PackageContainerInterface const &other) {
+   if (this != &other)
+      this->ConstructedBy = other.ConstructedBy;
+   return *this;
+}
+PackageContainerInterface::~PackageContainerInterface() {}
+
+PackageUniverse::PackageUniverse(pkgCache * const Owner) : _cont(Owner), d(NULL) {}
+PackageUniverse::PackageUniverse(pkgCacheFile * const Owner) : _cont(Owner->GetPkgCache()), d(NULL) {}
+PackageUniverse::~PackageUniverse() {}
+
+VersionContainerInterface::VersionContainerInterface() : d(NULL) {}
+VersionContainerInterface& VersionContainerInterface::operator=(VersionContainerInterface const &) {
+   return *this;
+}
+
+VersionContainerInterface::~VersionContainerInterface() {}
 }