summaryrefslogtreecommitdiff
path: root/apt-pkg/edsp/edspsystem.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-09-08 22:14:11 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-09-14 15:22:18 +0200
commit188a6fcf4f13df1fd362a0aff27a23493ddd1ec5 (patch)
treed7d29209986acf989484cd0050601b55d5e40dba /apt-pkg/edsp/edspsystem.cc
parent8fec289ad8a2c42350c24d5c97b0f104fbbea176 (diff)
implement autobit and pinning in EDSP solver 'apt'
The parser creates a preferences as well as an extended states file based on the EDSP scenario file, which isn't the most efficient way of dealing with this as thes text files have to be parsed again by another layer of the code, but it needs the least changes and works good enough for now. The 'apt' solver is in the end just a test solver like dump.
Diffstat (limited to 'apt-pkg/edsp/edspsystem.cc')
-rw-r--r--apt-pkg/edsp/edspsystem.cc46
1 files changed, 44 insertions, 2 deletions
diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc
index f577efcbd..c52d537f3 100644
--- a/apt-pkg/edsp/edspsystem.cc
+++ b/apt-pkg/edsp/edspsystem.cc
@@ -17,15 +17,55 @@
#include <apt-pkg/edspsystem.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/fileutl.h>
#include <stddef.h>
+#include <unistd.h>
+
#include <string>
#include <vector>
/*}}}*/
+class edspSystemPrivate {
+ std::string tempDir;
+ std::string tempStatesFile;
+ std::string tempPrefsFile;
+
+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);
+ }
+
+ void DeInitialize()
+ {
+ if (tempDir.empty())
+ return;
+
+ unlink(tempStatesFile.c_str());
+ unlink(tempPrefsFile.c_str());
+ rmdir(tempDir.c_str());
+ }
+
+ ~edspSystemPrivate() { DeInitialize(); }
+};
// System::edspSystem - Constructor /*{{{*/
-edspSystem::edspSystem() : pkgSystem("Debian APT solver interface", &debVS), d(NULL), StatusFile(NULL)
+edspSystem::edspSystem() : pkgSystem("Debian APT solver interface", &debVS), d(new edspSystemPrivate()), StatusFile(NULL)
{
}
/*}}}*/
@@ -33,6 +73,7 @@ edspSystem::edspSystem() : pkgSystem("Debian APT solver interface", &debVS), d(N
edspSystem::~edspSystem()
{
delete StatusFile;
+ delete d;
}
/*}}}*/
// System::Lock - Get the lock /*{{{*/
@@ -59,7 +100,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");