]>
git.saurik.com Git - apt.git/blob - apt-pkg/depcache.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: depcache.cc,v 1.2 1998/07/12 23:58:24 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>
16 #include <apt-pkg/version.h>
17 #include <apt-pkg/error.h>
20 // DepCache::pkgDepCache - Constructors /*{{{*/
21 // ---------------------------------------------------------------------
23 pkgDepCache::pkgDepCache(MMap
&Map
) :
24 pkgCache(Map
), PkgState(0), DepState(0)
26 if (_error
->PendingError() == false)
30 // DepCache::~pkgDepCache - Destructor /*{{{*/
31 // ---------------------------------------------------------------------
33 pkgDepCache::~pkgDepCache()
39 // DepCache::ReMap - Regenerate the extra data for the new cache /*{{{*/
40 // ---------------------------------------------------------------------
41 /* pkgCache's constructors call this function, but because the object is not
42 fully constructed at that point it will not result in this function being
43 called but pkgCache::ReMap will be instead.*/
44 bool pkgDepCache::ReMap()
46 if (pkgCache::ReMap() == false)
52 // DepCache::Init - Generate the initial extra structures. /*{{{*/
53 // ---------------------------------------------------------------------
54 /* This allocats the extension buffers and initializes them. */
55 bool pkgDepCache::Init()
59 PkgState
= new StateCache
[Head().PackageCount
];
60 DepState
= new unsigned char[Head().DependsCount
];
61 memset(PkgState
,0,sizeof(*PkgState
)*Head().PackageCount
);
62 memset(DepState
,0,sizeof(*DepState
)*Head().DependsCount
);
64 /* Set the current state of everything. In this state all of the
65 packages are kept exactly as is. See AllUpgrade */
66 for (PkgIterator I
= PkgBegin(); I
.end() != true; I
++)
68 // Find the proper cache slot
69 StateCache
&State
= PkgState
[I
->ID
];
72 // Figure out the install version
73 State
.CandidateVer
= GetCandidateVer(I
);
74 State
.InstallVer
= I
.CurrentVer();
75 State
.Mode
= ModeKeep
;
77 State
.Update(I
,*this);
85 // DepCache::GetCandidateVer - Returns the Candidate install version /*{{{*/
86 // ---------------------------------------------------------------------
87 /* The default just returns the target version if it exists or the
89 pkgDepCache::VerIterator
pkgDepCache::GetCandidateVer(PkgIterator Pkg
)
91 // Try to use an explicit target
92 if (Pkg
->TargetVer
== 0)
94 /* Not source versions cannot be a candidate version unless they
95 are already installed */
96 for (VerIterator I
= Pkg
.VersionList(); I
.end() == false; I
++)
98 if (Pkg
.CurrentVer() == I
)
100 for (VerFileIterator J
= I
.FileList(); J
.end() == false; J
++)
101 if ((J
.File()->Flags
& Flag::NotSource
) == 0)
105 return VerIterator(*this,0);
108 return Pkg
.TargetVer();
111 // DepCache::IsImportantDep - True if the dependency is important /*{{{*/
112 // ---------------------------------------------------------------------
114 bool pkgDepCache::IsImportantDep(DepIterator Dep
)
116 return Dep
.IsCritical();
120 // DepCache::CheckDep - Checks a single dependency /*{{{*/
121 // ---------------------------------------------------------------------
122 /* This first checks the dependency against the main target package and
123 then walks along the package provides list and checks if each provides
124 will be installed then checks the provides against the dep. Res will be
125 set to the package which was used to satisfy the dep. */
126 bool pkgDepCache::CheckDep(DepIterator Dep
,int Type
,PkgIterator
&Res
)
128 Res
= Dep
.TargetPkg();
130 /* Check simple depends. A depends -should- never self match but
131 we allow it anyhow because dpkg does. Technically it is a packaging
132 bug. Conflicts may never self match */
133 if (Dep
.TargetPkg() != Dep
.ParentPkg() || Dep
->Type
!= Dep::Conflicts
)
135 PkgIterator Pkg
= Dep
.TargetPkg();
136 // Check the base package
137 if (Type
== NowVersion
&& Pkg
->CurrentVer
!= 0)
138 if (pkgCheckDep(Dep
.TargetVer(),
139 Pkg
.CurrentVer().VerStr(),Dep
->CompareOp
) == true)
142 if (Type
== InstallVersion
&& PkgState
[Pkg
->ID
].InstallVer
!= 0)
143 if (pkgCheckDep(Dep
.TargetVer(),
144 PkgState
[Pkg
->ID
].InstVerIter(*this).VerStr(),
145 Dep
->CompareOp
) == true)
148 if (Type
== CandidateVersion
&& PkgState
[Pkg
->ID
].CandidateVer
!= 0)
149 if (pkgCheckDep(Dep
.TargetVer(),
150 PkgState
[Pkg
->ID
].CandidateVerIter(*this).VerStr(),
151 Dep
->CompareOp
) == true)
155 // Check the providing packages
156 PrvIterator P
= Dep
.TargetPkg().ProvidesList();
157 PkgIterator Pkg
= Dep
.ParentPkg();
158 for (; P
.end() != true; P
++)
160 /* Provides may never be applied against the same package if it is
161 a conflicts. See the comment above. */
162 if (P
.OwnerPkg() == Pkg
&& Dep
->Type
== Dep::Conflicts
)
165 // Check if the provides is a hit
166 if (Type
== NowVersion
)
168 if (P
.OwnerPkg().CurrentVer() != P
.OwnerVer())
172 if (Type
== InstallVersion
)
174 StateCache
&State
= PkgState
[P
.OwnerPkg()->ID
];
175 if (State
.InstallVer
!= (Version
*)P
.OwnerVer())
179 if (Type
== CandidateVersion
)
181 StateCache
&State
= PkgState
[P
.OwnerPkg()->ID
];
182 if (State
.CandidateVer
!= (Version
*)P
.OwnerVer())
186 // Compare the versions.
187 if (pkgCheckDep(Dep
.TargetVer(),P
.ProvideVersion(),Dep
->CompareOp
) == true)
197 // DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/
198 // ---------------------------------------------------------------------
199 /* Call with Mult = -1 to preform the inverse opration */
200 void pkgDepCache::AddSizes(const PkgIterator
&Pkg
,long Mult
)
202 StateCache
&P
= PkgState
[Pkg
->ID
];
204 // Compute the size data
205 if (P
.NewInstall() == true)
207 iUsrSize
+= Mult
*P
.InstVerIter(*this)->InstalledSize
;
208 iDownloadSize
+= Mult
*P
.InstVerIter(*this)->Size
;
212 if (Pkg
->CurrentVer
!= 0 && P
.InstallVer
!= (Version
*)Pkg
.CurrentVer() &&
215 iUsrSize
+= Mult
*(P
.InstVerIter(*this)->InstalledSize
-
216 Pkg
.CurrentVer()->InstalledSize
);
217 iDownloadSize
+= Mult
*P
.InstVerIter(*this)->Size
;
221 if (Pkg
->CurrentVer
!= 0 && P
.InstallVer
== 0)
222 iUsrSize
-= Mult
*Pkg
.CurrentVer()->InstalledSize
;
225 // DepCache::AddStates - Add the package to the state counter /*{{{*/
226 // ---------------------------------------------------------------------
227 /* This routine is tricky to use, you must make sure that it is never
228 called twice for the same package. This means the Remove/Add section
229 should be as short as possible and not encompass any code that will
230 calld Remove/Add itself. Remember, dependencies can be circular so
231 while processing a dep for Pkg it is possible that Add/Remove
232 will be called on Pkg */
233 void pkgDepCache::AddStates(const PkgIterator
&Pkg
,int Add
)
235 StateCache
&State
= PkgState
[Pkg
->ID
];
237 // The Package is broken
238 if ((State
.DepState
& DepInstMin
) != DepInstMin
)
242 if (Pkg
.State() != PkgIterator::NeedsNothing
)
246 if (Pkg
->CurrentVer
== 0)
248 if (State
.Mode
== ModeInstall
)
253 // Installed, no upgrade
254 if (State
.Upgradable() == false)
256 if (State
.Mode
== ModeDelete
)
261 // Alll 3 are possible
262 if (State
.Mode
== ModeDelete
)
264 if (State
.Mode
== ModeKeep
)
266 if (State
.Mode
== ModeInstall
)
270 // DepCache::BuildGroupOrs - Generate the Or group dep data /*{{{*/
271 // ---------------------------------------------------------------------
272 /* The or group results are stored in the last item of the or group. This
273 allows easy detection of the state of a whole or'd group. */
274 void pkgDepCache::BuildGroupOrs(VerIterator
const &V
)
276 unsigned char Group
= 0;
278 for (DepIterator D
= V
.DependsList(); D
.end() != true; D
++)
280 // Build the dependency state.
281 unsigned char &State
= DepState
[D
->ID
];
283 /* Invert for Conflicts. We have to do this twice to get the
284 right sense for a conflicts group */
285 if (D
->Type
== Dep::Conflicts
)
288 // Add to the group if we are within an or..
291 if ((D
->CompareOp
& Dep::Or
) != Dep::Or
)
294 // Invert for Conflicts
295 if (D
->Type
== Dep::Conflicts
)
300 // DepCache::VersionState - Perform a pass over a dependency list /*{{{*/
301 // ---------------------------------------------------------------------
302 /* This is used to run over a dependency list and determine the dep
303 state of the list, filtering it through both a Min check and a Policy
304 check. The return result will have SetMin/SetPolicy low if a check
305 fails. It uses the DepState cache for it's computations. */
306 unsigned char pkgDepCache::VersionState(DepIterator D
,unsigned char Check
,
307 unsigned char SetMin
,
308 unsigned char SetPolicy
)
310 unsigned char Dep
= 0xFF;
312 while (D
.end() != true)
314 // Compute a single dependency element (glob or)
315 DepIterator Start
= D
;
316 unsigned char State
= 0;
317 for (bool LastOR
= true; D
.end() == false && LastOR
== true; D
++)
319 State
|= DepState
[D
->ID
];
320 LastOR
= (D
->CompareOp
& Dep::Or
) == Dep::Or
;
323 // Minimum deps that must be satisfied to have a working package
324 if (Start
.IsCritical() == true)
325 if ((State
& Check
) != Check
)
328 // Policy deps that must be satisfied to install the package
329 if (IsImportantDep(Start
) == true &&
330 (State
& Check
) != Check
)
337 // DepCache::DependencyState - Compute the 3 results for a dep /*{{{*/
338 // ---------------------------------------------------------------------
339 /* This is the main dependency computation bit. It computes the 3 main
340 results for a dependencys, Now, Install and Candidate. Callers must
341 invert the result if dealing with conflicts. */
342 unsigned char pkgDepCache::DependencyState(DepIterator
&D
)
344 unsigned char State
= 0;
346 if (CheckDep(D
,NowVersion
) == true)
348 if (CheckDep(D
,InstallVersion
) == true)
350 if (CheckDep(D
,CandidateVersion
) == true)
356 // DepCache::UpdateVerState - Compute the Dep member of the state /*{{{*/
357 // ---------------------------------------------------------------------
358 /* This determines the combined dependency representation of a package
359 for its two states now and install. This is done by using the pre-generated
360 dependency information. */
361 void pkgDepCache::UpdateVerState(PkgIterator Pkg
)
363 // Empty deps are always true
364 StateCache
&State
= PkgState
[Pkg
->ID
];
365 State
.DepState
= 0xFF;
367 // Check the Current state
368 if (Pkg
->CurrentVer
!= 0)
370 DepIterator D
= Pkg
.CurrentVer().DependsList();
371 State
.DepState
&= VersionState(D
,DepNow
,DepNowMin
,DepNowPolicy
);
374 /* Check the candidate state. We do not compare against the whole as
375 a candidate state but check the candidate version against the
377 if (State
.CandidateVer
!= 0)
379 DepIterator D
= State
.CandidateVerIter(*this).DependsList();
380 State
.DepState
&= VersionState(D
,DepInstall
,DepCandMin
,DepCandPolicy
);
383 // Check target state which can only be current or installed
384 if (State
.InstallVer
!= 0)
386 DepIterator D
= State
.InstVerIter(*this).DependsList();
387 State
.DepState
&= VersionState(D
,DepInstall
,DepInstMin
,DepInstPolicy
);
391 // DepCache::Update - Figure out all the state information /*{{{*/
392 // ---------------------------------------------------------------------
393 /* This will figure out the state of all the packages and all the
394 dependencies based on the current policy. */
395 void pkgDepCache::Update()
405 // Perform the depends pass
406 for (PkgIterator I
= PkgBegin(); I
.end() != true; I
++)
408 for (VerIterator V
= I
.VersionList(); V
.end() != true; V
++)
410 unsigned char Group
= 0;
412 for (DepIterator D
= V
.DependsList(); D
.end() != true; D
++)
414 // Build the dependency state.
415 unsigned char &State
= DepState
[D
->ID
];
416 State
= DependencyState(D
);;
418 // Add to the group if we are within an or..
421 if ((D
->CompareOp
& Dep::Or
) != Dep::Or
)
424 // Invert for Conflicts
425 if (D
->Type
== Dep::Conflicts
)
430 // Compute the pacakge dependency state and size additions
437 // DepCache::Update - Update the deps list of a package /*{{{*/
438 // ---------------------------------------------------------------------
439 /* This is a helper for update that only does the dep portion of the scan.
440 It is mainly ment to scan reverse dependencies. */
441 void pkgDepCache::Update(DepIterator D
)
443 // Update the reverse deps
444 for (;D
.end() != true; D
++)
446 unsigned char &State
= DepState
[D
->ID
];
447 State
= DependencyState(D
);
449 // Invert for Conflicts
450 if (D
->Type
== Dep::Conflicts
)
453 RemoveStates(D
.ParentPkg());
454 BuildGroupOrs(D
.ParentVer());
455 UpdateVerState(D
.ParentPkg());
456 AddStates(D
.ParentPkg());
460 // DepCache::Update - Update the related deps of a package /*{{{*/
461 // ---------------------------------------------------------------------
462 /* This is called whenever the state of a package changes. It updates
463 all cached dependencies related to this package. */
464 void pkgDepCache::Update(PkgIterator
const &Pkg
)
466 // Recompute the dep of the package
471 // Update the reverse deps
472 Update(Pkg
.RevDependsList());
474 // Update the provides map for the current ver
475 if (Pkg
->CurrentVer
!= 0)
476 for (PrvIterator P
= Pkg
.CurrentVer().ProvidesList();
477 P
.end() != true; P
++)
478 Update(P
.ParentPkg().RevDependsList());
480 // Update the provides map for the candidate ver
481 for (PrvIterator P
= PkgState
[Pkg
->ID
].CandidateVerIter(*this).ProvidesList();
482 P
.end() != true; P
++)
483 Update(P
.ParentPkg().RevDependsList());
488 // DepCache::MarkKeep - Put the package in the keep state /*{{{*/
489 // ---------------------------------------------------------------------
491 void pkgDepCache::MarkKeep(PkgIterator
const &Pkg
,bool Soft
)
493 // Simplifies other routines.
494 if (Pkg
.end() == true)
497 /* We changed the soft state all the time so the UI is a bit nicer
499 StateCache
&P
= PkgState
[Pkg
->ID
];
501 P
.iFlags
|= AutoKept
;
503 P
.iFlags
&= ~AutoKept
;
505 // Check that it is not already kept
506 if (P
.Mode
== ModeKeep
)
509 // We dont even try to keep virtual packages..
510 if (Pkg
->VersionList
== 0)
513 P
.Flags
&= ~Flag::Auto
;
518 if (Pkg
->CurrentVer
== 0)
521 P
.InstallVer
= Pkg
.CurrentVer();
530 // DepCache::MarkDelete - Put the package in the delete state /*{{{*/
531 // ---------------------------------------------------------------------
533 void pkgDepCache::MarkDelete(PkgIterator
const &Pkg
)
535 // Simplifies other routines.
536 if (Pkg
.end() == true)
539 // Check that it is not already marked for delete
540 StateCache
&P
= PkgState
[Pkg
->ID
];
541 P
.iFlags
&= ~AutoKept
;
542 if (P
.Mode
== ModeDelete
|| P
.InstallVer
== 0)
545 // We dont even try to delete virtual packages..
546 if (Pkg
->VersionList
== 0)
554 P
.Flags
&= Flag::Auto
;
561 // DepCache::MarkInstall - Put the package in the install state /*{{{*/
562 // ---------------------------------------------------------------------
564 void pkgDepCache::MarkInstall(PkgIterator
const &Pkg
,bool AutoInst
)
566 // Simplifies other routines.
567 if (Pkg
.end() == true)
570 /* Check that it is not already marked for install and that it can be
572 StateCache
&P
= PkgState
[Pkg
->ID
];
573 P
.iFlags
&= ~AutoKept
;
574 if (P
.InstBroken() == false && (P
.Mode
== ModeInstall
||
575 P
.CandidateVer
== (Version
*)Pkg
.CurrentVer()))
577 if (P
.CandidateVer
== (Version
*)Pkg
.CurrentVer() && P
.InstallVer
== 0)
582 // We dont even try to install virtual packages..
583 if (Pkg
->VersionList
== 0)
586 /* Target the candidate version and remove the autoflag. We reset the
587 autoflag below if this was called recursively. Otherwise the user
588 should have the ability to de-auto a package by changing its state */
592 P
.Mode
= ModeInstall
;
593 P
.InstallVer
= P
.CandidateVer
;
594 P
.Flags
&= ~Flag::Auto
;
595 if (P
.CandidateVer
== (Version
*)Pkg
.CurrentVer())
602 if (AutoInst
== false)
605 DepIterator Dep
= P
.InstVerIter(*this).DependsList();
606 for (; Dep
.end() != true;)
609 DepIterator Start
= Dep
;
611 for (bool LastOR
= true; Dep
.end() == false && LastOR
== true; Dep
++)
613 LastOR
= (Dep
->CompareOp
& Dep::Or
) == Dep::Or
;
615 if ((DepState
[Dep
->ID
] & DepInstall
) == DepInstall
)
619 // Dep is satisfied okay.
623 /* Check if this dep should be consider for install. If it is a user
624 defined important dep and we are installed a new package then
625 it will be installed. Otherwise we only worry about critical deps */
626 if (IsImportantDep(Start
) == false)
628 if (Pkg
->CurrentVer
!= 0 && Start
.IsCritical() == false)
631 // Now we have to take action...
632 PkgIterator P
= Start
.SmartTargetPkg();
633 if ((DepState
[Start
->ID
] & DepCVer
) == DepCVer
)
637 // Set the autoflag, after MarkInstall because MarkInstall unsets it
638 if (P
->CurrentVer
== 0)
639 PkgState
[P
->ID
].Flags
|= Flag::Auto
;
644 // For conflicts we just de-install the package and mark as auto
645 if (Start
->Type
== Dep::Conflicts
)
647 Version
**List
= Start
.AllTargets();
648 for (Version
**I
= List
; *I
!= 0; I
++)
650 VerIterator
Ver(*this,*I
);
651 PkgIterator Pkg
= Ver
.ParentPkg();
654 PkgState
[Pkg
->ID
].Flags
|= Flag::Auto
;
664 // DepCache::ResolveConflicts - Figure the auto upgrades /*{{{*/
665 // ---------------------------------------------------------------------
666 /* This routine attempts to resolve conflicts generated by automatic
667 upgrading. It is known as 'Stage 1' but that name isn't as proper anymore.
669 It's most important function is during the initial load of APT. The
670 loading code will mark every package for upgrade to it's candidate version
671 and then call this routine. This routine will then 'soft keep' every
672 package that causes conflict, is conflicted, or so on. It is a bit
673 agressive in that it may unselect more packages in some odd cases
674 than are strictly necessary but in the case where no packages were
675 conflicting before it will always produce a system with no packages
678 This routine is also used during state changes that require autoupgrade
679 scanning. That is, if a new package is marked for install then all packages
680 that have been soft kept are reconsidered for upgrade.
682 It is called with state information about what can be un-upgraded and
683 what the pre-upgrade install state was. It is expected that the caller
684 has already marked the desired packages to the install state. Bit 0 is
685 the original install state and Bit 1 is controls whether the package
688 void pkgDepCache::ResolveConflicts(unsigned char *Touched
)
694 for (PkgIterator I
= PkgBegin(); I
.end() != true; I
++)
696 // The package will install OK
697 if ((PkgState
[I
->ID
].DepState
& DepInstMin
) == DepInstMin
)
700 /* The package was broken before and this upgrade will not
701 make things better. We simply mark the package for keep
702 and assume an upgrade attempt will be hopeless. This might
704 if ((Touched
[I
->ID
] & (1 << 0)) != (1 << 0))
706 // The package isnt to be touched
707 if ((Touched
[I
->ID
] & (1 << 1)) == (1 << 1))
713 // Check to see if not upgrading it will solve the problem
714 if (I
->CurrentVer
!= 0)
716 // The package isnt to be touched
717 if ((Touched
[I
->ID
] & (1 << 1)) == (1 << 1))
719 if (PkgState
[I
->ID
].Mode
!= ModeKeep
)
725 /* Check if the package is sill broken. If so then we cant leave
726 it as is and get a working system. Lets try marking some
727 depends for 'keep'. This is brutal, it keeps everything in
728 sight to fix the problem. */
729 DepIterator D
= I
.CurrentVer().DependsList();
730 for (;(PkgState
[I
->ID
].DepState
& DepInstMin
) != DepInstMin
&&
731 D
.end() != true; D
++)
733 // We only worry about critical deps.
734 if (D
.IsCritical() != true)
737 unsigned char State
= DepState
[D
->ID
];
739 // This dep never was set before so we dont need to set it now
740 if ((State
& DepNow
) != DepNow
)
743 // The dep is okay now no worries.
744 if ((State
& DepInstall
) == DepInstall
)
747 // Locate a target to keep
748 PkgIterator
P(*this);
749 if (CheckDep(D
,NowVersion
,P
) == true)
751 // We cant touch this package
752 if ((Touched
[P
->ID
] & (1 << 1)) == (1 << 1))
759 while (Again
== true);
762 // DepCache::PromoteAutoKeep - Gentler version of the above /*{{{*/
763 // ---------------------------------------------------------------------
764 /* This is used when installing packages, all it does is attempt to promote
765 everything that has been auto-kept. It simply promotes everything
766 irregardless of it having a chance to work and then runs ResolveConflicts
767 on the result. This allows circular depends loops to work but isn't
769 void pkgDepCache::PromoteAutoKeep()
771 /* Initialize the touchd array. Bit 0 is the old install state bit 1
772 is the touch value */
773 unsigned char *Touch
= new unsigned char[Head().PackageCount
];
774 for (unsigned int I
= 0; I
!= Head().PackageCount
; I
++)
776 if ((PkgState
[I
].DepState
& DepInstMin
) == DepInstMin
)
782 // This allows circular depends to work
783 for (PkgIterator I
= PkgBegin(); I
.end() != true; I
++)
785 /* It wasnt installed before or it is not autokept or it is not
787 StateCache
&P
= PkgState
[I
->ID
];
788 if (I
->CurrentVer
== 0 || P
.Mode
!= ModeKeep
|| I
->VersionList
== 0 ||
789 P
.CandidateVer
== (Version
*)I
.CurrentVer() ||
790 (P
.iFlags
& AutoKept
) != AutoKept
)
793 P
.Mode
= ModeInstall
;
794 P
.InstallVer
= P
.CandidateVer
;
795 if (P
.CandidateVer
== (Version
*)I
.CurrentVer())
798 // Okay autoupgrade it.
799 Touch
[I
->ID
] |= 1 << 1;
803 ResolveConflicts(Touch
);
808 // DepCache::AllUpgrade - Try to upgrade everything /*{{{*/
809 // ---------------------------------------------------------------------
811 void pkgDepCache::AllUpgrade()
813 // Set everything to an upgrade mode
814 for (PkgIterator I
= PkgBegin(); I
.end() != true; I
++)
816 StateCache
&State
= PkgState
[I
->ID
];
818 /* We dont upgrade packages marked for deletion or that are
819 not installed or that don't have an upgrade */
820 if (State
.Mode
== ModeDelete
|| I
->CurrentVer
== 0 ||
821 (Version
*)I
.CurrentVer() == State
.CandidateVer
)
824 // Set the state to upgrade
826 State
.Mode
= ModeInstall
;
827 State
.InstallVer
= State
.CandidateVer
;
828 if (State
.CandidateVer
== (Version
*)I
.CurrentVer())
829 State
.Mode
= ModeKeep
;
831 // Do not upgrade things that have the hold flag set.
832 if (I
->SelectedState
== State::Hold
)
834 State
.InstallVer
= I
.CurrentVer();
835 State
.Mode
= ModeKeep
;
837 State
.Update(I
,*this);
842 /* Initialize the touchd array. Bit 0 is the old install state bit 1
843 is the touch value */
844 unsigned char *Touch
= new unsigned char[Head().PackageCount
];
845 for (unsigned int I
= 0; I
!= Head().PackageCount
; I
++)
847 if ((PkgState
[I
].DepState
& DepNowMin
) == DepNowMin
)
848 Touch
[I
] = (1 << 0) | (1 << 1);
853 // Now downgrade everything that is broken
854 ResolveConflicts(Touch
);
860 // StateCache::Update - Compute the various static display things /*{{{*/
861 // ---------------------------------------------------------------------
862 /* This is called whenever the Candidate version changes. */
863 void pkgDepCache::StateCache::Update(PkgIterator Pkg
,pkgCache
&Cache
)
866 VerIterator Ver
= CandidateVerIter(Cache
);
868 // Use a null string or the version string
869 if (Ver
.end() == true)
872 CandVersion
= Ver
.VerStr();
874 // Find the current version
876 if (Pkg
->CurrentVer
!= 0)
877 CurVersion
= Pkg
.CurrentVer().VerStr();
879 // Strip off the epochs for display
880 CurVersion
= StripEpoch(CurVersion
);
881 CandVersion
= StripEpoch(CandVersion
);
883 // Figure out if its up or down or equal
884 Status
= Ver
.CompareVer(Pkg
.CurrentVer());
885 if (Pkg
->CurrentVer
== 0 || Pkg
->VersionList
== 0 || CandidateVer
== 0)
889 // StateCache::StripEpoch - Remove the epoch specifier from the version /*{{{*/
890 // ---------------------------------------------------------------------
892 const char *pkgDepCache::StateCache::StripEpoch(const char *Ver
)
898 for (const char *I
= Ver
; *I
!= 0; I
++)