libapt-pkg-dev  v0.9.7.5ubuntu5.4
Debian+Ubuntu APT Package Management
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pkgDepCache Class Reference

#include <depcache.h>

Inheritance diagram for pkgDepCache:
Collaboration diagram for pkgDepCache:

Classes

class  ActionGroup
 Represents an active action group. More...
 
class  DefaultRootSetFunc
 Returns true for packages matching a regular expression in APT::NeverAutoRemove. More...
 
class  InRootSetFunc
 An arbitrary predicate on packages. More...
 
class  Policy
 
struct  StateCache
 

Public Types

enum  DepFlags {
  DepNow = (1 << 0),
  DepInstall = (1 << 1),
  DepCVer = (1 << 2),
  DepGNow = (1 << 3),
  DepGInstall = (1 << 4),
  DepGCVer = (1 << 5)
}
 
enum  DepStateFlags {
  DepNowPolicy = (1 << 0),
  DepNowMin = (1 << 1),
  DepInstPolicy = (1 << 2),
  DepInstMin = (1 << 3),
  DepCandPolicy = (1 << 4),
  DepCandMin = (1 << 5)
}
 
enum  InternalFlags {
  AutoKept = (1 << 0),
  Purge = (1 << 1),
  ReInstall = (1 << 2),
  Protected = (1 << 3)
}
 
enum  ModeList {
  ModeDelete = 0,
  ModeKeep = 1,
  ModeInstall = 2
}
 
enum  VersionTypes {
  NowVersion,
  InstallVersion,
  CandidateVersion
}
 

Public Member Functions

 pkgDepCache (pkgCache *Cache, Policy *Plcy=0)
 
virtual ~pkgDepCache ()
 
unsigned long BadCount ()
 
unsigned long BrokenCount ()
 
void BuildGroupOrs (VerIterator const &V)
 
unsigned long long DebSize ()
 
unsigned long DelCount ()
 
GrpIterator FindGrp (std::string const &Name)
 
PkgIterator FindPkg (std::string const &Name)
 
PkgIterator FindPkg (std::string const &Name, std::string const &Arch)
 
pkgCacheGetCache ()
 
VerIterator GetCandidateVer (PkgIterator const &Pkg)
 
PolicyGetPolicy ()
 
virtual InRootSetFuncGetRootSetFunc ()
 
GrpIterator GrpBegin ()
 
HeaderHead ()
 
bool Init (OpProgress *Prog)
 
unsigned long InstCount ()
 
virtual bool IsDeleteOk (const PkgIterator &Pkg, bool MarkPurge=false, unsigned long Depth=0, bool FromUser=true)
 
bool IsImportantDep (DepIterator Dep)
 
virtual bool IsInstallOk (const PkgIterator &Pkg, bool AutoInst=true, unsigned long Depth=0, bool FromUser=true)
 
unsigned long KeepCount ()
 
bool MarkAndSweep (InRootSetFunc &rootFunc)
 Update the Marked and Garbage fields of all packages. More...
 
bool MarkAndSweep ()
 
virtual bool MarkFollowsRecommends ()
 
virtual bool MarkFollowsSuggests ()
 
 operator pkgCache & ()
 
StateCacheoperator[] (PkgIterator const &I)
 
unsigned char & operator[] (DepIterator const &I)
 
PkgIterator PkgBegin ()
 
unsigned long PolicyBrokenCount ()
 
bool readStateFile (OpProgress *prog)
 
void Update (OpProgress *Prog=0)
 
void UpdateVerState (PkgIterator Pkg)
 
signed long long UsrSize ()
 
pkgVersioningSystemVS ()
 
bool writeStateFile (OpProgress *prog, bool InstalledOnly=true)
 
State Manipulators
bool MarkKeep (PkgIterator const &Pkg, bool Soft=false, bool FromUser=true, unsigned long Depth=0)
 
bool MarkDelete (PkgIterator const &Pkg, bool MarkPurge=false, unsigned long Depth=0, bool FromUser=true)
 
bool MarkInstall (PkgIterator const &Pkg, bool AutoInst=true, unsigned long Depth=0, bool FromUser=true, bool ForceImportantDeps=false)
 
void MarkProtected (PkgIterator const &Pkg)
 
void SetReInstall (PkgIterator const &Pkg, bool To)
 
void SetCandidateVersion (VerIterator TargetVer)
 
bool SetCandidateRelease (pkgCache::VerIterator TargetVer, std::string const &TargetRel)
 
bool SetCandidateRelease (pkgCache::VerIterator TargetVer, std::string const &TargetRel, std::list< std::pair< pkgCache::VerIterator, pkgCache::VerIterator > > &Changed)
 Set the candidate version for dependencies too if needed. More...
 
void MarkAuto (const PkgIterator &Pkg, bool Auto)
 Set the "is automatically installed" flag of Pkg. More...
 

Protected Types

typedef pkgCache::Dep Dep
 
typedef pkgCache::DepIterator DepIterator
 
typedef pkgCache::DescIterator DescIterator
 
typedef pkgCache::Description Description
 
typedef pkgCache::Flag Flag
 
typedef pkgCache::GrpIterator GrpIterator
 
typedef pkgCache::Header Header
 
typedef pkgCache::Package Package
 
typedef pkgCache::PkgFileIterator PkgFileIterator
 
typedef pkgCache::PkgIterator PkgIterator
 
typedef pkgCache::PrvIterator PrvIterator
 
typedef pkgCache::VerFileIterator VerFileIterator
 
typedef pkgCache::VerIterator VerIterator
 
typedef pkgCache::Version Version
 

Protected Member Functions

void AddSizes (const PkgIterator &Pkg, bool const Invert=false)
 
void AddStates (const PkgIterator &Pkg, bool const Invert=false)
 
bool CheckDep (DepIterator Dep, int Type, PkgIterator &Res)
 
bool CheckDep (DepIterator Dep, int Type)
 
unsigned char DependencyState (DepIterator &D)
 
void RemoveSizes (const PkgIterator &Pkg)
 
void RemoveStates (const PkgIterator &Pkg)
 
void Update (DepIterator Dep)
 
void Update (PkgIterator const &P)
 
unsigned char VersionState (DepIterator D, unsigned char Check, unsigned char SetMin, unsigned char SetPolicy)
 

Protected Attributes

pkgCacheCache
 
bool DebugAutoInstall
 
bool DebugMarker
 
PolicydelLocalPolicy
 
unsigned char * DepState
 
unsigned long iBadCount
 
unsigned long iBrokenCount
 
unsigned long iDelCount
 
unsigned long long iDownloadSize
 Stores how much we need to download to get the packages. More...
 
unsigned long iInstCount
 
unsigned long iKeepCount
 
unsigned long iPolicyBrokenCount
 
signed long long iUsrSize
 Stores the space changes after installation. More...
 
PolicyLocalPolicy
 
StateCachePkgState
 

Private Member Functions

bool IsModeChangeOk (ModeList const mode, PkgIterator const &Pkg, unsigned long const Depth, bool const FromUser)
 
void MarkPackage (const pkgCache::PkgIterator &pkg, const pkgCache::VerIterator &ver, bool const &follow_recommends, bool const &follow_suggests)
 Mark a single package and all its unmarked important dependencies during mark-and-sweep. More...
 
bool MarkRequired (InRootSetFunc &rootFunc)
 Update the Marked field of all packages. More...
 
bool Sweep ()
 Set the StateCache::Garbage flag on all packages that should be removed. More...
 

Private Attributes

int group_level
 The number of open "action groups"; certain post-action operations are suppressed if this number is > 0. More...
 

Friends

class ActionGroup
 

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
DepNow 
DepInstall 
DepCVer 
DepGNow 
DepGInstall 
DepGCVer 
Enumerator
DepNowPolicy 
DepNowMin 
DepInstPolicy 
DepInstMin 
DepCandPolicy 
DepCandMin 
Enumerator
AutoKept 
Purge 
ReInstall 
Protected 
Enumerator
ModeDelete 
ModeKeep 
ModeInstall 
Enumerator
NowVersion 
InstallVersion 
CandidateVersion 

Constructor & Destructor Documentation

pkgDepCache::pkgDepCache ( pkgCache Cache,
Policy Plcy = 0 
)
virtual pkgDepCache::~pkgDepCache ( )
virtual

Member Function Documentation

void pkgDepCache::AddSizes ( const PkgIterator Pkg,
bool const  Invert = false 
)
protected

Referenced by RemoveSizes().

Here is the caller graph for this function:

void pkgDepCache::AddStates ( const PkgIterator Pkg,
bool const  Invert = false 
)
protected

Referenced by RemoveStates().

Here is the caller graph for this function:

unsigned long pkgDepCache::BadCount ( )
inline

References iBadCount.

unsigned long pkgDepCache::BrokenCount ( )
inline

References iBrokenCount.

void pkgDepCache::BuildGroupOrs ( VerIterator const &  V)
bool pkgDepCache::CheckDep ( DepIterator  Dep,
int  Type,
PkgIterator Res 
)
protected

Referenced by CheckDep().

Here is the caller graph for this function:

bool pkgDepCache::CheckDep ( DepIterator  Dep,
int  Type 
)
inlineprotected

References CheckDep().

Here is the call graph for this function:

unsigned long long pkgDepCache::DebSize ( )
inline

References iDownloadSize.

unsigned long pkgDepCache::DelCount ( )
inline

References iDelCount.

unsigned char pkgDepCache::DependencyState ( DepIterator D)
protected
GrpIterator pkgDepCache::FindGrp ( std::string const &  Name)
inline

References Cache, and pkgCache::FindGrp().

Here is the call graph for this function:

PkgIterator pkgDepCache::FindPkg ( std::string const &  Name)
inline

References Cache, and pkgCache::FindPkg().

Here is the call graph for this function:

PkgIterator pkgDepCache::FindPkg ( std::string const &  Name,
std::string const &  Arch 
)
inline

References Cache, and pkgCache::FindPkg().

Here is the call graph for this function:

pkgCache& pkgDepCache::GetCache ( )
inline

References Cache.

VerIterator pkgDepCache::GetCandidateVer ( PkgIterator const &  Pkg)
inline

References pkgDepCache::Policy::GetCandidateVer(), and LocalPolicy.

Here is the call graph for this function:

Policy& pkgDepCache::GetPolicy ( )
inline

References LocalPolicy.

virtual InRootSetFunc* pkgDepCache::GetRootSetFunc ( )
virtual
Returns
A function identifying packages in the root set other than manually installed packages and essential packages, or NULL if an error occurs.
Todo:
Is this the best place for this function? Perhaps the settings for mark-and-sweep should be stored in a single external class?

Referenced by MarkAndSweep().

Here is the caller graph for this function:

GrpIterator pkgDepCache::GrpBegin ( )
inline

References Cache, and pkgCache::GrpBegin().

Here is the call graph for this function:

Header& pkgDepCache::Head ( )
inline

References Cache, and pkgCache::HeaderP.

bool pkgDepCache::Init ( OpProgress Prog)
unsigned long pkgDepCache::InstCount ( )
inline

References iInstCount.

virtual bool pkgDepCache::IsDeleteOk ( const PkgIterator Pkg,
bool  MarkPurge = false,
unsigned long  Depth = 0,
bool  FromUser = true 
)
virtual
Returns
true if it's OK for MarkDelete to remove the given package.

See the default implementation for a simple example how this method can be used. Overriding implementations should use the hold-state-flag to cache results from previous checks of this package - also it should be used if the default resolver implementation is also used to ensure that these packages are handled like "normal" dpkg holds.

The parameters are the same as in the calling MarkDelete:

Parameters
Pkgthe package that MarkDelete wants to remove.
Purgeshould we purge instead of "only" remove?
Depthrecursive deep of this Marker call
FromUserwas the remove requested by the user?
bool pkgDepCache::IsImportantDep ( DepIterator  Dep)
inline

References pkgDepCache::Policy::IsImportantDep(), and LocalPolicy.

Here is the call graph for this function:

virtual bool pkgDepCache::IsInstallOk ( const PkgIterator Pkg,
bool  AutoInst = true,
unsigned long  Depth = 0,
bool  FromUser = true 
)
virtual
Returns
true if it's OK for MarkInstall to install the given package.

See the default implementation for a simple example how this method can be used. Overriding implementations should use the hold-state-flag to cache results from previous checks of this package - also it should be used if the default resolver implementation is also used to ensure that these packages are handled like "normal" dpkg holds.

The parameters are the same as in the calling MarkInstall:

Parameters
Pkgthe package that MarkInstall wants to install.
AutoInstneeds a previous MarkInstall this package?
Depthrecursive deep of this Marker call
FromUserwas the install requested by the user?
bool pkgDepCache::IsModeChangeOk ( ModeList const  mode,
PkgIterator const &  Pkg,
unsigned long const  Depth,
bool const  FromUser 
)
private
unsigned long pkgDepCache::KeepCount ( )
inline

References iKeepCount.

bool pkgDepCache::MarkAndSweep ( InRootSetFunc rootFunc)
inline

Update the Marked and Garbage fields of all packages.

This routine is implicitly invoked after all state manipulators and when an ActionGroup is destroyed. It invokes MarkRequired and Sweep to do its dirty work.

Parameters
rootFuncA predicate that returns true for packages that should be added to the root set.

References MarkRequired(), and Sweep().

Here is the call graph for this function:

bool pkgDepCache::MarkAndSweep ( )
inline

References GetRootSetFunc().

Here is the call graph for this function:

void pkgDepCache::MarkAuto ( const PkgIterator Pkg,
bool  Auto 
)

Set the "is automatically installed" flag of Pkg.

bool pkgDepCache::MarkDelete ( PkgIterator const &  Pkg,
bool  MarkPurge = false,
unsigned long  Depth = 0,
bool  FromUser = true 
)
virtual bool pkgDepCache::MarkFollowsRecommends ( )
virtual
Returns
true if the garbage collector should follow recommendations.
virtual bool pkgDepCache::MarkFollowsSuggests ( )
virtual
Returns
true if the garbage collector should follow suggestions.
bool pkgDepCache::MarkInstall ( PkgIterator const &  Pkg,
bool  AutoInst = true,
unsigned long  Depth = 0,
bool  FromUser = true,
bool  ForceImportantDeps = false 
)
bool pkgDepCache::MarkKeep ( PkgIterator const &  Pkg,
bool  Soft = false,
bool  FromUser = true,
unsigned long  Depth = 0 
)
void pkgDepCache::MarkPackage ( const pkgCache::PkgIterator pkg,
const pkgCache::VerIterator ver,
bool const &  follow_recommends,
bool const &  follow_suggests 
)
private

Mark a single package and all its unmarked important dependencies during mark-and-sweep.

Recursively invokes itself to mark all dependencies of the package.

Parameters
pkgThe package to mark.
verThe version of the package that is to be marked.
follow_recommendsIf true, recommendations of the package will be recursively marked.
follow_suggestsIf true, suggestions of the package will be recursively marked.
void pkgDepCache::MarkProtected ( PkgIterator const &  Pkg)
inline

References pkgDepCache::StateCache::iFlags, PkgState, and Protected.

Referenced by pkgProblemResolver::Protect().

Here is the caller graph for this function:

bool pkgDepCache::MarkRequired ( InRootSetFunc rootFunc)
private

Update the Marked field of all packages.

Each package's StateCache::Marked field will be set to true if and only if it can be reached from the root set. By default, the root set consists of the set of manually installed or essential packages, but it can be extended using the parameter #rootFunc.

Parameters
rootFuncA callback that can be used to add extra packages to the root set.
Returns
false if an error occurred.

Referenced by MarkAndSweep().

Here is the caller graph for this function:

pkgDepCache::operator pkgCache & ( )
inline

References Cache.

StateCache& pkgDepCache::operator[] ( PkgIterator const &  I)
inline

References PkgState.

unsigned char& pkgDepCache::operator[] ( DepIterator const &  I)
inline

References DepState.

PkgIterator pkgDepCache::PkgBegin ( )
inline

References Cache, and pkgCache::PkgBegin().

Here is the call graph for this function:

unsigned long pkgDepCache::PolicyBrokenCount ( )
inline

References iPolicyBrokenCount.

bool pkgDepCache::readStateFile ( OpProgress prog)
void pkgDepCache::RemoveSizes ( const PkgIterator Pkg)
inlineprotected

References AddSizes().

Here is the call graph for this function:

void pkgDepCache::RemoveStates ( const PkgIterator Pkg)
inlineprotected

References AddStates().

Here is the call graph for this function:

bool pkgDepCache::SetCandidateRelease ( pkgCache::VerIterator  TargetVer,
std::string const &  TargetRel 
)
bool pkgDepCache::SetCandidateRelease ( pkgCache::VerIterator  TargetVer,
std::string const &  TargetRel,
std::list< std::pair< pkgCache::VerIterator, pkgCache::VerIterator > > &  Changed 
)

Set the candidate version for dependencies too if needed.

Sets not only the candidate version as SetCandidateVersion does, but walks also down the dependency tree and checks if it is required to set the candidate of the dependency to a version from the given release, too.

Parameters
TargetVernew candidate version of the package
TargetReltry to switch to this release if needed
[out]Changeda list of pairs consisting of the old version of the changed package and the version which required the switch of this dependency
Returns
true if the switch was successful, false otherwise
void pkgDepCache::SetCandidateVersion ( VerIterator  TargetVer)
void pkgDepCache::SetReInstall ( PkgIterator const &  Pkg,
bool  To 
)
bool pkgDepCache::Sweep ( )
private

Set the StateCache::Garbage flag on all packages that should be removed.

Packages that were not marked by the last call to MarkRequired are tested to see whether they are actually garbage. If so, they are marked as such.

Returns
false if an error occurred.

Referenced by MarkAndSweep().

Here is the caller graph for this function:

void pkgDepCache::Update ( DepIterator  Dep)
protected
void pkgDepCache::Update ( PkgIterator const &  P)
protected
void pkgDepCache::Update ( OpProgress Prog = 0)
void pkgDepCache::UpdateVerState ( PkgIterator  Pkg)
signed long long pkgDepCache::UsrSize ( )
inline

References iUsrSize.

unsigned char pkgDepCache::VersionState ( DepIterator  D,
unsigned char  Check,
unsigned char  SetMin,
unsigned char  SetPolicy 
)
protected
pkgVersioningSystem& pkgDepCache::VS ( )
inline

References Cache, and pkgCache::VS.

bool pkgDepCache::writeStateFile ( OpProgress prog,
bool  InstalledOnly = true 
)

Friends And Related Function Documentation

friend class ActionGroup
friend

Member Data Documentation

pkgCache* pkgDepCache::Cache
protected
bool pkgDepCache::DebugAutoInstall
protected
bool pkgDepCache::DebugMarker
protected
Policy* pkgDepCache::delLocalPolicy
protected
unsigned char* pkgDepCache::DepState
protected

Referenced by operator[]().

int pkgDepCache::group_level
private

The number of open "action groups"; certain post-action operations are suppressed if this number is > 0.

unsigned long pkgDepCache::iBadCount
protected

Referenced by BadCount().

unsigned long pkgDepCache::iBrokenCount
protected

Referenced by BrokenCount().

unsigned long pkgDepCache::iDelCount
protected

Referenced by DelCount().

unsigned long long pkgDepCache::iDownloadSize
protected

Stores how much we need to download to get the packages.

Referenced by DebSize().

unsigned long pkgDepCache::iInstCount
protected

Referenced by InstCount().

unsigned long pkgDepCache::iKeepCount
protected

Referenced by KeepCount().

unsigned long pkgDepCache::iPolicyBrokenCount
protected

Referenced by PolicyBrokenCount().

signed long long pkgDepCache::iUsrSize
protected

Stores the space changes after installation.

Referenced by UsrSize().

Policy* pkgDepCache::LocalPolicy
protected
StateCache* pkgDepCache::PkgState
protected

Referenced by MarkProtected(), and operator[]().


The documentation for this class was generated from the following file: