-// GetCandidateVer - Returns the Candidate install version /*{{{*/
-// ---------------------------------------------------------------------
-/* This should really use the DepCache or something.. Copied from there.
- Allow current is required to filter out the status file when emitting
- an available file. */
-static pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator Pkg,
- bool AllowCurrent = true)
-{
- /* Not source/not automatic versions cannot be a candidate version
- unless they are already installed */
- for (pkgCache::VerIterator I = Pkg.VersionList(); I.end() == false; I++)
- {
- if (Pkg.CurrentVer() == I && AllowCurrent == true)
- return I;
-
- for (pkgCache::VerFileIterator J = I.FileList(); J.end() == false; J++)
- if ((J.File()->Flags & pkgCache::Flag::NotSource) == 0 &&
- (J.File()->Flags & pkgCache::Flag::NotAutomatic) == 0)
- return I;
- }
-
- return pkgCache::VerIterator(*GCache,0);
-}
- /*}}}*/