You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

124 lines
3.3 KiB

  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/fileutl.h>
  16. #include <apt-pkg/pkgcache.h>
  17. #include <apt-pkg/cacheiterators.h>
  18. #include <stddef.h>
  19. #include <string>
  20. #include <vector>
  21. #include <apti18n.h>
  22. /*}}}*/
  23. // System::edspSystem - Constructor /*{{{*/
  24. edspSystem::edspSystem() : pkgSystem("Debian APT solver interface", &debVS), d(NULL), StatusFile(NULL)
  25. {
  26. }
  27. /*}}}*/
  28. // System::~debSystem - Destructor /*{{{*/
  29. edspSystem::~edspSystem()
  30. {
  31. delete StatusFile;
  32. }
  33. /*}}}*/
  34. // System::Lock - Get the lock /*{{{*/
  35. bool edspSystem::Lock()
  36. {
  37. return true;
  38. }
  39. /*}}}*/
  40. // System::UnLock - Drop a lock /*{{{*/
  41. bool edspSystem::UnLock(bool /*NoErrors*/)
  42. {
  43. return true;
  44. }
  45. /*}}}*/
  46. // System::CreatePM - Create the underlying package manager /*{{{*/
  47. // ---------------------------------------------------------------------
  48. /* we can't use edsp input as input for real installations - just a
  49. simulation can work, but everything else will fail bigtime */
  50. pkgPackageManager *edspSystem::CreatePM(pkgDepCache * /*Cache*/) const
  51. {
  52. return NULL;
  53. }
  54. /*}}}*/
  55. // System::Initialize - Setup the configuration space.. /*{{{*/
  56. bool edspSystem::Initialize(Configuration &Cnf)
  57. {
  58. Cnf.Set("Dir::State::extended_states", "/dev/null");
  59. Cnf.Set("Dir::State::status","/dev/null");
  60. Cnf.Set("Dir::State::lists","/dev/null");
  61. Cnf.Set("Debug::NoLocking", "true");
  62. Cnf.Set("APT::Get::Simulate", "true");
  63. if (StatusFile) {
  64. delete StatusFile;
  65. StatusFile = 0;
  66. }
  67. return true;
  68. }
  69. /*}}}*/
  70. // System::ArchiveSupported - Is a file format supported /*{{{*/
  71. bool edspSystem::ArchiveSupported(const char * /*Type*/)
  72. {
  73. return false;
  74. }
  75. /*}}}*/
  76. // System::Score - Determine if we should use the edsp system /*{{{*/
  77. signed edspSystem::Score(Configuration const &Cnf)
  78. {
  79. if (Cnf.Find("edsp::scenario", "") == "stdin")
  80. return 1000;
  81. if (RealFileExists(Cnf.FindFile("edsp::scenario","")) == true)
  82. return 1000;
  83. return -1000;
  84. }
  85. /*}}}*/
  86. bool edspSystem::AddStatusFiles(std::vector<pkgIndexFile *> &List) /*{{{*/
  87. {
  88. if (StatusFile == 0)
  89. {
  90. if (_config->Find("edsp::scenario", "") == "stdin")
  91. StatusFile = new edspIndex("stdin");
  92. else
  93. StatusFile = new edspIndex(_config->FindFile("edsp::scenario"));
  94. }
  95. List.push_back(StatusFile);
  96. return true;
  97. }
  98. /*}}}*/
  99. // System::FindIndex - Get an index file for status files /*{{{*/
  100. bool edspSystem::FindIndex(pkgCache::PkgFileIterator File,
  101. pkgIndexFile *&Found) const
  102. {
  103. if (StatusFile == 0)
  104. return false;
  105. if (StatusFile->FindInCache(*File.Cache()) == File)
  106. {
  107. Found = StatusFile;
  108. return true;
  109. }
  110. return false;
  111. }
  112. /*}}}*/
  113. APT_HIDDEN edspSystem edspSys;