Просмотр исходного кода

merge the AutoInstOk patch from debian-experimental

Michael Vogt лет назад: 17
Родитель
Сommit
d116d66834
4 измененных файлов с 32 добавлено и 33 удалено
  1. 1 1
      apt-pkg/algorithms.cc
  2. 16 19
      apt-pkg/depcache.cc
  3. 14 12
      apt-pkg/depcache.h
  4. 1 1
      debian/changelog

+ 1 - 1
apt-pkg/algorithms.cc

@@ -985,7 +985,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 			// Consider other options
 			// Consider other options
 			if (InOr == false)
 			if (InOr == false)
 			{
 			{
-			   if (Cache.IsAutoInstallOk(I) == true)
+			   if (Cache.AutoInstOk(I, Cache[I].CandidateVerIter(Cache),Start) == true)
 			   {
 			   {
 			      if (Debug == true)
 			      if (Debug == true)
 			         clog << "  Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl;
 			         clog << "  Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl;

+ 16 - 19
apt-pkg/depcache.cc

@@ -846,17 +846,6 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
    // 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;
-
-   /* if the user doesn't request directly the install we have to check
-      if this install will conflict with any rule a application
-      like apt-get or aptitude might has set (for the user)
-      e.g. forbidden versions, holds or other magic stuff */
-   if(FromUser == false && !IsAutoInstallOk(Pkg, Depth))
-   {
-      MarkKeep(Pkg, false, FromUser, Depth);
-      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 */
@@ -1015,7 +1004,8 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 	    }
 	    }
 	 }
 	 }
 	 
 	 
-	 if (InstPkg.end() == false) 
+	 if (InstPkg.end() == false &&
+	     AutoInstOk(InstPkg, (*this)[InstPkg].CandidateVerIter(*this), Start))
 	 {
 	 {
 	    if(DebugAutoInstall == true)
 	    if(DebugAutoInstall == true)
 	       std::clog << OutputInDepth(Depth) << "Installing " << InstPkg.Name()
 	       std::clog << OutputInDepth(Depth) << "Installing " << InstPkg.Name()
@@ -1053,21 +1043,28 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 	    PkgIterator Pkg = Ver.ParentPkg();
 	    PkgIterator Pkg = Ver.ParentPkg();
 
 
 	    if (Start->Type != Dep::DpkgBreaks)
 	    if (Start->Type != Dep::DpkgBreaks)
-	       MarkDelete(Pkg,false,Depth + 1);
+	    {
+	       if(AutoInstOk(Pkg, VerIterator(*this), Start))
+		  MarkDelete(Pkg);
+	    }
 	    else
 	    else
-	       if (PkgState[Pkg->ID].CandidateVer != *I)
+	       if (PkgState[Pkg->ID].CandidateVer != *I &&
+		   AutoInstOk(Pkg, VerIterator(*this, PkgState[Pkg->ID].CandidateVer), Start))
 		  MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps);
 		  MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps);
 	 }
 	 }
 	 continue;
 	 continue;
       }      
       }      
    }
    }
 }
 }
-									/*}}}*/
-// DepCache::IsAutoInstallOk - check if it is to install this package	/*{{{*/
+
+// DepCache::AutoInstOk - check if it is to install this package	/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
-/* The default implementation is useless, but an application using this
-   library can override this method to control the MarkInstall behaviour */
-bool pkgDepCache::IsAutoInstallOk(const PkgIterator &Pkg, unsigned long Depth)
+/* The default implementation just honors dpkg hold
+   But an application using this  library can override this method
+   to control the MarkInstall behaviour */
+bool pkgDepCache::AutoInstOk(const PkgIterator &Pkg, 
+                             const VerIterator &v,
+                             const DepIterator &d)
 {
 {
    return (Pkg->SelectedState != pkgCache::State::Hold);
    return (Pkg->SelectedState != pkgCache::State::Hold);
 }
 }

+ 14 - 12
apt-pkg/depcache.h

@@ -363,6 +363,20 @@ class pkgDepCache : protected pkgCache::Namespace
     */
     */
    virtual bool MarkFollowsSuggests();
    virtual bool MarkFollowsSuggests();
 
 
+   /** \return \b true if it's OK for MarkInstall to recursively
+    *  install the given version of the given package.
+    *
+    *  \param p  the package that MarkInstall wants to install.
+    *  \param v  the version being installed, or an end iterator
+    *            if p is being removed.
+    *  \param d  the dependency being fixed.
+    *
+    *  The default implementation unconditionally returns \b true.
+    */
+   virtual bool AutoInstOk(const PkgIterator &p,
+			   const VerIterator &v,
+			   const DepIterator &d);
+
    /** \brief Update the Marked and Garbage fields of all packages.
    /** \brief Update the Marked and Garbage fields of all packages.
     *
     *
     *  This routine is implicitly invoked after all state manipulators
     *  This routine is implicitly invoked after all state manipulators
@@ -397,18 +411,6 @@ class pkgDepCache : protected pkgCache::Namespace
 		    unsigned long Depth = 0, bool FromUser = true,
 		    unsigned long Depth = 0, bool FromUser = true,
 		    bool ForceImportantDeps = false);
 		    bool ForceImportantDeps = false);
 
 
-   /** \return \b true if it's OK for MarkInstall to recursively
-    *  install the given package automatically.
-    *
-    *  \param Pkg  the package that MarkInstall wants to install.
-    *
-    *  \param Depth  output depth used for the debugging messages
-    *
-    *  The default implementation unconditionally returns \b true.
-    */
-   virtual bool IsAutoInstallOk(const PkgIterator &Pkg,
-				unsigned long Depth = 0);
-
    void SetReInstall(PkgIterator const &Pkg,bool To);
    void SetReInstall(PkgIterator const &Pkg,bool To);
    void SetCandidateVersion(VerIterator TargetVer);
    void SetCandidateVersion(VerIterator TargetVer);
 
 

+ 1 - 1
debian/changelog

@@ -33,7 +33,7 @@ apt (0.7.22) UNRELEASED; urgency=low
   * support IsAutoInstallOk in the resolver too
   * support IsAutoInstallOk in the resolver too
 
 
   [ Michael Vogt ]
   [ Michael Vogt ]
-  * honor the dpkg hold state in IsAutoInstallOk (closes: #64141)
+  * honor the dpkg hold state in AutoInstOk (closes: #64141)
   
   
   [ Julian Andres Klode ]
   [ Julian Andres Klode ]
   * apt-pkg/contrib/configuration.cc: Fix a small memory leak in
   * apt-pkg/contrib/configuration.cc: Fix a small memory leak in