std::vector<std::string> Architectures;
std::vector<std::string> Languages;
bool UsePDiffs;
+ std::string UseByHash;
};
std::vector<debSectionEntry> DebEntries;
time_t ValidUntilMin;
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 KeepCompressed = APT_T_CONFIG_BOOL("KeepCompressed", GzipIndex);
bool const DefaultEnabled = APT_T_CONFIG_BOOL("DefaultEnabled", true);
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("TARGET_OF", Type));
Options.insert(std::make_pair("CREATED_BY", *T));
Options.insert(std::make_pair("PDIFFS", UsePDiffs ? "yes" : "no"));
+ 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 (IsOpt == false)
+ {
+ auto const arch = Options.find("ARCHITECTURE");
+ if (arch != Options.end() && arch->second == "all")
+ IsOpt = true;
+ }
+
IndexTarget Target(
MetaKey,
ShortDesc,
LongDesc,
Options.find("BASE_URI")->second + MetaKey,
- IsOptional,
+ IsOpt,
KeepCompressed,
Options
);
std::vector<std::string> const &Targets,
std::vector<std::string> const &Architectures,
std::vector<std::string> Languages,
- bool const usePDiffs)
+ bool const usePDiffs, std::string const &useByHash)
{
if (Languages.empty() == true)
Languages.push_back("none");
debReleaseIndexPrivate::debSectionEntry const entry = {
- sourcesEntry, Name, Targets, Architectures, Languages, usePDiffs
+ sourcesEntry, Name, Targets, Architectures, Languages, usePDiffs, useByHash
};
if (isSrc)
d->DebSrcEntries.push_back(entry);
return false;
pkgTagFile TagFile(&Fd, Fd.Size());
- if (_error->PendingError() == true)
+ if (Fd.IsOpen() == false || Fd.Failed())
{
if (ErrorText != NULL)
strprintf(*ErrorText, _("Unable to parse Release file %s"),Filename.c_str());
Suite = Section.FindS("Suite");
Codename = Section.FindS("Codename");
+ {
+ std::string const archs = Section.FindS("Architectures");
+ 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)
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 FileExists(MetaIndexFile("InRelease"));
}
/*}}}*/
+bool debReleaseIndex::IsArchitectureSupported(std::string const &arch) const/*{{{*/
+{
+ if (d->Architectures.empty())
+ 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)
// signature for an 'InRelease' file couldn't be checked
if (OpenMaybeClearSignedFile(ReleaseFile, Rel) == false)
return false;
- if (_error->PendingError() == true)
- return false;
// Store the IMS information
pkgCache::RlsFileIterator File = Gen.GetCurRlsFile();
pkgTagFile TagFile(&Rel, Rel.Size());
pkgTagSection Section;
- if (_error->PendingError() == true || TagFile.Step(Section) == false)
+ if (Rel.IsOpen() == false || Rel.Failed() || TagFile.Step(Section) == false)
return false;
std::string data;
if (data.empty() == false) \
{ \
map_stringitem_t const storage = Gen.StoreString(pkgCacheGenerator::TYPE, data); \
+ if (storage == 0) return false; \
STORE = storage; \
}
APT_INRELEASE(MIXED, "Suite", File->Archive)
Section.FindFlag("NotAutomatic", File->Flags, pkgCache::Flag::NotAutomatic);
Section.FindFlag("ButAutomaticUpgrades", File->Flags, pkgCache::Flag::ButAutomaticUpgrades);
- return !_error->PendingError();
+ return true;
}
/*}}}*/
// ReleaseIndex::FindInCache - Find this index /*{{{*/
else
Values = defaultValues;
+ // all is a very special architecture users shouldn't be concerned with explicitly
+ if (Name == "arch" && std::find(Values.begin(), Values.end(), "all") == Values.end())
+ Values.push_back("all");
+
if ((val = Options.find(Name + "+")) != Options.end())
{
std::vector<std::string> const plus = VectorizeString(val->second, ',');
UsePDiffs = StringToBool(opt->second);
}
+ std::string UseByHash = _config->Find("APT::Acquire::By-Hash", "yes");
+ UseByHash = _config->Find("Acquire::By-Hash", UseByHash);
+ {
+ std::string const host = ::URI(URI).Host;
+ UseByHash = _config->Find("APT::Acquire::" + host + "::By-Hash", UseByHash);
+ UseByHash = _config->Find("Acquire::" + host + "::By-Hash", UseByHash);
+ std::map<std::string, std::string>::const_iterator const opt = Options.find("by-hash");
+ if (opt != Options.end())
+ UseByHash = opt->second;
+ }
+
auto const entry = Options.find("sourceslist-entry");
Deb->AddComponent(
entry->second,
mytargets,
parsePlusMinusOptions("arch", Options, APT::Configuration::getArchitectures()),
parsePlusMinusOptions("lang", Options, APT::Configuration::getLanguages(true)),
- UsePDiffs
+ UsePDiffs,
+ UseByHash
);
if (Deb->SetTrusted(GetTriStateOption(Options, "trusted")) == false ||