]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/metaindex.cc
follow the googletest merge in build-depends
[apt.git] / apt-pkg / metaindex.cc
index baf695f164e05ccfdbf1ceb1ae8d7e4e081153f1..8b31051fb54debd1e160b3073f30f46910adff35 100644 (file)
@@ -3,7 +3,7 @@
 #include <apt-pkg/indexfile.h>
 #include <apt-pkg/metaindex.h>
 
-#include <stddef.h>
+#include <apt-pkg/debmetaindex.h>
 
 #include <string>
 #include <vector>
@@ -34,12 +34,15 @@ metaIndex::metaIndex(std::string const &URI, std::string const &Dist,
 
 metaIndex::~metaIndex()
 {
-   if (Indexes == 0)
-      return;
-   for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin();
-        I != (*Indexes).end(); ++I)
-      delete *I;
-   delete Indexes;
+   if (Indexes != 0)
+   {
+      for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin();
+           I != (*Indexes).end(); ++I)
+        delete *I;
+      delete Indexes;
+   }
+   for (auto const &E: Entries)
+      delete E.second;
 }
 
 // one line Getters for public fields                                  /*{{{*/
@@ -54,16 +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               /*{{{*/
 {
-   // TODO: Used to be an explicit value set in the constructor
-   return "";
+   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 /*{{{*/
@@ -99,3 +111,20 @@ void metaIndex::swapLoad(metaIndex * const OldMetaIndex)            /*{{{*/
    std::swap(LoadedSuccessfully, OldMetaIndex->LoadedSuccessfully);
 }
                                                                        /*}}}*/
+
+bool metaIndex::IsArchitectureSupported(std::string const &arch) const /*{{{*/
+{
+   debReleaseIndex const * const deb = dynamic_cast<debReleaseIndex const *>(this);
+   if (deb != NULL)
+      return deb->IsArchitectureSupported(arch);
+   return true;
+}
+                                                                       /*}}}*/
+bool metaIndex::IsArchitectureAllSupportedFor(IndexTarget const &target) const/*{{{*/
+{
+   debReleaseIndex const * const deb = dynamic_cast<debReleaseIndex const *>(this);
+   if (deb != NULL)
+      return deb->IsArchitectureAllSupportedFor(target);
+   return true;
+}
+                                                                       /*}}}*/