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