]>
Commit | Line | Data |
---|---|---|
6c139d6e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
b9c0654c | 3 | // $Id: packagemanager.cc,v 1.30 2003/04/27 03:04:15 doogie Exp $ |
6c139d6e AL |
4 | /* ###################################################################### |
5 | ||
6 | Package Manager - Abstacts the package manager | |
7 | ||
8 | More work is needed in the area of transitioning provides, ie exim | |
9 | replacing smail. This can cause interesing side effects. | |
10 | ||
11 | Other cases involving conflicts+replaces should be tested. | |
12 | ||
13 | ##################################################################### */ | |
14 | /*}}}*/ | |
15 | // Include Files /*{{{*/ | |
094a497d AL |
16 | #include <apt-pkg/packagemanager.h> |
17 | #include <apt-pkg/orderlist.h> | |
18 | #include <apt-pkg/depcache.h> | |
19 | #include <apt-pkg/error.h> | |
20 | #include <apt-pkg/version.h> | |
03e39e59 | 21 | #include <apt-pkg/acquire-item.h> |
30e1eab5 AL |
22 | #include <apt-pkg/algorithms.h> |
23 | #include <apt-pkg/configuration.h> | |
b2e465d6 AL |
24 | #include <apt-pkg/sptr.h> |
25 | ||
26 | #include <apti18n.h> | |
5819a761 | 27 | #include <iostream> |
6c139d6e AL |
28 | /*}}}*/ |
29 | ||
5819a761 AL |
30 | using namespace std; |
31 | ||
6c139d6e AL |
32 | // PM::PackageManager - Constructor /*{{{*/ |
33 | // --------------------------------------------------------------------- | |
34 | /* */ | |
b2e465d6 | 35 | pkgPackageManager::pkgPackageManager(pkgDepCache *pCache) : Cache(*pCache) |
6c139d6e AL |
36 | { |
37 | FileNames = new string[Cache.Head().PackageCount]; | |
38 | List = 0; | |
30e1eab5 | 39 | Debug = _config->FindB("Debug::pkgPackageManager",false); |
6c139d6e AL |
40 | } |
41 | /*}}}*/ | |
42 | // PM::PackageManager - Destructor /*{{{*/ | |
43 | // --------------------------------------------------------------------- | |
44 | /* */ | |
45 | pkgPackageManager::~pkgPackageManager() | |
46 | { | |
47 | delete List; | |
48 | delete [] FileNames; | |
49 | } | |
50 | /*}}}*/ | |
03e39e59 AL |
51 | // PM::GetArchives - Queue the archives for download /*{{{*/ |
52 | // --------------------------------------------------------------------- | |
53 | /* */ | |
54 | bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, | |
55 | pkgRecords *Recs) | |
56 | { | |
7a1b1f8b AL |
57 | if (CreateOrderList() == false) |
58 | return false; | |
59 | ||
60 | if (List->OrderUnpack() == false) | |
61 | return _error->Error("Internal ordering error"); | |
62 | ||
63 | for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) | |
64 | { | |
65 | PkgIterator Pkg(Cache,*I); | |
281daf46 AL |
66 | FileNames[Pkg->ID] = string(); |
67 | ||
7a1b1f8b AL |
68 | // Skip packages to erase |
69 | if (Cache[Pkg].Delete() == true) | |
03e39e59 | 70 | continue; |
d38b7b3d AL |
71 | |
72 | // Skip Packages that need configure only. | |
9dbb421f AL |
73 | if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && |
74 | Cache[Pkg].Keep() == true) | |
d38b7b3d | 75 | continue; |
281daf46 AL |
76 | |
77 | // Skip already processed packages | |
78 | if (List->IsNow(Pkg) == false) | |
79 | continue; | |
80 | ||
7a1b1f8b AL |
81 | new pkgAcqArchive(Owner,Sources,Recs,Cache[Pkg].InstVerIter(Cache), |
82 | FileNames[Pkg->ID]); | |
03e39e59 | 83 | } |
7a1b1f8b | 84 | |
03e39e59 AL |
85 | return true; |
86 | } | |
87 | /*}}}*/ | |
6c139d6e AL |
88 | // PM::FixMissing - Keep all missing packages /*{{{*/ |
89 | // --------------------------------------------------------------------- | |
90 | /* This is called to correct the installation when packages could not | |
91 | be downloaded. */ | |
92 | bool pkgPackageManager::FixMissing() | |
bdae53f1 | 93 | { |
b2e465d6 | 94 | pkgProblemResolver Resolve(&Cache); |
2fd65468 AL |
95 | List->SetFileList(FileNames); |
96 | ||
9dbb421f | 97 | bool Bad = false; |
6c139d6e AL |
98 | for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) |
99 | { | |
2fd65468 | 100 | if (List->IsMissing(I) == false) |
9dbb421f | 101 | continue; |
2fd65468 | 102 | |
9dbb421f AL |
103 | // Okay, this file is missing and we need it. Mark it for keep |
104 | Bad = true; | |
6c139d6e AL |
105 | Cache.MarkKeep(I); |
106 | } | |
bdae53f1 AL |
107 | |
108 | // We have to empty the list otherwise it will not have the new changes | |
109 | delete List; | |
110 | List = 0; | |
6c139d6e | 111 | |
9dbb421f AL |
112 | if (Bad == false) |
113 | return true; | |
114 | ||
6c139d6e | 115 | // Now downgrade everything that is broken |
30e1eab5 | 116 | return Resolve.ResolveByKeep() == true && Cache.BrokenCount() == 0; |
6c139d6e AL |
117 | } |
118 | /*}}}*/ | |
119 | ||
7a1b1f8b AL |
120 | // PM::CreateOrderList - Create the ordering class /*{{{*/ |
121 | // --------------------------------------------------------------------- | |
122 | /* This populates the ordering list with all the packages that are | |
123 | going to change. */ | |
124 | bool pkgPackageManager::CreateOrderList() | |
125 | { | |
281daf46 AL |
126 | if (List != 0) |
127 | return true; | |
128 | ||
7a1b1f8b | 129 | delete List; |
b2e465d6 | 130 | List = new pkgOrderList(&Cache); |
7a1b1f8b | 131 | |
b9c0654c | 132 | bool NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); |
079cc404 | 133 | |
7a1b1f8b AL |
134 | // Generate the list of affected packages and sort it |
135 | for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) | |
136 | { | |
e7b470ee AL |
137 | // Ignore no-version packages |
138 | if (I->VersionList == 0) | |
139 | continue; | |
140 | ||
138d4b3d AL |
141 | // Mark the package and its dependends for immediate configuration |
142 | if (((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential || | |
143 | (I->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important) && | |
079cc404 | 144 | NoImmConfigure == false) |
7a1b1f8b AL |
145 | { |
146 | List->Flag(I,pkgOrderList::Immediate); | |
d38b7b3d AL |
147 | |
148 | // Look for other packages to make immediate configurea | |
7a1b1f8b AL |
149 | if (Cache[I].InstallVer != 0) |
150 | for (DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); | |
151 | D.end() == false; D++) | |
152 | if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) | |
153 | List->Flag(D.TargetPkg(),pkgOrderList::Immediate); | |
d38b7b3d AL |
154 | |
155 | // And again with the current version. | |
7a1b1f8b AL |
156 | if (I->CurrentVer != 0) |
157 | for (DepIterator D = I.CurrentVer().DependsList(); | |
158 | D.end() == false; D++) | |
159 | if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) | |
160 | List->Flag(D.TargetPkg(),pkgOrderList::Immediate); | |
161 | } | |
162 | ||
163 | // Not interesting | |
164 | if ((Cache[I].Keep() == true || | |
165 | Cache[I].InstVerIter(Cache) == I.CurrentVer()) && | |
d556d1a1 | 166 | I.State() == pkgCache::PkgIterator::NeedsNothing && |
d0c59649 | 167 | (Cache[I].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall && |
d556d1a1 AL |
168 | (I.Purge() != false || Cache[I].Mode != pkgDepCache::ModeDelete || |
169 | (Cache[I].iFlags & pkgDepCache::Purge) != pkgDepCache::Purge)) | |
7a1b1f8b AL |
170 | continue; |
171 | ||
172 | // Append it to the list | |
138d4b3d | 173 | List->push_back(I); |
7a1b1f8b AL |
174 | } |
175 | ||
176 | return true; | |
177 | } | |
178 | /*}}}*/ | |
6c139d6e AL |
179 | // PM::DepAlwaysTrue - Returns true if this dep is irrelevent /*{{{*/ |
180 | // --------------------------------------------------------------------- | |
181 | /* The restriction on provides is to eliminate the case when provides | |
182 | are transitioning between valid states [ie exim to smail] */ | |
183 | bool pkgPackageManager::DepAlwaysTrue(DepIterator D) | |
184 | { | |
185 | if (D.TargetPkg()->ProvidesList != 0) | |
186 | return false; | |
187 | ||
188 | if ((Cache[D] & pkgDepCache::DepInstall) != 0 && | |
189 | (Cache[D] & pkgDepCache::DepNow) != 0) | |
190 | return true; | |
191 | return false; | |
192 | } | |
193 | /*}}}*/ | |
194 | // PM::CheckRConflicts - Look for reverse conflicts /*{{{*/ | |
195 | // --------------------------------------------------------------------- | |
196 | /* This looks over the reverses for a conflicts line that needs early | |
197 | removal. */ | |
198 | bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D, | |
199 | const char *Ver) | |
200 | { | |
201 | for (;D.end() == false; D++) | |
202 | { | |
b2e465d6 AL |
203 | if (D->Type != pkgCache::Dep::Conflicts && |
204 | D->Type != pkgCache::Dep::Obsoletes) | |
6c139d6e | 205 | continue; |
5af32db6 AL |
206 | |
207 | // The package hasnt been changed | |
208 | if (List->IsNow(Pkg) == false) | |
209 | continue; | |
6c139d6e | 210 | |
5af32db6 AL |
211 | // Ignore self conflicts, ignore conflicts from irrelevent versions |
212 | if (D.ParentPkg() == Pkg || D.ParentVer() != D.ParentPkg().CurrentVer()) | |
6c139d6e AL |
213 | continue; |
214 | ||
b2e465d6 | 215 | if (Cache.VS().CheckDep(Ver,D->CompareOp,D.TargetVer()) == false) |
6c139d6e | 216 | continue; |
b2e465d6 | 217 | |
6c139d6e | 218 | if (EarlyRemove(D.ParentPkg()) == false) |
5af32db6 AL |
219 | return _error->Error("Reverse conflicts early remove for package '%s' failed", |
220 | Pkg.Name()); | |
221 | } | |
6c139d6e AL |
222 | return true; |
223 | } | |
224 | /*}}}*/ | |
225 | // PM::ConfigureAll - Run the all out configuration /*{{{*/ | |
226 | // --------------------------------------------------------------------- | |
227 | /* This configures every package. It is assumed they are all unpacked and | |
228 | that the final configuration is valid. */ | |
229 | bool pkgPackageManager::ConfigureAll() | |
230 | { | |
b2e465d6 | 231 | pkgOrderList OList(&Cache); |
6c139d6e AL |
232 | |
233 | // Populate the order list | |
234 | for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) | |
235 | if (List->IsFlag(pkgCache::PkgIterator(Cache,*I), | |
236 | pkgOrderList::UnPacked) == true) | |
237 | OList.push_back(*I); | |
238 | ||
239 | if (OList.OrderConfigure() == false) | |
240 | return false; | |
241 | ||
242 | // Perform the configuring | |
243 | for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) | |
244 | { | |
245 | PkgIterator Pkg(Cache,*I); | |
246 | ||
247 | if (Configure(Pkg) == false) | |
248 | return false; | |
249 | ||
250 | List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); | |
251 | } | |
252 | ||
253 | return true; | |
254 | } | |
255 | /*}}}*/ | |
256 | // PM::SmartConfigure - Perform immediate configuration of the pkg /*{{{*/ | |
257 | // --------------------------------------------------------------------- | |
258 | /* This routine scheduals the configuration of the given package and all | |
259 | of it's dependents. */ | |
260 | bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) | |
261 | { | |
b2e465d6 | 262 | pkgOrderList OList(&Cache); |
6c139d6e AL |
263 | |
264 | if (DepAdd(OList,Pkg) == false) | |
265 | return false; | |
266 | ||
267 | if (OList.OrderConfigure() == false) | |
268 | return false; | |
b2e465d6 | 269 | |
6c139d6e AL |
270 | // Perform the configuring |
271 | for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) | |
272 | { | |
273 | PkgIterator Pkg(Cache,*I); | |
274 | ||
275 | if (Configure(Pkg) == false) | |
276 | return false; | |
277 | ||
278 | List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); | |
279 | } | |
280 | ||
281 | // Sanity Check | |
282 | if (List->IsFlag(Pkg,pkgOrderList::Configured) == false) | |
283 | return _error->Error("Internal error, could not immediate configure %s",Pkg.Name()); | |
284 | ||
285 | return true; | |
286 | } | |
287 | /*}}}*/ | |
288 | // PM::DepAdd - Add all dependents to the oder list /*{{{*/ | |
289 | // --------------------------------------------------------------------- | |
290 | /* This recursively adds all dependents to the order list */ | |
291 | bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) | |
292 | { | |
293 | if (OList.IsFlag(Pkg,pkgOrderList::Added) == true) | |
294 | return true; | |
295 | if (List->IsFlag(Pkg,pkgOrderList::Configured) == true) | |
296 | return true; | |
297 | if (List->IsFlag(Pkg,pkgOrderList::UnPacked) == false) | |
298 | return false; | |
b2e465d6 | 299 | |
6c139d6e AL |
300 | // Put the package on the list |
301 | OList.push_back(Pkg); | |
302 | OList.Flag(Pkg,pkgOrderList::Added); | |
303 | Depth++; | |
304 | ||
305 | // Check the dependencies to see if they are all satisfied. | |
306 | bool Bad = false; | |
307 | for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); D.end() == false;) | |
308 | { | |
b50b2c97 | 309 | if (D->Type != pkgCache::Dep::Depends && D->Type != pkgCache::Dep::PreDepends) |
6c139d6e AL |
310 | { |
311 | D++; | |
312 | continue; | |
313 | } | |
314 | ||
315 | // Grok or groups | |
316 | Bad = true; | |
317 | for (bool LastOR = true; D.end() == false && LastOR == true; D++) | |
318 | { | |
b50b2c97 | 319 | LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; |
6c139d6e AL |
320 | |
321 | if (Bad == false) | |
322 | continue; | |
323 | ||
b2e465d6 | 324 | SPtrArray<Version *> VList = D.AllTargets(); |
6c139d6e AL |
325 | for (Version **I = VList; *I != 0 && Bad == true; I++) |
326 | { | |
327 | VerIterator Ver(Cache,*I); | |
328 | PkgIterator Pkg = Ver.ParentPkg(); | |
329 | ||
330 | // See if the current version is ok | |
331 | if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true && | |
332 | Pkg.State() == PkgIterator::NeedsNothing) | |
333 | { | |
334 | Bad = false; | |
335 | continue; | |
336 | } | |
337 | ||
338 | // Not the install version | |
339 | if (Cache[Pkg].InstallVer != *I || | |
340 | (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)) | |
341 | continue; | |
b2e465d6 | 342 | |
6c139d6e AL |
343 | if (List->IsFlag(Pkg,pkgOrderList::UnPacked) == true) |
344 | Bad = !DepAdd(OList,Pkg,Depth); | |
345 | if (List->IsFlag(Pkg,pkgOrderList::Configured) == true) | |
346 | Bad = false; | |
347 | } | |
6c139d6e AL |
348 | } |
349 | ||
350 | if (Bad == true) | |
351 | { | |
352 | OList.Flag(Pkg,0,pkgOrderList::Added); | |
353 | OList.pop_back(); | |
354 | Depth--; | |
355 | return false; | |
356 | } | |
357 | } | |
358 | ||
359 | Depth--; | |
360 | return true; | |
361 | } | |
362 | /*}}}*/ | |
363 | // PM::EarlyRemove - Perform removal of packages before their time /*{{{*/ | |
364 | // --------------------------------------------------------------------- | |
365 | /* This is called to deal with conflicts arising from unpacking */ | |
366 | bool pkgPackageManager::EarlyRemove(PkgIterator Pkg) | |
367 | { | |
368 | if (List->IsNow(Pkg) == false) | |
369 | return true; | |
370 | ||
371 | // Already removed it | |
372 | if (List->IsFlag(Pkg,pkgOrderList::Removed) == true) | |
373 | return true; | |
374 | ||
375 | // Woops, it will not be re-installed! | |
376 | if (List->IsFlag(Pkg,pkgOrderList::InList) == false) | |
377 | return false; | |
9d4c8f67 AL |
378 | |
379 | // Essential packages get special treatment | |
5af32db6 | 380 | bool IsEssential = false; |
9d4c8f67 | 381 | if ((Pkg->Flags & pkgCache::Flag::Essential) != 0) |
5af32db6 AL |
382 | IsEssential = true; |
383 | ||
384 | /* Check for packages that are the dependents of essential packages and | |
385 | promote them too */ | |
386 | if (Pkg->CurrentVer != 0) | |
387 | { | |
388 | for (DepIterator D = Pkg.RevDependsList(); D.end() == false && | |
389 | IsEssential == false; D++) | |
390 | if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) | |
391 | if ((D.ParentPkg()->Flags & pkgCache::Flag::Essential) != 0) | |
392 | IsEssential = true; | |
393 | } | |
394 | ||
395 | if (IsEssential == true) | |
9d4c8f67 AL |
396 | { |
397 | if (_config->FindB("APT::Force-LoopBreak",false) == false) | |
b2e465d6 AL |
398 | return _error->Error(_("This installation run will require temporarily " |
399 | "removing the essential package %s due to a " | |
400 | "Conflicts/Pre-Depends loop. This is often bad, " | |
401 | "but if you really want to do it, activate the " | |
402 | "APT::Force-LoopBreak option."),Pkg.Name()); | |
9d4c8f67 | 403 | } |
6c139d6e AL |
404 | |
405 | bool Res = SmartRemove(Pkg); | |
406 | if (Cache[Pkg].Delete() == false) | |
407 | List->Flag(Pkg,pkgOrderList::Removed,pkgOrderList::States); | |
408 | ||
409 | return Res; | |
410 | } | |
411 | /*}}}*/ | |
412 | // PM::SmartRemove - Removal Helper /*{{{*/ | |
413 | // --------------------------------------------------------------------- | |
414 | /* */ | |
415 | bool pkgPackageManager::SmartRemove(PkgIterator Pkg) | |
416 | { | |
417 | if (List->IsNow(Pkg) == false) | |
418 | return true; | |
419 | ||
420 | List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); | |
fc4b5c9f | 421 | return Remove(Pkg,(Cache[Pkg].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge); |
6c139d6e AL |
422 | } |
423 | /*}}}*/ | |
424 | // PM::SmartUnPack - Install helper /*{{{*/ | |
425 | // --------------------------------------------------------------------- | |
426 | /* This performs the task of handling pre-depends. */ | |
427 | bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) | |
428 | { | |
429 | // Check if it is already unpacked | |
430 | if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && | |
431 | Cache[Pkg].Keep() == true) | |
432 | { | |
433 | List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); | |
434 | if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true) | |
435 | if (SmartConfigure(Pkg) == false) | |
b2e465d6 | 436 | return _error->Error("Internal Error, Could not perform immediate configuration (1) on %s",Pkg.Name()); |
6c139d6e AL |
437 | return true; |
438 | } | |
981d20eb | 439 | |
6c139d6e AL |
440 | /* See if this packages install version has any predependencies |
441 | that are not met by 'now' packages. */ | |
442 | for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); | |
421c8d10 | 443 | D.end() == false; ) |
6c139d6e | 444 | { |
421c8d10 AL |
445 | // Compute a single dependency element (glob or) |
446 | pkgCache::DepIterator Start; | |
447 | pkgCache::DepIterator End; | |
448 | D.GlobOr(Start,End); | |
449 | ||
450 | while (End->Type == pkgCache::Dep::PreDepends) | |
6c139d6e AL |
451 | { |
452 | // Look for possible ok targets. | |
b2e465d6 | 453 | SPtrArray<Version *> VList = Start.AllTargets(); |
6c139d6e AL |
454 | bool Bad = true; |
455 | for (Version **I = VList; *I != 0 && Bad == true; I++) | |
456 | { | |
457 | VerIterator Ver(Cache,*I); | |
458 | PkgIterator Pkg = Ver.ParentPkg(); | |
459 | ||
460 | // See if the current version is ok | |
461 | if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true && | |
462 | Pkg.State() == PkgIterator::NeedsNothing) | |
463 | { | |
464 | Bad = false; | |
465 | continue; | |
466 | } | |
467 | } | |
468 | ||
469 | // Look for something that could be configured. | |
470 | for (Version **I = VList; *I != 0 && Bad == true; I++) | |
471 | { | |
472 | VerIterator Ver(Cache,*I); | |
473 | PkgIterator Pkg = Ver.ParentPkg(); | |
474 | ||
475 | // Not the install version | |
476 | if (Cache[Pkg].InstallVer != *I || | |
477 | (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)) | |
478 | continue; | |
479 | ||
480 | Bad = !SmartConfigure(Pkg); | |
481 | } | |
1006601e | 482 | |
421c8d10 | 483 | /* If this or element did not match then continue on to the |
1006601e | 484 | next or element until a matching element is found */ |
421c8d10 | 485 | if (Bad == true) |
1006601e AL |
486 | { |
487 | // This triggers if someone make a pre-depends/depend loop. | |
421c8d10 | 488 | if (Start == End) |
1006601e AL |
489 | return _error->Error("Couldn't configure pre-depend %s for %s, " |
490 | "probably a dependency cycle.", | |
491 | End.TargetPkg().Name(),Pkg.Name()); | |
421c8d10 AL |
492 | Start++; |
493 | } | |
494 | else | |
495 | break; | |
6c139d6e AL |
496 | } |
497 | ||
b2e465d6 AL |
498 | if (End->Type == pkgCache::Dep::Conflicts || |
499 | End->Type == pkgCache::Dep::Obsoletes) | |
6c139d6e AL |
500 | { |
501 | /* Look for conflicts. Two packages that are both in the install | |
502 | state cannot conflict so we don't check.. */ | |
b2e465d6 | 503 | SPtrArray<Version *> VList = End.AllTargets(); |
6c139d6e AL |
504 | for (Version **I = VList; *I != 0; I++) |
505 | { | |
506 | VerIterator Ver(Cache,*I); | |
507 | PkgIterator Pkg = Ver.ParentPkg(); | |
508 | ||
509 | // See if the current version is conflicting | |
510 | if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true) | |
511 | { | |
512 | if (EarlyRemove(Pkg) == false) | |
513 | return _error->Error("Internal Error, Could not early remove %s",Pkg.Name()); | |
514 | } | |
515 | } | |
6c139d6e AL |
516 | } |
517 | } | |
518 | ||
519 | // Check for reverse conflicts. | |
5af32db6 AL |
520 | if (CheckRConflicts(Pkg,Pkg.RevDependsList(), |
521 | Cache[Pkg].InstVerIter(Cache).VerStr()) == false) | |
522 | return false; | |
523 | ||
6c139d6e AL |
524 | for (PrvIterator P = Cache[Pkg].InstVerIter(Cache).ProvidesList(); |
525 | P.end() == false; P++) | |
526 | CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion()); | |
527 | ||
528 | if (Install(Pkg,FileNames[Pkg->ID]) == false) | |
529 | return false; | |
530 | ||
531 | List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); | |
532 | ||
533 | // Perform immedate configuration of the package. | |
534 | if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true) | |
535 | if (SmartConfigure(Pkg) == false) | |
b2e465d6 | 536 | return _error->Error("Internal Error, Could not perform immediate configuration (2) on %s",Pkg.Name()); |
6c139d6e AL |
537 | |
538 | return true; | |
539 | } | |
540 | /*}}}*/ | |
541 | // PM::OrderInstall - Installation ordering routine /*{{{*/ | |
542 | // --------------------------------------------------------------------- | |
543 | /* */ | |
281daf46 | 544 | pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() |
6c139d6e | 545 | { |
7a1b1f8b | 546 | if (CreateOrderList() == false) |
281daf46 AL |
547 | return Failed; |
548 | ||
549 | Reset(); | |
6c139d6e | 550 | |
30e1eab5 AL |
551 | if (Debug == true) |
552 | clog << "Begining to order" << endl; | |
6c139d6e | 553 | |
281daf46 AL |
554 | if (List->OrderUnpack(FileNames) == false) |
555 | { | |
556 | _error->Error("Internal ordering error"); | |
557 | return Failed; | |
558 | } | |
559 | ||
30e1eab5 AL |
560 | if (Debug == true) |
561 | clog << "Done ordering" << endl; | |
562 | ||
281daf46 | 563 | bool DoneSomething = false; |
6c139d6e AL |
564 | for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) |
565 | { | |
566 | PkgIterator Pkg(Cache,*I); | |
281daf46 AL |
567 | |
568 | if (List->IsNow(Pkg) == false) | |
569 | { | |
570 | if (Debug == true) | |
571 | clog << "Skipping already done " << Pkg.Name() << endl; | |
572 | continue; | |
573 | } | |
574 | ||
2fd65468 | 575 | if (List->IsMissing(Pkg) == true) |
281daf46 AL |
576 | { |
577 | if (Debug == true) | |
a3eaf954 | 578 | clog << "Sequence completed at " << Pkg.Name() << endl; |
281daf46 AL |
579 | if (DoneSomething == false) |
580 | { | |
581 | _error->Error("Internal Error, ordering was unable to handle the media swap"); | |
582 | return Failed; | |
583 | } | |
584 | return Incomplete; | |
585 | } | |
6c139d6e AL |
586 | |
587 | // Sanity check | |
d0c59649 AL |
588 | if (Cache[Pkg].Keep() == true && |
589 | Pkg.State() == pkgCache::PkgIterator::NeedsNothing && | |
590 | (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall) | |
281daf46 | 591 | { |
71a174ee | 592 | _error->Error("Internal Error, trying to manipulate a kept package (%s)",Pkg.Name()); |
281daf46 AL |
593 | return Failed; |
594 | } | |
6c139d6e AL |
595 | |
596 | // Perform a delete or an install | |
597 | if (Cache[Pkg].Delete() == true) | |
598 | { | |
599 | if (SmartRemove(Pkg) == false) | |
281daf46 | 600 | return Failed; |
6c139d6e AL |
601 | } |
602 | else | |
603 | if (SmartUnPack(Pkg) == false) | |
281daf46 AL |
604 | return Failed; |
605 | DoneSomething = true; | |
6c139d6e AL |
606 | } |
607 | ||
608 | // Final run through the configure phase | |
609 | if (ConfigureAll() == false) | |
281daf46 | 610 | return Failed; |
6c139d6e AL |
611 | |
612 | // Sanity check | |
613 | for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) | |
281daf46 | 614 | { |
6c139d6e | 615 | if (List->IsFlag(*I,pkgOrderList::Configured) == false) |
281daf46 AL |
616 | { |
617 | _error->Error("Internal error, packages left unconfigured. %s", | |
618 | PkgIterator(Cache,*I).Name()); | |
619 | return Failed; | |
620 | } | |
621 | } | |
622 | ||
623 | return Completed; | |
6c139d6e AL |
624 | } |
625 | /*}}}*/ | |
626 | // PM::DoInstall - Does the installation /*{{{*/ | |
627 | // --------------------------------------------------------------------- | |
628 | /* This uses the filenames in FileNames and the information in the | |
629 | DepCache to perform the installation of packages.*/ | |
75ef8f14 | 630 | pkgPackageManager::OrderResult pkgPackageManager::DoInstall(int status_fd) |
6c139d6e | 631 | { |
281daf46 | 632 | OrderResult Res = OrderInstall(); |
71a174ee MV |
633 | if(Debug) |
634 | std::clog << "OrderInstall() returned: " << Res << std::endl; | |
281daf46 | 635 | if (Res != Failed) |
75ef8f14 | 636 | if (Go(status_fd) == false) |
281daf46 AL |
637 | return Failed; |
638 | return Res; | |
6c139d6e AL |
639 | } |
640 | /*}}}*/ |