+ // lazy-create foo (of amd64) provides foo:amd64 at the time we first need it
+ if (Arch == "any")
+ {
+ size_t const found = Name.find(':');
+ StringView const NameA = Name.substr(0, found);
+ StringView const ArchA = Name.substr(found + 1);
+ pkgCache::PkgIterator PkgA = Cache.FindPkg(NameA, ArchA);
+ if (PkgA.end() == false)
+ {
+ Dynamic<pkgCache::PkgIterator> DynPkgA(PkgA);
+ 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<pkgCache::VerIterator> DynV(V);
+ for (; V.end() == false; ++V)
+ {
+ if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false)
+ return false;
+ }
+ }
+ }
+ return true;
+}
+ /*}}}*/
+// CacheGenerator::AddImplicitDepends /*{{{*/
+bool pkgCacheGenerator::AddImplicitDepends(pkgCache::GrpIterator &G,
+ pkgCache::PkgIterator &P,
+ pkgCache::VerIterator &V)
+{
+ // copy P.Arch() into a string here as a cache remap
+ // in NewDepends() later may alter the pointer location
+ string Arch = P.Arch() == NULL ? "" : P.Arch();
+ map_pointer_t *OldDepLast = NULL;
+ /* MultiArch handling introduces a lot of implicit Dependencies:
+ - MultiArch: same → Co-Installable if they have the same version
+ - All others conflict with all other group members */
+ bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
+ pkgCache::PkgIterator D = G.PackageList();
+ Dynamic<pkgCache::PkgIterator> DynD(D);
+ map_stringitem_t const VerStrIdx = V->VerStr;
+ for (; D.end() != true; D = G.NextPkg(D))
+ {
+ if (Arch == D.Arch() || D->VersionList == 0)
+ continue;
+ /* We allow only one installed arch at the time
+ per group, therefore each group member conflicts
+ with all other group members */
+ if (coInstall == true)
+ {
+ // Replaces: ${self}:other ( << ${binary:Version})
+ NewDepends(D, V, VerStrIdx,
+ pkgCache::Dep::Less | pkgCache::Dep::MultiArchImplicit, pkgCache::Dep::Replaces,
+ OldDepLast);
+ // Breaks: ${self}:other (!= ${binary:Version})
+ NewDepends(D, V, VerStrIdx,
+ pkgCache::Dep::NotEquals | pkgCache::Dep::MultiArchImplicit, pkgCache::Dep::DpkgBreaks,
+ OldDepLast);
+ } else {
+ // Conflicts: ${self}:other
+ NewDepends(D, V, 0,
+ pkgCache::Dep::NoOp | pkgCache::Dep::MultiArchImplicit, pkgCache::Dep::Conflicts,
+ OldDepLast);
+ }
+ }
+ return true;
+}
+bool pkgCacheGenerator::AddImplicitDepends(pkgCache::VerIterator &V,
+ pkgCache::PkgIterator &D)
+{
+ /* MultiArch handling introduces a lot of implicit Dependencies:
+ - MultiArch: same → Co-Installable if they have the same version
+ - All others conflict with all other group members */
+ map_pointer_t *OldDepLast = NULL;
+ bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
+ if (coInstall == true)
+ {
+ map_stringitem_t const VerStrIdx = V->VerStr;
+ // Replaces: ${self}:other ( << ${binary:Version})
+ NewDepends(D, V, VerStrIdx,
+ pkgCache::Dep::Less | pkgCache::Dep::MultiArchImplicit, pkgCache::Dep::Replaces,
+ OldDepLast);
+ // Breaks: ${self}:other (!= ${binary:Version})
+ NewDepends(D, V, VerStrIdx,
+ pkgCache::Dep::NotEquals | pkgCache::Dep::MultiArchImplicit, pkgCache::Dep::DpkgBreaks,
+ OldDepLast);
+ } else {
+ // Conflicts: ${self}:other
+ NewDepends(D, V, 0,
+ pkgCache::Dep::NoOp | pkgCache::Dep::MultiArchImplicit, pkgCache::Dep::Conflicts,
+ OldDepLast);
+ }