]> git.saurik.com Git - apt.git/commitdiff
Merge from DonKult
authorJulian Andres Klode <jak@debian.org>
Fri, 15 Apr 2011 12:25:43 +0000 (14:25 +0200)
committerJulian Andres Klode <jak@debian.org>
Fri, 15 Apr 2011 12:25:43 +0000 (14:25 +0200)
apt-pkg/pkgcache.cc
apt-pkg/pkgcache.h
apt-pkg/pkgcachegen.cc
debian/changelog

index c6326abf12fb2d98b67d4e73a3b5433668e2c52d..b63900adb94ca3bba06f13959b61f820ea5bff7a 100644 (file)
@@ -217,6 +217,9 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
        if (found == string::npos)
                return FindPkg(Name, "native");
        string const Arch = Name.substr(found+1);
+       /* Beware: This is specialcased to handle pkg:any in dependencies as
+          these are linked to virtual pkg:any named packages with all archs.
+          If you want any arch from a given pkg, use FindPkg(pkg,arch) */
        if (Arch == "any")
                return FindPkg(Name, "any");
        return FindPkg(Name.substr(0, found), Arch);
@@ -228,7 +231,7 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
 pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) {
        if (MultiArchCache() == false) {
                if (Arch == "native" || Arch == "all" || Arch == "any" ||
-                   Arch == _config->Find("APT::Architecture"))
+                   Arch == NativeArch())
                        return SingleArchFindPkg(Name);
                else
                        return PkgIterator(*this,0);
@@ -322,15 +325,15 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const {
        if (Arch == "any")
                return PkgIterator(*Owner, Owner->PkgP + S->FirstPackage);
 
-       static string const myArch = _config->Find("APT::Architecture");
+       char const* const myArch = Owner->NativeArch();
        /* Most of the time the package for our native architecture is
           the one we add at first to the cache, but this would be the
           last one we check, so we do it now. */
        if (Arch == "native" || Arch == myArch || Arch == "all") {
-               Arch = myArch;
                pkgCache::Package *Pkg = Owner->PkgP + S->LastPackage;
-               if (stringcasecmp(Arch, Owner->StrP + Pkg->Arch) == 0)
+               if (strcasecmp(myArch, Owner->StrP + Pkg->Arch) == 0)
                        return PkgIterator(*Owner, Pkg);
+               Arch = myArch;
        }
 
        /* Iterate over the list to find the matching arch
@@ -503,7 +506,8 @@ std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
 {
    string fullname = Name();
    if (Pretty == false ||
-       (strcmp(Arch(), "all") != 0 && _config->Find("APT::Architecture") != Arch()))
+       (strcmp(Arch(), "all") != 0 &&
+       strcmp(Owner->NativeArch(), Arch()) != 0))
       return fullname.append(":").append(Arch());
    return fullname;
 }
index d654a29769a97024b4d7c26a70d05c211da1c078..1b174372481f0a1a7a43a4ce1fb24c3f7a4d29de 100644 (file)
@@ -215,6 +215,7 @@ class pkgCache                                                              /*{{{*/
 private:
    bool MultiArchEnabled;
    PkgIterator SingleArchFindPkg(const string &Name);
+   inline char const * const NativeArch() const;
 };
                                                                        /*}}}*/
 // Header structure                                                    /*{{{*/
@@ -649,6 +650,11 @@ struct pkgCache::StringItem
    map_ptrloc NextItem;      // StringItem
 };
                                                                        /*}}}*/
+
+
+inline char const * const pkgCache::NativeArch() const
+       { return StrP + HeaderP->Architecture; };
+
 #include <apt-pkg/cacheiterators.h>
 
 inline pkgCache::GrpIterator pkgCache::GrpBegin() 
index b0ee04554995636c16d5d609576b08c28299e872..9820fde81996c413494970f74f4eb57834b8cba9 100644 (file)
@@ -479,7 +479,8 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
    // Set the name, arch and the ID
    Pkg->Name = Grp->Name;
    Pkg->Group = Grp.Index();
-   map_ptrloc const idxArch = WriteUniqString((Arch == "all") ? _config->Find("APT::Architecture") : Arch.c_str());
+   // all is mapped to the native architecture
+   map_ptrloc const idxArch = (Arch == "all") ? Cache.HeaderP->Architecture : WriteUniqString(Arch.c_str());
    if (unlikely(idxArch == 0))
       return false;
    Pkg->Arch = idxArch;
@@ -783,7 +784,7 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
 
    // We do not add self referencing provides
    if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() ||
-       (PkgArch == "all" && _config->Find("APT::Architecture") == Ver.ParentPkg().Arch())))
+       (PkgArch == "all" && strcmp((Cache.StrP + Cache.HeaderP->Architecture), Ver.ParentPkg().Arch()) == 0)))
       return true;
    
    // Get a structure
index 4372ef737b79552eb6947bb7e8a5174b3794a646..c312bb6d294d0f1012328702070384c2d901c496 100644 (file)
@@ -24,6 +24,11 @@ apt (0.8.14) UNRELEASED; urgency=low
     - run unattended-upgrades even if there was a error during
       the apt-get update (LP: #676295)
 
+  [ David Kalnischkies ]
+  * apt-pkg/pkgcache.cc:
+    - use the native Architecture stored in the cache header instead of
+      loading it from configuration as suggested by Julian Andres Klode
+
  -- Julian Andres Klode <jak@debian.org>  Thu, 07 Apr 2011 11:48:46 +0200
 
 apt (0.8.13.2) unstable; urgency=low