metaindex.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. using std::string;
  17. #endif
  18. class pkgAcquire;
  19. class IndexTarget;
  20. class pkgCacheGenerator;
  21. class OpProgress;
  22. class metaIndex
  23. {
  24. public:
  25. APT_IGNORE_DEPRECATED_PUSH
  26. struct checkSum
  27. {
  28. std::string MetaKeyFilename;
  29. HashStringList Hashes;
  30. unsigned long long Size;
  31. APT_DEPRECATED_MSG("Use the HashStringList member Hashes instead of a hardcoded HashString") HashString Hash;
  32. };
  33. APT_IGNORE_DEPRECATED_POP
  34. enum APT_HIDDEN TriState {
  35. TRI_YES, TRI_DONTCARE, TRI_NO, TRI_UNSET
  36. };
  37. private:
  38. void * const d;
  39. protected:
  40. std::vector <pkgIndexFile *> *Indexes;
  41. // parsed from the sources.list
  42. const char *Type;
  43. std::string URI;
  44. std::string Dist;
  45. TriState Trusted;
  46. std::string SignedBy;
  47. // parsed from a file
  48. std::string Suite;
  49. std::string Codename;
  50. time_t Date;
  51. time_t ValidUntil;
  52. bool SupportsAcquireByHash;
  53. std::map<std::string, checkSum *> Entries;
  54. TriState LoadedSuccessfully;
  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 GetSignedBy() const;
  62. std::string GetCodename() const;
  63. std::string GetSuite() const;
  64. bool GetSupportsAcquireByHash() const;
  65. time_t GetValidUntil() const;
  66. time_t GetDate() const;
  67. std::string GetExpectedDist() const;
  68. bool CheckDist(std::string const &MaybeDist) const;
  69. // Interface for acquire
  70. virtual std::string Describe() const;
  71. virtual std::string ArchiveURI(std::string const& File) const = 0;
  72. virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) = 0;
  73. virtual std::vector<IndexTarget> GetIndexTargets() const = 0;
  74. virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0;
  75. virtual bool IsTrusted() const = 0;
  76. virtual bool Load(std::string const &Filename, std::string * const ErrorText) = 0;
  77. /** @return a new metaIndex object based on this one, but without information from #Load */
  78. virtual metaIndex * UnloadedClone() const = 0;
  79. // the given metaIndex is potentially invalid after this call and should be deleted
  80. void swapLoad(metaIndex * const OldMetaIndex);
  81. // Lookup functions for parsed Hashes
  82. checkSum *Lookup(std::string const &MetaKey) const;
  83. /** \brief tests if a checksum for this file is available */
  84. bool Exists(std::string const &MetaKey) const;
  85. std::vector<std::string> MetaKeys() const;
  86. TriState GetLoadedSuccessfully() const;
  87. // Interfaces for pkgCacheGen
  88. virtual pkgCache::RlsFileIterator FindInCache(pkgCache &Cache, bool const ModifyCheck) const;
  89. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
  90. metaIndex(std::string const &URI, std::string const &Dist,
  91. char const * const Type);
  92. virtual ~metaIndex();
  93. // FIXME: make virtual on next abi break
  94. bool IsArchitectureSupported(std::string const &arch) const;
  95. bool IsArchitectureAllSupportedFor(IndexTarget const &target) const;
  96. };
  97. #endif