+// GetCandidateVer - Returns the Candidate install version /*{{{*/
+// ---------------------------------------------------------------------
+/* This should really use the DepCache or something.. Copied from there. */
+static pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator Pkg)
+{
+ /* 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)
+ 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);
+}
+ /*}}}*/