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.
 
 
 
 
 
 

131 lines
3.9 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. using std::string;
  17. #endif
  18. class pkgAcquire;
  19. class IndexTarget;
  20. class pkgCacheGenerator;
  21. class OpProgress;
  22. class metaIndexPrivate;
  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_MSG("Use the HashStringList member Hashes instead of a hardcoded HashString") 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. metaIndexPrivate * 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. std::string SignedBy;
  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. TriState LoadedSuccessfully;
  56. public:
  57. // Various accessors
  58. std::string GetURI() const;
  59. std::string GetDist() const;
  60. const char* GetType() const;
  61. TriState GetTrusted() const;
  62. std::string GetSignedBy() const;
  63. std::string GetOrigin() const;
  64. std::string GetLabel() const;
  65. std::string GetVersion() const;
  66. std::string GetCodename() const;
  67. std::string GetSuite() const;
  68. std::string GetReleaseNotes() const;
  69. signed short GetDefaultPin() const;
  70. bool GetSupportsAcquireByHash() const;
  71. time_t GetValidUntil() const;
  72. time_t GetDate() const;
  73. std::string GetExpectedDist() const;
  74. bool CheckDist(std::string const &MaybeDist) const;
  75. // Interface for acquire
  76. virtual std::string Describe() const;
  77. virtual std::string ArchiveURI(std::string const& File) const = 0;
  78. virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) = 0;
  79. virtual std::vector<IndexTarget> GetIndexTargets() const = 0;
  80. virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0;
  81. virtual bool IsTrusted() const = 0;
  82. virtual bool Load(std::string const &Filename, std::string * const ErrorText) = 0;
  83. /** @return a new metaIndex object based on this one, but without information from #Load */
  84. virtual metaIndex * UnloadedClone() const = 0;
  85. // the given metaIndex is potentially invalid after this call and should be deleted
  86. void swapLoad(metaIndex * const OldMetaIndex);
  87. // Lookup functions for parsed Hashes
  88. checkSum *Lookup(std::string const &MetaKey) const;
  89. /** \brief tests if a checksum for this file is available */
  90. bool Exists(std::string const &MetaKey) const;
  91. std::vector<std::string> MetaKeys() const;
  92. TriState GetLoadedSuccessfully() const;
  93. // Interfaces for pkgCacheGen
  94. virtual pkgCache::RlsFileIterator FindInCache(pkgCache &Cache, bool const ModifyCheck) const;
  95. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
  96. metaIndex(std::string const &URI, std::string const &Dist,
  97. char const * const Type);
  98. virtual ~metaIndex();
  99. // FIXME: make virtual on next abi break
  100. bool IsArchitectureSupported(std::string const &arch) const;
  101. bool IsArchitectureAllSupportedFor(IndexTarget const &target) const;
  102. bool HasSupportForComponent(std::string const &component) const;
  103. // FIXME: should be members of the class on abi break
  104. APT_HIDDEN void SetOrigin(std::string const &origin);
  105. APT_HIDDEN void SetLabel(std::string const &label);
  106. APT_HIDDEN void SetVersion(std::string const &version);
  107. APT_HIDDEN void SetDefaultPin(signed short const defaultpin);
  108. APT_HIDDEN void SetReleaseNotes(std::string const &notes);
  109. };
  110. #endif