+ if (pkgset.getConstructor() != PackageSet::UNKNOWN)
+ helper.showErrors(errors);
+ return found;
+}
+ /*}}}*/
+// FromPackage - versions from package based on fallback /*{{{*/
+bool VersionContainerInterface::FromPackage(VersionContainerInterface * const vci,
+ pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &P,
+ Version const &fallback,
+ CacheSetHelper &helper) {
+ pkgCache::VerIterator V;
+ bool showErrors;
+ bool found = false;
+ switch(fallback) {
+ case ALL:
+ if (P->VersionList != 0)
+ for (V = P.VersionList(); V.end() != true; ++V)
+ found |= vci->insert(V);
+ else
+ helper.canNotFindAllVer(vci, Cache, P);
+ break;
+ case CANDANDINST:
+ found |= vci->insert(getInstalledVer(Cache, P, helper));
+ found |= vci->insert(getCandidateVer(Cache, P, helper));
+ break;
+ case CANDIDATE:
+ found |= vci->insert(getCandidateVer(Cache, P, helper));
+ break;
+ case INSTALLED:
+ found |= vci->insert(getInstalledVer(Cache, P, helper));
+ break;
+ case CANDINST:
+ showErrors = helper.showErrors(false);
+ V = getCandidateVer(Cache, P, helper);
+ if (V.end() == true)
+ V = getInstalledVer(Cache, P, helper);
+ helper.showErrors(showErrors);
+ if (V.end() == false)
+ found |= vci->insert(V);
+ else
+ helper.canNotFindInstCandVer(vci, Cache, P);
+ break;
+ case INSTCAND:
+ showErrors = helper.showErrors(false);
+ V = getInstalledVer(Cache, P, helper);
+ if (V.end() == true)
+ V = getCandidateVer(Cache, P, helper);
+ helper.showErrors(showErrors);
+ if (V.end() == false)
+ found |= vci->insert(V);
+ else
+ helper.canNotFindInstCandVer(vci, Cache, P);
+ break;
+ case NEWEST:
+ if (P->VersionList != 0)
+ found |= vci->insert(P.VersionList());
+ else
+ helper.canNotFindNewestVer(Cache, P);
+ break;
+ }
+ return found;
+}
+ /*}}}*/
+// getCandidateVer - Returns the candidate version of the given package /*{{{*/
+pkgCache::VerIterator VersionContainerInterface::getCandidateVer(pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
+ pkgCache::VerIterator Cand;
+ if (Cache.IsPolicyBuilt() == true || Cache.IsDepCacheBuilt() == false) {
+ if (unlikely(Cache.GetPolicy() == 0))
+ return pkgCache::VerIterator(Cache);
+ Cand = Cache.GetPolicy()->GetCandidateVer(Pkg);
+ } else {
+ Cand = Cache[Pkg].CandidateVerIter(Cache);
+ }
+ if (Cand.end() == true)
+ return helper.canNotFindCandidateVer(Cache, Pkg);
+ return Cand;
+}
+ /*}}}*/
+// getInstalledVer - Returns the installed version of the given package /*{{{*/
+pkgCache::VerIterator VersionContainerInterface::getInstalledVer(pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) {
+ if (Pkg->CurrentVer == 0)
+ return helper.canNotFindInstalledVer(Cache, Pkg);
+ return Pkg.CurrentVer();
+}
+ /*}}}*/
+
+// canNotFindPkgName - handle the case no package has this name /*{{{*/
+pkgCache::PkgIterator CacheSetHelper::canNotFindPkgName(pkgCacheFile &Cache,
+ std::string const &str) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Unable to locate package %s"), str.c_str());
+ return pkgCache::PkgIterator(Cache, 0);
+}
+ /*}}}*/
+// canNotFindTask - handle the case no package is found for a task /*{{{*/
+void CacheSetHelper::canNotFindTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Couldn't find task '%s'"), pattern.c_str());
+}
+ /*}}}*/
+// canNotFindRegEx - handle the case no package is found by a regex /*{{{*/
+void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str());
+}
+ /*}}}*/
+// canNotFindPackage - handle the case no package is found from a string/*{{{*/
+void CacheSetHelper::canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str) {
+}
+ /*}}}*/
+// canNotFindAllVer /*{{{*/
+void CacheSetHelper::canNotFindAllVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Can't select versions from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str());
+}
+ /*}}}*/
+// canNotFindInstCandVer /*{{{*/
+void CacheSetHelper::canNotFindInstCandVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
+}
+ /*}}}*/
+// canNotFindInstCandVer /*{{{*/
+void CacheSetHelper::canNotFindCandInstVer(VersionContainerInterface * const vci, pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Can't select installed nor candidate version from package '%s' as it has neither of them"), Pkg.FullName(true).c_str());
+}
+ /*}}}*/
+// canNotFindNewestVer /*{{{*/
+pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Can't select newest version from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str());
+ return pkgCache::VerIterator(Cache, 0);
+}
+ /*}}}*/
+// canNotFindCandidateVer /*{{{*/
+pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Can't select candidate version from package %s as it has no candidate"), Pkg.FullName(true).c_str());
+ return pkgCache::VerIterator(Cache, 0);
+}
+ /*}}}*/
+// canNotFindInstalledVer /*{{{*/
+pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache,
+ pkgCache::PkgIterator const &Pkg) {
+ if (ShowError == true)
+ _error->Insert(ErrorType, _("Can't select installed version from package %s as it is not installed"), Pkg.FullName(true).c_str());
+ return pkgCache::VerIterator(Cache, 0);
+}
+ /*}}}*/
+// showTaskSelection /*{{{*/
+void CacheSetHelper::showTaskSelection(pkgCache::PkgIterator const &pkg,
+ std::string const &pattern) {
+}
+ /*}}}*/
+// showRegExSelection /*{{{*/
+void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &pkg,
+ std::string const &pattern) {
+}
+ /*}}}*/
+// showSelectedVersion /*{{{*/
+void CacheSetHelper::showSelectedVersion(pkgCache::PkgIterator const &Pkg,
+ pkgCache::VerIterator const Ver,
+ std::string const &ver,
+ bool const verIsRel) {