* apt-pkg/pkgcache.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 25 Jul 2010 06:24:03 +0000 (08:24 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 25 Jul 2010 06:24:03 +0000 (08:24 +0200)
  - prefer non-virtual packages in FindPreferredPkg

apt-pkg/cacheiterators.h
apt-pkg/pkgcache.cc
debian/changelog

index 1dcc345..0be9368 100644 (file)
@@ -115,8 +115,11 @@ class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> {
        /** \brief find the package with the "best" architecture
 
            The best architecture is either the "native" or the first
-           in the list of Architectures which is not an end-Pointer */
-       PkgIterator FindPreferredPkg() const;
+           in the list of Architectures which is not an end-Pointer
+
+           \param PreferNonVirtual tries to respond with a non-virtual package
+                  and only if this fails returns the best virtual package */
+       PkgIterator FindPreferredPkg(bool const &PreferNonVirtual = true) const;
        PkgIterator NextPkg(PkgIterator const &Pkg) const;
 
        // Constructors
index 8af8ef7..9e1f8b6 100644 (file)
@@ -349,19 +349,21 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const {
 // GrpIterator::FindPreferredPkg - Locate the "best" package           /*{{{*/
 // ---------------------------------------------------------------------
 /* Returns an End-Pointer on error, pointer to the package otherwise */
-pkgCache::PkgIterator pkgCache::GrpIterator::FindPreferredPkg() const {
+pkgCache::PkgIterator pkgCache::GrpIterator::FindPreferredPkg(bool const &PreferNonVirtual) const {
        pkgCache::PkgIterator Pkg = FindPkg("native");
-       if (Pkg.end() == false)
+       if (Pkg.end() == false && (PreferNonVirtual == false || Pkg->VersionList != 0))
                return Pkg;
 
        std::vector<std::string> const archs = APT::Configuration::getArchitectures();
        for (std::vector<std::string>::const_iterator a = archs.begin();
             a != archs.end(); ++a) {
                Pkg = FindPkg(*a);
-               if (Pkg.end() == false)
+               if (Pkg.end() == false && (PreferNonVirtual == false || Pkg->VersionList != 0))
                        return Pkg;
        }
 
+       if (PreferNonVirtual == true)
+               return FindPreferredPkg(false);
        return PkgIterator(*Owner, 0);
 }
                                                                        /*}}}*/
index 0482971..aff194e 100644 (file)
@@ -7,8 +7,10 @@ apt (0.7.26~exp11) experimental; urgency=low
     - be able to omit dependency types in (r)depends (Closes: #319006)
   * apt-pkg/cacheset.cc:
     - move them back to the library as they look stable now
+  * apt-pkg/pkgcache.cc:
+    - prefer non-virtual packages in FindPreferredPkg
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 17 Jul 2010 19:56:47 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Sun, 25 Jul 2010 08:20:41 +0200
 
 apt (0.7.26~exp10) experimental; urgency=low