]>
git.saurik.com Git - apt.git/blob - apt-pkg/depcache.cc
6296892ba42c34c6071024ea64c60c47be346eca
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: depcache.cc,v 1.25 2001/05/27 05:36:04 jgg Exp $
4 /* ######################################################################
6 Dependency Cache - Caches Dependency information.
8 ##################################################################### */
10 // Include Files /*{{{*/
12 #pragma implementation "apt-pkg/depcache.h"
14 #include <apt-pkg/depcache.h>
15 #include <apt-pkg/version.h>
16 #include <apt-pkg/error.h>
17 #include <apt-pkg/sptr.h>
18 #include <apt-pkg/algorithms.h>
19 #include <apt-pkg/configuration.h>
23 // DepCache::pkgDepCache - Constructors /*{{{*/
24 // ---------------------------------------------------------------------
26 pkgDepCache::pkgDepCache(pkgCache
*pCache
,Policy
*Plcy
) :
27 Cache(pCache
), PkgState(0), DepState(0)
32 delLocalPolicy
= LocalPolicy
= new Policy
;
35 // DepCache::~pkgDepCache - Destructor /*{{{*/
36 // ---------------------------------------------------------------------
38 pkgDepCache::~pkgDepCache()
42 delete delLocalPolicy
;
45 // DepCache::Init - Generate the initial extra structures. /*{{{*/
46 // ---------------------------------------------------------------------
47 /* This allocats the extension buffers and initializes them. */
48 bool pkgDepCache::Init(OpProgress
*Prog
)
52 PkgState
= new StateCache
[Head().PackageCount
];
53 DepState
= new unsigned char[Head().DependsCount
];
54 memset(PkgState
,0,sizeof(*PkgState
)*Head().PackageCount
);
55 memset(DepState
,0,sizeof(*DepState
)*Head().DependsCount
);
59 Prog
->OverallProgress(0,2*Head().PackageCount
,Head().PackageCount
,
60 _("Building dependency tree"));
61 Prog
->SubProgress(Head().PackageCount
,_("Candidate versions"));
64 /* Set the current state of everything. In this state all of the
65 packages are kept exactly as is. See AllUpgrade */
67 for (PkgIterator I
= PkgBegin(); I
.end() != true; I
++,Done
++)
72 // Find the proper cache slot
73 StateCache
&State
= PkgState
[I
->ID
];
76 // Figure out the install version
77 State
.CandidateVer
= GetCandidateVer(I
);
78 State
.InstallVer
= I
.CurrentVer();
79 State
.Mode
= ModeKeep
;
81 State
.Update(I
,*this);
87 Prog
->OverallProgress(Head().PackageCount
,2*Head().PackageCount
,
89 _("Building dependency tree"));
90 Prog
->SubProgress(Head().PackageCount
,_("Dependency generation"));
102 // DepCache::CheckDep - Checks a single dependency /*{{{*/
103 // ---------------------------------------------------------------------
104 /* This first checks the dependency against the main target package and
105 then walks along the package provides list and checks if each provides
106 will be installed then checks the provides against the dep. Res will be
107 set to the package which was used to satisfy the dep. */
108 bool pkgDepCache::CheckDep(DepIterator Dep
,int Type
,PkgIterator
&Res
)
110 Res
= Dep
.TargetPkg();
112 /* Check simple depends. A depends -should- never self match but
113 we allow it anyhow because dpkg does. Technically it is a packaging
114 bug. Conflicts may never self match */
115 if (Dep
.TargetPkg() != Dep
.ParentPkg() ||
116 (Dep
->Type
!= Dep::Conflicts
&& Dep
->Type
!= Dep::Obsoletes
))
118 PkgIterator Pkg
= Dep
.TargetPkg();
119 // Check the base package
120 if (Type
== NowVersion
&& Pkg
->CurrentVer
!= 0)
121 if (VS().CheckDep(Pkg
.CurrentVer().VerStr(),Dep
->CompareOp
,
122 Dep
.TargetVer()) == true)
125 if (Type
== InstallVersion
&& PkgState
[Pkg
->ID
].InstallVer
!= 0)
126 if (VS().CheckDep(PkgState
[Pkg
->ID
].InstVerIter(*this).VerStr(),
127 Dep
->CompareOp
,Dep
.TargetVer()) == true)
130 if (Type
== CandidateVersion
&& PkgState
[Pkg
->ID
].CandidateVer
!= 0)
131 if (VS().CheckDep(PkgState
[Pkg
->ID
].CandidateVerIter(*this).VerStr(),
132 Dep
->CompareOp
,Dep
.TargetVer()) == true)
136 if (Dep
->Type
== Dep::Obsoletes
)
139 // Check the providing packages
140 PrvIterator P
= Dep
.TargetPkg().ProvidesList();
141 PkgIterator Pkg
= Dep
.ParentPkg();
142 for (; P
.end() != true; P
++)
144 /* Provides may never be applied against the same package if it is
145 a conflicts. See the comment above. */
146 if (P
.OwnerPkg() == Pkg
&& Dep
->Type
== Dep::Conflicts
)
149 // Check if the provides is a hit
150 if (Type
== NowVersion
)
152 if (P
.OwnerPkg().CurrentVer() != P
.OwnerVer())
156 if (Type
== InstallVersion
)
158 StateCache
&State
= PkgState
[P
.OwnerPkg()->ID
];
159 if (State
.InstallVer
!= (Version
*)P
.OwnerVer())
163 if (Type
== CandidateVersion
)
165 StateCache
&State
= PkgState
[P
.OwnerPkg()->ID
];
166 if (State
.CandidateVer
!= (Version
*)P
.OwnerVer())
170 // Compare the versions.
171 if (VS().CheckDep(P
.ProvideVersion(),Dep
->CompareOp
,Dep
.TargetVer()) == true)
181 // DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/
182 // ---------------------------------------------------------------------
183 /* Call with Mult = -1 to preform the inverse opration */
184 void pkgDepCache::AddSizes(const PkgIterator
&Pkg
,signed long Mult
)
186 StateCache
&P
= PkgState
[Pkg
->ID
];
188 if (Pkg
->VersionList
== 0)
191 if (Pkg
.State() == pkgCache::PkgIterator::NeedsConfigure
&&
195 // Compute the size data
196 if (P
.NewInstall() == true)
198 iUsrSize
+= (signed)(Mult
*P
.InstVerIter(*this)->InstalledSize
);
199 iDownloadSize
+= (signed)(Mult
*P
.InstVerIter(*this)->Size
);
204 if (Pkg
->CurrentVer
!= 0 &&
205 (P
.InstallVer
!= (Version
*)Pkg
.CurrentVer() ||
206 (P
.iFlags
& ReInstall
) == ReInstall
) && P
.InstallVer
!= 0)
208 iUsrSize
+= (signed)(Mult
*((signed)P
.InstVerIter(*this)->InstalledSize
-
209 (signed)Pkg
.CurrentVer()->InstalledSize
));
210 iDownloadSize
+= (signed)(Mult
*P
.InstVerIter(*this)->Size
);
215 if (Pkg
.State() == pkgCache::PkgIterator::NeedsUnpack
&&
218 iDownloadSize
+= (signed)(Mult
*P
.InstVerIter(*this)->Size
);
223 if (Pkg
->CurrentVer
!= 0 && P
.InstallVer
== 0)
225 iUsrSize
-= (signed)(Mult
*Pkg
.CurrentVer()->InstalledSize
);
230 // DepCache::AddStates - Add the package to the state counter /*{{{*/
231 // ---------------------------------------------------------------------
232 /* This routine is tricky to use, you must make sure that it is never
233 called twice for the same package. This means the Remove/Add section
234 should be as short as possible and not encompass any code that will
235 calld Remove/Add itself. Remember, dependencies can be circular so
236 while processing a dep for Pkg it is possible that Add/Remove
237 will be called on Pkg */
238 void pkgDepCache::AddStates(const PkgIterator
&Pkg
,int Add
)
240 StateCache
&State
= PkgState
[Pkg
->ID
];
242 // The Package is broken
243 if ((State
.DepState
& DepInstMin
) != DepInstMin
)
247 if (Pkg
.State() != PkgIterator::NeedsNothing
)
251 if (Pkg
->CurrentVer
== 0)
253 if (State
.Mode
== ModeDelete
&&
254 (State
.iFlags
| Purge
) == Purge
&& Pkg
.Purge() == false)
257 if (State
.Mode
== ModeInstall
)
262 // Installed, no upgrade
263 if (State
.Status
== 0)
265 if (State
.Mode
== ModeDelete
)
268 if ((State
.iFlags
& ReInstall
) == ReInstall
)
274 // Alll 3 are possible
275 if (State
.Mode
== ModeDelete
)
277 if (State
.Mode
== ModeKeep
)
279 if (State
.Mode
== ModeInstall
)
283 // DepCache::BuildGroupOrs - Generate the Or group dep data /*{{{*/
284 // ---------------------------------------------------------------------
285 /* The or group results are stored in the last item of the or group. This
286 allows easy detection of the state of a whole or'd group. */
287 void pkgDepCache::BuildGroupOrs(VerIterator
const &V
)
289 unsigned char Group
= 0;
291 for (DepIterator D
= V
.DependsList(); D
.end() != true; D
++)
293 // Build the dependency state.
294 unsigned char &State
= DepState
[D
->ID
];
296 /* Invert for Conflicts. We have to do this twice to get the
297 right sense for a conflicts group */
298 if (D
->Type
== Dep::Conflicts
|| D
->Type
== Dep::Obsoletes
)
301 // Add to the group if we are within an or..
305 if ((D
->CompareOp
& Dep::Or
) != Dep::Or
)
308 // Invert for Conflicts
309 if (D
->Type
== Dep::Conflicts
|| D
->Type
== Dep::Obsoletes
)
314 // DepCache::VersionState - Perform a pass over a dependency list /*{{{*/
315 // ---------------------------------------------------------------------
316 /* This is used to run over a dependency list and determine the dep
317 state of the list, filtering it through both a Min check and a Policy
318 check. The return result will have SetMin/SetPolicy low if a check
319 fails. It uses the DepState cache for it's computations. */
320 unsigned char pkgDepCache::VersionState(DepIterator D
,unsigned char Check
,
321 unsigned char SetMin
,
322 unsigned char SetPolicy
)
324 unsigned char Dep
= 0xFF;
326 while (D
.end() != true)
328 // Compute a single dependency element (glob or)
329 DepIterator Start
= D
;
330 unsigned char State
= 0;
331 for (bool LastOR
= true; D
.end() == false && LastOR
== true; D
++)
333 State
|= DepState
[D
->ID
];
334 LastOR
= (D
->CompareOp
& Dep::Or
) == Dep::Or
;
337 // Minimum deps that must be satisfied to have a working package
338 if (Start
.IsCritical() == true)
339 if ((State
& Check
) != Check
)
342 // Policy deps that must be satisfied to install the package
343 if (IsImportantDep(Start
) == true &&
344 (State
& Check
) != Check
)
351 // DepCache::DependencyState - Compute the 3 results for a dep /*{{{*/
352 // ---------------------------------------------------------------------
353 /* This is the main dependency computation bit. It computes the 3 main
354 results for a dependencys, Now, Install and Candidate. Callers must
355 invert the result if dealing with conflicts. */
356 unsigned char pkgDepCache::DependencyState(DepIterator
&D
)
358 unsigned char State
= 0;
360 if (CheckDep(D
,NowVersion
) == true)
362 if (CheckDep(D
,InstallVersion
) == true)
364 if (CheckDep(D
,CandidateVersion
) == true)
370 // DepCache::UpdateVerState - Compute the Dep member of the state /*{{{*/
371 // ---------------------------------------------------------------------
372 /* This determines the combined dependency representation of a package
373 for its two states now and install. This is done by using the pre-generated
374 dependency information. */
375 void pkgDepCache::UpdateVerState(PkgIterator Pkg
)
377 // Empty deps are always true
378 StateCache
&State
= PkgState
[Pkg
->ID
];
379 State
.DepState
= 0xFF;
381 // Check the Current state
382 if (Pkg
->CurrentVer
!= 0)
384 DepIterator D
= Pkg
.CurrentVer().DependsList();
385 State
.DepState
&= VersionState(D
,DepNow
,DepNowMin
,DepNowPolicy
);
388 /* Check the candidate state. We do not compare against the whole as
389 a candidate state but check the candidate version against the
391 if (State
.CandidateVer
!= 0)
393 DepIterator D
= State
.CandidateVerIter(*this).DependsList();
394 State
.DepState
&= VersionState(D
,DepInstall
,DepCandMin
,DepCandPolicy
);
397 // Check target state which can only be current or installed
398 if (State
.InstallVer
!= 0)
400 DepIterator D
= State
.InstVerIter(*this).DependsList();
401 State
.DepState
&= VersionState(D
,DepInstall
,DepInstMin
,DepInstPolicy
);
405 // DepCache::Update - Figure out all the state information /*{{{*/
406 // ---------------------------------------------------------------------
407 /* This will figure out the state of all the packages and all the
408 dependencies based on the current policy. */
409 void pkgDepCache::Update(OpProgress
*Prog
)
419 // Perform the depends pass
421 for (PkgIterator I
= PkgBegin(); I
.end() != true; I
++,Done
++)
423 if (Prog
!= 0 && Done%20
== 0)
424 Prog
->Progress(Done
);
425 for (VerIterator V
= I
.VersionList(); V
.end() != true; V
++)
427 unsigned char Group
= 0;
429 for (DepIterator D
= V
.DependsList(); D
.end() != true; D
++)
431 // Build the dependency state.
432 unsigned char &State
= DepState
[D
->ID
];
433 State
= DependencyState(D
);
435 // Add to the group if we are within an or..
438 if ((D
->CompareOp
& Dep::Or
) != Dep::Or
)
441 // Invert for Conflicts
442 if (D
->Type
== Dep::Conflicts
|| D
->Type
== Dep::Obsoletes
)
447 // Compute the pacakge dependency state and size additions
454 Prog
->Progress(Done
);
457 // DepCache::Update - Update the deps list of a package /*{{{*/
458 // ---------------------------------------------------------------------
459 /* This is a helper for update that only does the dep portion of the scan.
460 It is mainly ment to scan reverse dependencies. */
461 void pkgDepCache::Update(DepIterator D
)
463 // Update the reverse deps
464 for (;D
.end() != true; D
++)
466 unsigned char &State
= DepState
[D
->ID
];
467 State
= DependencyState(D
);
469 // Invert for Conflicts
470 if (D
->Type
== Dep::Conflicts
|| D
->Type
== Dep::Obsoletes
)
473 RemoveStates(D
.ParentPkg());
474 BuildGroupOrs(D
.ParentVer());
475 UpdateVerState(D
.ParentPkg());
476 AddStates(D
.ParentPkg());
480 // DepCache::Update - Update the related deps of a package /*{{{*/
481 // ---------------------------------------------------------------------
482 /* This is called whenever the state of a package changes. It updates
483 all cached dependencies related to this package. */
484 void pkgDepCache::Update(PkgIterator
const &Pkg
)
486 // Recompute the dep of the package
491 // Update the reverse deps
492 Update(Pkg
.RevDependsList());
494 // Update the provides map for the current ver
495 if (Pkg
->CurrentVer
!= 0)
496 for (PrvIterator P
= Pkg
.CurrentVer().ProvidesList();
497 P
.end() != true; P
++)
498 Update(P
.ParentPkg().RevDependsList());
500 // Update the provides map for the candidate ver
501 if (PkgState
[Pkg
->ID
].CandidateVer
!= 0)
502 for (PrvIterator P
= PkgState
[Pkg
->ID
].CandidateVerIter(*this).ProvidesList();
503 P
.end() != true; P
++)
504 Update(P
.ParentPkg().RevDependsList());
509 // DepCache::MarkKeep - Put the package in the keep state /*{{{*/
510 // ---------------------------------------------------------------------
512 void pkgDepCache::MarkKeep(PkgIterator
const &Pkg
,bool Soft
)
514 // Simplifies other routines.
515 if (Pkg
.end() == true)
518 /* Reject an attempt to keep a non-source broken installed package, those
520 if (Pkg
.State() == PkgIterator::NeedsUnpack
&&
521 Pkg
.CurrentVer().Downloadable() == false)
524 /* We changed the soft state all the time so the UI is a bit nicer
526 StateCache
&P
= PkgState
[Pkg
->ID
];
528 P
.iFlags
|= AutoKept
;
530 P
.iFlags
&= ~AutoKept
;
532 // Check that it is not already kept
533 if (P
.Mode
== ModeKeep
)
536 // We dont even try to keep virtual packages..
537 if (Pkg
->VersionList
== 0)
540 P
.Flags
&= ~Flag::Auto
;
545 if (Pkg
->CurrentVer
== 0)
548 P
.InstallVer
= Pkg
.CurrentVer();
557 // DepCache::MarkDelete - Put the package in the delete state /*{{{*/
558 // ---------------------------------------------------------------------
560 void pkgDepCache::MarkDelete(PkgIterator
const &Pkg
, bool rPurge
)
562 // Simplifies other routines.
563 if (Pkg
.end() == true)
566 // Check that it is not already marked for delete
567 StateCache
&P
= PkgState
[Pkg
->ID
];
568 P
.iFlags
&= ~(AutoKept
| Purge
);
572 if ((P
.Mode
== ModeDelete
|| P
.InstallVer
== 0) &&
573 (Pkg
.Purge() == true || rPurge
== false))
576 // We dont even try to delete virtual packages..
577 if (Pkg
->VersionList
== 0)
583 if (Pkg
->CurrentVer
== 0 && (Pkg
.Purge() == true || rPurge
== false))
588 P
.Flags
&= Flag::Auto
;
595 // DepCache::MarkInstall - Put the package in the install state /*{{{*/
596 // ---------------------------------------------------------------------
598 void pkgDepCache::MarkInstall(PkgIterator
const &Pkg
,bool AutoInst
,
604 // Simplifies other routines.
605 if (Pkg
.end() == true)
608 /* Check that it is not already marked for install and that it can be
610 StateCache
&P
= PkgState
[Pkg
->ID
];
611 P
.iFlags
&= ~AutoKept
;
612 if ((P
.InstPolicyBroken() == false && P
.InstBroken() == false) &&
613 (P
.Mode
== ModeInstall
||
614 P
.CandidateVer
== (Version
*)Pkg
.CurrentVer()))
616 if (P
.CandidateVer
== (Version
*)Pkg
.CurrentVer() && P
.InstallVer
== 0)
621 // See if there is even any possible instalation candidate
622 if (P
.CandidateVer
== 0)
624 // We dont even try to install virtual packages..
625 if (Pkg
->VersionList
== 0)
627 /* Target the candidate version and remove the autoflag. We reset the
628 autoflag below if this was called recursively. Otherwise the user
629 should have the ability to de-auto a package by changing its state */
633 P
.Mode
= ModeInstall
;
634 P
.InstallVer
= P
.CandidateVer
;
635 P
.Flags
&= ~Flag::Auto
;
636 if (P
.CandidateVer
== (Version
*)Pkg
.CurrentVer())
643 if (AutoInst
== false)
646 DepIterator Dep
= P
.InstVerIter(*this).DependsList();
647 for (; Dep
.end() != true;)
650 DepIterator Start
= Dep
;
653 for (bool LastOR
= true; Dep
.end() == false && LastOR
== true; Dep
++,Ors
++)
655 LastOR
= (Dep
->CompareOp
& Dep::Or
) == Dep::Or
;
657 if ((DepState
[Dep
->ID
] & DepInstall
) == DepInstall
)
661 // Dep is satisfied okay.
665 /* Check if this dep should be consider for install. If it is a user
666 defined important dep and we are installed a new package then
667 it will be installed. Otherwise we only worry about critical deps */
668 if (IsImportantDep(Start
) == false)
671 /* check if any ImportantDep() (but not Critial) where added
672 * since we installed the thing
674 bool isNewImportantDep
= false;
675 if(IsImportantDep(Start
) && !Start
.IsCritical())
678 VerIterator instVer
= Pkg
.CurrentVer();
679 for (DepIterator D
= instVer
.DependsList(); !D
.end(); D
++)
681 //FIXME: deal better with or-groups(?)
682 DepIterator LocalStart
= D
;
684 if(IsImportantDep(Dep
) && Start
.TargetPkg() == D
.TargetPkg())
687 // this is a new dep if it was not found to be already
688 // a important dep of the installed pacakge
689 isNewImportantDep
= !found
;
691 if(isNewImportantDep
)
692 if(_config
->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
693 std::clog
<< "new important dependency: "
694 << Start
.TargetPkg().Name() << std::endl
;
696 if (Pkg
->CurrentVer
!= 0 && Start
.IsCritical() == false && !isNewImportantDep
)
699 /* If we are in an or group locate the first or that can
700 succeed. We have already cached this.. */
701 for (; Ors
> 1 && (DepState
[Start
->ID
] & DepCVer
) != DepCVer
; Ors
--)
704 /* This bit is for processing the possibilty of an install/upgrade
705 fixing the problem */
706 SPtrArray
<Version
*> List
= Start
.AllTargets();
707 if ((DepState
[Start
->ID
] & DepCVer
) == DepCVer
)
709 // Right, find the best version to install..
710 Version
**Cur
= List
;
711 PkgIterator P
= Start
.TargetPkg();
712 PkgIterator
InstPkg(*Cache
,0);
714 // See if there are direct matches (at the start of the list)
715 for (; *Cur
!= 0 && (*Cur
)->ParentPkg
== P
.Index(); Cur
++)
717 PkgIterator
Pkg(*Cache
,Cache
->PkgP
+ (*Cur
)->ParentPkg
);
718 if (PkgState
[Pkg
->ID
].CandidateVer
!= *Cur
)
724 // Select the highest priority providing package
725 if (InstPkg
.end() == true)
727 pkgPrioSortList(*Cache
,Cur
);
728 for (; *Cur
!= 0; Cur
++)
730 PkgIterator
Pkg(*Cache
,Cache
->PkgP
+ (*Cur
)->ParentPkg
);
731 if (PkgState
[Pkg
->ID
].CandidateVer
!= *Cur
)
738 if (InstPkg
.end() == false)
740 if(_config
->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
741 std::clog
<< "Installing " << InstPkg
.Name()
742 << " as dep of " << Pkg
.Name()
744 MarkInstall(InstPkg
,true,Depth
+ 1);
746 // Set the autoflag, after MarkInstall because MarkInstall unsets it
747 if (P
->CurrentVer
== 0)
748 PkgState
[InstPkg
->ID
].Flags
|= Flag::Auto
;
754 /* For conflicts we just de-install the package and mark as auto,
755 Conflicts may not have or groups */
756 if (Start
->Type
== Dep::Conflicts
|| Start
->Type
== Dep::Obsoletes
)
758 for (Version
**I
= List
; *I
!= 0; I
++)
760 VerIterator
Ver(*this,*I
);
761 PkgIterator Pkg
= Ver
.ParentPkg();
764 PkgState
[Pkg
->ID
].Flags
|= Flag::Auto
;
771 // DepCache::SetReInstall - Set the reinstallation flag /*{{{*/
772 // ---------------------------------------------------------------------
774 void pkgDepCache::SetReInstall(PkgIterator
const &Pkg
,bool To
)
779 StateCache
&P
= PkgState
[Pkg
->ID
];
781 P
.iFlags
|= ReInstall
;
783 P
.iFlags
&= ~ReInstall
;
789 // DepCache::SetCandidateVersion - Change the candidate version /*{{{*/
790 // ---------------------------------------------------------------------
792 void pkgDepCache::SetCandidateVersion(VerIterator TargetVer
)
794 pkgCache::PkgIterator Pkg
= TargetVer
.ParentPkg();
795 StateCache
&P
= PkgState
[Pkg
->ID
];
800 if (P
.CandidateVer
== P
.InstallVer
)
801 P
.InstallVer
= (Version
*)TargetVer
;
802 P
.CandidateVer
= (Version
*)TargetVer
;
810 // StateCache::Update - Compute the various static display things /*{{{*/
811 // ---------------------------------------------------------------------
812 /* This is called whenever the Candidate version changes. */
813 void pkgDepCache::StateCache::Update(PkgIterator Pkg
,pkgCache
&Cache
)
816 VerIterator Ver
= CandidateVerIter(Cache
);
818 // Use a null string or the version string
819 if (Ver
.end() == true)
822 CandVersion
= Ver
.VerStr();
824 // Find the current version
826 if (Pkg
->CurrentVer
!= 0)
827 CurVersion
= Pkg
.CurrentVer().VerStr();
829 // Strip off the epochs for display
830 CurVersion
= StripEpoch(CurVersion
);
831 CandVersion
= StripEpoch(CandVersion
);
833 // Figure out if its up or down or equal
834 Status
= Ver
.CompareVer(Pkg
.CurrentVer());
835 if (Pkg
->CurrentVer
== 0 || Pkg
->VersionList
== 0 || CandidateVer
== 0)
839 // StateCache::StripEpoch - Remove the epoch specifier from the version /*{{{*/
840 // ---------------------------------------------------------------------
842 const char *pkgDepCache::StateCache::StripEpoch(const char *Ver
)
848 for (const char *I
= Ver
; *I
!= 0; I
++)
855 // Policy::GetCandidateVer - Returns the Candidate install version /*{{{*/
856 // ---------------------------------------------------------------------
857 /* The default just returns the highest available version that is not
858 a source and automatic. */
859 pkgCache::VerIterator
pkgDepCache::Policy::GetCandidateVer(PkgIterator Pkg
)
861 /* Not source/not automatic versions cannot be a candidate version
862 unless they are already installed */
863 VerIterator
Last(*(pkgCache
*)this,0);
865 for (VerIterator I
= Pkg
.VersionList(); I
.end() == false; I
++)
867 if (Pkg
.CurrentVer() == I
)
870 for (VerFileIterator J
= I
.FileList(); J
.end() == false; J
++)
872 if ((J
.File()->Flags
& Flag::NotSource
) != 0)
875 /* Stash the highest version of a not-automatic source, we use it
876 if there is nothing better */
877 if ((J
.File()->Flags
& Flag::NotAutomatic
) != 0)
879 if (Last
.end() == true)
891 // Policy::IsImportantDep - True if the dependency is important /*{{{*/
892 // ---------------------------------------------------------------------
894 bool pkgDepCache::Policy::IsImportantDep(DepIterator Dep
)
898 else if(Dep
->Type
== pkgCache::Dep::Recommends
)
899 return _config
->FindB("APT::Install-Recommends", false);
900 else if(Dep
->Type
== pkgCache::Dep::Suggests
)
901 return _config
->FindB("APT::Install-Suggests", false);