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