X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/453b82a388013e522b3a1b9fcd6ed0810dab1f4f..607bab3fe856d228f22e1cd96dbb7204e2f3375d:/apt-pkg/edsp/edspsystem.cc?ds=sidebyside diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc index 92edb8d77..0d967863e 100644 --- a/apt-pkg/edsp/edspsystem.cc +++ b/apt-pkg/edsp/edspsystem.cc @@ -15,32 +15,66 @@ #include #include #include -#include #include #include +#include #include +#include +#include + #include #include -#include /*}}}*/ -edspSystem edspSys; +class edspSystemPrivate { + std::string tempDir; + std::string tempStatesFile; + std::string tempPrefsFile; -// System::debSystem - Constructor /*{{{*/ -edspSystem::edspSystem() -{ - StatusFile = 0; +public: + edspSystemPrivate() {} + + void Initialize(Configuration &Cnf) + { + DeInitialize(); + Cnf.Set("Dir::State::extended_states", "/dev/null"); + Cnf.Set("Dir::Etc::preferences", "/dev/null"); + std::string const tmp = GetTempDir(); + char tmpname[100]; + snprintf(tmpname, sizeof(tmpname), "%s/apt-edsp-solver-XXXXXX", tmp.c_str()); + if (NULL == mkdtemp(tmpname)) + return; + tempDir = tmpname; + tempStatesFile = flCombine(tempDir, "extended_states"); + Cnf.Set("Dir::State::extended_states", tempStatesFile); + tempPrefsFile = flCombine(tempDir, "apt_preferences"); + Cnf.Set("Dir::Etc::preferences", tempPrefsFile); + } - Label = "Debian APT solver interface"; - VS = &debVS; + void DeInitialize() + { + if (tempDir.empty()) + return; + + RemoveFile("DeInitialize", tempStatesFile); + RemoveFile("DeInitialize", tempPrefsFile); + rmdir(tempDir.c_str()); + } + + ~edspSystemPrivate() { DeInitialize(); } +}; +// System::edspSystem - Constructor /*{{{*/ +edspSystem::edspSystem() : pkgSystem("Debian APT solver interface", &debVS), d(new edspSystemPrivate()), StatusFile(NULL) +{ } /*}}}*/ // System::~debSystem - Destructor /*{{{*/ edspSystem::~edspSystem() { delete StatusFile; + delete d; } /*}}}*/ // System::Lock - Get the lock /*{{{*/ @@ -67,7 +101,8 @@ pkgPackageManager *edspSystem::CreatePM(pkgDepCache * /*Cache*/) const // System::Initialize - Setup the configuration space.. /*{{{*/ bool edspSystem::Initialize(Configuration &Cnf) { - Cnf.Set("Dir::State::extended_states", "/dev/null"); + d->Initialize(Cnf); + Cnf.Set("Dir::Etc::preferencesparts", "/dev/null"); Cnf.Set("Dir::State::status","/dev/null"); Cnf.Set("Dir::State::lists","/dev/null"); @@ -87,23 +122,18 @@ bool edspSystem::ArchiveSupported(const char * /*Type*/) return false; } /*}}}*/ -// System::Score - Determine if we should use the edsp system /*{{{*/ -signed edspSystem::Score(Configuration const &Cnf) +// System::Score - Never use the EDSP system automatically /*{{{*/ +signed edspSystem::Score(Configuration const &) { - if (Cnf.Find("edsp::scenario", "") == "stdin") - return 1000; - if (RealFileExists(Cnf.FindFile("edsp::scenario","")) == true) - return 1000; return -1000; } /*}}}*/ -// System::AddStatusFiles - Register the status files /*{{{*/ -bool edspSystem::AddStatusFiles(std::vector &List) +bool edspSystem::AddStatusFiles(std::vector &List) /*{{{*/ { if (StatusFile == 0) { - if (_config->Find("edsp::scenario", "") == "stdin") - StatusFile = new edspIndex("stdin"); + if (_config->Find("edsp::scenario", "") == "/nonexistent/stdin") + StatusFile = new edspIndex("/nonexistent/stdin"); else StatusFile = new edspIndex(_config->FindFile("edsp::scenario")); } @@ -126,3 +156,5 @@ bool edspSystem::FindIndex(pkgCache::PkgFileIterator File, return false; } /*}}}*/ + +APT_HIDDEN edspSystem edspSys;