indexcopy.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. Index Copying - Aid for copying and verifying the index files
  5. ##################################################################### */
  6. /*}}}*/
  7. #ifndef INDEXCOPY_H
  8. #define INDEXCOPY_H
  9. #include <vector>
  10. #include <string>
  11. #include <stdio.h>
  12. #include <apt-pkg/macros.h>
  13. #ifndef APT_10_CLEANER_HEADERS
  14. #include <apt-pkg/gpgv.h>
  15. class FileFd;
  16. #endif
  17. #ifndef APT_8_CLEANER_HEADERS
  18. using std::string;
  19. using std::vector;
  20. #endif
  21. class pkgTagSection;
  22. class pkgCdromStatus;
  23. class FileFd;
  24. class metaIndex;
  25. class IndexCopy /*{{{*/
  26. {
  27. /** \brief dpointer placeholder (for later in case we need it) */
  28. void * const d;
  29. protected:
  30. pkgTagSection *Section;
  31. std::string ChopDirs(std::string Path,unsigned int Depth);
  32. bool ReconstructPrefix(std::string &Prefix,std::string OrigPath,std::string CD,
  33. std::string File);
  34. bool ReconstructChop(unsigned long &Chop,std::string Dir,std::string File);
  35. void ConvertToSourceList(std::string CD,std::string &Path);
  36. bool GrabFirst(std::string Path,std::string &To,unsigned int Depth);
  37. virtual bool GetFile(std::string &Filename,unsigned long long &Size) = 0;
  38. virtual bool RewriteEntry(FileFd &Target, std::string const &File) = 0;
  39. virtual const char *GetFileName() = 0;
  40. virtual const char *Type() = 0;
  41. public:
  42. bool CopyPackages(std::string CDROM,std::string Name,std::vector<std::string> &List,
  43. pkgCdromStatus *log);
  44. IndexCopy();
  45. virtual ~IndexCopy();
  46. };
  47. /*}}}*/
  48. class PackageCopy : public IndexCopy /*{{{*/
  49. {
  50. void * const d;
  51. protected:
  52. virtual bool GetFile(std::string &Filename,unsigned long long &Size) APT_OVERRIDE;
  53. virtual bool RewriteEntry(FileFd &Target, std::string const &File) APT_OVERRIDE;
  54. virtual const char *GetFileName() APT_OVERRIDE {return "Packages";};
  55. virtual const char *Type() APT_OVERRIDE {return "Package";};
  56. public:
  57. PackageCopy();
  58. virtual ~PackageCopy();
  59. };
  60. /*}}}*/
  61. class SourceCopy : public IndexCopy /*{{{*/
  62. {
  63. void * const d;
  64. protected:
  65. virtual bool GetFile(std::string &Filename,unsigned long long &Size) APT_OVERRIDE;
  66. virtual bool RewriteEntry(FileFd &Target, std::string const &File) APT_OVERRIDE;
  67. virtual const char *GetFileName() APT_OVERRIDE {return "Sources";};
  68. virtual const char *Type() APT_OVERRIDE {return "Source";};
  69. public:
  70. SourceCopy();
  71. virtual ~SourceCopy();
  72. };
  73. /*}}}*/
  74. class TranslationsCopy /*{{{*/
  75. {
  76. void * const d;
  77. protected:
  78. pkgTagSection *Section;
  79. public:
  80. bool CopyTranslations(std::string CDROM,std::string Name,std::vector<std::string> &List,
  81. pkgCdromStatus *log);
  82. TranslationsCopy();
  83. virtual ~TranslationsCopy();
  84. };
  85. /*}}}*/
  86. class SigVerify /*{{{*/
  87. {
  88. /** \brief dpointer placeholder (for later in case we need it) */
  89. void * const d;
  90. APT_HIDDEN bool Verify(std::string prefix,std::string file, metaIndex *records);
  91. APT_HIDDEN bool CopyMetaIndex(std::string CDROM, std::string CDName,
  92. std::string prefix, std::string file);
  93. public:
  94. bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList,
  95. std::vector<std::string> PkgList,std::vector<std::string> SrcList);
  96. APT_DEPRECATED static bool RunGPGV(std::string const &File, std::string const &FileOut,
  97. int const &statusfd, int fd[2]);
  98. APT_DEPRECATED static bool RunGPGV(std::string const &File, std::string const &FileOut,
  99. int const &statusfd = -1);
  100. SigVerify();
  101. virtual ~SigVerify();
  102. };
  103. /*}}}*/
  104. #endif