From a1464cb4025cd737ac57ea7392402d5efd2af027 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 14 Jun 2020 09:48:29 +0200 Subject: Deduplicate EDSP Provides line of M-A:foreign packages M-A:foreign causes Provides to apply to all architectures and as we wanted to avoid resolver changes for M-A those are done by explicitly creating these provides instead of forcing the resolvers to learn about this. The EDSP is a different beast though & we don't need this trick here especially as it leads to needless (but harmless) duplication. No sort+unique is done to avoid changing order (not that it should matter, but just to be sure), but the sets should be small enough to not make a huge difference either way. --- apt-pkg/edsp.cc | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 9f9976ef5..7e3993be4 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -29,8 +29,10 @@ #include #include +#include #include #include +#include #include #include @@ -119,19 +121,25 @@ static bool WriteScenarioDependency(FileFd &output, pkgCache::VerIterator const for (size_t i = 1; i < dependencies.size(); ++i) if (dependencies[i].empty() == false) WriteOkay(Okay, output, "\n", DepMap[i], ": ", dependencies[i]); - string provides; - for (pkgCache::PrvIterator Prv = Ver.ProvidesList(); Prv.end() == false; ++Prv) + std::vector provides; + for (auto Prv = Ver.ProvidesList(); not Prv.end(); ++Prv) { - if (Prv.IsMultiArchImplicit() == true) + if (Prv.IsMultiArchImplicit()) continue; - if (provides.empty() == false) - provides.append(", "); - provides.append(Prv.Name()); + std::string provide = Prv.Name(); if (Prv->ProvideVersion != 0) - provides.append(" (= ").append(Prv.ProvideVersion()).append(")"); + provide.append(" (= ").append(Prv.ProvideVersion()).append(")"); + if ((Ver->MultiArch & pkgCache::Version::Foreign) != 0 && std::find(provides.cbegin(), provides.cend(), provide) != provides.cend()) + continue; + provides.emplace_back(std::move(provide)); + } + if (not provides.empty()) + { + std::ostringstream out; + std::copy(provides.begin(), provides.end() - 1, std::ostream_iterator(out, ", ")); + out << provides.back(); + WriteOkay(Okay, output, "\nProvides: ", out.str()); } - if (provides.empty() == false) - WriteOkay(Okay, output, "\nProvides: ", provides); return WriteOkay(Okay, output, "\n"); } /*}}}*/ -- cgit v1.2.3