diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/cacheiterators.h | 13 | ||||
-rw-r--r-- | apt-pkg/depcache.cc | 47 | ||||
-rw-r--r-- | apt-pkg/depcache.h | 10 | ||||
-rw-r--r-- | apt-pkg/pkgcache.cc | 51 |
4 files changed, 103 insertions, 18 deletions
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 63f9de8fc..cf79b3a6b 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -80,7 +80,13 @@ class pkgCache::PkgIterator inline PrvIterator ProvidesList() const; inline unsigned long Index() const {return Pkg - Owner->PkgP;}; OkState State() const; - + + //Nice printable representation + friend std::ostream& operator<<(std::ostream& out, pkgCache::PkgIterator Pkg); + + const char *CandVersion() const; + const char *CurVersion() const; + // Constructors inline PkgIterator(pkgCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner), HashIndex(0) @@ -111,7 +117,10 @@ class pkgCache::VerIterator inline bool operator ==(const VerIterator &B) const {return Ver == B.Ver;}; inline bool operator !=(const VerIterator &B) const {return Ver != B.Ver;}; int CompareVer(const VerIterator &B) const; - + + // Testing + inline bool IsGood() const { return Ver && Owner && ! end();}; + // Accessors inline Version *operator ->() {return Ver;}; inline Version const *operator ->() const {return Ver;}; diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 2411bfe89..e9ef9cedc 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -47,6 +47,13 @@ ConfigValueInSubTree(const char* SubTree, const char *needle) return false; } +std::string OutputInDepth(const unsigned long Depth) +{ + std::string output = ""; + for(unsigned long d=Depth; d > 0; d--) + output += " "; + return output; +} pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) : cache(cache), released(false) @@ -83,6 +90,8 @@ pkgDepCache::ActionGroup::~ActionGroup() pkgDepCache::pkgDepCache(pkgCache *pCache,Policy *Plcy) : group_level(0), Cache(pCache), PkgState(0), DepState(0) { + DebugMarker = _config->FindB("Debug::pkgDepCache::Marker", false); + DebugAutoInstall = _config->FindB("Debug::pkgDepCache::AutoInstall", false); delLocalPolicy = 0; LocalPolicy = Plcy; if (LocalPolicy == 0) @@ -705,7 +714,8 @@ void pkgDepCache::Update(PkgIterator const &Pkg) // DepCache::MarkKeep - Put the package in the keep state /*{{{*/ // --------------------------------------------------------------------- /* */ -void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser) +void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser, + unsigned long Depth) { // Simplifies other routines. if (Pkg.end() == true) @@ -746,6 +756,9 @@ void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser) P.Flags &= ~Flag::Auto; #endif + if (DebugMarker == true) + std::clog << OutputInDepth(Depth) << "MarkKeep " << Pkg << std::endl; + RemoveSizes(Pkg); RemoveStates(Pkg); @@ -765,7 +778,8 @@ void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser) // DepCache::MarkDelete - Put the package in the delete state /*{{{*/ // --------------------------------------------------------------------- /* */ -void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge) +void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge, + unsigned long Depth) { // Simplifies other routines. if (Pkg.end() == true) @@ -787,6 +801,9 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge) if (Pkg->VersionList == 0) return; + if (DebugMarker == true) + std::clog << OutputInDepth(Depth) << "MarkDelete " << Pkg << std::endl; + RemoveSizes(Pkg); RemoveStates(Pkg); @@ -826,7 +843,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, P.CandidateVer == (Version *)Pkg.CurrentVer())) { if (P.CandidateVer == (Version *)Pkg.CurrentVer() && P.InstallVer == 0) - MarkKeep(Pkg, false, FromUser); + MarkKeep(Pkg, false, FromUser, Depth+1); return; } @@ -868,6 +885,9 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, if (AutoInst == false) return; + if (DebugMarker == true) + std::clog << OutputInDepth(Depth) << "MarkInstall " << Pkg << std::endl; + DepIterator Dep = P.InstVerIter(*this).DependsList(); for (; Dep.end() != true;) { @@ -937,12 +957,12 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, } } if(isNewImportantDep) - if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true) - std::clog << "new important dependency: " + if(DebugAutoInstall == true) + std::clog << OutputInDepth(Depth) << "new important dependency: " << Start.TargetPkg().Name() << std::endl; if(isPreviouslySatisfiedImportantDep) - if(_config->FindB("Debug::pkgDepCache::AutoInstall", false) == true) - std::clog << "previously satisfied important dependency on " + if(DebugAutoInstall == true) + std::clog << OutputInDepth(Depth) << "previously satisfied important dependency on " << Start.TargetPkg().Name() << std::endl; // skip important deps if the package is already installed @@ -993,15 +1013,16 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, if (InstPkg.end() == false) { - if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true) - std::clog << "Installing " << InstPkg.Name() - << " as dep of " << Pkg.Name() + if(DebugAutoInstall == true) + std::clog << OutputInDepth(Depth) << "Installing " << InstPkg.Name() + << " as " << Start.DepType() << " of " << Pkg.Name() << std::endl; // now check if we should consider it a automatic dependency or not if(Pkg.Section() && ConfigValueInSubTree("APT::Never-MarkAuto-Sections", Pkg.Section())) { - if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true) - std::clog << "Setting NOT as auto-installed (direct dep of pkg in APT::Never-MarkAuto-Sections)" << std::endl; + if(DebugAutoInstall == true) + std::clog << OutputInDepth(Depth) << "Setting NOT as auto-installed (direct " + << Start.DepType() << " of pkg in APT::Never-MarkAuto-Sections)" << std::endl; MarkInstall(InstPkg,true,Depth + 1, true); } else @@ -1028,7 +1049,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, PkgIterator Pkg = Ver.ParentPkg(); if (Start->Type != Dep::DpkgBreaks) - MarkDelete(Pkg); + MarkDelete(Pkg,false,Depth + 1); else if (PkgState[Pkg->ID].CandidateVer != *I) MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps); diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index f41ad17e9..2d33e21d7 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -294,7 +294,10 @@ class pkgDepCache : protected pkgCache::Namespace unsigned long iBrokenCount; unsigned long iPolicyBrokenCount; unsigned long iBadCount; - + + bool DebugMarker; + bool DebugAutoInstall; + Policy *delLocalPolicy; // For memory clean up.. Policy *LocalPolicy; @@ -387,8 +390,9 @@ class pkgDepCache : protected pkgCache::Namespace */ // @{ void MarkKeep(PkgIterator const &Pkg, bool Soft = false, - bool FromUser = true); - void MarkDelete(PkgIterator const &Pkg,bool Purge = false); + bool FromUser = true, unsigned long Depth = 0); + void MarkDelete(PkgIterator const &Pkg, bool Purge = false, + unsigned long Depth = 0); void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true, unsigned long Depth = 0, bool FromUser = true, bool ForceImportantDeps = false); diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 81a254483..4e10093a8 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -21,6 +21,7 @@ /*}}}*/ // Include Files /*{{{*/ #include <apt-pkg/pkgcache.h> +#include <apt-pkg/policy.h> #include <apt-pkg/indexfile.h> #include <apt-pkg/version.h> #include <apt-pkg/error.h> @@ -290,6 +291,56 @@ pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const return NeedsNothing; } /*}}}*/ +// PkgIterator::CandVersion - Returns the candidate version string /*{{{*/ +// --------------------------------------------------------------------- +/* Return string representing of the candidate version. */ +const char * +pkgCache::PkgIterator::CandVersion() const +{ + //TargetVer is empty, so don't use it. + VerIterator version = pkgPolicy::pkgPolicy(Owner).GetCandidateVer(*this); + if (version.IsGood()) + return version.VerStr(); + return 0; +}; + /*}}}*/ +// PkgIterator::CurVersion - Returns the current version string /*{{{*/ +// --------------------------------------------------------------------- +/* Return string representing of the current version. */ +const char * +pkgCache::PkgIterator::CurVersion() const +{ + VerIterator version = CurrentVer(); + if (version.IsGood()) + return CurrentVer().VerStr(); + return 0; +}; + /*}}}*/ +// ostream operator to handle string representation of a package /*{{{*/ +// --------------------------------------------------------------------- +/* Output name < cur.rent.version -> candid.ate.version | new.est.version > (section) + Note that the characters <|>() are all literal above. Versions will be ommited + if they provide no new information (e.g. there is no newer version than candidate) + If no version and/or section can be found "none" is used. */ +std::ostream& +operator<<(ostream& out, pkgCache::PkgIterator Pkg) +{ + if (Pkg.end() == true) + return out << "invalid package"; + + string current = string(Pkg.CurVersion() == 0 ? "none" : Pkg.CurVersion()); + string candidate = string(Pkg.CandVersion() == 0 ? "none" : Pkg.CandVersion()); + string newest = string(Pkg.VersionList().end() ? "none" : Pkg.VersionList().VerStr()); + + out << Pkg.Name() << " < " << current; + if (current != candidate) + out << " -> " << candidate; + if ( newest != "none" && candidate != newest) + out << " | " << newest; + out << " > ( " << string(Pkg.Section()==0?"none":Pkg.Section()) << " )"; + return out; +} + /*}}}*/ // DepIterator::IsCritical - Returns true if the dep is important /*{{{*/ // --------------------------------------------------------------------- /* Currently critical deps are defined as depends, predepends and |