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