debindexfile.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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_OVERRIDE 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. virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
  35. debStatusIndex(std::string const &File);
  36. virtual ~debStatusIndex();
  37. };
  38. class debPackagesIndex : public pkgDebianIndexTargetFile
  39. {
  40. void * const d;
  41. protected:
  42. virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
  43. public:
  44. virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
  45. // Stuff for accessing files on remote items
  46. virtual std::string ArchiveInfo(pkgCache::VerIterator const &Ver) const APT_OVERRIDE;
  47. // Interface for the Cache Generator
  48. virtual bool HasPackages() const APT_OVERRIDE {return true;};
  49. debPackagesIndex(IndexTarget const &Target, bool const Trusted);
  50. virtual ~debPackagesIndex();
  51. };
  52. class debTranslationsIndex : public pkgDebianIndexTargetFile
  53. {
  54. void * const d;
  55. protected:
  56. virtual std::string GetArchitecture() const APT_OVERRIDE;
  57. virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
  58. virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
  59. APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
  60. public:
  61. virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
  62. // Interface for the Cache Generator
  63. virtual bool HasPackages() const APT_OVERRIDE;
  64. debTranslationsIndex(IndexTarget const &Target);
  65. virtual ~debTranslationsIndex();
  66. };
  67. class debSourcesIndex : public pkgDebianIndexTargetFile
  68. {
  69. void * const d;
  70. virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
  71. virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
  72. APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
  73. public:
  74. virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
  75. // Stuff for accessing files on remote items
  76. virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
  77. pkgSrcRecords::File const &File) const APT_OVERRIDE;
  78. // Interface for the record parsers
  79. virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE;
  80. // Interface for the Cache Generator
  81. virtual bool HasPackages() const APT_OVERRIDE {return false;};
  82. debSourcesIndex(IndexTarget const &Target, bool const Trusted);
  83. virtual ~debSourcesIndex();
  84. };
  85. class debDebPkgFileIndex : public pkgDebianIndexRealFile
  86. {
  87. void * const d;
  88. std::string DebFile;
  89. protected:
  90. virtual std::string GetComponent() const APT_OVERRIDE;
  91. virtual std::string GetArchitecture() const APT_OVERRIDE;
  92. virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
  93. virtual bool OpenListFile(FileFd &Pkg, std::string const &FileName) APT_OVERRIDE;
  94. APT_HIDDEN virtual pkgCacheListParser * CreateListParser(FileFd &Pkg) APT_OVERRIDE;
  95. public:
  96. virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
  97. /** get the control (file) content of the deb file
  98. *
  99. * @param[out] content of the control file
  100. * @param debfile is the filename of the .deb-file
  101. * @return \b true if successful, otherwise \b false.
  102. */
  103. static bool GetContent(std::ostream &content, std::string const &debfile);
  104. // Interface for the Cache Generator
  105. virtual bool HasPackages() const APT_OVERRIDE {return true;}
  106. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE;
  107. // Interface for acquire
  108. debDebPkgFileIndex(std::string const &DebFile);
  109. virtual ~debDebPkgFileIndex();
  110. //FIXME: use proper virtual-handling on next ABI break
  111. APT_HIDDEN std::string ArchiveInfo_impl(pkgCache::VerIterator const &Ver) const;
  112. };
  113. class debDscFileIndex : public pkgDebianIndexRealFile
  114. {
  115. void * const d;
  116. protected:
  117. virtual std::string GetComponent() const APT_OVERRIDE;
  118. virtual std::string GetArchitecture() const APT_OVERRIDE;
  119. virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
  120. public:
  121. virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
  122. virtual pkgSrcRecords::Parser *CreateSrcParser() const APT_OVERRIDE;
  123. virtual bool HasPackages() const APT_OVERRIDE {return false;};
  124. debDscFileIndex(std::string const &DscFile);
  125. virtual ~debDscFileIndex();
  126. };
  127. class debDebianSourceDirIndex : public debDscFileIndex
  128. {
  129. protected:
  130. virtual std::string GetComponent() const APT_OVERRIDE;
  131. public:
  132. virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
  133. };
  134. class debStringPackageIndex : public pkgDebianIndexRealFile
  135. {
  136. void * const d;
  137. protected:
  138. virtual std::string GetArchitecture() const APT_OVERRIDE;
  139. virtual std::string GetComponent() const APT_OVERRIDE;
  140. virtual uint8_t GetIndexFlags() const APT_OVERRIDE;
  141. public:
  142. virtual const Type *GetType() const APT_OVERRIDE APT_CONST;
  143. // Interface for the Cache Generator
  144. virtual bool HasPackages() const APT_OVERRIDE {return true;};
  145. // Abort if the file does not exist.
  146. virtual bool Exists() const APT_OVERRIDE {return true;};
  147. debStringPackageIndex(std::string const &content);
  148. virtual ~debStringPackageIndex();
  149. };
  150. #endif