]>
git.saurik.com Git - apt.git/blob - apt-pkg/packagemanager.cc
324b7ffba46c761f9e8409186804349aa367ce64
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: packagemanager.cc,v 1.30 2003/04/27 03:04:15 doogie Exp $
4 /* ######################################################################
6 Package Manager - Abstacts the package manager
8 More work is needed in the area of transitioning provides, ie exim
9 replacing smail. This can cause interesing side effects.
11 Other cases involving conflicts+replaces should be tested.
13 ##################################################################### */
15 // Include Files /*{{{*/
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>
21 #include <apt-pkg/acquire-item.h>
22 #include <apt-pkg/algorithms.h>
23 #include <apt-pkg/configuration.h>
24 #include <apt-pkg/sptr.h>
32 bool pkgPackageManager::SigINTStop
= false;
34 // PM::PackageManager - Constructor /*{{{*/
35 // ---------------------------------------------------------------------
37 pkgPackageManager::pkgPackageManager(pkgDepCache
*pCache
) : Cache(*pCache
)
39 FileNames
= new string
[Cache
.Head().PackageCount
];
41 Debug
= _config
->FindB("Debug::pkgPackageManager",false);
44 // PM::PackageManager - Destructor /*{{{*/
45 // ---------------------------------------------------------------------
47 pkgPackageManager::~pkgPackageManager()
53 // PM::GetArchives - Queue the archives for download /*{{{*/
54 // ---------------------------------------------------------------------
56 bool pkgPackageManager::GetArchives(pkgAcquire
*Owner
,pkgSourceList
*Sources
,
59 if (CreateOrderList() == false)
63 _config
->FindB("PackageManager::UnpackAll",true) ?
64 List
->OrderUnpack() : List
->OrderCritical();
65 if (ordering
== false)
66 return _error
->Error("Internal ordering error");
68 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
70 PkgIterator
Pkg(Cache
,*I
);
71 FileNames
[Pkg
->ID
] = string();
73 // Skip packages to erase
74 if (Cache
[Pkg
].Delete() == true)
77 // Skip Packages that need configure only.
78 if (Pkg
.State() == pkgCache::PkgIterator::NeedsConfigure
&&
79 Cache
[Pkg
].Keep() == true)
82 // Skip already processed packages
83 if (List
->IsNow(Pkg
) == false)
86 new pkgAcqArchive(Owner
,Sources
,Recs
,Cache
[Pkg
].InstVerIter(Cache
),
93 // PM::FixMissing - Keep all missing packages /*{{{*/
94 // ---------------------------------------------------------------------
95 /* This is called to correct the installation when packages could not
97 bool pkgPackageManager::FixMissing()
99 pkgDepCache::ActionGroup
group(Cache
);
100 pkgProblemResolver
Resolve(&Cache
);
101 List
->SetFileList(FileNames
);
104 for (PkgIterator I
= Cache
.PkgBegin(); I
.end() == false; I
++)
106 if (List
->IsMissing(I
) == false)
109 // Okay, this file is missing and we need it. Mark it for keep
111 Cache
.MarkKeep(I
, false, false);
114 // We have to empty the list otherwise it will not have the new changes
121 // Now downgrade everything that is broken
122 return Resolve
.ResolveByKeep() == true && Cache
.BrokenCount() == 0;
125 // PM::ImmediateAdd - Add the immediate flag recursivly /*{{{*/
126 // ---------------------------------------------------------------------
127 /* This adds the immediate flag to the pkg and recursively to the
130 void pkgPackageManager::ImmediateAdd(PkgIterator I
, bool UseInstallVer
, unsigned const int &Depth
)
136 if(Cache
[I
].InstallVer
== 0)
138 D
= Cache
[I
].InstVerIter(Cache
).DependsList();
140 if (I
->CurrentVer
== 0)
142 D
= I
.CurrentVer().DependsList();
145 for ( /* nothing */ ; D
.end() == false; D
++)
146 if (D
->Type
== pkgCache::Dep::Depends
|| D
->Type
== pkgCache::Dep::PreDepends
)
148 if(!List
->IsFlag(D
.TargetPkg(), pkgOrderList::Immediate
))
151 clog
<< OutputInDepth(Depth
) << "ImmediateAdd(): Adding Immediate flag to " << D
.TargetPkg() << " cause of " << D
.DepType() << " " << I
.Name() << endl
;
152 List
->Flag(D
.TargetPkg(),pkgOrderList::Immediate
);
153 ImmediateAdd(D
.TargetPkg(), UseInstallVer
, Depth
+ 1);
159 // PM::CreateOrderList - Create the ordering class /*{{{*/
160 // ---------------------------------------------------------------------
161 /* This populates the ordering list with all the packages that are
163 bool pkgPackageManager::CreateOrderList()
169 List
= new pkgOrderList(&Cache
);
171 NoImmConfigure
= !_config
->FindB("APT::Immediate-Configure",true);
172 ImmConfigureAll
= _config
->FindB("APT::Immediate-Configure-All",false);
174 if (Debug
&& ImmConfigureAll
)
175 clog
<< "CreateOrderList(): Adding Immediate flag for all packages because of APT::Immediate-Configure-All" << endl
;
177 // Generate the list of affected packages and sort it
178 for (PkgIterator I
= Cache
.PkgBegin(); I
.end() == false; I
++)
180 // Ignore no-version packages
181 if (I
->VersionList
== 0)
184 // Mark the package and its dependends for immediate configuration
185 if ((((I
->Flags
& pkgCache::Flag::Essential
) == pkgCache::Flag::Essential
||
186 (I
->Flags
& pkgCache::Flag::Important
) == pkgCache::Flag::Important
) &&
187 NoImmConfigure
== false) || ImmConfigureAll
)
189 if(Debug
&& !ImmConfigureAll
)
190 clog
<< "CreateOrderList(): Adding Immediate flag for " << I
.Name() << endl
;
191 List
->Flag(I
,pkgOrderList::Immediate
);
193 if (!ImmConfigureAll
) {
194 // Look for other install packages to make immediate configurea
195 ImmediateAdd(I
, true);
197 // And again with the current version.
198 ImmediateAdd(I
, false);
203 if ((Cache
[I
].Keep() == true ||
204 Cache
[I
].InstVerIter(Cache
) == I
.CurrentVer()) &&
205 I
.State() == pkgCache::PkgIterator::NeedsNothing
&&
206 (Cache
[I
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
&&
207 (I
.Purge() != false || Cache
[I
].Mode
!= pkgDepCache::ModeDelete
||
208 (Cache
[I
].iFlags
& pkgDepCache::Purge
) != pkgDepCache::Purge
))
211 // Append it to the list
218 // PM::DepAlwaysTrue - Returns true if this dep is irrelevent /*{{{*/
219 // ---------------------------------------------------------------------
220 /* The restriction on provides is to eliminate the case when provides
221 are transitioning between valid states [ie exim to smail] */
222 bool pkgPackageManager::DepAlwaysTrue(DepIterator D
)
224 if (D
.TargetPkg()->ProvidesList
!= 0)
227 if ((Cache
[D
] & pkgDepCache::DepInstall
) != 0 &&
228 (Cache
[D
] & pkgDepCache::DepNow
) != 0)
233 // PM::CheckRConflicts - Look for reverse conflicts /*{{{*/
234 // ---------------------------------------------------------------------
235 /* This looks over the reverses for a conflicts line that needs early
237 bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg
,DepIterator D
,
240 for (;D
.end() == false; D
++)
242 if (D
->Type
!= pkgCache::Dep::Conflicts
&&
243 D
->Type
!= pkgCache::Dep::Obsoletes
)
246 // The package hasnt been changed
247 if (List
->IsNow(Pkg
) == false)
250 // Ignore self conflicts, ignore conflicts from irrelevent versions
251 if (D
.ParentPkg() == Pkg
|| D
.ParentVer() != D
.ParentPkg().CurrentVer())
254 if (Cache
.VS().CheckDep(Ver
,D
->CompareOp
,D
.TargetVer()) == false)
257 if (EarlyRemove(D
.ParentPkg()) == false)
258 return _error
->Error("Reverse conflicts early remove for package '%s' failed",
264 // PM::ConfigureAll - Run the all out configuration /*{{{*/
265 // ---------------------------------------------------------------------
266 /* This configures every package. It is assumed they are all unpacked and
267 that the final configuration is valid. This is also used to catch packages
268 that have not been configured when using ImmConfigureAll */
269 bool pkgPackageManager::ConfigureAll()
271 pkgOrderList
OList(&Cache
);
273 // Populate the order list
274 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
275 if (List
->IsFlag(pkgCache::PkgIterator(Cache
,*I
),
276 pkgOrderList::UnPacked
) == true)
279 if (OList
.OrderConfigure() == false)
282 std::string
const conf
= _config
->Find("PackageManager::Configure","all");
283 bool const ConfigurePkgs
= (conf
== "all");
285 // Perform the configuring
286 for (pkgOrderList::iterator I
= OList
.begin(); I
!= OList
.end(); I
++)
288 PkgIterator
Pkg(Cache
,*I
);
290 /* Check if the package has been configured, this can happen if SmartConfigure
292 if (List
->IsFlag(Pkg
,pkgOrderList::Configured
)) continue;
294 if (ConfigurePkgs
== true && SmartConfigure(Pkg
) == false) {
295 _error
->Error("Internal error, packages left unconfigured. %s",Pkg
.Name());
299 List
->Flag(Pkg
,pkgOrderList::Configured
,pkgOrderList::States
);
305 // PM::SmartConfigure - Perform immediate configuration of the pkg /*{{{*/
306 // ---------------------------------------------------------------------
307 /* This routine trys to put the system in a state where Pkg can be configured,
308 this involves checking each of Pkg's dependanies and unpacking and
309 configuring packages where needed. */
310 bool pkgPackageManager::SmartConfigure(PkgIterator Pkg
)
313 clog
<< "SmartConfigure " << Pkg
.Name() << endl
;
315 VerIterator
const instVer
= Cache
[Pkg
].InstVerIter(Cache
);
317 /* Because of the ordered list, most dependancies should be unpacked,
318 however if there is a loop this is not the case, so check for dependancies before configuring.
319 This is done after the package installation as it makes it easier to deal with conflicts problems */
321 for (DepIterator D
= instVer
.DependsList();
324 // Compute a single dependency element (glob or)
325 pkgCache::DepIterator Start
;
326 pkgCache::DepIterator End
;
329 if (End
->Type
== pkgCache::Dep::Depends
)
332 // Check for dependanices that have not been unpacked, probably due to loops.
333 while (End
->Type
== pkgCache::Dep::Depends
) {
335 VerIterator InstallVer
;
336 SPtrArray
<Version
*> VList
= Start
.AllTargets();
338 for (Version
**I
= VList
; *I
!= 0; I
++) {
339 VerIterator
Ver(Cache
,*I
);
340 DepPkg
= Ver
.ParentPkg();
344 InstallVer
= VerIterator(Cache
,Cache
[DepPkg
].InstallVer
);
345 //VerIterator CandVer(Cache,Cache[DepPkg].CandidateVer);
347 if (Debug
&& false) {
349 cout
<< " Checking if " << Ver
<< " of " << DepPkg
.Name() << " satisfies this dependancy" << endl
;
351 cout
<< " Checking if " << Ver
.VerStr() << " of " << DepPkg
.Name() << " satisfies this dependancy" << endl
;
354 if (DepPkg
.CurrentVer()==0) {
355 cout
<< " CurrentVer " << DepPkg
.CurrentVer() << " IsNow " << List
->IsNow(DepPkg
) << " NeedsNothing " << (DepPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
357 cout
<< " CurrentVer " << DepPkg
.CurrentVer().VerStr() << " IsNow " << List
->IsNow(DepPkg
) << " NeedsNothing " << (DepPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
361 cout
<< " InstallVer " << InstallVer
<< endl
;
363 cout
<< " InstallVer " << InstallVer
.VerStr() << endl
;
366 // cout << " CandVer " << CandVer.VerStr() << endl;
368 cout
<< " Keep " << Cache
[DepPkg
].Keep() << " Unpacked " << List
->IsFlag(DepPkg
,pkgOrderList::UnPacked
) << " Configured " << List
->IsFlag(DepPkg
,pkgOrderList::Configured
) << endl
;
372 // Check if it satisfies this dependancy
373 if (DepPkg
.CurrentVer() == Ver
&& List
->IsNow(DepPkg
) == true &&
374 DepPkg
.State() == PkgIterator::NeedsNothing
)
380 if (Cache
[DepPkg
].InstallVer
== *I
) {
381 if (List
->IsFlag(DepPkg
,pkgOrderList::UnPacked
)) {
382 if (!List
->IsFlag(DepPkg
,pkgOrderList::Loop
)) {
383 List
->Flag(Pkg
,pkgOrderList::Loop
);
384 Bad
= !SmartConfigure(DepPkg
);
388 } else if (List
->IsFlag(DepPkg
,pkgOrderList::Configured
)) {
395 if (InstallVer
!= 0 && Bad
) {
397 List
->Flag(Pkg
,pkgOrderList::Loop
);
398 if (!List
->IsFlag(DepPkg
,pkgOrderList::Loop
)) {
400 cout
<< " Unpacking " << DepPkg
.Name() << " to avoid loop" << endl
;
401 SmartUnPack(DepPkg
, true);
407 if (!List
->IsFlag(DepPkg
,pkgOrderList::Loop
)) {
408 _error
->Warning("Could not satisfy dependancies for %s",Pkg
.Name());
419 static std::string
const conf
= _config
->Find("PackageManager::Configure","all");
420 static bool const ConfigurePkgs
= (conf
== "all" || conf
== "smart");
422 if (List
->IsFlag(Pkg
,pkgOrderList::Configured
))
423 return _error
->Error("Internal configure error on '%s'. ",Pkg
.Name(),1);
425 if (ConfigurePkgs
== true && Configure(Pkg
) == false)
428 List
->Flag(Pkg
,pkgOrderList::Configured
,pkgOrderList::States
);
430 if (Cache
[Pkg
].InstVerIter(Cache
)->MultiArch
== pkgCache::Version::Same
)
431 for (PkgIterator P
= Pkg
.Group().PackageList();
432 P
.end() == false; P
= Pkg
.Group().NextPkg(P
))
434 if (Pkg
== P
|| List
->IsFlag(P
,pkgOrderList::Configured
) == true ||
435 Cache
[P
].InstallVer
== 0 || (P
.CurrentVer() == Cache
[P
].InstallVer
&&
436 (Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
))
442 if (List
->IsFlag(Pkg
,pkgOrderList::Configured
) == false && Debug
)
443 _error
->Warning(_("Could not perform immediate configuration on '%s'. "
444 "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg
.Name(),1);
449 // PM::EarlyRemove - Perform removal of packages before their time /*{{{*/
450 // ---------------------------------------------------------------------
451 /* This is called to deal with conflicts arising from unpacking */
452 bool pkgPackageManager::EarlyRemove(PkgIterator Pkg
)
454 if (List
->IsNow(Pkg
) == false)
457 // Already removed it
458 if (List
->IsFlag(Pkg
,pkgOrderList::Removed
) == true)
461 // Woops, it will not be re-installed!
462 if (List
->IsFlag(Pkg
,pkgOrderList::InList
) == false)
465 // Essential packages get special treatment
466 bool IsEssential
= false;
467 if ((Pkg
->Flags
& pkgCache::Flag::Essential
) != 0)
470 /* Check for packages that are the dependents of essential packages and
472 if (Pkg
->CurrentVer
!= 0)
474 for (DepIterator D
= Pkg
.RevDependsList(); D
.end() == false &&
475 IsEssential
== false; D
++)
476 if (D
->Type
== pkgCache::Dep::Depends
|| D
->Type
== pkgCache::Dep::PreDepends
)
477 if ((D
.ParentPkg()->Flags
& pkgCache::Flag::Essential
) != 0)
481 if (IsEssential
== true)
483 if (_config
->FindB("APT::Force-LoopBreak",false) == false)
484 return _error
->Error(_("This installation run will require temporarily "
485 "removing the essential package %s due to a "
486 "Conflicts/Pre-Depends loop. This is often bad, "
487 "but if you really want to do it, activate the "
488 "APT::Force-LoopBreak option."),Pkg
.Name());
491 bool Res
= SmartRemove(Pkg
);
492 if (Cache
[Pkg
].Delete() == false)
493 List
->Flag(Pkg
,pkgOrderList::Removed
,pkgOrderList::States
);
498 // PM::SmartRemove - Removal Helper /*{{{*/
499 // ---------------------------------------------------------------------
501 bool pkgPackageManager::SmartRemove(PkgIterator Pkg
)
503 if (List
->IsNow(Pkg
) == false)
506 List
->Flag(Pkg
,pkgOrderList::Configured
,pkgOrderList::States
);
508 return Remove(Pkg
,(Cache
[Pkg
].iFlags
& pkgDepCache::Purge
) == pkgDepCache::Purge
);
512 // PM::SmartUnPack - Install helper /*{{{*/
513 // ---------------------------------------------------------------------
514 /* This puts the system in a state where it can Unpack Pkg, if Pkg is allready
515 unpacked, or when it has been unpacked, if Immediate==true it configures it. */
516 bool pkgPackageManager::SmartUnPack(PkgIterator Pkg
)
518 return SmartUnPack(Pkg
, true);
520 bool pkgPackageManager::SmartUnPack(PkgIterator Pkg
, bool const Immediate
)
523 clog
<< "SmartUnPack " << Pkg
.Name() << endl
;
525 // Check if it is already unpacked
526 if (Pkg
.State() == pkgCache::PkgIterator::NeedsConfigure
&&
527 Cache
[Pkg
].Keep() == true)
529 List
->Flag(Pkg
,pkgOrderList::UnPacked
,pkgOrderList::States
);
530 if (Immediate
== true &&
531 List
->IsFlag(Pkg
,pkgOrderList::Immediate
) == true)
532 if (SmartConfigure(Pkg
) == false)
533 _error
->Warning(_("Could not perform immediate configuration on already unpacked '%s'. "
534 "Please see man 5 apt.conf under APT::Immediate-Configure for details."),Pkg
.Name());
538 VerIterator
const instVer
= Cache
[Pkg
].InstVerIter(Cache
);
540 /* PreUnpack Checks: This loop checks and attemps to rectify and problems that would prevent the package being unpacked.
541 It addresses: PreDepends, Conflicts, Obsoletes and DpkgBreaks. Any resolutions that do not require it should
542 avoid configuration (calling SmartUnpack with Immediate=true), this is because any loops before Pkg is unpacked
543 can cause problems. This will be either dealt with if the package is configured as a dependancy of
544 Pkg (if and when Pkg is configured), or by the ConfigureAll call at the end of the for loop in OrderInstall. */
545 for (DepIterator D
= instVer
.DependsList();
548 // Compute a single dependency element (glob or)
549 pkgCache::DepIterator Start
;
550 pkgCache::DepIterator End
;
553 while (End
->Type
== pkgCache::Dep::PreDepends
)
556 clog
<< "PreDepends order for " << Pkg
.Name() << std::endl
;
558 // Look for possible ok targets.
559 SPtrArray
<Version
*> VList
= Start
.AllTargets();
561 for (Version
**I
= VList
; *I
!= 0 && Bad
== true; I
++)
563 VerIterator
Ver(Cache
,*I
);
564 PkgIterator Pkg
= Ver
.ParentPkg();
566 // See if the current version is ok
567 if (Pkg
.CurrentVer() == Ver
&& List
->IsNow(Pkg
) == true &&
568 Pkg
.State() == PkgIterator::NeedsNothing
)
572 clog
<< "Found ok package " << Pkg
.Name() << endl
;
577 // Look for something that could be configured.
578 for (Version
**I
= VList
; *I
!= 0 && Bad
== true; I
++)
580 VerIterator
Ver(Cache
,*I
);
581 PkgIterator Pkg
= Ver
.ParentPkg();
583 // Not the install version
584 if (Cache
[Pkg
].InstallVer
!= *I
||
585 (Cache
[Pkg
].Keep() == true && Pkg
.State() == PkgIterator::NeedsNothing
))
588 if (List
->IsFlag(Pkg
,pkgOrderList::Configured
)) {
594 clog
<< "Trying to SmartConfigure " << Pkg
.Name() << endl
;
595 Bad
= !SmartConfigure(Pkg
);
598 /* If this or element did not match then continue on to the
599 next or element until a matching element is found */
602 // This triggers if someone make a pre-depends/depend loop.
604 return _error
->Error("Couldn't configure pre-depend %s for %s, "
605 "probably a dependency cycle.",
606 End
.TargetPkg().Name(),Pkg
.Name());
613 if (End
->Type
== pkgCache::Dep::Conflicts
||
614 End
->Type
== pkgCache::Dep::Obsoletes
)
616 /* Look for conflicts. Two packages that are both in the install
617 state cannot conflict so we don't check.. */
618 SPtrArray
<Version
*> VList
= End
.AllTargets();
619 for (Version
**I
= VList
; *I
!= 0; I
++)
621 VerIterator
Ver(Cache
,*I
);
622 PkgIterator ConflictPkg
= Ver
.ParentPkg();
623 VerIterator
InstallVer(Cache
,Cache
[ConflictPkg
].InstallVer
);
625 // See if the current version is conflicting
626 if (ConflictPkg
.CurrentVer() == Ver
&& !List
->IsFlag(ConflictPkg
,pkgOrderList::UnPacked
))
629 cout
<< " " << Pkg
.Name() << " conflicts with " << ConflictPkg
.Name() << endl
;
631 if (Debug
&& false) {
633 cout
<< " Checking if " << Ver
<< " of " << ConflictPkg
.Name() << " satisfies this dependancy" << endl
;
635 cout
<< " Checking if " << Ver
.VerStr() << " of " << ConflictPkg
.Name() << " satisfies this dependancy" << endl
;
638 if (ConflictPkg
.CurrentVer()==0) {
639 cout
<< " CurrentVer " << ConflictPkg
.CurrentVer() << " IsNow " << List
->IsNow(ConflictPkg
) << " NeedsNothing " << (ConflictPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
641 cout
<< " CurrentVer " << ConflictPkg
.CurrentVer().VerStr() << " IsNow " << List
->IsNow(ConflictPkg
) << " NeedsNothing " << (ConflictPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
645 cout
<< " InstallVer " << InstallVer
<< endl
;
647 cout
<< " InstallVer " << InstallVer
.VerStr() << endl
;
650 cout
<< " Keep " << Cache
[ConflictPkg
].Keep() << " Unpacked " << List
->IsFlag(ConflictPkg
,pkgOrderList::UnPacked
) << " Configured " << List
->IsFlag(ConflictPkg
,pkgOrderList::Configured
) << " Removed " << List
->IsFlag(ConflictPkg
,pkgOrderList::Removed
) << " Loop " << List
->IsFlag(ConflictPkg
,pkgOrderList::Loop
) << endl
;
651 cout
<< " Delete " << Cache
[ConflictPkg
].Delete() << endl
;
654 if (!List
->IsFlag(ConflictPkg
,pkgOrderList::Loop
)) {
655 if (Cache
[ConflictPkg
].Keep() == 0 && Cache
[ConflictPkg
].InstallVer
!= 0) {
656 cout
<< "Unpacking " << ConflictPkg
.Name() << " to prevent conflict" << endl
;
657 List
->Flag(Pkg
,pkgOrderList::Loop
);
658 SmartUnPack(ConflictPkg
,false);
660 if (EarlyRemove(ConflictPkg
) == false)
661 return _error
->Error("Internal Error, Could not early remove %s",ConflictPkg
.Name());
664 if (!List
->IsFlag(ConflictPkg
,pkgOrderList::Removed
)) {
665 cout
<< "Because of conficts knot, removing " << ConflictPkg
.Name() << " to conflict violation" << endl
;
666 if (EarlyRemove(ConflictPkg
) == false)
667 return _error
->Error("Internal Error, Could not early remove %s",ConflictPkg
.Name());
675 if (End
->Type
== pkgCache::Dep::DpkgBreaks
) {
676 SPtrArray
<Version
*> VList
= End
.AllTargets();
677 for (Version
**I
= VList
; *I
!= 0; I
++)
679 VerIterator
Ver(Cache
,*I
);
680 PkgIterator BrokenPkg
= Ver
.ParentPkg();
681 VerIterator
InstallVer(Cache
,Cache
[BrokenPkg
].InstallVer
);
683 if (Debug
&& false) {
685 cout
<< " Checking if " << Ver
<< " of " << BrokenPkg
.Name() << " satisfies this dependancy" << endl
;
687 cout
<< " Checking if " << Ver
.VerStr() << " of " << BrokenPkg
.Name() << " satisfies this dependancy" << endl
;
690 if (BrokenPkg
.CurrentVer()==0) {
691 cout
<< " CurrentVer " << BrokenPkg
.CurrentVer() << " IsNow " << List
->IsNow(BrokenPkg
) << " NeedsNothing " << (BrokenPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
693 cout
<< " CurrentVer " << BrokenPkg
.CurrentVer().VerStr() << " IsNow " << List
->IsNow(BrokenPkg
) << " NeedsNothing " << (BrokenPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
697 cout
<< " InstallVer " << InstallVer
<< endl
;
699 cout
<< " InstallVer " << InstallVer
.VerStr() << endl
;
702 cout
<< " Keep " << Cache
[BrokenPkg
].Keep() << " Unpacked " << List
->IsFlag(BrokenPkg
,pkgOrderList::UnPacked
) << " Configured " << List
->IsFlag(BrokenPkg
,pkgOrderList::Configured
) << " Removed " << List
->IsFlag(BrokenPkg
,pkgOrderList::Removed
) << " Loop " << List
->IsFlag(BrokenPkg
,pkgOrderList::Loop
) << " InList " << List
->IsFlag(BrokenPkg
,pkgOrderList::InList
) << endl
;
703 cout
<< " Delete " << Cache
[BrokenPkg
].Delete() << endl
;
705 // Check if it needs to be unpacked
706 if (List
->IsFlag(BrokenPkg
,pkgOrderList::InList
) && Cache
[BrokenPkg
].Delete() == false &&
707 !List
->IsFlag(BrokenPkg
,pkgOrderList::Loop
) && List
->IsNow(BrokenPkg
)) {
708 List
->Flag(Pkg
,pkgOrderList::Loop
);
709 // Found a break, so unpack the package
711 cout
<< " Unpacking " << BrokenPkg
.Name() << " to avoid break" << endl
;
713 SmartUnPack(BrokenPkg
, false);
715 // Check if a package needs to be removed
716 if (Cache
[BrokenPkg
].Delete() == true && !List
->IsFlag(BrokenPkg
,pkgOrderList::Configured
)) {
718 cout
<< " Removing " << BrokenPkg
.Name() << " to avoid break" << endl
;
719 SmartRemove(BrokenPkg
);
725 // FIXME: Crude but effective fix, allows the SmartUnPack method to be used for packages that new to the system
727 //cout << "Check for reverse conflicts on " << Pkg.Name() << " " << instVer.VerStr() << endl;
729 // Check for reverse conflicts.
730 if (CheckRConflicts(Pkg
,Pkg
.RevDependsList(),
731 instVer
.VerStr()) == false)
734 for (PrvIterator P
= instVer
.ProvidesList();
735 P
.end() == false; P
++)
736 CheckRConflicts(Pkg
,P
.ParentPkg().RevDependsList(),P
.ProvideVersion());
738 List
->Flag(Pkg
,pkgOrderList::UnPacked
,pkgOrderList::States
);
740 if (instVer
->MultiArch
== pkgCache::Version::Same
)
741 for (PkgIterator P
= Pkg
.Group().PackageList();
742 P
.end() == false; P
= Pkg
.Group().NextPkg(P
))
744 if (Pkg
== P
|| List
->IsFlag(P
,pkgOrderList::UnPacked
) == true ||
745 Cache
[P
].InstallVer
== 0 || (P
.CurrentVer() == Cache
[P
].InstallVer
&&
746 (Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
))
748 SmartUnPack(P
, false);
752 VerIterator
InstallVer(Cache
,Cache
[Pkg
].InstallVer
);
753 //cout << "Check for reverse conflicts on " << Pkg.Name() << " " << InstallVer.VerStr() << endl;
755 // Check for reverse conflicts.
756 if (CheckRConflicts(Pkg
,Pkg
.RevDependsList(),
757 InstallVer
.VerStr()) == false)
760 List
->Flag(Pkg
,pkgOrderList::UnPacked
,pkgOrderList::States
);
763 if(Install(Pkg
,FileNames
[Pkg
->ID
]) == false)
766 if (Immediate
== true && List
->IsFlag(Pkg
,pkgOrderList::Immediate
) == true) {
768 // Perform immedate configuration of the package.
769 if (SmartConfigure(Pkg
) == false)
770 _error
->Warning(_("Could not perform immediate configuration on '%s'. "
771 "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg
.Name(),2);
777 // PM::OrderInstall - Installation ordering routine /*{{{*/
778 // ---------------------------------------------------------------------
780 pkgPackageManager::OrderResult
pkgPackageManager::OrderInstall()
782 if (CreateOrderList() == false)
788 clog
<< "Beginning to order" << endl
;
790 bool const ordering
=
791 _config
->FindB("PackageManager::UnpackAll",true) ?
792 List
->OrderUnpack(FileNames
) : List
->OrderCritical();
793 if (ordering
== false)
795 _error
->Error("Internal ordering error");
800 clog
<< "Done ordering" << endl
;
802 bool DoneSomething
= false;
803 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
805 PkgIterator
Pkg(Cache
,*I
);
807 if (List
->IsNow(Pkg
) == false)
809 if (!List
->IsFlag(Pkg
,pkgOrderList::Configured
) && !NoImmConfigure
) {
810 if (SmartConfigure(Pkg
) == false && Debug
)
811 _error
->Warning("Internal Error, Could not configure %s",Pkg
.Name());
812 // FIXME: The above warning message might need changing
815 clog
<< "Skipping already done " << Pkg
.Name() << endl
;
821 if (List
->IsMissing(Pkg
) == true)
824 clog
<< "Sequence completed at " << Pkg
.Name() << endl
;
825 if (DoneSomething
== false)
827 _error
->Error("Internal Error, ordering was unable to handle the media swap");
834 if (Cache
[Pkg
].Keep() == true &&
835 Pkg
.State() == pkgCache::PkgIterator::NeedsNothing
&&
836 (Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
)
838 _error
->Error("Internal Error, trying to manipulate a kept package (%s)",Pkg
.Name());
842 // Perform a delete or an install
843 if (Cache
[Pkg
].Delete() == true)
845 if (SmartRemove(Pkg
) == false)
849 if (SmartUnPack(Pkg
) == false)
851 DoneSomething
= true;
853 if (ImmConfigureAll
) {
854 /* ConfigureAll here to pick up and packages left unconfigured becuase they were unpacked in the
855 "PreUnpack Checks" section */
860 // Final run through the configure phase
861 if (ConfigureAll() == false)
865 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
867 if (List
->IsFlag(*I
,pkgOrderList::Configured
) == false)
869 _error
->Error("Internal error, packages left unconfigured. %s",
870 PkgIterator(Cache
,*I
).Name());
878 // PM::DoInstallPostFork - Does install part that happens after the fork /*{{{*/
879 // ---------------------------------------------------------------------
880 pkgPackageManager::OrderResult
881 pkgPackageManager::DoInstallPostFork(int statusFd
)
884 // FIXME: use SetCloseExec here once it taught about throwing
885 // exceptions instead of doing _exit(100) on failure
886 fcntl(statusFd
,F_SETFD
,FD_CLOEXEC
);
887 bool goResult
= Go(statusFd
);
888 if(goResult
== false)
894 // PM::DoInstall - Does the installation /*{{{*/
895 // ---------------------------------------------------------------------
896 /* This uses the filenames in FileNames and the information in the
897 DepCache to perform the installation of packages.*/
898 pkgPackageManager::OrderResult
pkgPackageManager::DoInstall(int statusFd
)
900 if(DoInstallPreFork() == Failed
)
903 return DoInstallPostFork(statusFd
);