From 3db58cf41785f1e0b7046bbe7f3ef5e545c9a658 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 25 Jul 2010 08:24:03 +0200 Subject: * apt-pkg/pkgcache.cc: - prefer non-virtual packages in FindPreferredPkg --- apt-pkg/cacheiterators.h | 7 +++++-- apt-pkg/pkgcache.cc | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 1dcc34532..0be9368bd 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -115,8 +115,11 @@ class pkgCache::GrpIterator: public Iterator { /** \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 diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 8af8ef7de..9e1f8b633 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -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 const archs = APT::Configuration::getArchitectures(); for (std::vector::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); } /*}}}*/ -- cgit v1.2.3