Просмотр исходного кода

rename Calculate- to GetIndexTargets and use it as official API

We need a general way to get from a sources.list entry to IndexTargets
and with this change we can move from pkgSourceList over the list of
metaIndexes it includes to the IndexTargets each metaIndex can have.

Git-Dch: Ignore
David Kalnischkies лет назад: 11
Родитель
Сommit
261727f05c
3 измененных файлов с 21 добавлено и 27 удалено
  1. 15 22
      apt-pkg/deb/debmetaindex.cc
  2. 4 1
      apt-pkg/deb/debmetaindex.h
  3. 2 4
      apt-pkg/metaindex.h

+ 15 - 22
apt-pkg/deb/debmetaindex.cc

@@ -229,7 +229,7 @@ struct ComputeIndexTargetsClass
    }
    }
 };
 };
 
 
-std::vector<IndexTarget> debReleaseIndex::ComputeIndexTargets() const
+std::vector<IndexTarget> debReleaseIndex::GetIndexTargets() const
 {
 {
    ComputeIndexTargetsClass comp;
    ComputeIndexTargetsClass comp;
    foreachTarget(URI, Dist, ArchEntries, comp);
    foreachTarget(URI, Dist, ArchEntries, comp);
@@ -247,7 +247,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
       iR->SetTrusted(false);
       iR->SetTrusted(false);
 
 
    // special case for --print-uris
    // special case for --print-uris
-   std::vector<IndexTarget> const targets = ComputeIndexTargets();
+   std::vector<IndexTarget> const targets = GetIndexTargets();
 #define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, std::map<std::string,std::string>())
 #define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, std::map<std::string,std::string>())
    pkgAcqMetaBase * const TransactionManager = new pkgAcqMetaClearSig(Owner,
    pkgAcqMetaBase * const TransactionManager = new pkgAcqMetaClearSig(Owner,
 	 APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
 	 APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
@@ -396,6 +396,7 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type
 
 
       map<string, string>::const_iterator const trusted = Options.find("trusted");
       map<string, string>::const_iterator const trusted = Options.find("trusted");
 
 
+      debReleaseIndex *Deb = NULL;
       for (vector<metaIndex *>::const_iterator I = List.begin();
       for (vector<metaIndex *>::const_iterator I = List.begin();
 	   I != List.end(); ++I)
 	   I != List.end(); ++I)
       {
       {
@@ -403,34 +404,23 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type
 	 if (strcmp((*I)->GetType(), "deb") != 0)
 	 if (strcmp((*I)->GetType(), "deb") != 0)
 	    continue;
 	    continue;
 
 
-	 debReleaseIndex *Deb = (debReleaseIndex *) (*I);
-	 if (trusted != Options.end())
-	    Deb->SetTrusted(StringToBool(trusted->second, false));
-
 	 /* This check insures that there will be only one Release file
 	 /* This check insures that there will be only one Release file
 	    queued for all the Packages files and Sources files it
 	    queued for all the Packages files and Sources files it
 	    corresponds to. */
 	    corresponds to. */
-	 if (Deb->GetURI() == URI && Deb->GetDist() == Dist)
+	 if ((*I)->GetURI() == URI && (*I)->GetDist() == Dist)
 	 {
 	 {
-	    if (IsSrc == true)
-	       Deb->PushSectionEntry("source", new debReleaseIndex::debSectionEntry(Section, IsSrc));
-	    else
-	    {
-	       if (Dist[Dist.size() - 1] == '/')
-		  Deb->PushSectionEntry("any", new debReleaseIndex::debSectionEntry(Section, IsSrc));
-	       else
-		  Deb->PushSectionEntry(Archs, new debReleaseIndex::debSectionEntry(Section, IsSrc));
-	    }
-	    return true;
+	    Deb = dynamic_cast<debReleaseIndex*>(*I);
+	    if (Deb != NULL)
+	       break;
 	 }
 	 }
       }
       }
 
 
       // No currently created Release file indexes this entry, so we create a new one.
       // No currently created Release file indexes this entry, so we create a new one.
-      debReleaseIndex *Deb;
-      if (trusted != Options.end())
-	 Deb = new debReleaseIndex(URI, Dist, StringToBool(trusted->second, false));
-      else
+      if (Deb == NULL)
+      {
 	 Deb = new debReleaseIndex(URI, Dist);
 	 Deb = new debReleaseIndex(URI, Dist);
+	 List.push_back(Deb);
+      }
 
 
       if (IsSrc == true)
       if (IsSrc == true)
 	 Deb->PushSectionEntry ("source", new debReleaseIndex::debSectionEntry(Section, IsSrc));
 	 Deb->PushSectionEntry ("source", new debReleaseIndex::debSectionEntry(Section, IsSrc));
@@ -441,7 +431,10 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type
 	 else
 	 else
 	    Deb->PushSectionEntry (Archs, new debReleaseIndex::debSectionEntry(Section, IsSrc));
 	    Deb->PushSectionEntry (Archs, new debReleaseIndex::debSectionEntry(Section, IsSrc));
       }
       }
-      List.push_back(Deb);
+
+      if (trusted != Options.end())
+	 Deb->SetTrusted(StringToBool(trusted->second, false));
+
       return true;
       return true;
    }
    }
 };
 };

+ 4 - 1
apt-pkg/deb/debmetaindex.h

@@ -46,7 +46,7 @@ class APT_HIDDEN debReleaseIndex : public metaIndex {
 
 
    virtual std::string ArchiveURI(std::string const &File) const {return URI + File;};
    virtual std::string ArchiveURI(std::string const &File) const {return URI + File;};
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
-   std::vector<IndexTarget> ComputeIndexTargets() const;
+   virtual std::vector<IndexTarget> GetIndexTargets() const;
 
 
    std::string MetaIndexInfo(const char *Type) const;
    std::string MetaIndexInfo(const char *Type) const;
    std::string MetaIndexFile(const char *Types) const;
    std::string MetaIndexFile(const char *Types) const;
@@ -78,6 +78,9 @@ class APT_HIDDEN debDebFileMetaIndex : public metaIndex
    virtual bool GetIndexes(pkgAcquire* /*Owner*/, const bool& /*GetAll=false*/) const {
    virtual bool GetIndexes(pkgAcquire* /*Owner*/, const bool& /*GetAll=false*/) const {
       return true;
       return true;
    }
    }
+   virtual std::vector<IndexTarget> GetIndexTargets() const {
+      return std::vector<IndexTarget>();
+   }
    virtual std::vector<pkgIndexFile *> *GetIndexFiles() {
    virtual std::vector<pkgIndexFile *> *GetIndexFiles() {
       return Indexes;
       return Indexes;
    }
    }

+ 2 - 4
apt-pkg/metaindex.h

@@ -22,6 +22,7 @@ using std::string;
 #endif
 #endif
 
 
 class pkgAcquire;
 class pkgAcquire;
+class IndexTarget;
 
 
 class metaIndex
 class metaIndex
 {
 {
@@ -40,16 +41,13 @@ class metaIndex
    virtual const char* GetType() const {return Type;}
    virtual const char* GetType() const {return Type;}
 
 
    // interface to to query it
    // interface to to query it
-#if APT_PKG_ABI >= 413
    /** \return the path of the local file (or "" if its not available) */
    /** \return the path of the local file (or "" if its not available) */
    virtual std::string LocalFileName() const;
    virtual std::string LocalFileName() const;
-#else
-   std::string LocalFileName() const;
-#endif
 
 
    // Interface for acquire
    // Interface for acquire
    virtual std::string ArchiveURI(std::string const& File) const = 0;
    virtual std::string ArchiveURI(std::string const& File) const = 0;
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const = 0;
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const = 0;
+   virtual std::vector<IndexTarget> GetIndexTargets() const = 0;
    virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0;
    virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0;
    virtual bool IsTrusted() const = 0;
    virtual bool IsTrusted() const = 0;