浏览代码

eipp: implement Immediate-Configuration flag

APT has 3 modes: no immediate configuration, all packages are configured
immediately and its default mode of configuring essentials and
pseudo-essentials immediately only. While this seems like a job of
different planers at first, it might be handy to have it as an option,
too, in case a planer (like apts internal one) supports different modes
where the introduction of individual planers would be counter intuitive.
David Kalnischkies 10 年之前
父节点
当前提交
a21aca106c
共有 5 个文件被更改,包括 38 次插入3 次删除
  1. 11 1
      apt-pkg/edsp.cc
  2. 10 1
      apt-pkg/edsp.h
  3. 7 1
      apt-pkg/packagemanager.cc
  4. 2 0
      cmdline/apt-internal-planer.cc
  5. 8 0
      doc/external-installation-planer-protocol.txt

+ 11 - 1
apt-pkg/edsp.cc

@@ -1112,7 +1112,6 @@ bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output,		/*{{{*/
 			unsigned int const flags,
 			OpProgress * const Progress)
 {
-   (void)(flags);
    if (Progress != NULL)
       Progress->SubProgress(Cache.Head().PackageCount, _("Send request to planer"));
    unsigned long p = 0;
@@ -1152,6 +1151,10 @@ bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output,		/*{{{*/
    if (reinst.empty() == false)
       WriteOkay(Okay, output, "ReInstall:", reinst, "\n");
    WriteOkay(Okay, output, "Planer: ", _config->Find("APT::Planer", "internal"), "\n");
+   if ((flags & Request::IMMEDIATE_CONFIGURATION_ALL) != 0)
+      WriteOkay(Okay, output, "Immediate-Configuration: yes\n");
+   else if ((flags & Request::NO_IMMEDIATE_CONFIGURATION) != 0)
+      WriteOkay(Okay, output, "Immediate-Configuration: no\n");
    return WriteOkay(Okay, output, "\n");
 }
 									/*}}}*/
@@ -1379,6 +1382,13 @@ bool EIPP::ReadRequest(int const input, std::list<std::pair<std::string,PKG_ACTI
 	    _config->Set("APT::Architectures", SubstVar(line, " ", ","));
 	 else if (LineStartsWithAndStrip(line, "Planer:"))
 	    ; // purely informational line
+	 else if (LineStartsWithAndStrip(line, "Immediate-Configuration:"))
+	 {
+	    if (localStringToBool(line, true))
+	       flags |= Request::IMMEDIATE_CONFIGURATION_ALL;
+	    else
+	       flags |= Request::NO_IMMEDIATE_CONFIGURATION;
+	 }
 	 else
 	    _error->Warning("Unknown line in EIPP Request stanza: %s", line.c_str());
 

+ 10 - 1
apt-pkg/edsp.h

@@ -239,8 +239,17 @@ namespace EDSP								/*{{{*/
 class pkgPackageManager;
 namespace EIPP								/*{{{*/
 {
+   namespace Request
+   {
+      enum Flags
+      {
+	 IMMEDIATE_CONFIGURATION_ALL = (1 << 0), /*!< try to keep the least amount of packages unconfigured as possible at all times */
+	 NO_IMMEDIATE_CONFIGURATION = (1 << 1), /*!< do not perform immediate configuration at all */
+      };
+   }
+
    APT_HIDDEN bool WriteRequest(pkgDepCache &Cache, FileFd &output,
-	 unsigned int const version, OpProgress * const Progress);
+	 unsigned int const flags, OpProgress * const Progress);
    APT_HIDDEN bool WriteScenario(pkgDepCache &Cache, FileFd &output,
 	 OpProgress * const Progress);
 

+ 7 - 1
apt-pkg/packagemanager.cc

@@ -1040,7 +1040,13 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall()
    std::string const planer = _config->Find("APT::Planer", "internal");
    if (planer != "internal")
    {
-      if (EIPP::OrderInstall(planer.c_str(), this, 0, nullptr))
+      unsigned int flags = 0;
+      if (_config->FindB("APT::Immediate-Configure", true) == false)
+	 flags |= EIPP::Request::NO_IMMEDIATE_CONFIGURATION;
+      else if (_config->FindB("APT::Immediate-Configure-All", false))
+	 flags |= EIPP::Request::IMMEDIATE_CONFIGURATION_ALL;
+
+      if (EIPP::OrderInstall(planer.c_str(), this, flags, nullptr))
 	 return Completed;
       else
 	 return Failed;

+ 2 - 0
cmdline/apt-internal-planer.cc

@@ -150,6 +150,8 @@ int main(int argc,const char *argv[])					/*{{{*/
 	unsigned int flags;
 	if (EIPP::ReadRequest(input, actions, flags) == false)
 		DIE("Parsing the request failed!");
+	_config->Set("APT::Immediate-Configure", (flags & EIPP::Request::NO_IMMEDIATE_CONFIGURATION) == 0);
+	_config->Set("APT::Immediate-Configure-All", (flags & EIPP::Request::IMMEDIATE_CONFIGURATION_ALL) != 0);
 
 	EDSP::WriteProgress(5, "Read scenario…", output);
 

+ 8 - 0
doc/external-installation-planer-protocol.txt

@@ -162,6 +162,14 @@ The following **preference fields** are supported in request stanzas:
   informational string specifying to which planer this request was send
   initially.
 
+- *Immediate-Configuration:** (option, unset by default) A boolean value
+  defining if the planer should try to configure all packages as quickly
+  as possible (true) or shouldn't perform any kind of immediate
+  configuration at all (false). If not explicitly set with this field
+  the planer is free to pick either mode or implementing e.g. a mode
+  which configures only packages immediately if they are flagged as
+  `Essential` (or are dependencies of packages marked as `Essential`).
+
 
 #### Package universe