]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcache.cc
merged from lp:~donkult/apt/sid
[apt.git] / apt-pkg / pkgcache.cc
index 8af8ef7de596d967314dc973b8cbb29fe3b27980..a66a5198d507f9bf35667660ae510a6bd0415839 100644 (file)
@@ -111,7 +111,10 @@ bool pkgCache::Header::CheckSizes(Header &Against) const
 /* */
 pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map)
 {
 /* */
 pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map)
 {
-   MultiArchEnabled = APT::Configuration::getArchitectures().size() > 1;
+   // call getArchitectures() with cached=false to ensure that the 
+   // architectures cache is re-evaulated. this is needed in cases
+   // when the APT::Architecture field changes between two cache creations
+   MultiArchEnabled = APT::Configuration::getArchitectures(false).size() > 1;
    if (DoMap == true)
       ReMap();
 }
    if (DoMap == true)
       ReMap();
 }
@@ -349,19 +352,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 */
 // 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");
        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);
                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;
        }
 
                        return Pkg;
        }
 
+       if (PreferNonVirtual == true)
+               return FindPreferredPkg(false);
        return PkgIterator(*Owner, 0);
 }
                                                                        /*}}}*/
        return PkgIterator(*Owner, 0);
 }
                                                                        /*}}}*/
@@ -659,6 +664,30 @@ void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End)
    }
 }
                                                                        /*}}}*/
    }
 }
                                                                        /*}}}*/
+// ostream operator to handle string representation of a dependecy     /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+std::ostream& operator<<(ostream& out, pkgCache::DepIterator D)
+{
+   if (D.end() == true)
+      return out << "invalid dependency";
+
+   pkgCache::PkgIterator P = D.ParentPkg();
+   pkgCache::PkgIterator T = D.TargetPkg();
+
+   out << (P.end() ? "invalid pkg" : P.FullName(false)) << " " << D.DepType()
+       << " on ";
+   if (T.end() == true)
+      out << "invalid pkg";
+   else
+      out << T;
+
+   if (D->Version != 0)
+      out << " (" << D.CompType() << " " << D.TargetVer() << ")";
+
+   return out;
+}
+                                                                       /*}}}*/
 // VerIterator::CompareVer - Fast version compare for same pkgs                /*{{{*/
 // ---------------------------------------------------------------------
 /* This just looks over the version list to see if B is listed before A. In
 // VerIterator::CompareVer - Fast version compare for same pkgs                /*{{{*/
 // ---------------------------------------------------------------------
 /* This just looks over the version list to see if B is listed before A. In
@@ -865,7 +894,8 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
       pkgCache::DescIterator Desc = DescDefault;
 
       for (; Desc.end() == false; Desc++)
       pkgCache::DescIterator Desc = DescDefault;
 
       for (; Desc.end() == false; Desc++)
-        if (*l == Desc.LanguageCode())
+        if (*l == Desc.LanguageCode() ||
+            (*l == "en" && strcmp(Desc.LanguageCode(),"") == 0))
            break;
       if (Desc.end() == true) 
         Desc = DescDefault;
            break;
       if (Desc.end() == true) 
         Desc = DescDefault;