]>
git.saurik.com Git - apt.git/blob - apt-pkg/packagemanager.cc
8bcf3d884f2a92b88dea78c00bce4fb1276cdca4
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 if (ConfigurePkgs
== true && SmartConfigure(Pkg
) == false) {
291 _error
->Error("Internal error, packages left unconfigured. %s",Pkg
.Name());
295 List
->Flag(Pkg
,pkgOrderList::Configured
,pkgOrderList::States
);
301 // PM::SmartConfigure - Perform immediate configuration of the pkg /*{{{*/
302 // ---------------------------------------------------------------------
303 /* This routine trys to put the system in a state where Pkg can be configured,
304 this involves checking each of Pkg's dependanies and unpacking and
305 configuring packages where needed. */
306 bool pkgPackageManager::SmartConfigure(PkgIterator Pkg
)
309 clog
<< "SmartConfigure " << Pkg
.Name() << endl
;
311 VerIterator
const instVer
= Cache
[Pkg
].InstVerIter(Cache
);
313 /* Because of the ordered list, most dependancies should be unpacked,
314 however if there is a loop this is not the case, so check for dependancies before configuring.
315 This is done after the package installation as it makes it easier to deal with conflicts problems */
317 for (DepIterator D
= instVer
.DependsList();
320 // Compute a single dependency element (glob or)
321 pkgCache::DepIterator Start
;
322 pkgCache::DepIterator End
;
325 if (End
->Type
== pkgCache::Dep::Depends
)
328 // Check for dependanices that have not been unpacked, probably due to loops.
329 while (End
->Type
== pkgCache::Dep::Depends
) {
331 VerIterator InstallVer
;
332 SPtrArray
<Version
*> VList
= Start
.AllTargets();
334 for (Version
**I
= VList
; *I
!= 0; I
++) {
335 VerIterator
Ver(Cache
,*I
);
336 DepPkg
= Ver
.ParentPkg();
340 InstallVer
= VerIterator(Cache
,Cache
[DepPkg
].InstallVer
);
341 //VerIterator CandVer(Cache,Cache[DepPkg].CandidateVer);
343 if (Debug
&& false) {
345 cout
<< " Checking if " << Ver
<< " of " << DepPkg
.Name() << " satisfies this dependancy" << endl
;
347 cout
<< " Checking if " << Ver
.VerStr() << " of " << DepPkg
.Name() << " satisfies this dependancy" << endl
;
350 if (DepPkg
.CurrentVer()==0) {
351 cout
<< " CurrentVer " << DepPkg
.CurrentVer() << " IsNow " << List
->IsNow(DepPkg
) << " NeedsNothing " << (DepPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
353 cout
<< " CurrentVer " << DepPkg
.CurrentVer().VerStr() << " IsNow " << List
->IsNow(DepPkg
) << " NeedsNothing " << (DepPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
357 cout
<< " InstallVer " << InstallVer
<< endl
;
359 cout
<< " InstallVer " << InstallVer
.VerStr() << endl
;
362 // cout << " CandVer " << CandVer.VerStr() << endl;
364 cout
<< " Keep " << Cache
[DepPkg
].Keep() << " Unpacked " << List
->IsFlag(DepPkg
,pkgOrderList::UnPacked
) << " Configured " << List
->IsFlag(DepPkg
,pkgOrderList::Configured
) << endl
;
368 // Check if it satisfies this dependancy
369 if (DepPkg
.CurrentVer() == Ver
&& List
->IsNow(DepPkg
) == true &&
370 DepPkg
.State() == PkgIterator::NeedsNothing
)
376 if (Cache
[DepPkg
].InstallVer
== *I
) {
377 if (List
->IsFlag(DepPkg
,pkgOrderList::UnPacked
)) {
378 if (!List
->IsFlag(DepPkg
,pkgOrderList::Loop
)) {
379 List
->Flag(Pkg
,pkgOrderList::Loop
);
380 Bad
= !SmartConfigure(DepPkg
);
384 } else if (List
->IsFlag(DepPkg
,pkgOrderList::Configured
)) {
391 if (InstallVer
!= 0 && Bad
) {
393 List
->Flag(Pkg
,pkgOrderList::Loop
);
394 if (!List
->IsFlag(DepPkg
,pkgOrderList::Loop
)) {
396 cout
<< " Unpacking " << DepPkg
.Name() << " to avoid loop" << endl
;
397 SmartUnPack(DepPkg
, true);
403 if (!List
->IsFlag(DepPkg
,pkgOrderList::Loop
)) {
404 _error
->Warning("Could not satisfy dependancies for %s",Pkg
.Name());
415 static std::string
const conf
= _config
->Find("PackageManager::Configure","all");
416 static bool const ConfigurePkgs
= (conf
== "all" || conf
== "smart");
418 if (ConfigurePkgs
== true && Configure(Pkg
) == false)
421 List
->Flag(Pkg
,pkgOrderList::Configured
,pkgOrderList::States
);
423 if (Cache
[Pkg
].InstVerIter(Cache
)->MultiArch
== pkgCache::Version::Same
)
424 for (PkgIterator P
= Pkg
.Group().PackageList();
425 P
.end() == false; P
= Pkg
.Group().NextPkg(P
))
427 if (Pkg
== P
|| List
->IsFlag(P
,pkgOrderList::Configured
) == true ||
428 Cache
[P
].InstallVer
== 0 || (P
.CurrentVer() == Cache
[P
].InstallVer
&&
429 (Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
))
435 if (List
->IsFlag(Pkg
,pkgOrderList::Configured
) == false && Debug
)
436 _error
->Warning(_("Could not perform immediate configuration on '%s'. "
437 "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg
.Name(),1);
442 // PM::EarlyRemove - Perform removal of packages before their time /*{{{*/
443 // ---------------------------------------------------------------------
444 /* This is called to deal with conflicts arising from unpacking */
445 bool pkgPackageManager::EarlyRemove(PkgIterator Pkg
)
447 if (List
->IsNow(Pkg
) == false)
450 // Already removed it
451 if (List
->IsFlag(Pkg
,pkgOrderList::Removed
) == true)
454 // Woops, it will not be re-installed!
455 if (List
->IsFlag(Pkg
,pkgOrderList::InList
) == false)
458 // Essential packages get special treatment
459 bool IsEssential
= false;
460 if ((Pkg
->Flags
& pkgCache::Flag::Essential
) != 0)
463 /* Check for packages that are the dependents of essential packages and
465 if (Pkg
->CurrentVer
!= 0)
467 for (DepIterator D
= Pkg
.RevDependsList(); D
.end() == false &&
468 IsEssential
== false; D
++)
469 if (D
->Type
== pkgCache::Dep::Depends
|| D
->Type
== pkgCache::Dep::PreDepends
)
470 if ((D
.ParentPkg()->Flags
& pkgCache::Flag::Essential
) != 0)
474 if (IsEssential
== true)
476 if (_config
->FindB("APT::Force-LoopBreak",false) == false)
477 return _error
->Error(_("This installation run will require temporarily "
478 "removing the essential package %s due to a "
479 "Conflicts/Pre-Depends loop. This is often bad, "
480 "but if you really want to do it, activate the "
481 "APT::Force-LoopBreak option."),Pkg
.Name());
484 bool Res
= SmartRemove(Pkg
);
485 if (Cache
[Pkg
].Delete() == false)
486 List
->Flag(Pkg
,pkgOrderList::Removed
,pkgOrderList::States
);
491 // PM::SmartRemove - Removal Helper /*{{{*/
492 // ---------------------------------------------------------------------
494 bool pkgPackageManager::SmartRemove(PkgIterator Pkg
)
496 if (List
->IsNow(Pkg
) == false)
499 List
->Flag(Pkg
,pkgOrderList::Configured
,pkgOrderList::States
);
501 return Remove(Pkg
,(Cache
[Pkg
].iFlags
& pkgDepCache::Purge
) == pkgDepCache::Purge
);
505 // PM::SmartUnPack - Install helper /*{{{*/
506 // ---------------------------------------------------------------------
507 /* This puts the system in a state where it can Unpack Pkg, if Pkg is allready
508 unpacked, or when it has been unpacked, if Immediate==true it configures it. */
509 bool pkgPackageManager::SmartUnPack(PkgIterator Pkg
)
511 return SmartUnPack(Pkg
, true);
513 bool pkgPackageManager::SmartUnPack(PkgIterator Pkg
, bool const Immediate
)
516 clog
<< "SmartUnPack " << Pkg
.Name() << endl
;
518 // Check if it is already unpacked
519 if (Pkg
.State() == pkgCache::PkgIterator::NeedsConfigure
&&
520 Cache
[Pkg
].Keep() == true)
522 List
->Flag(Pkg
,pkgOrderList::UnPacked
,pkgOrderList::States
);
523 if (Immediate
== true &&
524 List
->IsFlag(Pkg
,pkgOrderList::Immediate
) == true)
525 if (SmartConfigure(Pkg
) == false)
526 _error
->Warning(_("Could not perform immediate configuration on already unpacked '%s'. "
527 "Please see man 5 apt.conf under APT::Immediate-Configure for details."),Pkg
.Name());
531 VerIterator
const instVer
= Cache
[Pkg
].InstVerIter(Cache
);
533 /* PreUnpack Checks: This loop checks and attemps to rectify and problems that would prevent the package being unpacked.
534 It addresses: PreDepends, Conflicts, Obsoletes and DpkgBreaks. Any resolutions that do not require it should
535 avoid configuration (calling SmartUnpack with Immediate=true), this is because any loops before Pkg is unpacked
536 can cause problems. This will be either dealt with if the package is configured as a dependancy of
537 Pkg (if and when Pkg is configured), or by the ConfigureAll call at the end of the for loop in OrderInstall. */
538 for (DepIterator D
= instVer
.DependsList();
541 // Compute a single dependency element (glob or)
542 pkgCache::DepIterator Start
;
543 pkgCache::DepIterator End
;
546 while (End
->Type
== pkgCache::Dep::PreDepends
)
549 clog
<< "PreDepends order for " << Pkg
.Name() << std::endl
;
551 // Look for possible ok targets.
552 SPtrArray
<Version
*> VList
= Start
.AllTargets();
554 for (Version
**I
= VList
; *I
!= 0 && Bad
== true; I
++)
556 VerIterator
Ver(Cache
,*I
);
557 PkgIterator Pkg
= Ver
.ParentPkg();
559 // See if the current version is ok
560 if (Pkg
.CurrentVer() == Ver
&& List
->IsNow(Pkg
) == true &&
561 Pkg
.State() == PkgIterator::NeedsNothing
)
565 clog
<< "Found ok package " << Pkg
.Name() << endl
;
570 // Look for something that could be configured.
571 for (Version
**I
= VList
; *I
!= 0 && Bad
== true; I
++)
573 VerIterator
Ver(Cache
,*I
);
574 PkgIterator Pkg
= Ver
.ParentPkg();
576 // Not the install version
577 if (Cache
[Pkg
].InstallVer
!= *I
||
578 (Cache
[Pkg
].Keep() == true && Pkg
.State() == PkgIterator::NeedsNothing
))
582 clog
<< "Trying to SmartConfigure " << Pkg
.Name() << endl
;
583 Bad
= !SmartConfigure(Pkg
);
586 /* If this or element did not match then continue on to the
587 next or element until a matching element is found */
590 // This triggers if someone make a pre-depends/depend loop.
592 return _error
->Error("Couldn't configure pre-depend %s for %s, "
593 "probably a dependency cycle.",
594 End
.TargetPkg().Name(),Pkg
.Name());
601 if (End
->Type
== pkgCache::Dep::Conflicts
||
602 End
->Type
== pkgCache::Dep::Obsoletes
)
604 /* Look for conflicts. Two packages that are both in the install
605 state cannot conflict so we don't check.. */
606 SPtrArray
<Version
*> VList
= End
.AllTargets();
607 for (Version
**I
= VList
; *I
!= 0; I
++)
609 VerIterator
Ver(Cache
,*I
);
610 PkgIterator ConflictPkg
= Ver
.ParentPkg();
611 VerIterator
InstallVer(Cache
,Cache
[ConflictPkg
].InstallVer
);
613 // See if the current version is conflicting
614 if (ConflictPkg
.CurrentVer() == Ver
&& !List
->IsFlag(ConflictPkg
,pkgOrderList::UnPacked
))
617 cout
<< " " << Pkg
.Name() << " conflicts with " << ConflictPkg
.Name() << endl
;
619 if (Debug
&& false) {
621 cout
<< " Checking if " << Ver
<< " of " << ConflictPkg
.Name() << " satisfies this dependancy" << endl
;
623 cout
<< " Checking if " << Ver
.VerStr() << " of " << ConflictPkg
.Name() << " satisfies this dependancy" << endl
;
626 if (ConflictPkg
.CurrentVer()==0) {
627 cout
<< " CurrentVer " << ConflictPkg
.CurrentVer() << " IsNow " << List
->IsNow(ConflictPkg
) << " NeedsNothing " << (ConflictPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
629 cout
<< " CurrentVer " << ConflictPkg
.CurrentVer().VerStr() << " IsNow " << List
->IsNow(ConflictPkg
) << " NeedsNothing " << (ConflictPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
633 cout
<< " InstallVer " << InstallVer
<< endl
;
635 cout
<< " InstallVer " << InstallVer
.VerStr() << endl
;
638 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
;
639 cout
<< " Delete " << Cache
[ConflictPkg
].Delete() << endl
;
642 if (!List
->IsFlag(ConflictPkg
,pkgOrderList::Loop
)) {
643 if (Cache
[ConflictPkg
].Keep() == 0 && Cache
[ConflictPkg
].InstallVer
!= 0) {
644 cout
<< "Unpacking " << ConflictPkg
.Name() << " to prevent conflict" << endl
;
645 List
->Flag(Pkg
,pkgOrderList::Loop
);
646 SmartUnPack(ConflictPkg
,false);
648 if (EarlyRemove(ConflictPkg
) == false)
649 return _error
->Error("Internal Error, Could not early remove %s",ConflictPkg
.Name());
652 if (!List
->IsFlag(ConflictPkg
,pkgOrderList::Removed
)) {
653 cout
<< "Because of conficts knot, removing " << ConflictPkg
.Name() << " to conflict violation" << endl
;
654 if (EarlyRemove(ConflictPkg
) == false)
655 return _error
->Error("Internal Error, Could not early remove %s",ConflictPkg
.Name());
663 if (End
->Type
== pkgCache::Dep::DpkgBreaks
) {
664 SPtrArray
<Version
*> VList
= End
.AllTargets();
665 for (Version
**I
= VList
; *I
!= 0; I
++)
667 VerIterator
Ver(Cache
,*I
);
668 PkgIterator BrokenPkg
= Ver
.ParentPkg();
669 VerIterator
InstallVer(Cache
,Cache
[BrokenPkg
].InstallVer
);
671 if (Debug
&& false) {
673 cout
<< " Checking if " << Ver
<< " of " << BrokenPkg
.Name() << " satisfies this dependancy" << endl
;
675 cout
<< " Checking if " << Ver
.VerStr() << " of " << BrokenPkg
.Name() << " satisfies this dependancy" << endl
;
678 if (BrokenPkg
.CurrentVer()==0) {
679 cout
<< " CurrentVer " << BrokenPkg
.CurrentVer() << " IsNow " << List
->IsNow(BrokenPkg
) << " NeedsNothing " << (BrokenPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
681 cout
<< " CurrentVer " << BrokenPkg
.CurrentVer().VerStr() << " IsNow " << List
->IsNow(BrokenPkg
) << " NeedsNothing " << (BrokenPkg
.State() == PkgIterator::NeedsNothing
) << endl
;
685 cout
<< " InstallVer " << InstallVer
<< endl
;
687 cout
<< " InstallVer " << InstallVer
.VerStr() << endl
;
690 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
;
691 cout
<< " Delete " << Cache
[BrokenPkg
].Delete() << endl
;
693 // Check if it needs to be unpacked
694 if (List
->IsFlag(BrokenPkg
,pkgOrderList::InList
) && Cache
[BrokenPkg
].Delete() == false &&
695 !List
->IsFlag(BrokenPkg
,pkgOrderList::Loop
) && List
->IsNow(BrokenPkg
)) {
696 List
->Flag(Pkg
,pkgOrderList::Loop
);
697 // Found a break, so unpack the package
699 cout
<< " Unpacking " << BrokenPkg
.Name() << " to avoid break" << endl
;
701 SmartUnPack(BrokenPkg
, false);
703 // Check if a package needs to be removed
704 if (Cache
[BrokenPkg
].Delete() == true && !List
->IsFlag(BrokenPkg
,pkgOrderList::Configured
)) {
706 cout
<< " Removing " << BrokenPkg
.Name() << " to avoid break" << endl
;
707 SmartRemove(BrokenPkg
);
713 // FIXME: Crude but effective fix, allows the SmartUnPack method to be used for packages that new to the system
715 //cout << "Check for reverse conflicts on " << Pkg.Name() << " " << instVer.VerStr() << endl;
717 // Check for reverse conflicts.
718 if (CheckRConflicts(Pkg
,Pkg
.RevDependsList(),
719 instVer
.VerStr()) == false)
722 for (PrvIterator P
= instVer
.ProvidesList();
723 P
.end() == false; P
++)
724 CheckRConflicts(Pkg
,P
.ParentPkg().RevDependsList(),P
.ProvideVersion());
726 List
->Flag(Pkg
,pkgOrderList::UnPacked
,pkgOrderList::States
);
728 if (instVer
->MultiArch
== pkgCache::Version::Same
)
729 for (PkgIterator P
= Pkg
.Group().PackageList();
730 P
.end() == false; P
= Pkg
.Group().NextPkg(P
))
732 if (Pkg
== P
|| List
->IsFlag(P
,pkgOrderList::UnPacked
) == true ||
733 Cache
[P
].InstallVer
== 0 || (P
.CurrentVer() == Cache
[P
].InstallVer
&&
734 (Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
))
736 SmartUnPack(P
, false);
740 VerIterator
InstallVer(Cache
,Cache
[Pkg
].InstallVer
);
741 //cout << "Check for reverse conflicts on " << Pkg.Name() << " " << InstallVer.VerStr() << endl;
743 // Check for reverse conflicts.
744 if (CheckRConflicts(Pkg
,Pkg
.RevDependsList(),
745 InstallVer
.VerStr()) == false)
748 List
->Flag(Pkg
,pkgOrderList::UnPacked
,pkgOrderList::States
);
751 if(Install(Pkg
,FileNames
[Pkg
->ID
]) == false)
754 if (Immediate
== true && List
->IsFlag(Pkg
,pkgOrderList::Immediate
) == true) {
756 // Perform immedate configuration of the package.
757 if (SmartConfigure(Pkg
) == false)
758 _error
->Warning(_("Could not perform immediate configuration on '%s'. "
759 "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg
.Name(),2);
765 // PM::OrderInstall - Installation ordering routine /*{{{*/
766 // ---------------------------------------------------------------------
768 pkgPackageManager::OrderResult
pkgPackageManager::OrderInstall()
770 if (CreateOrderList() == false)
776 clog
<< "Beginning to order" << endl
;
778 bool const ordering
=
779 _config
->FindB("PackageManager::UnpackAll",true) ?
780 List
->OrderUnpack(FileNames
) : List
->OrderCritical();
781 if (ordering
== false)
783 _error
->Error("Internal ordering error");
788 clog
<< "Done ordering" << endl
;
790 bool DoneSomething
= false;
791 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
793 PkgIterator
Pkg(Cache
,*I
);
795 if (List
->IsNow(Pkg
) == false)
797 if (!List
->IsFlag(Pkg
,pkgOrderList::Configured
) && !NoImmConfigure
) {
798 if (SmartConfigure(Pkg
) == false && Debug
)
799 _error
->Warning("Internal Error, Could not configure %s",Pkg
.Name());
800 // FIXME: The above warning message might need changing
803 clog
<< "Skipping already done " << Pkg
.Name() << endl
;
809 if (List
->IsMissing(Pkg
) == true)
812 clog
<< "Sequence completed at " << Pkg
.Name() << endl
;
813 if (DoneSomething
== false)
815 _error
->Error("Internal Error, ordering was unable to handle the media swap");
822 if (Cache
[Pkg
].Keep() == true &&
823 Pkg
.State() == pkgCache::PkgIterator::NeedsNothing
&&
824 (Cache
[Pkg
].iFlags
& pkgDepCache::ReInstall
) != pkgDepCache::ReInstall
)
826 _error
->Error("Internal Error, trying to manipulate a kept package (%s)",Pkg
.Name());
830 // Perform a delete or an install
831 if (Cache
[Pkg
].Delete() == true)
833 if (SmartRemove(Pkg
) == false)
837 if (SmartUnPack(Pkg
) == false)
839 DoneSomething
= true;
841 if (ImmConfigureAll
) {
842 /* ConfigureAll here to pick up and packages left unconfigured becuase they were unpacked in the
843 "PreUnpack Checks" section */
848 // Final run through the configure phase
849 if (ConfigureAll() == false)
853 for (pkgOrderList::iterator I
= List
->begin(); I
!= List
->end(); I
++)
855 if (List
->IsFlag(*I
,pkgOrderList::Configured
) == false)
857 _error
->Error("Internal error, packages left unconfigured. %s",
858 PkgIterator(Cache
,*I
).Name());
866 // PM::DoInstallPostFork - Does install part that happens after the fork /*{{{*/
867 // ---------------------------------------------------------------------
868 pkgPackageManager::OrderResult
869 pkgPackageManager::DoInstallPostFork(int statusFd
)
872 // FIXME: use SetCloseExec here once it taught about throwing
873 // exceptions instead of doing _exit(100) on failure
874 fcntl(statusFd
,F_SETFD
,FD_CLOEXEC
);
875 bool goResult
= Go(statusFd
);
876 if(goResult
== false)
882 // PM::DoInstall - Does the installation /*{{{*/
883 // ---------------------------------------------------------------------
884 /* This uses the filenames in FileNames and the information in the
885 DepCache to perform the installation of packages.*/
886 pkgPackageManager::OrderResult
pkgPackageManager::DoInstall(int statusFd
)
888 if(DoInstallPreFork() == Failed
)
891 return DoInstallPostFork(statusFd
);