+ if (std::find(KeysB.begin(), KeysB.end(), *m.first) == KeysB.end())
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), m.first->c_str(), "<set>", "<unset>");
+ else
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), m.second->c_str(), "<set>", "<unset>");
+ }
+ if (m.second != KeysB.end())
+ {
+ if (std::find(KeysA.begin(), KeysA.end(), *m.second) == KeysA.end())
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), m.first->c_str(), "<set>", "<unset>");
+ else
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), m.second->c_str(), "<set>", "<unset>");
+ }
+ for (auto&& key: KeysA)
+ {
+ if (key == "BASE_URI" || key == "REPO_URI")
+ continue;
+ auto const a = OptionsA.find(key);
+ auto const b = OptionsB.find(key);
+ if (unlikely(a == OptionsA.end() || b == OptionsB.end()) || a->second != b->second)
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), key.c_str(), URI.c_str(), Dist.c_str());
+ }
+ return true;
+ }
+
+ static debReleaseIndex * GetDebReleaseIndexBy(std::vector<metaIndex *> &List, std::string const &URI,
+ std::string const &Dist, std::map<std::string, std::string> const &Options)
+ {
+ std::map<std::string,std::string> ReleaseOptions = {{
+ { "BASE_URI", constructMetaIndexURI(URI, Dist, "") },
+ { "REPO_URI", URI },
+ }};
+ if (GetBoolOption(Options, "allow-insecure", _config->FindB("Acquire::AllowInsecureRepositories")))
+ ReleaseOptions.emplace("ALLOW_INSECURE", "true");
+ if (GetBoolOption(Options, "allow-weak", _config->FindB("Acquire::AllowWeakRepositories")))
+ ReleaseOptions.emplace("ALLOW_WEAK", "true");
+ if (GetBoolOption(Options, "allow-downgrade-to-insecure", _config->FindB("Acquire::AllowDowngradeToInsecureRepositories")))
+ ReleaseOptions.emplace("ALLOW_DOWNGRADE_TO_INSECURE", "true");
+
+ debReleaseIndex * Deb = nullptr;
+ std::string const FileName = URItoFileName(constructMetaIndexURI(URI, Dist, "Release"));
+ for (auto const &I: List)
+ {
+ // We only worry about debian entries here
+ if (strcmp(I->GetType(), "deb") != 0)
+ continue;
+
+ auto const D = dynamic_cast<debReleaseIndex*>(I);
+ if (unlikely(D == nullptr))
+ continue;
+
+ /* This check ensures that there will be only one Release file
+ queued for all the Packages files and Sources files it
+ corresponds to. */
+ if (URItoFileName(D->MetaIndexURI("Release")) == FileName)
+ {
+ if (MapsAreEqual(ReleaseOptions, D->GetReleaseOptions(), URI, Dist) == false)
+ return nullptr;
+ Deb = D;
+ break;
+ }
+ }
+
+ // No currently created Release file indexes this entry, so we create a new one.
+ if (Deb == nullptr)
+ {
+ Deb = new debReleaseIndex(URI, Dist, ReleaseOptions);
+ List.push_back(Deb);