edspindexfile.cc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. The scenario file is designed to work as an intermediate file between
  5. APT and the resolver. Its on propose very similar to a dpkg status file
  6. ##################################################################### */
  7. /*}}}*/
  8. // Include Files /*{{{*/
  9. #include <config.h>
  10. #include <apt-pkg/edspindexfile.h>
  11. #include <apt-pkg/edsplistparser.h>
  12. #include <apt-pkg/sourcelist.h>
  13. #include <apt-pkg/configuration.h>
  14. #include <apt-pkg/progress.h>
  15. #include <apt-pkg/error.h>
  16. #include <apt-pkg/strutl.h>
  17. #include <apt-pkg/fileutl.h>
  18. #include <apt-pkg/acquire-item.h>
  19. #include <sys/stat.h>
  20. /*}}}*/
  21. // edspIndex::edspIndex - Constructor /*{{{*/
  22. // ---------------------------------------------------------------------
  23. /* */
  24. edspIndex::edspIndex(std::string File) : debStatusIndex(File)
  25. {
  26. }
  27. /*}}}*/
  28. // StatusIndex::Merge - Load the index file into a cache /*{{{*/
  29. bool edspIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
  30. {
  31. FileFd Pkg;
  32. if (File != "stdin")
  33. Pkg.Open(File, FileFd::ReadOnly);
  34. else
  35. Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly);
  36. if (_error->PendingError() == true)
  37. return false;
  38. edspListParser Parser(&Pkg);
  39. if (_error->PendingError() == true)
  40. return false;
  41. if (Prog != NULL)
  42. Prog->SubProgress(0,File);
  43. if (Gen.SelectFile(File,std::string(),*this) == false)
  44. return _error->Error("Problem with SelectFile %s",File.c_str());
  45. // Store the IMS information
  46. pkgCache::PkgFileIterator CFile = Gen.GetCurFile();
  47. CFile->Size = Pkg.FileSize();
  48. CFile->mtime = Pkg.ModificationTime();
  49. CFile->Archive = Gen.WriteUniqString("edsp::scenario");
  50. if (Gen.MergeList(Parser) == false)
  51. return _error->Error("Problem with MergeList %s",File.c_str());
  52. return true;
  53. }
  54. /*}}}*/
  55. // Index File types for APT /*{{{*/
  56. class edspIFType: public pkgIndexFile::Type
  57. {
  58. public:
  59. virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator File) const
  60. {
  61. // we don't have a record parser for this type as the file is not presistent
  62. return NULL;
  63. };
  64. edspIFType() {Label = "EDSP scenario file";};
  65. };
  66. static edspIFType _apt_Universe;
  67. const pkgIndexFile::Type *edspIndex::GetType() const
  68. {
  69. return &_apt_Universe;
  70. }
  71. /*}}}*/