time_t ValidUntilMax;
std::vector<std::string> Architectures;
+ std::vector<std::string> NoSupportForAll;
debReleaseIndexPrivate() : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0) {}
};
DefCompressionTypes = os.str();
}
}
+ std::string DefKeepCompressedAs;
+ {
+ std::vector<APT::Configuration::Compressor> comps = APT::Configuration::getCompressors();
+ if (comps.empty() == false)
+ {
+ std::sort(comps.begin(), comps.end(),
+ [](APT::Configuration::Compressor const &a, APT::Configuration::Compressor const &b) { return a.Cost < b.Cost; });
+ std::ostringstream os;
+ for (auto const &c : comps)
+ if (c.Cost != 0)
+ os << c.Extension.substr(1) << ' ';
+ DefKeepCompressedAs = os.str();
+ }
+ DefKeepCompressedAs += "uncompressed";
+ }
std::string const NativeArch = _config->Find("APT::Architecture");
bool const GzipIndex = _config->FindB("Acquire::GzipIndexes", false);
for (std::vector<debReleaseIndexPrivate::debSectionEntry>::const_iterator E = entries.begin(); E != entries.end(); ++E)
bool const UsePDiffs = APT_T_CONFIG_BOOL("PDiffs", E->UsePDiffs);
std::string const UseByHash = APT_T_CONFIG_STR("By-Hash", E->UseByHash);
std::string const CompressionTypes = APT_T_CONFIG_STR("CompressionTypes", DefCompressionTypes);
+ std::string KeepCompressedAs = APT_T_CONFIG_STR("KeepCompressedAs", "");
#undef APT_T_CONFIG_BOOL
#undef APT_T_CONFIG_STR
if (tplMetaKey.empty())
continue;
+ if (KeepCompressedAs.empty())
+ KeepCompressedAs = DefKeepCompressedAs;
+ else
+ {
+ std::vector<std::string> const defKeep = VectorizeString(DefKeepCompressedAs, ' ');
+ std::vector<std::string> const valKeep = VectorizeString(KeepCompressedAs, ' ');
+ std::vector<std::string> keep;
+ for (auto const &val : valKeep)
+ {
+ if (val.empty())
+ continue;
+ if (std::find(defKeep.begin(), defKeep.end(), val) == defKeep.end())
+ continue;
+ keep.push_back(val);
+ }
+ if (std::find(keep.begin(), keep.end(), "uncompressed") == keep.end())
+ keep.push_back("uncompressed");
+ std::ostringstream os;
+ std::copy(keep.begin(), keep.end()-1, std::ostream_iterator<std::string>(os, " "));
+ os << *keep.rbegin();
+ KeepCompressedAs = os.str();
+ }
+
for (std::vector<std::string>::const_iterator L = E->Languages.begin(); L != E->Languages.end(); ++L)
{
if (*L == "none" && tplMetaKey.find("$(LANGUAGE)") != std::string::npos)
Options.insert(std::make_pair("BY_HASH", UseByHash));
Options.insert(std::make_pair("DEFAULTENABLED", DefaultEnabled ? "yes" : "no"));
Options.insert(std::make_pair("COMPRESSIONTYPES", CompressionTypes));
+ Options.insert(std::make_pair("KEEPCOMPRESSEDAS", KeepCompressedAs));
Options.insert(std::make_pair("SOURCESENTRY", E->sourcesEntry));
bool IsOpt = IsOptional;
if (archs.empty() == false)
d->Architectures = VectorizeString(archs, ' ');
}
+ {
+ std::string const targets = Section.FindS("No-Support-for-Architecture-all");
+ if (targets.empty() == false)
+ d->NoSupportForAll = VectorizeString(targets, ' ');
+ }
bool FoundHashSum = false;
- for (int i=0;HashString::SupportedHashes()[i] != NULL; i++)
+ bool FoundStrongHashSum = false;
+ auto const SupportedHashes = HashString::SupportedHashes();
+ for (int i=0; SupportedHashes[i] != NULL; i++)
{
- if (!Section.Find(HashString::SupportedHashes()[i], Start, End))
+ if (!Section.Find(SupportedHashes[i], Start, End))
continue;
std::string Name;
if (!parseSumData(Start, End, Name, Hash, Size))
return false;
+ HashString const hs(SupportedHashes[i], Hash);
if (Entries.find(Name) == Entries.end())
{
metaIndex::checkSum *Sum = new metaIndex::checkSum;
Sum->MetaKeyFilename = Name;
Sum->Size = Size;
Sum->Hashes.FileSize(Size);
- APT_IGNORE_DEPRECATED(Sum->Hash = HashString(HashString::SupportedHashes()[i],Hash);)
+ APT_IGNORE_DEPRECATED(Sum->Hash = hs;)
Entries[Name] = Sum;
}
- Entries[Name]->Hashes.push_back(HashString(HashString::SupportedHashes()[i],Hash));
+ Entries[Name]->Hashes.push_back(hs);
FoundHashSum = true;
+ if (FoundStrongHashSum == false && hs.usable() == true)
+ FoundStrongHashSum = true;
}
}
strprintf(*ErrorText, _("No Hash entry in Release file %s"), Filename.c_str());
return false;
}
+ if(FoundStrongHashSum == false)
+ {
+ if (ErrorText != NULL)
+ strprintf(*ErrorText, _("No Hash entry in Release file %s, which is considered strong enough for security purposes"), Filename.c_str());
+ return false;
+ }
std::string const StrDate = Section.FindS("Date");
if (RFC1123StrToTime(StrDate.c_str(), Date) == false)
{
- if (ErrorText != NULL)
- strprintf(*ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str());
- return false;
+ _error->Warning( _("Invalid 'Date' entry in Release file %s"), Filename.c_str());
+ Date = 0;
}
bool CheckValidUntil = _config->FindB("Acquire::Check-Valid-Until", true);
MinAge = _config->FindI(("Acquire::Min-ValidTime::" + Label).c_str(), MinAge);
}
- if (MinAge != 0 && ValidUntil != 0) {
- time_t const min_date = Date + MinAge;
- if (ValidUntil < min_date)
- ValidUntil = min_date;
- }
- if (MaxAge != 0) {
- time_t const max_date = Date + MaxAge;
- if (ValidUntil == 0 || ValidUntil > max_date)
- ValidUntil = max_date;
+ if (MinAge != 0 || ValidUntil != 0 || MaxAge != 0)
+ {
+ if (MinAge != 0 && ValidUntil != 0) {
+ time_t const min_date = Date + MinAge;
+ if (ValidUntil < min_date)
+ ValidUntil = min_date;
+ }
+ if (MaxAge != 0 && Date != 0) {
+ time_t const max_date = Date + MaxAge;
+ if (ValidUntil == 0 || ValidUntil > max_date)
+ ValidUntil = max_date;
+ }
}
}
Trusted = pTrusted;
else if (Trusted != pTrusted)
// TRANSLATOR: The first is an option name from sources.list manpage, the other two URI and Suite
- return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Trusted", URI.c_str(), Dist.c_str());
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Trusted", URI.c_str(), Dist.c_str());
return true;
}
bool debReleaseIndex::SetCheckValidUntil(TriState const pCheckValidUntil)
if (d->CheckValidUntil == TRI_UNSET)
d->CheckValidUntil = pCheckValidUntil;
else if (d->CheckValidUntil != pCheckValidUntil)
- return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Check-Valid-Until", URI.c_str(), Dist.c_str());
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Check-Valid-Until", URI.c_str(), Dist.c_str());
return true;
}
bool debReleaseIndex::SetValidUntilMin(time_t const Valid)
if (d->ValidUntilMin == 0)
d->ValidUntilMin = Valid;
else if (d->ValidUntilMin != Valid)
- return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Min-ValidTime", URI.c_str(), Dist.c_str());
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Min-ValidTime", URI.c_str(), Dist.c_str());
return true;
}
bool debReleaseIndex::SetValidUntilMax(time_t const Valid)
if (d->ValidUntilMax == 0)
d->ValidUntilMax = Valid;
else if (d->ValidUntilMax != Valid)
- return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Max-ValidTime", URI.c_str(), Dist.c_str());
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Max-ValidTime", URI.c_str(), Dist.c_str());
return true;
}
bool debReleaseIndex::SetSignedBy(std::string const &pSignedBy)
finger.erase(std::remove(finger.begin(), finger.end(), ' '), finger.end());
std::transform(finger.begin(), finger.end(), finger.begin(), ::toupper);
if (finger.length() != 40 || finger.find_first_not_of("0123456789ABCDEF") != std::string::npos)
- return _error->Error(_("Invalid value set for option %s concerning source %s %s (%s)"), "Signed-By", URI.c_str(), Dist.c_str(), "not a fingerprint");
+ return _error->Error(_("Invalid value set for option %s regarding source %s %s (%s)"), "Signed-By", URI.c_str(), Dist.c_str(), "not a fingerprint");
}
SignedBy = pSignedBy;
}
else if (SignedBy != pSignedBy)
- return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Signed-By", URI.c_str(), Dist.c_str());
+ return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Signed-By", URI.c_str(), Dist.c_str());
return true;
}
/*}}}*/
return std::find(d->Architectures.begin(), d->Architectures.end(), arch) != d->Architectures.end();
}
/*}}}*/
+bool debReleaseIndex::IsArchitectureAllSupportedFor(IndexTarget const &target) const/*{{{*/
+{
+ if (d->NoSupportForAll.empty())
+ return true;
+ return std::find(d->NoSupportForAll.begin(), d->NoSupportForAll.end(), target.Option(IndexTarget::CREATED_BY)) == d->NoSupportForAll.end();
+}
+ /*}}}*/
std::vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles() /*{{{*/
{
if (Indexes != NULL)