Преглед изворни кода

* 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)

Michael Vogt пре 20 година
родитељ
комит
60681f9354
3 измењених фајлова са 16 додато и 7 уклоњено
  1. 11 5
      apt-pkg/depcache.cc
  2. 1 0
      apt-pkg/depcache.h
  3. 4 2
      cmdline/apt-get.cc

+ 11 - 5
apt-pkg/depcache.cc

@@ -16,7 +16,7 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/algorithms.h>
-    
+#include <apt-pkg/configuration.h>
 #include <apti18n.h>    
 #include <apti18n.h>    
 									/*}}}*/
 									/*}}}*/
 
 
@@ -609,7 +609,8 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
       installed */
       installed */
    StateCache &P = PkgState[Pkg->ID];
    StateCache &P = PkgState[Pkg->ID];
    P.iFlags &= ~AutoKept;
    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()))
 	P.CandidateVer == (Version *)Pkg.CurrentVer()))
    {
    {
       if (P.CandidateVer == (Version *)Pkg.CurrentVer() && P.InstallVer == 0)
       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
    // See if there is even any possible instalation candidate
    if (P.CandidateVer == 0)
    if (P.CandidateVer == 0)
       return;
       return;
-   
    // We dont even try to install virtual packages..
    // We dont even try to install virtual packages..
    if (Pkg->VersionList == 0)
    if (Pkg->VersionList == 0)
       return;
       return;
-   
    /* Target the candidate version and remove the autoflag. We reset the
    /* Target the candidate version and remove the autoflag. We reset the
       autoflag below if this was called recursively. Otherwise the user
       autoflag below if this was called recursively. Otherwise the user
       should have the ability to de-auto a package by changing its state */
       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)
 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;
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 1 - 0
apt-pkg/depcache.h

@@ -98,6 +98,7 @@ class pkgDepCache : protected pkgCache::Namespace
       inline bool Held() const {return Status != 0 && Keep();};
       inline bool Held() const {return Status != 0 && Keep();};
       inline bool NowBroken() const {return (DepState & DepNowMin) != DepNowMin;};
       inline bool NowBroken() const {return (DepState & DepNowMin) != DepNowMin;};
       inline bool InstBroken() const {return (DepState & DepInstMin) != DepInstMin;};
       inline bool InstBroken() const {return (DepState & DepInstMin) != DepInstMin;};
+      inline bool InstPolicyBroken() const {return (DepState & DepInstPolicy) != DepInstPolicy;};
       inline bool Install() const {return Mode == ModeInstall;};
       inline bool Install() const {return Mode == ModeInstall;};
       inline VerIterator InstVerIter(pkgCache &Cache)
       inline VerIterator InstVerIter(pkgCache &Cache)
                 {return VerIterator(Cache,InstallVer);};
                 {return VerIterator(Cache,InstallVer);};

+ 4 - 2
cmdline/apt-get.cc

@@ -1145,9 +1145,11 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
    else
    else
       ExpectedInst++;
       ExpectedInst++;
    
    
-   // Install it with autoinstalling enabled.
-   if (State.InstBroken() == true && BrokenFix == false)
+   // Install it with autoinstalling enabled (if we not respect the minial
+   // required deps or the policy)
+   if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && BrokenFix == false)
       Cache.MarkInstall(Pkg,true);
       Cache.MarkInstall(Pkg,true);
+
    return true;
    return true;
 }
 }
 									/*}}}*/
 									/*}}}*/