X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/916e5cb41edfa015fd8ec42ba140eb7c0c4cb511..610e13842a3718128c03454c5dfcbde49d323281:/apt-pkg/metaindex.cc?ds=sidebyside diff --git a/apt-pkg/metaindex.cc b/apt-pkg/metaindex.cc index 2292ac388..6e5792b78 100644 --- a/apt-pkg/metaindex.cc +++ b/apt-pkg/metaindex.cc @@ -1,44 +1,121 @@ +// Include Files /*{{{*/ +#include +#include +#include -#include +#include -#include "init.h" -#include "metaindex.h" +#include +#include + /*}}}*/ +std::string metaIndex::Describe() const +{ + return "Release"; +} -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) -string metaIndex::MetaIndexInfo(const char *Type) const +pkgCache::RlsFileIterator metaIndex::FindInCache(pkgCache &Cache, bool const) const { - string Info = ::URI::SiteOnly(URI) + ' '; - if (Dist[Dist.size() - 1] == '/') + return pkgCache::RlsFileIterator(Cache); +} + +bool metaIndex::Merge(pkgCacheGenerator &Gen,OpProgress *) const +{ + return Gen.SelectReleaseFile("", ""); +} + +metaIndex::metaIndex(std::string const &URI, std::string const &Dist, + char const * const Type) +: d(NULL), Indexes(NULL), Type(Type), URI(URI), Dist(Dist), Trusted(TRI_UNSET), + Date(0), ValidUntil(0), SupportsAcquireByHash(false), LoadedSuccessfully(TRI_UNSET) +{ + /* nothing */ +} + +metaIndex::~metaIndex() +{ + if (Indexes != 0) { - if (Dist != "/") - Info += Dist; + for (std::vector::iterator I = (*Indexes).begin(); + I != (*Indexes).end(); ++I) + delete *I; + delete Indexes; } - else - Info += Dist; - Info += " "; - Info += Type; - return Info; + for (auto const &E: Entries) + delete E.second; } -string metaIndex::MetaIndexFile(const char *Type) const +// one line Getters for public fields /*{{{*/ +APT_PURE std::string metaIndex::GetURI() const { return URI; } +APT_PURE std::string metaIndex::GetDist() const { return Dist; } +APT_PURE const char* metaIndex::GetType() const { return Type; } +APT_PURE metaIndex::TriState metaIndex::GetTrusted() const { return Trusted; } +APT_PURE std::string metaIndex::GetSignedBy() const { return SignedBy; } +APT_PURE std::string metaIndex::GetCodename() const { return Codename; } +APT_PURE std::string metaIndex::GetSuite() const { return Suite; } +APT_PURE bool metaIndex::GetSupportsAcquireByHash() const { return SupportsAcquireByHash; } +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 _config->FindDir("Dir::State::lists") + - URItoFileName(MetaIndexURI(Type)); + return (this->Codename == MaybeDist + || this->Suite == MaybeDist); } - -string metaIndex::MetaIndexURI(const char *Type) const +APT_PURE std::string metaIndex::GetExpectedDist() const { - string Res; + // TODO: Used to be an explicit value set in the constructor + return ""; +} + /*}}}*/ +APT_PURE metaIndex::checkSum *metaIndex::Lookup(string const &MetaKey) const /*{{{*/ +{ + std::map::const_iterator sum = Entries.find(MetaKey); + if (sum == Entries.end()) + return NULL; + return sum->second; +} + /*}}}*/ +APT_PURE bool metaIndex::Exists(string const &MetaKey) const /*{{{*/ +{ + return Entries.find(MetaKey) != Entries.end(); +} + /*}}}*/ +std::vector metaIndex::MetaKeys() const /*{{{*/ +{ + std::vector keys; + std::map::const_iterator I = Entries.begin(); + while(I != Entries.end()) { + keys.push_back((*I).first); + ++I; + } + return keys; +} + /*}}}*/ +void metaIndex::swapLoad(metaIndex * const OldMetaIndex) /*{{{*/ +{ + std::swap(Entries, OldMetaIndex->Entries); + std::swap(Date, OldMetaIndex->Date); + std::swap(ValidUntil, OldMetaIndex->ValidUntil); + std::swap(SupportsAcquireByHash, OldMetaIndex->SupportsAcquireByHash); + std::swap(LoadedSuccessfully, OldMetaIndex->LoadedSuccessfully); +} + /*}}}*/ - if (Dist == "/") - Res = URI; - else if (Dist[Dist.size()-1] == '/') - Res = URI + Dist; - else - Res = URI + "dists/" + Dist + "/"; - - Res += Type; - return Res; +bool metaIndex::IsArchitectureSupported(std::string const &arch) const /*{{{*/ +{ + debReleaseIndex const * const deb = dynamic_cast(this); + if (deb != NULL) + return deb->IsArchitectureSupported(arch); + return true; +} + /*}}}*/ +bool metaIndex::IsArchitectureAllSupportedFor(IndexTarget const &target) const/*{{{*/ +{ + debReleaseIndex const * const deb = dynamic_cast(this); + if (deb != NULL) + return deb->IsArchitectureAllSupportedFor(target); + return true; } -#endif + /*}}}*/