summaryrefslogtreecommitdiff
path: root/apt-pkg/policy.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/policy.cc')
-rw-r--r--apt-pkg/policy.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index b9a951990..26d1c17bd 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -123,6 +123,14 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator Pkg)
signed Max = GetPriority(Pkg);
pkgCache::VerIterator Pref = GetMatch(Pkg);
+ // no package = no candidate version
+ if (Pkg.end() == true)
+ return Pref;
+
+ // packages with a pin lower than 0 have no newer candidate than the current version
+ if (Max < 0)
+ return Pkg.CurrentVer();
+
/* Falling through to the default version.. Setting Max to zero
effectively excludes everything <= 0 which are the non-automatic
priorities.. The status file is given a prio of 100 which will exclude
@@ -256,8 +264,10 @@ class PreferenceSection : public pkgTagSection
Stop = (const char*) memchr(Stop,'\n',End-Stop);
}
};
-
-
+ /*}}}*/
+// ReadPinDir - Load the pin files from this dir into a Policy /*{{{*/
+// ---------------------------------------------------------------------
+/* */
bool ReadPinDir(pkgPolicy &Plcy,string Dir)
{
if (Dir.empty() == true)
@@ -268,12 +278,12 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir)
return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
vector<string> List;
-
+
for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D))
{
if (Ent->d_name[0] == '.')
continue;
-
+
// Skip bad file names ala run-parts
const char *C = Ent->d_name;
for (; *C != 0; C++)
@@ -281,17 +291,17 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir)
break;
if (*C != 0)
continue;
-
+
// Make sure it is a file and not something else
string File = flCombine(Dir,Ent->d_name);
struct stat St;
if (stat(File.c_str(),&St) != 0 || S_ISREG(St.st_mode) == 0)
continue;
-
- List.push_back(File);
- }
+
+ List.push_back(File);
+ }
closedir(D);
-
+
sort(List.begin(),List.end());
// Read the files
@@ -300,7 +310,6 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir)
return false;
return true;
}
-
/*}}}*/
// ReadPinFile - Load the pin file into a Policy /*{{{*/
// ---------------------------------------------------------------------