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