summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2020-06-14 09:48:29 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2020-06-14 10:19:39 +0200
commita1464cb4025cd737ac57ea7392402d5efd2af027 (patch)
tree7e43d5687996384ec1d2c7775da82f3e6732e32f /apt-pkg
parent419190f6c17aaf750887ec7471599681377fb01b (diff)
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.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/edsp.cc26
1 files changed, 17 insertions, 9 deletions
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 <sys/stat.h>
#include <unistd.h>
+#include <algorithm>
#include <array>
#include <limits>
+#include <sstream>
#include <string>
#include <apti18n.h>
@@ -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<std::string> 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<std::string>(out, ", "));
+ out << provides.back();
+ WriteOkay(Okay, output, "\nProvides: ", out.str());
}
- if (provides.empty() == false)
- WriteOkay(Okay, output, "\nProvides: ", provides);
return WriteOkay(Okay, output, "\n");
}
/*}}}*/