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