From 566046f403acb3f50df78be93ea3b68b9f2c3e7b Mon Sep 17 00:00:00 2001
From: David Kalnischkies <kalnischkies@gmail.com>
Date: Fri, 25 Mar 2011 20:17:32 +0100
Subject: * apt-pkg/pkgcachegen.cc:   - make "all"->"native" an implementation
 detail of NewPackage     rather than rewrite it in higher methods

---
 apt-pkg/pkgcache.cc    |  2 +-
 apt-pkg/pkgcachegen.cc | 12 ++++--------
 debian/changelog       |  5 ++++-
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 7014aee22..dbcbd9c26 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -321,7 +321,7 @@ pkgCache::PkgIterator pkgCache::GrpIterator::FindPkg(string Arch) const {
 	/* 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) {
+	if (Arch == "native" || Arch == myArch || Arch == "all") {
 		Arch = myArch;
 		pkgCache::Package *Pkg = Owner->PkgP + S->LastPackage;
 		if (stringcasecmp(Arch, Owner->StrP + Pkg->Arch) == 0)
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index d44dbf3a9..ae031fee4 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -178,12 +178,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
       if (PackageName.empty() == true)
 	 return false;
 
-      /* Treat Arch all packages as the same as the native arch. */
-      string Arch;
-      if (List.ArchitectureAll() == true)
-	 Arch = _config->Find("APT::Architecture");
-      else
-	 Arch = List.Architecture();
+      string const Arch = List.Architecture();
  
       // Get a pointer to the package structure
       pkgCache::PkgIterator Pkg;
@@ -484,7 +479,7 @@ 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.c_str());
+   map_ptrloc const idxArch = WriteUniqString((Arch == "all") ? _config->Find("APT::Architecture") : Arch.c_str());
    if (unlikely(idxArch == 0))
       return false;
    Pkg->Arch = idxArch;
@@ -787,7 +782,8 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver,
    pkgCache &Cache = Owner->Cache;
 
    // We do not add self referencing provides
-   if (Ver.ParentPkg().Name() == PkgName && PkgArch == Ver.Arch())
+   if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() ||
+	(PkgArch == "all" && _config->Find("APT::Architecture") == Ver.ParentPkg().Arch())))
       return true;
    
    // Get a structure
diff --git a/debian/changelog b/debian/changelog
index 90a56968c..e46c69ca4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -15,8 +15,11 @@ apt (0.8.13.1) UNRELEASED; urgency=low
       as suggested by Charles Plessy (Closes: #619083)
   * apt-pkg/depcache.cc:
     - remove pseudo handling leftover from SetReInstall
+  * apt-pkg/pkgcachegen.cc:
+    - make "all"->"native" an implementation detail of NewPackage
+      rather than rewrite it in higher methods
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 25 Mar 2011 20:06:03 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 25 Mar 2011 20:15:18 +0100
 
 apt (0.8.13) unstable; urgency=low
 
-- 
cgit v1.2.3