Преглед изворни кода

* 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

David Kalnischkies пре 15 година
родитељ
комит
959470da73
4 измењених фајлова са 23 додато и 7 уклоњено
  1. 6 5
      apt-pkg/pkgcache.cc
  2. 6 0
      apt-pkg/pkgcache.h
  3. 3 2
      apt-pkg/pkgcachegen.cc
  4. 8 0
      debian/changelog

+ 6 - 5
apt-pkg/pkgcache.cc

@@ -231,7 +231,7 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
 pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) {
 pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) {
 	if (MultiArchCache() == false) {
 	if (MultiArchCache() == false) {
 		if (Arch == "native" || Arch == "all" || Arch == "any" ||
 		if (Arch == "native" || Arch == "all" || Arch == "any" ||
-		    Arch == _config->Find("APT::Architecture"))
+		    Arch == NativeArch())
 			return SingleArchFindPkg(Name);
 			return SingleArchFindPkg(Name);
 		else
 		else
 			return PkgIterator(*this,0);
 			return PkgIterator(*this,0);
@@ -325,15 +325,15 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const {
 	if (Arch == "any")
 	if (Arch == "any")
 		return PkgIterator(*Owner, Owner->PkgP + S->FirstPackage);
 		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
 	/* 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
 	   the one we add at first to the cache, but this would be the
 	   last one we check, so we do it now. */
 	   last one we check, so we do it now. */
 	if (Arch == "native" || Arch == myArch || Arch == "all") {
 	if (Arch == "native" || Arch == myArch || Arch == "all") {
-		Arch = myArch;
 		pkgCache::Package *Pkg = Owner->PkgP + S->LastPackage;
 		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);
 			return PkgIterator(*Owner, Pkg);
+		Arch = myArch;
 	}
 	}
 
 
 	/* Iterate over the list to find the matching arch
 	/* Iterate over the list to find the matching arch
@@ -506,7 +506,8 @@ std::string pkgCache::PkgIterator::FullName(bool const &Pretty) const
 {
 {
    string fullname = Name();
    string fullname = Name();
    if (Pretty == false ||
    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.append(":").append(Arch());
    return fullname;
    return fullname;
 }
 }

+ 6 - 0
apt-pkg/pkgcache.h

@@ -215,6 +215,7 @@ class pkgCache								/*{{{*/
 private:
 private:
    bool MultiArchEnabled;
    bool MultiArchEnabled;
    PkgIterator SingleArchFindPkg(const string &Name);
    PkgIterator SingleArchFindPkg(const string &Name);
+   inline char const * const NativeArch() const;
 };
 };
 									/*}}}*/
 									/*}}}*/
 // Header structure							/*{{{*/
 // Header structure							/*{{{*/
@@ -649,6 +650,11 @@ struct pkgCache::StringItem
    map_ptrloc NextItem;      // StringItem
    map_ptrloc NextItem;      // StringItem
 };
 };
 									/*}}}*/
 									/*}}}*/
+
+
+inline char const * const pkgCache::NativeArch() const
+	{ return StrP + HeaderP->Architecture; };
+
 #include <apt-pkg/cacheiterators.h>
 #include <apt-pkg/cacheiterators.h>
 
 
 inline pkgCache::GrpIterator pkgCache::GrpBegin() 
 inline pkgCache::GrpIterator pkgCache::GrpBegin() 

+ 3 - 2
apt-pkg/pkgcachegen.cc

@@ -479,7 +479,8 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name
    // Set the name, arch and the ID
    // Set the name, arch and the ID
    Pkg->Name = Grp->Name;
    Pkg->Name = Grp->Name;
    Pkg->Group = Grp.Index();
    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))
    if (unlikely(idxArch == 0))
       return false;
       return false;
    Pkg->Arch = idxArch;
    Pkg->Arch = idxArch;
@@ -783,7 +784,7 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
 
 
    // We do not add self referencing provides
    // We do not add self referencing provides
    if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() ||
    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;
       return true;
    
    
    // Get a structure
    // Get a structure

+ 8 - 0
debian/changelog

@@ -1,3 +1,11 @@
+apt (0.8.13.3) unstable; urgency=low
+
+  * 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
+
+ -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 06 Apr 2011 16:43:08 +0200
+
 apt (0.8.13.2) unstable; urgency=low
 apt (0.8.13.2) unstable; urgency=low
 
 
   [ David Kalnischkies ]
   [ David Kalnischkies ]