indexcopy.h 3.7 KB

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