From 60681f9354217c830943315951e6559253bfa832 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 2 May 2006 09:44:30 +0200 Subject: * depcache.cc: - added APT::Install-{Recommends,Suggests} global option * depcache.h: - added DepCache::State::InstPolicyBroken() to check if the current install state violates the policy (compated with InstBroken() that only checks for the minimal requirements) --- apt-pkg/depcache.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'apt-pkg/depcache.cc') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index dd1c794c9..589fc2f7d 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -16,7 +16,7 @@ #include #include #include - +#include #include /*}}}*/ @@ -609,7 +609,8 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, installed */ StateCache &P = PkgState[Pkg->ID]; P.iFlags &= ~AutoKept; - if (P.InstBroken() == false && (P.Mode == ModeInstall || + if ((P.InstPolicyBroken() == false && P.InstBroken() == false) && + (P.Mode == ModeInstall || P.CandidateVer == (Version *)Pkg.CurrentVer())) { if (P.CandidateVer == (Version *)Pkg.CurrentVer() && P.InstallVer == 0) @@ -620,11 +621,9 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, // See if there is even any possible instalation candidate if (P.CandidateVer == 0) return; - // We dont even try to install virtual packages.. if (Pkg->VersionList == 0) return; - /* Target the candidate version and remove the autoflag. We reset the autoflag below if this was called recursively. Otherwise the user should have the ability to de-auto a package by changing its state */ @@ -864,6 +863,13 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator Pkg) /* */ bool pkgDepCache::Policy::IsImportantDep(DepIterator Dep) { - return Dep.IsCritical(); + if(Dep.IsCritical()) + return true; + else if(Dep->Type == pkgCache::Dep::Recommends) + return _config->FindB("APT::Install-Recommends", false); + else if(Dep->Type == pkgCache::Dep::Suggests) + return _config->FindB("APT::Install-Suggests", false); + + return false; } /*}}}*/ -- cgit v1.2.3 From 1b1c2224f5777956f345471b600ed56203c2d400 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 9 Aug 2006 20:01:46 +0200 Subject: * apt-pkg/depcache.cc: - find new important dependencies on upgrade and deal with them --- apt-pkg/depcache.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'apt-pkg/depcache.cc') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 8560ce4fd..6296892ba 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -667,7 +667,33 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, it will be installed. Otherwise we only worry about critical deps */ if (IsImportantDep(Start) == false) continue; - if (Pkg->CurrentVer != 0 && Start.IsCritical() == false) + + /* check if any ImportantDep() (but not Critial) where added + * since we installed the thing + */ + bool isNewImportantDep = false; + if(IsImportantDep(Start) && !Start.IsCritical()) + { + bool found=false; + VerIterator instVer = Pkg.CurrentVer(); + for (DepIterator D = instVer.DependsList(); !D.end(); D++) + { + //FIXME: deal better with or-groups(?) + DepIterator LocalStart = D; + + if(IsImportantDep(Dep) && Start.TargetPkg() == D.TargetPkg()) + found=true; + } + // this is a new dep if it was not found to be already + // a important dep of the installed pacakge + isNewImportantDep = !found; + } + if(isNewImportantDep) + if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true) + std::clog << "new important dependency: " + << Start.TargetPkg().Name() << std::endl; + + if (Pkg->CurrentVer != 0 && Start.IsCritical() == false && !isNewImportantDep) continue; /* If we are in an or group locate the first or that can -- cgit v1.2.3 From 4ef9a929f1cb74f08f764b321cbea62cbfe025a2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 11 Aug 2006 11:30:11 +0200 Subject: * cmdline/apt-get.cc: - added "--fix-policy" option to make it easy to fix any not-install recommends * apt-pkg/depcache.{cc,h} - MarkInstall() has a new "ForceImportantDeps" option (defaults to false) to fice the install of recommends even for already installed pkgs - a new PolicyBroken() function to see how much of the recommends are broken --- apt-pkg/depcache.cc | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'apt-pkg/depcache.cc') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 6296892ba..bfcb8e0eb 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -239,9 +239,11 @@ void pkgDepCache::AddStates(const PkgIterator &Pkg,int Add) { StateCache &State = PkgState[Pkg->ID]; - // The Package is broken + // The Package is broken (either minimal dep or policy dep) if ((State.DepState & DepInstMin) != DepInstMin) iBrokenCount += Add; + if ((State.DepState & DepInstPolicy) != DepInstPolicy) + iPolicyBrokenCount += Add; // Bad state if (Pkg.State() != PkgIterator::NeedsNothing) @@ -596,7 +598,7 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge) // --------------------------------------------------------------------- /* */ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, - unsigned long Depth) + unsigned long Depth, bool ForceImportantDeps) { if (Depth > 100) return; @@ -664,24 +666,26 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, /* Check if this dep should be consider for install. If it is a user defined important dep and we are installed a new package then - it will be installed. Otherwise we only worry about critical deps */ + it will be installed. Otherwise we only check for important + deps that have changed from the installed version + */ if (IsImportantDep(Start) == false) continue; - + /* check if any ImportantDep() (but not Critial) where added - * since we installed the thing + * since we installed the package */ bool isNewImportantDep = false; - if(IsImportantDep(Start) && !Start.IsCritical()) + if(!ForceImportantDeps && !Start.IsCritical()) { bool found=false; VerIterator instVer = Pkg.CurrentVer(); - for (DepIterator D = instVer.DependsList(); !D.end(); D++) + for (DepIterator D = instVer.DependsList(); D.end() != true; D++) { //FIXME: deal better with or-groups(?) DepIterator LocalStart = D; - if(IsImportantDep(Dep) && Start.TargetPkg() == D.TargetPkg()) + if(IsImportantDep(D) && Start.TargetPkg() == D.TargetPkg()) found=true; } // this is a new dep if it was not found to be already @@ -693,7 +697,9 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, std::clog << "new important dependency: " << Start.TargetPkg().Name() << std::endl; - if (Pkg->CurrentVer != 0 && Start.IsCritical() == false && !isNewImportantDep) + // skip important deps if the package is already installed + if (Pkg->CurrentVer != 0 && Start.IsCritical() == false + && !isNewImportantDep && !ForceImportantDeps) continue; /* If we are in an or group locate the first or that can @@ -741,7 +747,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, std::clog << "Installing " << InstPkg.Name() << " as dep of " << Pkg.Name() << std::endl; - MarkInstall(InstPkg,true,Depth + 1); + MarkInstall(InstPkg,true,Depth + 1, ForceImportantDeps); // Set the autoflag, after MarkInstall because MarkInstall unsets it if (P->CurrentVer == 0) -- cgit v1.2.3 From 6ea086805714e0dbeecfb5e3e26d3489a624bcd4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 11 Aug 2006 17:27:13 +0200 Subject: * apt-pkg/depcache.cc: - only work on instVer if we actually have one --- apt-pkg/depcache.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'apt-pkg/depcache.cc') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index bfcb8e0eb..b5b96dbcf 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -680,14 +680,15 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, { bool found=false; VerIterator instVer = Pkg.CurrentVer(); - for (DepIterator D = instVer.DependsList(); D.end() != true; D++) - { - //FIXME: deal better with or-groups(?) - DepIterator LocalStart = D; - - if(IsImportantDep(D) && Start.TargetPkg() == D.TargetPkg()) - found=true; - } + if(!instVer.end()) + for (DepIterator D = instVer.DependsList(); D.end() != true; D++) + { + //FIXME: deal better with or-groups(?) + DepIterator LocalStart = D; + + if(IsImportantDep(D) && Start.TargetPkg() == D.TargetPkg()) + found=true; + } // this is a new dep if it was not found to be already // a important dep of the installed pacakge isNewImportantDep = !found; -- cgit v1.2.3