+bool pkgSourceList::Type::ParseStanza(vector<metaIndex *> &List, /*{{{*/
+ pkgTagSection &Tags,
+ unsigned int const i,
+ FileFd &Fd)
+{
+ map<string, string> Options;
+
+ string Enabled = Tags.FindS("Enabled");
+ if (Enabled.empty() == false && StringToBool(Enabled) == false)
+ return true;
+
+ std::map<char const * const, std::pair<char const * const, bool> > mapping;
+#define APT_PLUSMINUS(X, Y) \
+ mapping.insert(std::make_pair(X, std::make_pair(Y, true))); \
+ mapping.insert(std::make_pair(X "Add", std::make_pair(Y "+", true))); \
+ mapping.insert(std::make_pair(X "Remove", std::make_pair(Y "-", true)))
+ APT_PLUSMINUS("Architectures", "arch");
+ APT_PLUSMINUS("Languages", "lang");
+ APT_PLUSMINUS("Targets", "target");
+#undef APT_PLUSMINUS
+ mapping.insert(std::make_pair("Trusted", std::make_pair("trusted", false)));
+ mapping.insert(std::make_pair("Check-Valid-Until", std::make_pair("check-valid-until", false)));
+ mapping.insert(std::make_pair("Valid-Until-Min", std::make_pair("valid-until-min", false)));
+ mapping.insert(std::make_pair("Valid-Until-Max", std::make_pair("valid-until-max", false)));
+ mapping.insert(std::make_pair("Signed-By", std::make_pair("signed-by", false)));
+
+ for (std::map<char const * const, std::pair<char const * const, bool> >::const_iterator m = mapping.begin(); m != mapping.end(); ++m)
+ if (Tags.Exists(m->first))
+ {
+ std::string option = Tags.FindS(m->first);
+ // for deb822 the " " is the delimiter, but the backend expects ","
+ if (m->second.second == true)
+ std::replace(option.begin(), option.end(), ' ', ',');
+ Options[m->second.first] = option;
+ }
+
+ // now create one item per suite/section
+ string Suite = Tags.FindS("Suites");
+ Suite = SubstVar(Suite,"$(ARCH)",_config->Find("APT::Architecture"));
+ string const Component = Tags.FindS("Components");
+ string const URIS = Tags.FindS("URIs");
+
+ std::vector<std::string> const list_uris = VectorizeString(URIS, ' ');
+ std::vector<std::string> const list_suite = VectorizeString(Suite, ' ');
+ std::vector<std::string> const list_comp = VectorizeString(Component, ' ');
+
+ if (list_uris.empty())
+ // TRANSLATOR: %u is a line number, the first %s is a filename of a file with the extension "second %s" and the third %s is a unique identifier for bugreports
+ return _error->Error(_("Malformed entry %u in %s file %s (%s)"), i, "sources", Fd.Name().c_str(), "URI");
+
+ for (std::vector<std::string>::const_iterator U = list_uris.begin();
+ U != list_uris.end(); ++U)
+ {
+ std::string URI = *U;
+ if (U->empty() || FixupURI(URI) == false)
+ return _error->Error(_("Malformed entry %u in %s file %s (%s)"), i, "sources", Fd.Name().c_str(), "URI parse");
+
+ if (list_suite.empty())
+ return _error->Error(_("Malformed entry %u in %s file %s (%s)"), i, "sources", Fd.Name().c_str(), "Suite");
+
+ for (std::vector<std::string>::const_iterator S = list_suite.begin();
+ S != list_suite.end(); ++S)
+ {
+ if (S->empty() == false && (*S)[S->size() - 1] == '/')
+ {
+ if (list_comp.empty() == false)
+ return _error->Error(_("Malformed entry %u in %s file %s (%s)"), i, "sources", Fd.Name().c_str(), "absolute Suite Component");
+ if (CreateItem(List, URI, *S, "", Options) == false)
+ return false;
+ }
+ else
+ {
+ if (list_comp.empty())
+ return _error->Error(_("Malformed entry %u in %s file %s (%s)"), i, "sources", Fd.Name().c_str(), "Component");
+
+ for (std::vector<std::string>::const_iterator C = list_comp.begin();
+ C != list_comp.end(); ++C)
+ {
+ if (CreateItem(List, URI, *S, *C, Options) == false)
+ {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+ /*}}}*/