]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/depcache.cc
add hook for auto-install (closes: #470035)
[apt.git] / apt-pkg / depcache.cc
index e9ef9cedc5d769bff186e55374e4527fc59caf6e..fcc6f4a4e1b486f241a33f36159b8908baf18fac 100644 (file)
@@ -853,6 +853,17 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
    // We dont even try to install virtual packages..
    if (Pkg->VersionList == 0)
       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
       autoflag below if this was called recursively. Otherwise the user
       should have the ability to de-auto a package by changing its state */
@@ -1059,6 +1070,15 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
    }
 }
                                                                        /*}}}*/
+// DepCache::IsAutoInstallOk - 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)
+{
+   return true;
+}
+                                                                       /*}}}*/
 // DepCache::SetReInstall - Set the reinstallation flag                        /*{{{*/
 // ---------------------------------------------------------------------
 /* */