From d7c92411dc1f4c6be098d1425f9c1c075e0c2154 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 28 May 2017 19:18:30 +0200 Subject: warn if an expected file can't be acquired If we couldn't find an entry for a Sources file we would generate an error while for a Packages file we would silently skip it due to assuming it is missing because it is empty. We can do better by checking if the repository declares that it supports a component we want to get the file from and if not say so and hint at the user making a typo. An example were this helps is mozilla.debian.net which dropped the firefox-aurora component (as upstream did) meaning no upgrades until the user notices manually that the repository doesn't provide packages anymore. With this commit warnings are raised hopefully causing the user to investigate what is wrong (sooner). --- apt-pkg/deb/debmetaindex.cc | 18 ++++++++++++++++++ apt-pkg/deb/debmetaindex.h | 1 + 2 files changed, 19 insertions(+) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index cba00aa8e..8c82414cb 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -51,6 +51,7 @@ class APT_HIDDEN debReleaseIndexPrivate /*{{{*/ std::vector Architectures; std::vector NoSupportForAll; + std::vector SupportedComponents; std::map const ReleaseOptions; debReleaseIndexPrivate(std::map const &Options) : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0), ReleaseOptions(Options) {} @@ -404,6 +405,16 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro if (targets.empty() == false) d->NoSupportForAll = VectorizeString(targets, ' '); } + for (auto const &comp: VectorizeString(Section.FindS("Components"), ' ')) + { + if (comp.empty()) + continue; + auto const pos = comp.find_last_of('/'); + if (pos == std::string::npos) + d->SupportedComponents.push_back(std::move(comp)); + else // e.g. security.debian.org uses this style + d->SupportedComponents.push_back(comp.substr(pos + 1)); + } bool FoundHashSum = false; bool FoundStrongHashSum = false; @@ -733,6 +744,13 @@ bool debReleaseIndex::IsArchitectureAllSupportedFor(IndexTarget const &target) c return std::find(d->NoSupportForAll.begin(), d->NoSupportForAll.end(), target.Option(IndexTarget::CREATED_BY)) == d->NoSupportForAll.end(); } /*}}}*/ +bool debReleaseIndex::HasSupportForComponent(std::string const &component) const/*{{{*/ +{ + if (d->SupportedComponents.empty()) + return true; + return std::find(d->SupportedComponents.begin(), d->SupportedComponents.end(), component) != d->SupportedComponents.end(); +} + /*}}}*/ std::vector *debReleaseIndex::GetIndexFiles() /*{{{*/ { if (Indexes != NULL) diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h index f903617f7..450ca94c9 100644 --- a/apt-pkg/deb/debmetaindex.h +++ b/apt-pkg/deb/debmetaindex.h @@ -61,6 +61,7 @@ class APT_HIDDEN debReleaseIndex : public metaIndex virtual bool IsTrusted() const APT_OVERRIDE; bool IsArchitectureSupported(std::string const &arch) const; bool IsArchitectureAllSupportedFor(IndexTarget const &target) const; + bool HasSupportForComponent(std::string const &component) const; void AddComponent(std::string const &sourcesEntry, bool const isSrc, std::string const &Name, -- cgit v1.2.3-70-g09d2