You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

112 lines
3.0 KiB

  1. #ifndef PKGLIB_METAINDEX_H
  2. #define PKGLIB_METAINDEX_H
  3. #include <apt-pkg/indexfile.h>
  4. #include <apt-pkg/init.h>
  5. #include <stddef.h>
  6. #include <string>
  7. #include <vector>
  8. #ifndef APT_10_CLEANER_HEADERS
  9. #include <apt-pkg/pkgcache.h>
  10. class pkgCacheGenerator;
  11. class OpProgress;
  12. #endif
  13. #ifndef APT_8_CLEANER_HEADERS
  14. #include <apt-pkg/srcrecords.h>
  15. #include <apt-pkg/pkgrecords.h>
  16. #include <apt-pkg/vendor.h>
  17. using std::string;
  18. #endif
  19. class pkgAcquire;
  20. class IndexTarget;
  21. class pkgCacheGenerator;
  22. class OpProgress;
  23. class metaIndex
  24. {
  25. public:
  26. APT_IGNORE_DEPRECATED_PUSH
  27. struct checkSum
  28. {
  29. std::string MetaKeyFilename;
  30. HashStringList Hashes;
  31. unsigned long long Size;
  32. APT_DEPRECATED HashString Hash;
  33. };
  34. APT_IGNORE_DEPRECATED_POP
  35. enum APT_HIDDEN TriState {
  36. TRI_YES, TRI_DONTCARE, TRI_NO, TRI_UNSET
  37. };
  38. private:
  39. void * const d;
  40. protected:
  41. std::vector <pkgIndexFile *> *Indexes;
  42. // parsed from the sources.list
  43. const char *Type;
  44. std::string URI;
  45. std::string Dist;
  46. TriState Trusted;
  47. TriState LoadedSuccessfully;
  48. // parsed from a file
  49. std::string Suite;
  50. std::string Codename;
  51. time_t Date;
  52. time_t ValidUntil;
  53. bool SupportsAcquireByHash;
  54. std::map<std::string, checkSum *> Entries;
  55. public:
  56. // Various accessors
  57. std::string GetURI() const;
  58. std::string GetDist() const;
  59. const char* GetType() const;
  60. TriState GetTrusted() const;
  61. std::string GetCodename() const;
  62. std::string GetSuite() const;
  63. bool GetSupportsAcquireByHash() const;
  64. time_t GetValidUntil() const;
  65. time_t GetDate() const;
  66. std::string GetExpectedDist() const;
  67. bool CheckDist(std::string const &MaybeDist) const;
  68. // Interface for acquire
  69. virtual std::string Describe() const;
  70. virtual std::string ArchiveURI(std::string const& File) const = 0;
  71. virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) = 0;
  72. virtual std::vector<IndexTarget> GetIndexTargets() const = 0;
  73. virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0;
  74. virtual bool IsTrusted() const = 0;
  75. virtual bool Load(std::string const &Filename, std::string * const ErrorText) = 0;
  76. /** @return a new metaIndex object based on this one, but without information from #Load */
  77. virtual metaIndex * UnloadedClone() const = 0;
  78. // the given metaIndex is potentially invalid after this call and should be deleted
  79. void swapLoad(metaIndex * const OldMetaIndex);
  80. // Lookup functions for parsed Hashes
  81. checkSum *Lookup(std::string const &MetaKey) const;
  82. /** \brief tests if a checksum for this file is available */
  83. bool Exists(std::string const &MetaKey) const;
  84. std::vector<std::string> MetaKeys() const;
  85. TriState GetLoadedSuccessfully() const;
  86. // Interfaces for pkgCacheGen
  87. virtual pkgCache::RlsFileIterator FindInCache(pkgCache &Cache, bool const ModifyCheck) const;
  88. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
  89. metaIndex(std::string const &URI, std::string const &Dist,
  90. char const * const Type);
  91. virtual ~metaIndex();
  92. };
  93. #endif