38 #ifndef PKGLIB_DEPCACHE_H
39 #define PKGLIB_DEPCACHE_H
41 #include <apt-pkg/configuration.h>
49 #ifndef APT_8_CLEANER_HEADERS
50 #include <apt-pkg/progress.h>
51 #include <apt-pkg/error.h>
87 bool const &follow_recommends,
88 bool const &follow_suggests);
119 enum DepFlags {DepNow = (1 << 0),DepInstall = (1 << 1),DepCVer = (1 << 2),
120 DepGNow = (1 << 3),DepGInstall = (1 << 4),DepGCVer = (1 << 5)};
123 enum DepStateFlags {DepNowPolicy = (1 << 0), DepNowMin = (1 << 1),
124 DepInstPolicy = (1 << 2), DepInstMin = (1 << 3),
125 DepCandPolicy = (1 << 4), DepCandMin = (1 << 5)};
128 enum InternalFlags {AutoKept = (1 << 0), Purge = (1 << 1), ReInstall = (1 << 2), Protected = (1 << 3)};
130 enum VersionTypes {NowVersion, InstallVersion, CandidateVersion};
131 enum ModeList {ModeDelete = 0, ModeKeep = 1, ModeInstall = 2};
204 const char *CandVersion;
205 const char *CurVersion;
208 Version *CandidateVer;
214 unsigned short Flags;
215 unsigned short iFlags;
231 unsigned char DepState;
234 const char *StripEpoch(
const char *Ver);
238 inline bool NewInstall()
const {
return Status == 2 && Mode == ModeInstall;};
239 inline bool Delete()
const {
return Mode == ModeDelete;};
240 inline bool Purge()
const {
return Delete() ==
true && (iFlags & pkgDepCache::Purge) == pkgDepCache::Purge; };
241 inline bool Keep()
const {
return Mode == ModeKeep;};
242 inline bool Protect()
const {
return (iFlags & Protected) == Protected;};
243 inline bool Upgrade()
const {
return Status > 0 && Mode == ModeInstall;};
244 inline bool Upgradable()
const {
return Status >= 1;};
245 inline bool Downgrade()
const {
return Status < 0 && Mode == ModeInstall;};
246 inline bool Held()
const {
return Status != 0 && Keep();};
247 inline bool NowBroken()
const {
return (DepState & DepNowMin) != DepNowMin;};
248 inline bool NowPolicyBroken()
const {
return (DepState & DepNowPolicy) != DepNowPolicy;};
249 inline bool InstBroken()
const {
return (DepState & DepInstMin) != DepInstMin;};
250 inline bool InstPolicyBroken()
const {
return (DepState & DepInstPolicy) != DepInstPolicy;};
251 inline bool Install()
const {
return Mode == ModeInstall;};
252 inline bool ReInstall()
const {
return Delete() ==
false && (iFlags & pkgDepCache::ReInstall) == pkgDepCache::ReInstall;};
253 inline VerIterator InstVerIter(
pkgCache &Cache)
254 {
return VerIterator(Cache,InstallVer);};
255 inline VerIterator CandidateVerIter(
pkgCache &Cache)
256 {
return VerIterator(Cache,CandidateVer);};
260 void BuildGroupOrs(VerIterator
const &V);
261 void UpdateVerState(PkgIterator Pkg);
268 InstallRecommends = _config->FindB(
"APT::Install-Recommends",
false);
269 InstallSuggests = _config->FindB(
"APT::Install-Suggests",
false);
274 virtual signed short GetPriority(
PkgIterator const &Pkg);
280 bool InstallRecommends;
281 bool InstallSuggests;
297 unsigned char *DepState;
303 unsigned long iInstCount;
304 unsigned long iDelCount;
305 unsigned long iKeepCount;
306 unsigned long iBrokenCount;
307 unsigned long iPolicyBrokenCount;
308 unsigned long iBadCount;
311 bool DebugAutoInstall;
321 return CheckDep(Dep,Type,Res);
325 unsigned char DependencyState(DepIterator &D);
326 unsigned char VersionState(DepIterator D,
unsigned char Check,
327 unsigned char SetMin,
328 unsigned char SetPolicy);
331 void Update(DepIterator Dep);
332 void Update(PkgIterator
const &P);
335 void AddSizes(
const PkgIterator &Pkg,
bool const Invert =
false);
336 inline void RemoveSizes(
const PkgIterator &Pkg) {AddSizes(Pkg,
true);};
337 void AddStates(
const PkgIterator &Pkg,
bool const Invert =
false);
338 inline void RemoveStates(
const PkgIterator &Pkg) {AddStates(Pkg,
true);};
343 inline operator pkgCache &() {
return *Cache;};
344 inline Header &Head() {
return *Cache->HeaderP;};
345 inline GrpIterator GrpBegin() {
return Cache->GrpBegin();};
346 inline PkgIterator PkgBegin() {
return Cache->PkgBegin();};
347 inline GrpIterator FindGrp(std::string
const &Name) {
return Cache->FindGrp(Name);};
348 inline PkgIterator FindPkg(std::string
const &Name) {
return Cache->FindPkg(Name);};
349 inline PkgIterator FindPkg(std::string
const &Name, std::string
const &Arch) {
return Cache->FindPkg(Name, Arch);};
351 inline pkgCache &GetCache() {
return *Cache;};
355 inline VerIterator GetCandidateVer(PkgIterator
const &Pkg) {
return LocalPolicy->GetCandidateVer(Pkg);};
356 inline bool IsImportantDep(DepIterator Dep) {
return LocalPolicy->IsImportantDep(Dep);};
357 inline Policy &GetPolicy() {
return *LocalPolicy;};
360 inline StateCache &operator [](PkgIterator
const &I) {
return PkgState[I->ID];};
361 inline unsigned char &operator [](DepIterator
const &I) {
return DepState[I->ID];};
392 return MarkRequired(rootFunc) && Sweep();
399 return MarkAndSweep(*f.get());
407 bool MarkKeep(PkgIterator
const &Pkg,
bool Soft =
false,
408 bool FromUser =
true,
unsigned long Depth = 0);
409 bool MarkDelete(PkgIterator
const &Pkg,
bool MarkPurge =
false,
410 unsigned long Depth = 0,
bool FromUser =
true);
411 bool MarkInstall(PkgIterator
const &Pkg,
bool AutoInst =
true,
412 unsigned long Depth = 0,
bool FromUser =
true,
413 bool ForceImportantDeps =
false);
414 void MarkProtected(PkgIterator
const &Pkg) { PkgState[Pkg->ID].iFlags |= Protected; };
416 void SetReInstall(PkgIterator
const &Pkg,
bool To);
417 void SetCandidateVersion(VerIterator TargetVer);
419 std::string
const &TargetRel);
435 std::string
const &TargetRel,
436 std::list<std::pair<pkgCache::VerIterator, pkgCache::VerIterator> > &Changed);
439 void MarkAuto(
const PkgIterator &Pkg,
bool Auto);
457 virtual bool IsInstallOk(
const PkgIterator &Pkg,
bool AutoInst =
true,
458 unsigned long Depth = 0,
bool FromUser =
true);
472 virtual bool IsDeleteOk(
const PkgIterator &Pkg,
bool MarkPurge =
false,
473 unsigned long Depth = 0,
bool FromUser =
true);
477 bool writeStateFile(
OpProgress *prog,
bool InstalledOnly=
true);
480 inline signed long long UsrSize() {
return iUsrSize;};
482 inline unsigned long DelCount() {
return iDelCount;};
483 inline unsigned long KeepCount() {
return iKeepCount;};
484 inline unsigned long InstCount() {
return iInstCount;};
485 inline unsigned long BrokenCount() {
return iBrokenCount;};
486 inline unsigned long PolicyBrokenCount() {
return iPolicyBrokenCount;};
487 inline unsigned long BadCount() {
return iBadCount;};
498 bool IsInstallOkMultiArchSameVersionSynced(PkgIterator
const &Pkg,
499 bool const AutoInst,
unsigned long const Depth,
bool const FromUser);
502 bool IsDeleteOkProtectInstallRequests(PkgIterator
const &Pkg,
503 bool const rPurge,
unsigned long const Depth,
bool const FromUser);
506 bool IsModeChangeOk(ModeList
const mode, PkgIterator
const &Pkg,
507 unsigned long const Depth,
bool const FromUser);