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