- // Look for a package pin and evaluate it.
- signed Max = GetPriority(Pkg);
- pkgCache::VerIterator Pref = GetMatch(Pkg);
-
- // Alternatives in case we can not find our package pin (Bug#512318).
- signed MaxAlt = 0;
- pkgCache::VerIterator PrefAlt;
-
- // 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
- not-automatic sources, except in a single shot not-installed mode.
- The second pseduo-status file is at prio 1000, above which will permit
- the user to force-downgrade things.
-
- The user pin is subject to the same priority rules as default
- selections. Thus there are two ways to create a pin - a pin that
- tracks the default when the default is taken away, and a permanent
- pin that stays at that setting.
- */
- for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; Ver++)
- {
- /* Lets see if this version is the installed version */
- bool instVer = (Pkg.CurrentVer() == Ver);
- if (Ver.Pseudo() == true && instVer == false)
- {
- pkgCache::PkgIterator const allPkg = Ver.ParentPkg().Group().FindPkg("all");
- if (allPkg->CurrentVer != 0 && allPkg.CurrentVer()->Hash == Ver->Hash &&
- strcmp(allPkg.CurVersion(), Ver.VerStr()) == 0)
- instVer = true;
- }