- std::vector<std::string> lang = APT::Configuration::getLanguages(true);
- std::vector<std::string>::iterator lend = std::remove(lang.begin(), lang.end(), "none");
- if (lend != lang.end())
- lang.erase(lend);
-
- if (lang.empty() == true)
- return IndexTargets;
-
- // get the Translation-* files, later we will skip download of non-existent if we have an index
- for (std::set<std::string>::const_iterator s = sections.begin();
- s != sections.end(); ++s) {
- for (std::vector<std::string>::const_iterator l = lang.begin();
- l != lang.end(); ++l) {
- IndexTarget * Target = new OptionalIndexTarget();
- Target->ShortDesc = "Translation-" + *l;
- Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s);
- Target->URI = TranslationIndexURI(l->c_str(), *s);
- Target->Description = Info (Target->ShortDesc.c_str(), *s);
- IndexTargets->push_back(Target);
- }
- }
+ // Only source release
+ if (IndexTargets->empty() == false && ArchEntries.size() == 1)
+ return IndexTargets;
+
+ std::vector<std::string> const targets = _config->FindVector("APT::Acquire::Targets::deb", "", true);
+ for (std::vector<std::string>::const_iterator T = targets.begin(); T != targets.end(); ++T)
+ {
+#define APT_T_CONFIG(X) _config->Find(std::string("APT::Acquire::Targets::deb::") + *T + "::" + (X))
+ std::string const URI = APT_T_CONFIG(flatArchive ? "flatURI" : "URI");
+ std::string const ShortDesc = APT_T_CONFIG("ShortDescription");
+ std::string const LongDesc = APT_T_CONFIG(flatArchive ? "flatDescription" : "Description");
+ bool const IsOptional = _config->FindB(std::string("APT::Acquire::Targets::deb::") + *T + "::Optional", true);
+#undef APT_T_CONFIG
+ if (URI.empty())
+ continue;
+
+ for (map<string, vector<debSectionEntry const*> >::const_iterator a = ArchEntries.begin();
+ a != ArchEntries.end(); ++a)
+ {
+ if (a->first == "source")
+ continue;
+
+ for (vector <const debSectionEntry *>::const_iterator I = a->second.begin();
+ I != a->second.end(); ++I) {
+
+ for (vector<std::string>::const_iterator l = lang.begin(); l != lang.end(); ++l)
+ {
+ if (*l == "none" && URI.find("$(LANGUAGE)") != std::string::npos)
+ continue;
+
+ struct SubstVar subst[] = {
+ { "$(SITE)", &Site },
+ { "$(RELEASE)", &Release },
+ { "$(COMPONENT)", &((*I)->Section) },
+ { "$(LANGUAGE)", &(*l) },
+ { "$(ARCHITECTURE)", &(a->first) },
+ { NULL, NULL }
+ };
+ std::string const name = SubstVar(URI, subst);
+ IndexTarget * Target;
+ if (IsOptional == true)
+ {
+ Target = new OptionalIndexTarget(
+ name,
+ SubstVar(ShortDesc, subst),
+ SubstVar(LongDesc, subst),
+ baseURI + name
+ );
+ }
+ else
+ {
+ Target = new IndexTarget(
+ name,
+ SubstVar(ShortDesc, subst),
+ SubstVar(LongDesc, subst),
+ baseURI + name
+ );
+ }
+ IndexTargets->push_back(Target);
+
+ if (URI.find("$(LANGUAGE)") == std::string::npos)
+ break;
+ }
+
+ if (URI.find("$(COMPONENT)") == std::string::npos)
+ break;
+ }
+
+ if (URI.find("$(ARCHITECTURE)") == std::string::npos)
+ break;
+ }
+ }