From 530302ef25d14bd7577f18cf98c2fa868c3c1dd3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 20 Jan 2016 00:09:36 +0100 Subject: always create pkg at the time pkg:arch is created To resolve dependencies like "pkg:arch" we create a package with the name "pkg:arch" and the architecture "any". We create these packages only if a dependency needs it as these kind of dependencies aren't that common. This commit ensured that in the even this architecture specific dependency is the only relation this package has we still create the underlying package to have them available in provides resolution. --- apt-pkg/pkgcachegen.cc | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'apt-pkg/pkgcachegen.cc') diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 55d1ee89d..6e307fba9 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -660,31 +660,44 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg, StringView Name, if (Arch == "any") { size_t const found = Name.find(':'); - StringView const NameA = Name.substr(0, found); StringView ArchA = Name.substr(found + 1); - pkgCache::PkgIterator PkgA = Cache.FindPkg(NameA, ArchA); - if (PkgA.end() == false) + if (ArchA != "any") { // ArchA is used inside the loop which might remap (NameA is not used) Dynamic DynArchA(ArchA); + StringView NameA = Name.substr(0, found); + pkgCache::PkgIterator PkgA = Cache.FindPkg(NameA, ArchA); Dynamic DynPkgA(PkgA); - pkgCache::PrvIterator Prv = PkgA.ProvidesList(); - for (; Prv.end() == false; ++Prv) + if (PkgA.end()) { - if (Prv.IsMultiArchImplicit()) - continue; - pkgCache::VerIterator V = Prv.OwnerVer(); - if (ArchA != V.ParentPkg().Arch()) - continue; - if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) + Dynamic DynNameA(NameA); + if (NewPackage(PkgA, NameA, ArchA) == false) return false; } - pkgCache::VerIterator V = PkgA.VersionList(); - Dynamic DynV(V); - for (; V.end() == false; ++V) + if (unlikely(PkgA.end())) + return _error->Fatal("NewPackage was successful for %s:%s," + "but the package doesn't exist anyhow!", + NameA.to_string().c_str(), ArchA.to_string().c_str()); + else { - if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) - return false; + pkgCache::PrvIterator Prv = PkgA.ProvidesList(); + for (; Prv.end() == false; ++Prv) + { + if (Prv.IsMultiArchImplicit()) + continue; + pkgCache::VerIterator V = Prv.OwnerVer(); + if (ArchA != V.ParentPkg().Arch()) + continue; + if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) + return false; + } + pkgCache::VerIterator V = PkgA.VersionList(); + Dynamic DynV(V); + for (; V.end() == false; ++V) + { + if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) + return false; + } } } } -- cgit v1.2.3