#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
-#include <apt-pkg/sptr.h>
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/versionmatch.h>
return Pref;
}
-
-// Policy::GetCandidateVer - Get the candidate install version /*{{{*/
+ /*}}}*/
+// Policy::GetCandidateVerNew - Get the candidate install version /*{{{*/
// ---------------------------------------------------------------------
/* Evaluate the package pins and the default list to deteremine what the
best package is. */
int candPriority = -1;
pkgVersioningSystem *vs = Cache->VS;
- for (pkgCache::VerIterator ver = Pkg.VersionList(); ver.end() == false; ver++) {
- int priority = GetPriority(ver);
+ for (pkgCache::VerIterator ver = Pkg.VersionList(); ver.end() == false; ++ver) {
+ int priority = GetPriority(ver, true);
- if (priority == 0 || priority <= candPriority)
- continue;
+ if (priority == 0 || priority <= candPriority)
+ continue;
- // TODO: Maybe optimize to not compare versions
- if (!cur.end() && priority < 1000
- && (vs->CmpVersion(ver.VerStr(), cur.VerStr()) < 0))
- continue;
+ // TODO: Maybe optimize to not compare versions
+ if (!cur.end() && priority < 1000
+ && (vs->CmpVersion(ver.VerStr(), cur.VerStr()) < 0))
+ continue;
candPriority = priority;
cand = ver;
// Find matching version(s) and copy the pin into it
pkgVersionMatch Match(P->Data,P->Type);
- for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; Ver++)
+ for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; ++Ver)
{
if (Match.VersionMatches(Ver)) {
Pin *VP = VerPins + Ver->ID;
if (DirectoryExists(Dir) == false)
{
- _error->WarningE("DirectoryExists",_("Unable to read %s"),Dir.c_str());
+ if (Dir != "/dev/null")
+ _error->WarningE("DirectoryExists",_("Unable to read %s"),Dir.c_str());
return true;
}
return true;
FileFd Fd(File,FileFd::ReadOnly);
- pkgTagFile TF(&Fd);
- if (_error->PendingError() == true)
+ pkgTagFile TF(&Fd, pkgTagFile::SUPPORT_COMMENTS);
+ if (Fd.IsOpen() == false || Fd.Failed())
return false;
- pkgUserTagSection Tags;
+ pkgTagSection Tags;
while (TF.Step(Tags) == true)
{
// can happen when there are only comments in a record
}
for (; Word != End && isspace(*Word) != 0; Word++);
- int priority = Tags.FindI("Pin-Priority", 0);
+ _error->PushToStack();
+ int const priority = Tags.FindI("Pin-Priority", 0);
+ bool const newError = _error->PendingError();
+ _error->MergeWithStack();
if (priority < std::numeric_limits<short>::min() ||
priority > std::numeric_limits<short>::max() ||
- _error->PendingError()) {
+ newError) {
return _error->Error(_("%s: Value %s is outside the range of valid pin priorities (%d to %d)"),
File.c_str(), Tags.FindS("Pin-Priority").c_str(),
std::numeric_limits<short>::min(),