1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
5 This system provides the abstraction to use the scenario 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).
9 ##################################################################### */
11 // Include Files /*{{{*/
14 #include <apt-pkg/configuration.h>
15 #include <apt-pkg/debversion.h>
16 #include <apt-pkg/edspindexfile.h>
17 #include <apt-pkg/edspsystem.h>
18 #include <apt-pkg/fileutl.h>
19 #include <apt-pkg/pkgcache.h>
20 #include <apt-pkg/cacheiterators.h>
29 // System::edspSystem - Constructor /*{{{*/
30 edspSystem::edspSystem() : pkgSystem("Debian APT solver interface", &debVS
), d(NULL
), StatusFile(NULL
)
34 // System::~debSystem - Destructor /*{{{*/
35 edspSystem::~edspSystem()
40 // System::Lock - Get the lock /*{{{*/
41 bool edspSystem::Lock()
46 // System::UnLock - Drop a lock /*{{{*/
47 bool edspSystem::UnLock(bool /*NoErrors*/)
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 */
56 pkgPackageManager
*edspSystem::CreatePM(pkgDepCache
* /*Cache*/) const
61 // System::Initialize - Setup the configuration space.. /*{{{*/
62 bool edspSystem::Initialize(Configuration
&Cnf
)
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");
68 Cnf
.Set("Debug::NoLocking", "true");
69 Cnf
.Set("APT::Get::Simulate", "true");
78 // System::ArchiveSupported - Is a file format supported /*{{{*/
79 bool edspSystem::ArchiveSupported(const char * /*Type*/)
84 // System::Score - Determine if we should use the edsp system /*{{{*/
85 signed edspSystem::Score(Configuration
const &Cnf
)
87 if (Cnf
.Find("edsp::scenario", "") == "stdin")
89 if (RealFileExists(Cnf
.FindFile("edsp::scenario","")) == true)
94 // System::AddStatusFiles - Register the status files /*{{{*/
95 bool edspSystem::AddStatusFiles(std::vector
<pkgIndexFile
*> &List
)
99 if (_config
->Find("edsp::scenario", "") == "stdin")
100 StatusFile
= new edspIndex("stdin");
102 StatusFile
= new edspIndex(_config
->FindFile("edsp::scenario"));
104 List
.push_back(StatusFile
);
108 // System::FindIndex - Get an index file for status files /*{{{*/
109 bool edspSystem::FindIndex(pkgCache::PkgFileIterator File
,
110 pkgIndexFile
*&Found
) const
114 if (StatusFile
->FindInCache(*File
.Cache()) == File
)
124 APT_HIDDEN edspSystem edspSys
;