From eddc9dd092138fee6e71f92ba41dc21918a03f73 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 6 Apr 2011 13:27:52 +0200 Subject: document the pkg:any specialcasing in FindPkg as well to make it clear that it is a needed "hack" to support multi-arch in the least breaking way --- apt-pkg/pkgcache.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index c6326abf1..c16005e38 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -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); -- cgit v1.2.3 From 959470da73e7dc325321bb5024f1fd6d24bd9e9b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 6 Apr 2011 16:47:58 +0200 Subject: * 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 --- apt-pkg/pkgcache.cc | 11 ++++++----- apt-pkg/pkgcache.h | 6 ++++++ apt-pkg/pkgcachegen.cc | 5 +++-- debian/changelog | 8 ++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index c16005e38..b63900adb 100644 --- a/apt-pkg/pkgcache.cc +++ b/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) { 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); @@ -325,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 @@ -506,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; } diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index d654a2976..1b1743724 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -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 inline pkgCache::GrpIterator pkgCache::GrpBegin() diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index b0ee04554..9820fde81 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -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 diff --git a/debian/changelog b/debian/changelog index 03bbe86d4..f3a867a9e 100644 --- a/debian/changelog +++ b/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 Wed, 06 Apr 2011 16:43:08 +0200 + apt (0.8.13.2) unstable; urgency=low [ David Kalnischkies ] -- cgit v1.2.3