ソースを参照

add hook for auto-install (closes: #470035)

Michael Vogt 17 年 前
コミット
2d403b9201
共有3 個のファイルを変更した34 個の追加0 個の削除を含む
  1. 20 0
      apt-pkg/depcache.cc
  2. 13 0
      apt-pkg/depcache.h
  3. 1 0
      debian/changelog

+ 20 - 0
apt-pkg/depcache.cc

@@ -853,6 +853,17 @@ 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 */
@@ -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			/*{{{*/
 // DepCache::SetReInstall - Set the reinstallation flag			/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
 /* */
 /* */

+ 13 - 0
apt-pkg/depcache.h

@@ -396,6 +396,19 @@ class pkgDepCache : protected pkgCache::Namespace
    void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true,
    void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true,
 		    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 - 0
debian/changelog

@@ -29,6 +29,7 @@ apt (0.7.22) UNRELEASED; urgency=low
   * add Debug::pkgProblemResolver::ShowScores and make the scores
   * add Debug::pkgProblemResolver::ShowScores and make the scores
     adjustable
     adjustable
   * do not write state file in simulate mode (closes: #433007)
   * do not write state file in simulate mode (closes: #433007)
+  * add hook for auto-install (closes: #470035)
 
 
   [ 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