debindexfile.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: debindexfile.h,v 1.3.2.1 2003/12/24 23:09:17 mdz Exp $
  4. /* ######################################################################
  5. Debian Index Files
  6. There are three sorts currently
  7. Package files that have File: tags
  8. Package files that don't (/var/lib/dpkg/status)
  9. Source files
  10. ##################################################################### */
  11. /*}}}*/
  12. #ifndef PKGLIB_DEBINDEXFILE_H
  13. #define PKGLIB_DEBINDEXFILE_H
  14. #include <apt-pkg/indexfile.h>
  15. #include <apt-pkg/cacheiterators.h>
  16. #include <apt-pkg/pkgcache.h>
  17. #include <apt-pkg/srcrecords.h>
  18. #include <string>
  19. class OpProgress;
  20. class pkgAcquire;
  21. class pkgCacheGenerator;
  22. class APT_HIDDEN debStatusIndex : public pkgIndexFile
  23. {
  24. /** \brief dpointer placeholder (for later in case we need it) */
  25. void *d;
  26. protected:
  27. std::string File;
  28. public:
  29. virtual const Type *GetType() const APT_CONST;
  30. // Interface for acquire
  31. virtual std::string Describe(bool /*Short*/) const {return File;};
  32. // Interface for the Cache Generator
  33. virtual bool Exists() const;
  34. virtual bool HasPackages() const {return true;};
  35. virtual unsigned long Size() const;
  36. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
  37. bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog, unsigned long const Flag) const;
  38. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
  39. debStatusIndex(std::string File);
  40. virtual ~debStatusIndex();
  41. };
  42. class APT_HIDDEN debPackagesIndex : public pkgIndexFile
  43. {
  44. /** \brief dpointer placeholder (for later in case we need it) */
  45. void *d;
  46. std::string URI;
  47. std::string Dist;
  48. std::string Section;
  49. std::string Architecture;
  50. APT_HIDDEN std::string Info(const char *Type) const;
  51. APT_HIDDEN std::string IndexFile(const char *Type) const;
  52. APT_HIDDEN std::string IndexURI(const char *Type) const;
  53. public:
  54. virtual const Type *GetType() const APT_CONST;
  55. // Stuff for accessing files on remote items
  56. virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
  57. virtual std::string ArchiveURI(std::string File) const {return URI + File;};
  58. // Interface for acquire
  59. virtual std::string Describe(bool Short) const;
  60. // Interface for the Cache Generator
  61. virtual bool Exists() const;
  62. virtual bool HasPackages() const {return true;};
  63. virtual unsigned long Size() const;
  64. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
  65. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
  66. debPackagesIndex(std::string const &URI, std::string const &Dist, std::string const &Section,
  67. bool const &Trusted, std::string const &Arch = "native");
  68. virtual ~debPackagesIndex();
  69. };
  70. class APT_HIDDEN debTranslationsIndex : public pkgIndexFile
  71. {
  72. /** \brief dpointer placeholder (for later in case we need it) */
  73. void *d;
  74. std::string const URI;
  75. std::string const Dist;
  76. std::string const Section;
  77. std::string const Language;
  78. APT_HIDDEN std::string Info(const char *Type) const;
  79. APT_HIDDEN std::string IndexFile(const char *Type) const;
  80. APT_HIDDEN std::string IndexURI(const char *Type) const;
  81. APT_HIDDEN std::string TranslationFile() const {return std::string("Translation-").append(Language);};
  82. public:
  83. virtual const Type *GetType() const APT_CONST;
  84. // Interface for acquire
  85. virtual std::string Describe(bool Short) const;
  86. // Interface for the Cache Generator
  87. virtual bool Exists() const;
  88. virtual bool HasPackages() const;
  89. virtual unsigned long Size() const;
  90. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
  91. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
  92. debTranslationsIndex(std::string const &URI,std::string const &Dist,std::string const &Section, std::string const &Language);
  93. virtual ~debTranslationsIndex();
  94. };
  95. class APT_HIDDEN debSourcesIndex : public pkgIndexFile
  96. {
  97. /** \brief dpointer placeholder (for later in case we need it) */
  98. void *d;
  99. std::string URI;
  100. std::string Dist;
  101. std::string Section;
  102. APT_HIDDEN std::string Info(const char *Type) const;
  103. APT_HIDDEN std::string IndexFile(const char *Type) const;
  104. APT_HIDDEN std::string IndexURI(const char *Type) const;
  105. public:
  106. virtual const Type *GetType() const APT_CONST;
  107. // Stuff for accessing files on remote items
  108. virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
  109. pkgSrcRecords::File const &File) const;
  110. virtual std::string ArchiveURI(std::string File) const {return URI + File;};
  111. // Interface for acquire
  112. virtual std::string Describe(bool Short) const;
  113. // Interface for the record parsers
  114. virtual pkgSrcRecords::Parser *CreateSrcParser() const;
  115. // Interface for the Cache Generator
  116. virtual bool Exists() const;
  117. virtual bool HasPackages() const {return false;};
  118. virtual unsigned long Size() const;
  119. debSourcesIndex(std::string URI,std::string Dist,std::string Section,bool Trusted);
  120. virtual ~debSourcesIndex();
  121. };
  122. class APT_HIDDEN debDebPkgFileIndex : public pkgIndexFile
  123. {
  124. private:
  125. void *d;
  126. std::string DebFile;
  127. std::string DebFileFullPath;
  128. public:
  129. virtual const Type *GetType() const APT_CONST;
  130. virtual std::string Describe(bool /*Short*/) const {
  131. return DebFile;
  132. }
  133. /** get the control (file) content of the deb file
  134. *
  135. * @param[out] content of the control file
  136. * @param debfile is the filename of the .deb-file
  137. * @return \b true if successful, otherwise \b false.
  138. */
  139. static bool GetContent(std::ostream &content, std::string const &debfile);
  140. // Interface for the Cache Generator
  141. virtual bool Exists() const;
  142. virtual bool HasPackages() const {
  143. return true;
  144. };
  145. virtual unsigned long Size() const;
  146. virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
  147. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
  148. // Interface for acquire
  149. virtual std::string ArchiveURI(std::string /*File*/) const;
  150. debDebPkgFileIndex(std::string DebFile);
  151. virtual ~debDebPkgFileIndex();
  152. };
  153. class APT_HIDDEN debDscFileIndex : public pkgIndexFile
  154. {
  155. private:
  156. std::string DscFile;
  157. public:
  158. virtual const Type *GetType() const APT_CONST;
  159. virtual pkgSrcRecords::Parser *CreateSrcParser() const;
  160. virtual bool Exists() const;
  161. virtual bool HasPackages() const {return false;};
  162. virtual unsigned long Size() const;
  163. virtual std::string Describe(bool /*Short*/) const {
  164. return DscFile;
  165. };
  166. debDscFileIndex(std::string &DscFile);
  167. virtual ~debDscFileIndex() {};
  168. };
  169. class APT_HIDDEN debDebianSourceDirIndex : public debDscFileIndex
  170. {
  171. public:
  172. virtual const Type *GetType() const APT_CONST;
  173. };
  174. #endif