X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/cf28bcadb301d00f6534fea97ccf1fde63041e7b..115ba31b90e0d6643670d7d079f9f27b0e05f1c2:/cmdline/cacheset.cc diff --git a/cmdline/cacheset.cc b/cmdline/cacheset.cc index cc2860a22..78c9d3f6c 100644 --- a/cmdline/cacheset.cc +++ b/cmdline/cacheset.cc @@ -33,13 +33,13 @@ PackageSet PackageSet::FromTask(pkgCacheFile &Cache, std::string pattern, CacheS } if (pattern[pattern.length() -1] != '^') - return APT::PackageSet(); + return APT::PackageSet(TASK); pattern.erase(pattern.length()-1); if (unlikely(Cache.GetPkgCache() == 0 || Cache.GetDepCache() == 0)) - return APT::PackageSet(); + return APT::PackageSet(TASK); - PackageSet pkgset; + PackageSet pkgset(TASK); // get the records pkgRecords Recs(Cache); @@ -85,7 +85,7 @@ PackageSet PackageSet::FromTask(pkgCacheFile &Cache, std::string pattern, CacheS PackageSet PackageSet::FromRegEx(pkgCacheFile &Cache, std::string pattern, CacheSetHelper &helper) { static const char * const isregex = ".?+*|[^$"; if (pattern.find_first_of(isregex) == std::string::npos) - return PackageSet(); + return PackageSet(REGEX); size_t archfound = pattern.find_last_of(':'); std::string arch = "native"; @@ -103,13 +103,13 @@ PackageSet PackageSet::FromRegEx(pkgCacheFile &Cache, std::string pattern, Cache char Error[300]; regerror(Res, &Pattern, Error, sizeof(Error)); _error->Error(_("Regex compilation error - %s"), Error); - return PackageSet(); + return PackageSet(REGEX); } if (unlikely(Cache.GetPkgCache() == 0)) - return PackageSet(); + return PackageSet(REGEX); - PackageSet pkgset; + PackageSet pkgset(REGEX); for (pkgCache::GrpIterator Grp = Cache.GetPkgCache()->GrpBegin(); Grp.end() == false; ++Grp) { if (regexec(&Pattern, Grp.Name(), 0, 0, 0) != 0) @@ -318,6 +318,9 @@ APT::VersionSet VersionSet::FromString(pkgCacheFile &Cache, std::string pkg, } VersionSet verset; + bool errors = true; + if (pkgset.getConstructor() != PackageSet::UNKNOWN) + errors = helper.showErrors(false); for (PackageSet::const_iterator P = pkgset.begin(); P != pkgset.end(); ++P) { if (vertag == string::npos) { @@ -348,6 +351,8 @@ APT::VersionSet VersionSet::FromString(pkgCacheFile &Cache, std::string pkg, helper.showSelectedVersion(P, V, ver, verIsRel); verset.insert(V); } + if (pkgset.getConstructor() != PackageSet::UNKNOWN) + helper.showErrors(errors); return verset; } /*}}}*/ @@ -411,12 +416,13 @@ VersionSet VersionSet::FromPackage(pkgCacheFile &Cache, pkgCache::PkgIterator co pkgCache::VerIterator VersionSet::getCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, CacheSetHelper &helper) { pkgCache::VerIterator Cand; - if (Cache.IsDepCacheBuilt() == true) - Cand = Cache[Pkg].CandidateVerIter(Cache); - else { + 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); @@ -487,7 +493,7 @@ pkgCache::VerIterator CacheSetHelper::canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) { if (ShowError == true) _error->Error(_("Can't select newest version from package '%s' as it is purely virtual"), Pkg.FullName(true).c_str()); - return pkgCache::VerIterator(Cache); + return pkgCache::VerIterator(Cache, 0); } /*}}}*/ // canNotFindCandidateVer /*{{{*/ @@ -495,7 +501,7 @@ pkgCache::VerIterator CacheSetHelper::canNotFindCandidateVer(pkgCacheFile &Cache pkgCache::PkgIterator const &Pkg) { if (ShowError == true) _error->Error(_("Can't select candidate version from package %s as it has no candidate"), Pkg.FullName(true).c_str()); - return pkgCache::VerIterator(Cache); + return pkgCache::VerIterator(Cache, 0); } /*}}}*/ // canNotFindInstalledVer /*{{{*/ @@ -503,7 +509,7 @@ pkgCache::VerIterator CacheSetHelper::canNotFindInstalledVer(pkgCacheFile &Cache pkgCache::PkgIterator const &Pkg) { if (ShowError == true) _error->Error(_("Can't select installed version from package %s as it is not installed"), Pkg.FullName(true).c_str()); - return pkgCache::VerIterator(Cache); + return pkgCache::VerIterator(Cache, 0); } /*}}}*/ }