]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
Merge remote-tracking branch 'donkult/debian/sid' into debian/sid
[apt.git] / apt-pkg / depcache.cc
index a48cd8b0cf8b9f9b43b6409508f7dd040ed5587f..9f8422fecafb0bd750624e564cf951b9a233e314 100644 (file)
@@ -351,18 +351,15 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
       PkgIterator Pkg = Dep.TargetPkg();
       // Check the base package
       if (Type == NowVersion && Pkg->CurrentVer != 0)
-        if (VS().CheckDep(Pkg.CurrentVer().VerStr(),Dep->CompareOp,
-                                Dep.TargetVer()) == true)
+        if (Dep.IsSatisfied(Pkg.CurrentVer()) == true)
            return true;
       
       if (Type == InstallVersion && PkgState[Pkg->ID].InstallVer != 0)
-        if (VS().CheckDep(PkgState[Pkg->ID].InstVerIter(*this).VerStr(),
-                                Dep->CompareOp,Dep.TargetVer()) == true)
+        if (Dep.IsSatisfied(PkgState[Pkg->ID].InstVerIter(*this)) == true)
            return true;
       
       if (Type == CandidateVersion && PkgState[Pkg->ID].CandidateVer != 0)
-        if (VS().CheckDep(PkgState[Pkg->ID].CandidateVerIter(*this).VerStr(),
-                                Dep->CompareOp,Dep.TargetVer()) == true)
+        if (Dep.IsSatisfied(PkgState[Pkg->ID].CandidateVerIter(*this)) == true)
            return true;
    }
    
@@ -398,7 +395,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
       }
       
       // Compare the versions.
-      if (VS().CheckDep(P.ProvideVersion(),Dep->CompareOp,Dep.TargetVer()) == true)
+      if (Dep.IsSatisfied(P) == true)
       {
         Res = P.OwnerPkg();
         return true;
@@ -1007,7 +1004,7 @@ struct CompareProviders {
       }
       // higher priority seems like a good idea
       if (AV->Priority != BV->Priority)
-        return AV->Priority < BV->Priority;
+        return AV->Priority > BV->Priority;
       // prefer native architecture
       if (strcmp(A.Arch(), B.Arch()) != 0)
       {
@@ -1192,28 +1189,34 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
       {
         APT::VersionList verlist;
         pkgCache::VerIterator Cand = PkgState[Start.TargetPkg()->ID].CandidateVerIter(*this);
-        if (Cand.end() == false && VS().CheckDep(Cand.VerStr(), Start->CompareOp, Start.TargetVer()) == true)
+        if (Cand.end() == false && Start.IsSatisfied(Cand) == true)
            verlist.insert(Cand);
         for (PrvIterator Prv = Start.TargetPkg().ProvidesList(); Prv.end() != true; ++Prv)
         {
            pkgCache::VerIterator V = Prv.OwnerVer();
            pkgCache::VerIterator Cand = PkgState[Prv.OwnerPkg()->ID].CandidateVerIter(*this);
-           if (Cand.end() == true || V != Cand ||
-               VS().CheckDep(Prv.ProvideVersion(), Start->CompareOp, Start.TargetVer()) == false)
+           if (Cand.end() == true || V != Cand || Start.IsSatisfied(Prv) == false)
               continue;
            verlist.insert(Cand);
         }
         CompareProviders comp(Start);
-        APT::VersionList::iterator InstVer = std::max_element(verlist.begin(), verlist.end(), comp);
 
-        if (InstVer != verlist.end())
-        {
+        do {
+           APT::VersionList::iterator InstVer = std::max_element(verlist.begin(), verlist.end(), comp);
+
+           if (InstVer == verlist.end())
+              break;
+
            pkgCache::PkgIterator InstPkg = InstVer.ParentPkg();
            if(DebugAutoInstall == true)
               std::clog << OutputInDepth(Depth) << "Installing " << InstPkg.Name()
                         << " as " << Start.DepType() << " of " << Pkg.Name()
                         << std::endl;
-           MarkInstall(InstPkg, true, Depth + 1, false, ForceImportantDeps);
+           if (MarkInstall(InstPkg, true, Depth + 1, false, ForceImportantDeps) == false)
+           {
+              verlist.erase(InstVer);
+              continue;
+           }
            // now check if we should consider it a automatic dependency or not
            if(InstPkg->CurrentVer == 0 && Pkg->Section != 0 && ConfigValueInSubTree("APT::Never-MarkAuto-Sections", Pkg.Section()))
            {
@@ -1222,7 +1225,8 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
                             << Start.DepType() << " of pkg in APT::Never-MarkAuto-Sections)" << std::endl;
               MarkAuto(InstPkg, false);
            }
-        }
+           break;
+        } while(true);
         continue;
       }
       /* Negative dependencies have no or-group
@@ -1247,9 +1251,16 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
                PkgState[Pkg->ID].CandidateVer != *I &&
                MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps) == true)
               continue;
-           else if ((Start->Type == pkgCache::Dep::Conflicts || Start->Type == pkgCache::Dep::DpkgBreaks) &&
-                    MarkDelete(Pkg,false,Depth + 1, false) == false)
-              break;
+           else if (Start->Type == pkgCache::Dep::Conflicts || 
+                     Start->Type == pkgCache::Dep::DpkgBreaks) 
+            {
+               if(DebugAutoInstall == true)
+                  std::clog << OutputInDepth(Depth) 
+                            << " Removing: " << Pkg.Name()
+                            << std::endl;
+               if (MarkDelete(Pkg,false,Depth + 1, false) == false)
+                  break;
+            }
         }
         continue;
       }
@@ -1407,7 +1418,7 @@ bool pkgDepCache::SetCandidateRelease(pkgCache::VerIterator TargetVer,
         if (Cand.end() == true)
            continue;
         // check if the current candidate is enough for the versioned dependency - and installable?
-        if (VS().CheckDep(P.CandVersion(), Start->CompareOp, Start.TargetVer()) == true &&
+        if (Start.IsSatisfied(Cand) == true &&
             (VersionState(Cand.DependsList(), DepInstall, DepCandMin, DepCandPolicy) & DepCandMin) == DepCandMin)
         {
            itsFine = true;
@@ -1441,7 +1452,7 @@ bool pkgDepCache::SetCandidateRelease(pkgCache::VerIterator TargetVer,
            V = Match.Find(D.TargetPkg());
 
         // check if the version from this release could satisfy the dependency
-        if (V.end() == true || VS().CheckDep(V.VerStr(), D->CompareOp, D.TargetVer()) == false)
+        if (V.end() == true || D.IsSatisfied(V) == false)
         {
            if (stillOr == true)
               continue;
@@ -1771,7 +1782,7 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
           for(VerIterator V = d.TargetPkg().VersionList(); 
               !V.end(); ++V)
           {
-             if(_system->VS->CheckDep(V.VerStr(), d->CompareOp, d.TargetVer()))
+             if(d.IsSatisfied(V))
              {
                if(debug_autoremove)
                  {
@@ -1793,8 +1804,7 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
           for(PrvIterator prv=d.TargetPkg().ProvidesList(); 
               !prv.end(); ++prv)
           {
-             if(_system->VS->CheckDep(prv.ProvideVersion(), d->CompareOp, 
-                                      d.TargetVer()))
+             if(d.IsSatisfied(prv))
              {
                if(debug_autoremove)
                  {