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