summaryrefslogtreecommitdiff
path: root/apt-pkg/metaindex.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-11-11 13:05:38 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2016-11-11 23:40:39 +0100
commitd0c7d4d6328418b7c9f434a3398e5f7e08b7359c (patch)
tree4a29050c1cff44bea2b192350733dfa16707ad2c /apt-pkg/metaindex.cc
parenta9b724eedd0c9d8c36725c5b8f57d51ea9f7dcd1 (diff)
don't warn if untransformed distribution matches
A suite or codename entry in the Release file is checked against the distribution field in the sources.list entry that lead to the download of that Release file. This distribution entry can contain slashes in the distribution field: deb http://security.debian.org/debian wheezy/updates main However, the Release file may only contain "wheezy" in the Codename field and not "wheezy/updates". So a transformation needs to take place that removes the last / and everything that comes after (e.g. "/updates"). This fails, however, for valid cases like a reprepro snapshot where the given Codename contains slashes but is perfectly fine and doesn't need to be transformed. Since that transformation is essentially just a workaround for special cases like the security repository, it should be checked if the literal Codename without any transformations happened is valid and only if isn't the dist should be checked against the transformated one. This way special cases like security.debian.org are handled and reprepro snapshots work too. The initial patch was taken as insperationto move whole transformation to CheckDist() which makes this method more accepting & easier to use (but according to codesearch.d.n we are the only users anyhow). Thanks: Lukas Anzinger for initial patch Closes: 644610
Diffstat (limited to 'apt-pkg/metaindex.cc')
-rw-r--r--apt-pkg/metaindex.cc26
1 files changed, 18 insertions, 8 deletions
diff --git a/apt-pkg/metaindex.cc b/apt-pkg/metaindex.cc
index 281824855..8b31051fb 100644
--- a/apt-pkg/metaindex.cc
+++ b/apt-pkg/metaindex.cc
@@ -57,15 +57,25 @@ APT_PURE bool metaIndex::GetSupportsAcquireByHash() const { return SupportsAcqui
APT_PURE time_t metaIndex::GetValidUntil() const { return ValidUntil; }
APT_PURE time_t metaIndex::GetDate() const { return this->Date; }
APT_PURE metaIndex::TriState metaIndex::GetLoadedSuccessfully() const { return LoadedSuccessfully; }
-
-APT_PURE bool metaIndex::CheckDist(string const &MaybeDist) const
-{
- return (this->Codename == MaybeDist
- || this->Suite == MaybeDist);
-}
-APT_PURE std::string metaIndex::GetExpectedDist() const
+APT_PURE std::string metaIndex::GetExpectedDist() const { return Dist; }
+ /*}}}*/
+bool metaIndex::CheckDist(string const &MaybeDist) const /*{{{*/
{
- return Dist;
+ if (MaybeDist.empty() || this->Codename == MaybeDist || this->Suite == MaybeDist)
+ return true;
+
+ std::string Transformed = MaybeDist;
+ if (Transformed == "../project/experimental")
+ Transformed = "experimental";
+
+ auto const pos = Transformed.rfind('/');
+ if (pos != string::npos)
+ Transformed = Transformed.substr(0, pos);
+
+ if (Transformed == ".")
+ Transformed.clear();
+
+ return Transformed.empty() || this->Codename == Transformed || this->Suite == Transformed;
}
/*}}}*/
APT_PURE metaIndex::checkSum *metaIndex::Lookup(string const &MetaKey) const /*{{{*/