debindexfile.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. Debian Index Files
  5. There are three sorts currently
  6. Package files that have File: tags
  7. Package files that don't (/var/lib/dpkg/status)
  8. Source files
  9. ##################################################################### */
  10. /*}}}*/
  11. #ifndef PKGLIB_DEBINDEXFILE_H
  12. #define PKGLIB_DEBINDEXFILE_H
  13. #include <apt-pkg/indexfile.h>
  14. #include <apt-pkg/cacheiterators.h>
  15. #include <apt-pkg/pkgcache.h>
  16. #include <apt-pkg/srcrecords.h>
  17. #include <string>
  18. class OpProgress;
  19. class pkgAcquire;
  20. class pkgCacheGenerator;
  21. class debStatusIndex : public pkgDebianIndexRealFile
  22. {
  23. void * const d;
  24. protected:
  25. virtual std::string GetArchitecture() const APT_OVERRIDE;
  26. virtual std::string GetComponent() const APT_OVERRIDE;
  27. virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
  28. public:
  29. virtual const Type *GetType() const APT_CONST;
  30. // Interface for the Cache Generator
  31. virtual bool HasPackages() const APT_OVERRIDE {return true;};
  32. // Abort if the file does not exist.
  33. virtual bool Exists() const APT_OVERRIDE {return true;};
  34. debStatusIndex(std::string const &File);
  35. virtual ~debStatusIndex();
  36. };
  37. class debPackagesIndex : public pkgDebianIndexTargetFile
  38. {
  39. void * const d;
  40. protected:
  41. virtual uint8_t GetIndexFlags() const;
  42. public:
  43. virtual const Type *GetType() const APT_CONST;
  44. // Stuff for accessing files on remote items
  45. virtual std::string ArchiveInfo(pkgCache::VerIterator const &Ver) const APT_OVERRIDE;
  46. // Interface for the Cache Generator
  47. virtual bool HasPackages() const APT_OVERRIDE {return true;};
  48. debPackagesIndex(IndexTarget const &Target, bool const Trusted);
  49. virtual ~debPackagesIndex();
  50. };
  51. class debTranslationsIndex : public pkgDebianIndexTargetFile
  52. {
  53. void * const d;
  54. protected:
  55. virtual std::string GetArchitecture() const APT_OVERRIDE;
  56. virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
  57. virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
  58. APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
  59. public:
  60. virtual const Type *GetType() const APT_CONST;
  61. // Interface for the Cache Generator
  62. virtual bool HasPackages() const APT_OVERRIDE;
  63. debTranslationsIndex(IndexTarget const &Target);
  64. virtual ~debTranslationsIndex();
  65. };
  66. class debSourcesIndex : public pkgDebianIndexTargetFile
  67. {
  68. void * const d;
  69. virtual uint8_t GetIndexFlags() const;
  70. virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
  71. APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
  72. public:
  73. virtual const Type *GetType() const APT_CONST;
  74. // Stuff for accessing files on remote items
  75. virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
  76. pkgSrcRecords::File const &File) const APT_OVERRIDE;
  77. // Interface for the record parsers
  78. virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE;
  79. // Interface for the Cache Generator
  80. virtual bool HasPackages() const APT_OVERRIDE {return false;};
  81. debSourcesIndex(IndexTarget const &Target, bool const Trusted);
  82. virtual ~debSourcesIndex();
  83. };
  84. class debDebPkgFileIndex : public pkgDebianIndexRealFile
  85. {
  86. void * const d;
  87. std::string DebFile;
  88. protected:
  89. virtual std::string GetComponent() const APT_OVERRIDE;
  90. virtual std::string GetArchitecture() const APT_OVERRIDE;
  91. virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
  92. virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
  93. APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
  94. public:
  95. virtual const Type *GetType() const APT_CONST;
  96. /** get the control (file) content of the deb file
  97. *
  98. * @param[out] content of the control file
  99. * @param debfile is the filename of the .deb-file
  100. * @return \b true if successful, otherwise \b false.
  101. */
  102. static bool GetContent(std::ostream &content, std::string const &debfile);
  103. // Interface for the Cache Generator
  104. virtual bool HasPackages() const APT_OVERRIDE {return true;}
  105. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
  106. // Interface for acquire
  107. debDebPkgFileIndex(std::string const &DebFile);
  108. virtual ~debDebPkgFileIndex();
  109. };
  110. class debDscFileIndex : public pkgDebianIndexRealFile
  111. {
  112. void * const d;
  113. public:
  114. virtual const Type *GetType() const APT_CONST;
  115. virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE;
  116. virtual bool HasPackages() const APT_OVERRIDE {return false;};
  117. debDscFileIndex(std::string const &DscFile);
  118. virtual ~debDscFileIndex();
  119. };
  120. class debDebianSourceDirIndex : public debDscFileIndex
  121. {
  122. public:
  123. virtual const Type *GetType() const APT_CONST;
  124. };
  125. #endif