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 // PM::PackageManager - Constructor /*{{{*/
33 // ---------------------------------------------------------------------
35 pkgPackageManager::pkgPackageManager(pkgDepCache
*pCache
) : Cache(*pCache
)
37 FileNames
= new string
[Cache
.Head().PackageCount
];
39 Debug
= _config
->FindB("Debug::pkgPackageManager",false);
42 // PM::PackageManager - Destructor /*{{{*/
43 // ---------------------------------------------------------------------
45 pkgPackageManager::~pkgPackageManager()
51 // PM::GetArchives - Queue the archives for download /*{{{*/
52 // ---------------------------------------------------------------------
54 bool pkgPackageManager::GetArchives(pkgAcquire
*Owner
,pkgSourceList
*Sources
,
57 if (CreateOrderList() == false)
61 _config
->FindB("PackageManager::UnpackAll",true) ?
62 List
->OrderUnpack() : List
->OrderCritical();
63 if (ordering
== false)
64 return _error
->Error("Internal ordering error");
66 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
68 PkgIterator
Pkg(Cache
,*I
);
69 FileNames
[Pkg
->ID
] = string();
71 // Skip packages to erase
72 if (Cache
[Pkg
].Delete() == true)
75 // Skip Packages that need configure only.
76 if (Pkg
.State() == pkgCache::PkgIterator::NeedsConfigure
&&
77 Cache
[Pkg
].Keep() == true)
80 // Skip already processed packages
81 if (List
->IsNow(Pkg
) == false)
84 new pkgAcqArchive(Owner
,Sources
,Recs
,Cache
[Pkg
].InstVerIter(Cache
),
91 // PM::FixMissing - Keep all missing packages /*{{{*/
92 // ---------------------------------------------------------------------
93 /* This is called to correct the installation when packages could not
95 bool pkgPackageManager::FixMissing()
97 pkgDepCache::ActionGroup
group(Cache
);
98 pkgProblemResolver
Resolve(&Cache
);
99 List
->SetFileList(FileNames
);
102 for (PkgIterator I
= Cache
.PkgBegin(); I
.end() == false; I
++)
104 if (List
->IsMissing(I
) == false)
107 // Okay, this file is missing and we need it. Mark it for keep
109 Cache
.MarkKeep(I
, false, false);
112 // We have to empty the list otherwise it will not have the new changes
119 // Now downgrade everything that is broken
120 return Resolve
.ResolveByKeep() == true && Cache
.BrokenCount() == 0;
123 // PM::ImmediateAdd - Add the immediate flag recursivly /*{{{*/
124 // ---------------------------------------------------------------------
125 /* This adds the immediate flag to the pkg and recursively to the
128 void pkgPackageManager::ImmediateAdd(PkgIterator I
, bool UseInstallVer
, unsigned const int &Depth
)
134 if(Cache
[I
].InstallVer
== 0)
136 D
= Cache
[I
].InstVerIter(Cache
).DependsList();
138 if (I
->CurrentVer
== 0)
140 D
= I
.CurrentVer().DependsList();
143 for ( /* nothing */ ; D
.end() == false; D
++)
144 if (D
->Type
== pkgCache::Dep::Depends
|| D
->Type
== pkgCache::Dep::PreDepends
)
146 if(!List
->IsFlag(D
.TargetPkg(), pkgOrderList::Immediate
))
149 clog
<< OutputInDepth(Depth
) << "ImmediateAdd(): Adding Immediate flag to " << D
.TargetPkg() << " cause of " << D
.DepType() << " " << I
.Name() << endl
;
150 List
->Flag(D
.TargetPkg(),pkgOrderList::Immediate
);
151 ImmediateAdd(D
.TargetPkg(), UseInstallVer
, Depth
+ 1);
157 // PM::CreateOrderList - Create the ordering class /*{{{*/
158 // ---------------------------------------------------------------------
159 /* This populates the ordering list with all the packages that are
161 bool pkgPackageManager::CreateOrderList()
167 List
= new pkgOrderList(&Cache
);
169 static bool const NoImmConfigure
= !_config
->FindB("APT::Immediate-Configure",true);
171 // Generate the list of affected packages and sort it
172 for (PkgIterator I
= Cache
.PkgBegin(); I
.end() == false; I
++)
174 // Ignore no-version packages
175 if (I
->VersionList
== 0)
178 // Mark the package and its dependends for immediate configuration
179 if (((I
->Flags
& pkgCache::Flag::Essential
) == pkgCache::Flag::Essential
||
180 (I
->Flags
& pkgCache::Flag::Important
) == pkgCache::Flag::Important
) &&
181 NoImmConfigure
== false)
184 clog
<< "CreateOrderList(): Adding Immediate flag for " << I
.Name() << endl
;
185 List
->Flag(I
,pkgOrderList::Immediate
);
187 // Look for other install packages to make immediate configurea
188 ImmediateAdd(I
, true);
190 // And again with the current version.
191 ImmediateAdd(I
, false);
195 if ((Cache
[I
].Keep() == true ||
196 Cache
[I
].InstVerIter(Cache
) == I
.CurrentVer()) &&
197 I
.State() == pkgCache::PkgIterator::NeedsNothing
&&
198 (Cache
[I
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
&&
199 (I
.Purge() != false || Cache
[I
].Mode
!= pkgDepCache::ModeDelete
||
200 (Cache
[I
].iFlags
& pkgDepCache::Purge
) != pkgDepCache::Purge
))
203 // Append it to the list
210 // PM::DepAlwaysTrue - Returns true if this dep is irrelevent /*{{{*/
211 // ---------------------------------------------------------------------
212 /* The restriction on provides is to eliminate the case when provides
213 are transitioning between valid states [ie exim to smail] */
214 bool pkgPackageManager::DepAlwaysTrue(DepIterator D
)
216 if (D
.TargetPkg()->ProvidesList
!= 0)
219 if ((Cache
[D
] & pkgDepCache::DepInstall
) != 0 &&
220 (Cache
[D
] & pkgDepCache::DepNow
) != 0)
225 // PM::CheckRConflicts - Look for reverse conflicts /*{{{*/
226 // ---------------------------------------------------------------------
227 /* This looks over the reverses for a conflicts line that needs early
229 bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg
,DepIterator D
,
232 for (;D
.end() == false; D
++)
234 if (D
->Type
!= pkgCache::Dep::Conflicts
&&
235 D
->Type
!= pkgCache::Dep::Obsoletes
)
238 // The package hasnt been changed
239 if (List
->IsNow(Pkg
) == false)
242 // Ignore self conflicts, ignore conflicts from irrelevent versions
243 if (D
.ParentPkg() == Pkg
|| D
.ParentVer() != D
.ParentPkg().CurrentVer())
246 if (Cache
.VS().CheckDep(Ver
,D
->CompareOp
,D
.TargetVer()) == false)
249 if (EarlyRemove(D
.ParentPkg()) == false)
250 return _error
->Error("Reverse conflicts early remove for package '%s' failed",
256 // PM::ConfigureAll - Run the all out configuration /*{{{*/
257 // ---------------------------------------------------------------------
258 /* This configures every package. It is assumed they are all unpacked and
259 that the final configuration is valid. */
260 bool pkgPackageManager::ConfigureAll()
262 pkgOrderList
OList(&Cache
);
264 // Populate the order list
265 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
266 if (List
->IsFlag(pkgCache::PkgIterator(Cache
,*I
),
267 pkgOrderList::UnPacked
) == true)
270 if (OList
.OrderConfigure() == false)
273 std::string
const conf
= _config
->Find("PackageManager::Configure","all");
274 bool const ConfigurePkgs
= (conf
== "all");
276 // Perform the configuring
277 for (pkgOrderList::iterator I
= OList
.begin(); I
!= OList
.end(); I
++)
279 PkgIterator
Pkg(Cache
,*I
);
281 if (ConfigurePkgs
== true && VerifyAndConfigure(Pkg
,OList
) == false)
284 List
->Flag(Pkg
,pkgOrderList::Configured
,pkgOrderList::States
);
290 // PM::SmartConfigure - Perform immediate configuration of the pkg /*{{{*/
291 // ---------------------------------------------------------------------
292 /* This routine scheduals the configuration of the given package and all
293 of it's dependents. */
294 bool pkgPackageManager::SmartConfigure(PkgIterator Pkg
)
297 clog
<< "SmartConfigure " << Pkg
.Name() << endl
;
299 pkgOrderList
OList(&Cache
);
301 if (DepAdd(OList
,Pkg
) == false)
304 static std::string
const conf
= _config
->Find("PackageManager::Configure","all");
305 static bool const ConfigurePkgs
= (conf
== "all" || conf
== "smart");
307 if (ConfigurePkgs
== true)
308 if (OList
.OrderConfigure() == false)
311 // Perform the configuring
312 for (pkgOrderList::iterator I
= OList
.begin(); I
!= OList
.end(); I
++)
314 PkgIterator
Pkg(Cache
,*I
);
316 if (ConfigurePkgs
== true && VerifyAndConfigure(Pkg
,OList
) == false)
319 List
->Flag(Pkg
,pkgOrderList::Configured
,pkgOrderList::States
);
322 if (Cache
[Pkg
].InstVerIter(Cache
)->MultiArch
== pkgCache::Version::Same
)
323 for (PkgIterator P
= Pkg
.Group().PackageList();
324 P
.end() == false; P
= Pkg
.Group().NextPkg(P
))
326 if (Pkg
== P
|| List
->IsFlag(P
,pkgOrderList::Configured
) == true ||
327 Cache
[P
].InstallVer
== 0 || (P
.CurrentVer() == Cache
[P
].InstallVer
&&
328 (Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
))
334 if (List
->IsFlag(Pkg
,pkgOrderList::Configured
) == false)
335 return _error
->Error(_("Could not perform immediate configuration on '%s'. "
336 "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg
.Name(),1);
341 // PM::VerifyConfigure - Check configuration of dependancies /*{{{*/
342 // ---------------------------------------------------------------------
343 /* This routine checks that all a packages dependancies have been
344 configured, before it is going to be configured. If this gives a warning
345 on a virtual package, it means that the package thats providing it is not
347 bool pkgPackageManager::VerifyConfigure(PkgIterator Pkg
, pkgOrderList
&OList
)
349 // If this is true at the end, then the package should not be configured
351 // This holds the the OR status of the previous dependancy
352 bool previousOr
=false;
354 // First iterate through the dependancies of Pkg
355 for (DepIterator D
= Cache
[Pkg
].InstVerIter(Cache
).DependsList(); D
.end() == false; D
++)
358 /* If the dependancy is of type Depends or PreDepends, we need to check it, but only if it is going to be
359 configured at some point */
360 if (D
->Type
== pkgCache::Dep::Depends
|| D
->Type
== pkgCache::Dep::PreDepends
) {
362 /* If the previous package and this package are OR dependancies, and the previous package satisfied the dependancy
363 then skip this dependancy as it is not relevent, this will repeat for the next package if the situation is the
365 if (previousOr
&& !error
) { // As error has not been reset, this refers to the previous dependancy
366 previousOr
= (D
->CompareOp
& pkgCache::Dep::Or
) == pkgCache::Dep::Or
;
373 // Check thorugh all possible versions of this dependancy (D)
374 SPtrArray
<Version
*> VList
= D
.AllTargets();
375 for (Version
**I
= VList
; *I
!= 0; I
++)
377 VerIterator
DepVer(Cache
,*I
);
378 PkgIterator DepPkg
= DepVer
.ParentPkg();
379 VerIterator
DepInstallVer(Cache
,Cache
[DepPkg
].InstallVer
);
381 if (DepPkg
.CurrentVer() == DepVer
&& !List
->IsFlag(DepPkg
,pkgOrderList::UnPacked
)) {
386 if (Cache
[DepPkg
].InstallVer
== DepVer
&&
387 (List
->IsFlag(DepPkg
,pkgOrderList::Configured
) || OList
.IsFlag(DepPkg
,pkgOrderList::InList
))) {
393 /* Only worry here if this package is a OR with the next, as even though this package does not satisfy the OR
394 the next one might */
395 if (error
&& !((D
->CompareOp
& pkgCache::Dep::Or
) == pkgCache::Dep::Or
)) {
396 _error
->Error("Package %s should not be configured because package %s is not configured",Pkg
.Name(),D
.TargetPkg().Name());
398 /* If the previous package is a OR but not this package, but there is still an error then fail as it will not
400 } else if (error
&& previousOr
&& !((D
->CompareOp
& pkgCache::Dep::Or
) == pkgCache::Dep::Or
)) {
401 _error
->Error("Package %s should not be configured because package %s (or any alternatives) are not configured",Pkg
.Name(),D
.TargetPkg().Name());
405 previousOr
= (D
->CompareOp
& pkgCache::Dep::Or
) == pkgCache::Dep::Or
;
413 // PM::VerifyAndConfigure - Check configuration of dependancies /*{{{*/
414 // ---------------------------------------------------------------------
415 /* This routine verifies if a package can be configured and if so
417 bool pkgPackageManager::VerifyAndConfigure(PkgIterator Pkg
, pkgOrderList
&OList
)
419 if (VerifyConfigure(Pkg
, OList
))
420 return Configure(Pkg
);
426 // PM::DepAdd - Add all dependents to the oder list /*{{{*/
427 // ---------------------------------------------------------------------
428 /* This recursively adds all dependents to the order list */
429 bool pkgPackageManager::DepAdd(pkgOrderList
&OList
,PkgIterator Pkg
,int Depth
)
431 if (OList
.IsFlag(Pkg
,pkgOrderList::Added
) == true)
433 if (List
->IsFlag(Pkg
,pkgOrderList::Configured
) == true)
435 if (List
->IsFlag(Pkg
,pkgOrderList::UnPacked
) == false)
439 std::clog
<< OutputInDepth(Depth
) << "DepAdd: " << Pkg
.Name() << std::endl
;
441 // Put the package on the list
442 OList
.push_back(Pkg
);
443 OList
.Flag(Pkg
,pkgOrderList::Added
);
446 // Check the dependencies to see if they are all satisfied.
448 for (DepIterator D
= Cache
[Pkg
].InstVerIter(Cache
).DependsList(); D
.end() == false;)
450 if (D
->Type
!= pkgCache::Dep::Depends
&& D
->Type
!= pkgCache::Dep::PreDepends
)
458 for (bool LastOR
= true; D
.end() == false && LastOR
== true; D
++)
460 LastOR
= (D
->CompareOp
& pkgCache::Dep::Or
) == pkgCache::Dep::Or
;
465 SPtrArray
<Version
*> VList
= D
.AllTargets();
466 for (Version
**I
= VList
; *I
!= 0 && Bad
== true; I
++)
468 VerIterator
Ver(Cache
,*I
);
469 PkgIterator Pkg
= Ver
.ParentPkg();
471 // See if the current version is ok
472 if (Pkg
.CurrentVer() == Ver
&& List
->IsNow(Pkg
) == true &&
473 Pkg
.State() == PkgIterator::NeedsNothing
)
479 // Check if this package is being re-installed
480 if ((Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) == pkgDepCache::ReInstall
&& Cache
[Pkg
].InstallVer
!= *I
&&
481 List
->IsNow(Pkg
) == true && Pkg
.State() == PkgIterator::NeedsNothing
) {
486 // Not the install version
487 if (Cache
[Pkg
].InstallVer
!= *I
||
488 (Cache
[Pkg
].Keep() == true && Pkg
.State() == PkgIterator::NeedsNothing
))
491 if (List
->IsFlag(Pkg
,pkgOrderList::UnPacked
) == true)
492 Bad
= !DepAdd(OList
,Pkg
,Depth
);
493 if (List
->IsFlag(Pkg
,pkgOrderList::Configured
) == true)
501 std::clog
<< OutputInDepth(Depth
) << "DepAdd FAILS on: " << Pkg
.Name() << std::endl
;
502 OList
.Flag(Pkg
,0,pkgOrderList::Added
);
513 // PM::EarlyRemove - Perform removal of packages before their time /*{{{*/
514 // ---------------------------------------------------------------------
515 /* This is called to deal with conflicts arising from unpacking */
516 bool pkgPackageManager::EarlyRemove(PkgIterator Pkg
)
518 if (List
->IsNow(Pkg
) == false)
521 // Already removed it
522 if (List
->IsFlag(Pkg
,pkgOrderList::Removed
) == true)
525 // Woops, it will not be re-installed!
526 if (List
->IsFlag(Pkg
,pkgOrderList::InList
) == false)
529 // Essential packages get special treatment
530 bool IsEssential
= false;
531 if ((Pkg
->Flags
& pkgCache::Flag::Essential
) != 0)
534 /* Check for packages that are the dependents of essential packages and
536 if (Pkg
->CurrentVer
!= 0)
538 for (DepIterator D
= Pkg
.RevDependsList(); D
.end() == false &&
539 IsEssential
== false; D
++)
540 if (D
->Type
== pkgCache::Dep::Depends
|| D
->Type
== pkgCache::Dep::PreDepends
)
541 if ((D
.ParentPkg()->Flags
& pkgCache::Flag::Essential
) != 0)
545 if (IsEssential
== true)
547 if (_config
->FindB("APT::Force-LoopBreak",false) == false)
548 return _error
->Error(_("This installation run will require temporarily "
549 "removing the essential package %s due to a "
550 "Conflicts/Pre-Depends loop. This is often bad, "
551 "but if you really want to do it, activate the "
552 "APT::Force-LoopBreak option."),Pkg
.Name());
555 bool Res
= SmartRemove(Pkg
);
556 if (Cache
[Pkg
].Delete() == false)
557 List
->Flag(Pkg
,pkgOrderList::Removed
,pkgOrderList::States
);
562 // PM::SmartRemove - Removal Helper /*{{{*/
563 // ---------------------------------------------------------------------
565 bool pkgPackageManager::SmartRemove(PkgIterator Pkg
)
567 if (List
->IsNow(Pkg
) == false)
570 List
->Flag(Pkg
,pkgOrderList::Configured
,pkgOrderList::States
);
572 return Remove(Pkg
,(Cache
[Pkg
].iFlags
& pkgDepCache::Purge
) == pkgDepCache::Purge
);
576 // PM::SmartUnPack - Install helper /*{{{*/
577 // ---------------------------------------------------------------------
578 /* This performs the task of handling pre-depends. */
579 bool pkgPackageManager::SmartUnPack(PkgIterator Pkg
)
581 return SmartUnPack(Pkg
, true);
583 bool pkgPackageManager::SmartUnPack(PkgIterator Pkg
, bool const Immediate
)
586 clog
<< "SmartUnPack " << Pkg
.Name() << endl
;
588 // Check if it is already unpacked
589 if (Pkg
.State() == pkgCache::PkgIterator::NeedsConfigure
&&
590 Cache
[Pkg
].Keep() == true)
592 List
->Flag(Pkg
,pkgOrderList::UnPacked
,pkgOrderList::States
);
593 if (Immediate
== true &&
594 List
->IsFlag(Pkg
,pkgOrderList::Immediate
) == true)
595 if (SmartConfigure(Pkg
) == false)
596 return _error
->Error(_("Could not perform immediate configuration on already unpacked '%s'. "
597 "Please see man 5 apt.conf under APT::Immediate-Configure for details."),Pkg
.Name());
601 VerIterator
const instVer
= Cache
[Pkg
].InstVerIter(Cache
);
603 /* See if this packages install version has any predependencies
604 that are not met by 'now' packages. */
605 for (DepIterator D
= instVer
.DependsList();
608 // Compute a single dependency element (glob or)
609 pkgCache::DepIterator Start
;
610 pkgCache::DepIterator End
;
613 while (End
->Type
== pkgCache::Dep::PreDepends
)
616 clog
<< "PreDepends order for " << Pkg
.Name() << std::endl
;
618 // Look for possible ok targets.
619 SPtrArray
<Version
*> VList
= Start
.AllTargets();
621 for (Version
**I
= VList
; *I
!= 0 && Bad
== true; I
++)
623 VerIterator
Ver(Cache
,*I
);
624 PkgIterator Pkg
= Ver
.ParentPkg();
626 // See if the current version is ok
627 if (Pkg
.CurrentVer() == Ver
&& List
->IsNow(Pkg
) == true &&
628 Pkg
.State() == PkgIterator::NeedsNothing
)
632 clog
<< "Found ok package " << Pkg
.Name() << endl
;
637 // Look for something that could be configured.
638 for (Version
**I
= VList
; *I
!= 0 && Bad
== true; I
++)
640 VerIterator
Ver(Cache
,*I
);
641 PkgIterator Pkg
= Ver
.ParentPkg();
643 // Not the install version
644 if (Cache
[Pkg
].InstallVer
!= *I
||
645 (Cache
[Pkg
].Keep() == true && Pkg
.State() == PkgIterator::NeedsNothing
))
649 clog
<< "Trying to SmartConfigure " << Pkg
.Name() << endl
;
650 Bad
= !SmartConfigure(Pkg
);
653 /* If this or element did not match then continue on to the
654 next or element until a matching element is found */
657 // This triggers if someone make a pre-depends/depend loop.
659 return _error
->Error("Couldn't configure pre-depend %s for %s, "
660 "probably a dependency cycle.",
661 End
.TargetPkg().Name(),Pkg
.Name());
668 if (End
->Type
== pkgCache::Dep::Conflicts
||
669 End
->Type
== pkgCache::Dep::Obsoletes
)
671 /* Look for conflicts. Two packages that are both in the install
672 state cannot conflict so we don't check.. */
673 SPtrArray
<Version
*> VList
= End
.AllTargets();
674 for (Version
**I
= VList
; *I
!= 0; I
++)
676 VerIterator
Ver(Cache
,*I
);
677 PkgIterator Pkg
= Ver
.ParentPkg();
679 // See if the current version is conflicting
680 if (Pkg
.CurrentVer() == Ver
&& List
->IsNow(Pkg
) == true)
682 if (EarlyRemove(Pkg
) == false)
683 return _error
->Error("Internal Error, Could not early remove %s",Pkg
.Name());
689 if (End
->Type
== pkgCache::Dep::DpkgBreaks
) {
690 SPtrArray
<Version
*> VList
= End
.AllTargets();
691 for (Version
**I
= VList
; *I
!= 0; I
++)
693 VerIterator
Ver(Cache
,*I
);
694 PkgIterator Pkg
= Ver
.ParentPkg();
695 // Check if it needs to be unpacked
696 if (List
->IsFlag(Pkg
,pkgOrderList::InList
) && Cache
[Pkg
].Delete() == false) {
697 // Found a break, so unpack the package
698 SmartUnPack(Pkg
, false);
704 // Check for reverse conflicts.
705 if (CheckRConflicts(Pkg
,Pkg
.RevDependsList(),
706 instVer
.VerStr()) == false)
709 for (PrvIterator P
= instVer
.ProvidesList();
710 P
.end() == false; P
++)
711 CheckRConflicts(Pkg
,P
.ParentPkg().RevDependsList(),P
.ProvideVersion());
713 List
->Flag(Pkg
,pkgOrderList::UnPacked
,pkgOrderList::States
);
715 if (instVer
->MultiArch
== pkgCache::Version::Same
)
716 for (PkgIterator P
= Pkg
.Group().PackageList();
717 P
.end() == false; P
= Pkg
.Group().NextPkg(P
))
719 if (Pkg
== P
|| List
->IsFlag(P
,pkgOrderList::UnPacked
) == true ||
720 Cache
[P
].InstallVer
== 0 || (P
.CurrentVer() == Cache
[P
].InstallVer
&&
721 (Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
))
723 SmartUnPack(P
, false);
726 if(Install(Pkg
,FileNames
[Pkg
->ID
]) == false)
729 // Perform immedate configuration of the package.
730 if (Immediate
== true &&
731 List
->IsFlag(Pkg
,pkgOrderList::Immediate
) == true)
732 if (SmartConfigure(Pkg
) == false)
733 return _error
->Error(_("Could not perform immediate configuration on '%s'. "
734 "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg
.Name(),2);
739 // PM::OrderInstall - Installation ordering routine /*{{{*/
740 // ---------------------------------------------------------------------
742 pkgPackageManager::OrderResult
pkgPackageManager::OrderInstall()
744 if (CreateOrderList() == false)
750 clog
<< "Beginning to order" << endl
;
752 bool const ordering
=
753 _config
->FindB("PackageManager::UnpackAll",true) ?
754 List
->OrderUnpack(FileNames
) : List
->OrderCritical();
755 if (ordering
== false)
757 _error
->Error("Internal ordering error");
762 clog
<< "Done ordering" << endl
;
764 bool DoneSomething
= false;
765 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
767 PkgIterator
Pkg(Cache
,*I
);
769 if (List
->IsNow(Pkg
) == false)
772 clog
<< "Skipping already done " << Pkg
.Name() << endl
;
776 if (List
->IsMissing(Pkg
) == true)
779 clog
<< "Sequence completed at " << Pkg
.Name() << endl
;
780 if (DoneSomething
== false)
782 _error
->Error("Internal Error, ordering was unable to handle the media swap");
789 if (Cache
[Pkg
].Keep() == true &&
790 Pkg
.State() == pkgCache::PkgIterator::NeedsNothing
&&
791 (Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
)
793 _error
->Error("Internal Error, trying to manipulate a kept package (%s)",Pkg
.Name());
797 // Perform a delete or an install
798 if (Cache
[Pkg
].Delete() == true)
800 if (SmartRemove(Pkg
) == false)
804 if (SmartUnPack(Pkg
) == false)
806 DoneSomething
= true;
809 // Final run through the configure phase
810 if (ConfigureAll() == false)
814 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
816 if (List
->IsFlag(*I
,pkgOrderList::Configured
) == false)
818 _error
->Error("Internal error, packages left unconfigured. %s",
819 PkgIterator(Cache
,*I
).Name());
827 // PM::DoInstallPostFork - Does install part that happens after the fork /*{{{*/
828 // ---------------------------------------------------------------------
829 pkgPackageManager::OrderResult
830 pkgPackageManager::DoInstallPostFork(int statusFd
)
833 // FIXME: use SetCloseExec here once it taught about throwing
834 // exceptions instead of doing _exit(100) on failure
835 fcntl(statusFd
,F_SETFD
,FD_CLOEXEC
);
836 bool goResult
= Go(statusFd
);
837 if(goResult
== false)
843 // PM::DoInstall - Does the installation /*{{{*/
844 // ---------------------------------------------------------------------
845 /* This uses the filenames in FileNames and the information in the
846 DepCache to perform the installation of packages.*/
847 pkgPackageManager::OrderResult
pkgPackageManager::DoInstall(int statusFd
)
849 if(DoInstallPreFork() == Failed
)
852 return DoInstallPostFork(statusFd
);