]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
move the broken dependency detection above the new recommends detection
[apt.git] / apt-pkg / depcache.cc
index 1c89bd32f9907c180b9f150da1b686b9cfd81798..508e45962af7eb63d7ce14612b706214a17a3601 100644 (file)
@@ -70,7 +70,7 @@ void pkgDepCache::ActionGroup::release()
            cache.MarkAndSweep();
        }
 
-      released = false;
+      released = true;
     }
 }
 
@@ -339,8 +339,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
    /* Check simple depends. A depends -should- never self match but 
       we allow it anyhow because dpkg does. Technically it is a packaging
       bug. Conflicts may never self match */
-   if (Dep.TargetPkg() != Dep.ParentPkg() ||
-       (Dep->Type != Dep::Conflicts && Dep->Type != Dep::DpkgBreaks && Dep->Type != Dep::Obsoletes))
+   if (Dep.TargetPkg() != Dep.ParentPkg() || Dep.IsNegative() == false)
    {
       PkgIterator Pkg = Dep.TargetPkg();
       // Check the base package
@@ -370,8 +369,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
    {
       /* Provides may never be applied against the same package (or group)
          if it is a conflicts. See the comment above. */
-      if (P.OwnerPkg()->Group == Pkg->Group &&
-         (Dep->Type == Dep::Conflicts || Dep->Type == Dep::DpkgBreaks))
+      if (P.OwnerPkg()->Group == Pkg->Group && Dep.IsNegative() == true)
         continue;
       
       // Check if the provides is a hit
@@ -549,8 +547,8 @@ void pkgDepCache::AddStates(const PkgIterator &Pkg,int Add)
    // Not installed
    if (Pkg->CurrentVer == 0)
    {
-      if (State.Mode == ModeDelete && 
-         (State.iFlags | Purge) == Purge && Pkg.Purge() == false)
+      if (State.Mode == ModeDelete &&
+         (State.iFlags & Purge) == Purge && Pkg.Purge() == false)
         iDelCount += Add;
       
       if (State.Mode == ModeInstall)
@@ -594,9 +592,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V)
 
       /* Invert for Conflicts. We have to do this twice to get the
          right sense for a conflicts group */
-      if (D->Type == Dep::Conflicts ||
-         D->Type == Dep::DpkgBreaks ||
-         D->Type == Dep::Obsoletes)
+      if (D.IsNegative() == true)
         State = ~State;
       
       // Add to the group if we are within an or..
@@ -607,9 +603,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V)
         Group = 0;
       
       // Invert for Conflicts
-      if (D->Type == Dep::Conflicts ||
-         D->Type == Dep::DpkgBreaks ||
-         D->Type == Dep::Obsoletes)
+      if (D.IsNegative() == true)
         State = ~State;
    }    
 }
@@ -742,9 +736,7 @@ void pkgDepCache::Update(OpProgress *Prog)
               Group = 0;
 
            // Invert for Conflicts
-           if (D->Type == Dep::Conflicts ||
-               D->Type == Dep::DpkgBreaks ||
-               D->Type == Dep::Obsoletes)
+           if (D.IsNegative() == true)
               State = ~State;
         }
       }
@@ -774,9 +766,7 @@ void pkgDepCache::Update(DepIterator D)
       State = DependencyState(D);
     
       // Invert for Conflicts
-      if (D->Type == Dep::Conflicts ||
-         D->Type == Dep::DpkgBreaks ||
-         D->Type == Dep::Obsoletes)
+      if (D.IsNegative() == true)
         State = ~State;
 
       RemoveStates(D.ParentPkg());
@@ -964,11 +954,26 @@ bool pkgDepCache::IsModeChangeOk(ModeList const mode, PkgIterator const &Pkg,
    if (unlikely(Pkg.end() == true || Pkg->VersionList == 0))
       return false;
 
+   // the user is always right
+   if (FromUser == true)
+      return true;
+
+   StateCache &P = PkgState[Pkg->ID];
+
+   // if previous state was set by user only user can reset it
+   if ((P.iFlags & Protected) == Protected)
+   {
+      if (unlikely(DebugMarker == true) && P.Mode != mode)
+        std::clog << OutputInDepth(Depth) << "Ignore Mark" << PrintMode(mode)
+                  << " of " << Pkg << " as its mode (" << PrintMode(P.Mode)
+                  << ") is protected" << std::endl;
+      return false;
+   }
    // enforce dpkg holds
-   if (FromUser == false && mode != ModeKeep && Pkg->SelectedState == pkgCache::State::Hold &&
+   else if (mode != ModeKeep && Pkg->SelectedState == pkgCache::State::Hold &&
            _config->FindB("APT::Ignore-Hold",false) == false)
    {
-      if (unlikely(DebugMarker == true) && PkgState[Pkg->ID].Mode != mode)
+      if (unlikely(DebugMarker == true) && P.Mode != mode)
         std::clog << OutputInDepth(Depth) << "Hold prevents Mark" << PrintMode(mode)
                   << " of " << Pkg << std::endl;
       return false;
@@ -1073,7 +1078,22 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
       */
       if (IsImportantDep(Start) == false)
         continue;
-      
+
+      /* If we are in an or group locate the first or that can 
+         succeed. We have already cached this.. */
+      for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; --Ors)
+        ++Start;
+      if (Ors == 1 && (DepState[Start->ID] &DepCVer) != DepCVer && Start.IsNegative() == false)
+      {
+        if(DebugAutoInstall == true)
+           std::clog << OutputInDepth(Depth) << Start << " can't be satisfied!" << std::endl;
+        if (Start.IsCritical() == false)
+           continue;
+        // if the dependency was critical, we can't install it, so remove it again
+        MarkDelete(Pkg,false,Depth + 1, false);
+        return;
+      }
+
       /* Check if any ImportantDep() (but not Critical) were added
        * since we installed the package.  Also check for deps that
        * were satisfied in the past: for instance, if a version
@@ -1128,11 +1148,6 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
          && !ForceImportantDeps)
         continue;
       
-      /* If we are in an or group locate the first or that can 
-         succeed. We have already cached this.. */
-      for (; Ors > 1 && (DepState[Start->ID] & DepCVer) != DepCVer; Ors--)
-        Start++;
-
       /* This bit is for processing the possibilty of an install/upgrade
          fixing the problem */
       SPtrArray<Version *> List = Start.AllTargets();
@@ -1197,8 +1212,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
       /* For conflicts we just de-install the package and mark as auto,
          Conflicts may not have or groups.  For dpkg's Breaks we try to
          upgrade the package. */
-      if (Start->Type == Dep::Conflicts || Start->Type == Dep::Obsoletes ||
-         Start->Type == Dep::DpkgBreaks)
+      if (Start.IsNegative() == true)
       {
         for (Version **I = List; *I != 0; I++)
         {