edspsystem.cc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. This system provides the abstraction to use the scenario file as the
  5. only source of package information to be able to feed the created file
  6. back to APT for its own consumption (eat your own dogfood).
  7. ##################################################################### */
  8. /*}}}*/
  9. // Include Files /*{{{*/
  10. #include <config.h>
  11. #include <apt-pkg/configuration.h>
  12. #include <apt-pkg/debversion.h>
  13. #include <apt-pkg/edspindexfile.h>
  14. #include <apt-pkg/edspsystem.h>
  15. #include <apt-pkg/pkgcache.h>
  16. #include <apt-pkg/cacheiterators.h>
  17. #include <stddef.h>
  18. #include <string>
  19. #include <vector>
  20. /*}}}*/
  21. // System::edspSystem - Constructor /*{{{*/
  22. edspSystem::edspSystem() : pkgSystem("Debian APT solver interface", &debVS), d(NULL), StatusFile(NULL)
  23. {
  24. }
  25. /*}}}*/
  26. // System::~debSystem - Destructor /*{{{*/
  27. edspSystem::~edspSystem()
  28. {
  29. delete StatusFile;
  30. }
  31. /*}}}*/
  32. // System::Lock - Get the lock /*{{{*/
  33. bool edspSystem::Lock()
  34. {
  35. return true;
  36. }
  37. /*}}}*/
  38. // System::UnLock - Drop a lock /*{{{*/
  39. bool edspSystem::UnLock(bool /*NoErrors*/)
  40. {
  41. return true;
  42. }
  43. /*}}}*/
  44. // System::CreatePM - Create the underlying package manager /*{{{*/
  45. // ---------------------------------------------------------------------
  46. /* we can't use edsp input as input for real installations - just a
  47. simulation can work, but everything else will fail bigtime */
  48. pkgPackageManager *edspSystem::CreatePM(pkgDepCache * /*Cache*/) const
  49. {
  50. return NULL;
  51. }
  52. /*}}}*/
  53. // System::Initialize - Setup the configuration space.. /*{{{*/
  54. bool edspSystem::Initialize(Configuration &Cnf)
  55. {
  56. Cnf.Set("Dir::State::extended_states", "/dev/null");
  57. Cnf.Set("Dir::State::status","/dev/null");
  58. Cnf.Set("Dir::State::lists","/dev/null");
  59. Cnf.Set("Debug::NoLocking", "true");
  60. Cnf.Set("APT::Get::Simulate", "true");
  61. if (StatusFile) {
  62. delete StatusFile;
  63. StatusFile = 0;
  64. }
  65. return true;
  66. }
  67. /*}}}*/
  68. // System::ArchiveSupported - Is a file format supported /*{{{*/
  69. bool edspSystem::ArchiveSupported(const char * /*Type*/)
  70. {
  71. return false;
  72. }
  73. /*}}}*/
  74. // System::Score - Never use the EDSP system automatically /*{{{*/
  75. signed edspSystem::Score(Configuration const &)
  76. {
  77. return -1000;
  78. }
  79. /*}}}*/
  80. bool edspSystem::AddStatusFiles(std::vector<pkgIndexFile *> &List) /*{{{*/
  81. {
  82. if (StatusFile == 0)
  83. {
  84. if (_config->Find("edsp::scenario", "") == "stdin")
  85. StatusFile = new edspIndex("stdin");
  86. else
  87. StatusFile = new edspIndex(_config->FindFile("edsp::scenario"));
  88. }
  89. List.push_back(StatusFile);
  90. return true;
  91. }
  92. /*}}}*/
  93. // System::FindIndex - Get an index file for status files /*{{{*/
  94. bool edspSystem::FindIndex(pkgCache::PkgFileIterator File,
  95. pkgIndexFile *&Found) const
  96. {
  97. if (StatusFile == 0)
  98. return false;
  99. if (StatusFile->FindInCache(*File.Cache()) == File)
  100. {
  101. Found = StatusFile;
  102. return true;
  103. }
  104. return false;
  105. }
  106. /*}}}*/
  107. APT_HIDDEN edspSystem edspSys;