]> git.saurik.com Git - apt.git/commitdiff
edsp: support generic and solver-specific configs
authorDavid Kalnischkies <david@kalnischkies.de>
Tue, 10 May 2016 20:48:31 +0000 (22:48 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Tue, 10 May 2016 20:48:31 +0000 (22:48 +0200)
The spec was slightly inconsistent if the preferences setting is
available only as generic or specific setting & the code only supported
the specific one, while for the strict-pinning was only generic…

As the usual pattern for apt is to have both options we adapt the spec
and code to support both as well.

This also adds a purely informal "Solver" field so in case the request
is saved in a file, we know to which solver the sent preferences apply.

Closes: 823918
apt-pkg/edsp.cc
doc/external-dependency-solver-protocol.txt

index 77928379f5ab66d104671803ff326e44d6324e39..e54f0d1df0d659af0bbfba74c148b5943221c913 100644 (file)
@@ -288,14 +288,15 @@ bool EDSP::WriteRequest(pkgDepCache &Cache, FILE* output, bool const Upgrade,
       fprintf(output, "Dist-Upgrade: yes\n");
    if (AutoRemove == true)
       fprintf(output, "Autoremove: yes\n");
-   if (_config->FindB("APT::Solver::Strict-Pinning", true) == false)
+   auto const solver = _config->Find("APT::Solver", "internal");
+   fprintf(output, "Solver: %s\n", solver.c_str());
+   auto const solverconf = std::string("APT::Solver::") + solver + "::";
+   if (_config->FindB(solverconf + "Strict-Pinning", _config->FindB("APT::Solver::Strict-Pinning", true)) == false)
       fprintf(output, "Strict-Pinning: no\n");
-   string solverpref("APT::Solver::");
-   solverpref.append(_config->Find("APT::Solver", "internal")).append("::Preferences");
-   if (_config->Exists(solverpref) == true)
-      fprintf(output, "Preferences: %s\n", _config->Find(solverpref,"").c_str());
+   auto const solverpref = _config->Find(solverconf + "Preferences", _config->Find("APT::Solver::Preferences", ""));
+   if (solverpref.empty() == false)
+      fprintf(output, "Preferences: %s\n", solverpref.c_str());
    fprintf(output, "\n");
-
    return true;
 }
                                                                        /*}}}*/
@@ -468,6 +469,8 @@ bool EDSP::ReadRequest(int const input, std::list<std::string> &install,
            std::string const archs = line.c_str() + 15;
            _config->Set("APT::Architectures", SubstVar(archs, " ", ","));
         }
+        else if (line.compare(0, 7, "Solver:") == 0)
+           ; // purely informational line
         else
            _error->Warning("Unknown line in EDSP Request stanza: %s", line.c_str());
 
index 5757991a835af14e590cb83d10710a70a58d8d0f..e2bd95866f303abea02de859fbdff9202a7d5672 100644 (file)
@@ -58,17 +58,24 @@ configuration documentation for more, and more up to date, information.
 - **APT::Solver**: the name of the solver to be used for
   dependency solving. Defaults to `internal`
 
+- **Dir::Bin::Solvers**: absolute path of the directory where to look for
+  external solvers. Defaults to `/usr/lib/apt/solvers`.
+
 - **APT::Solver::Strict-Pinning**: whether pinning must be strictly
   respected (as the internal solver does) or can be slightly deviated
   from. Defaults to `yes`.
 
-- **APT::Solver::NAME::Preferences** (where NAME is a solver name):
-  solver-specific user preference string used during dependency solving,
-  when the solver NAME is in use. Check solver-specific documentation
-  for what is supported here. Defaults to the empty string.
+- **APT::Solver::Preferences**: user preference string used during
+  dependency solving by the requested solver. Check the documentation
+  of the solver you are using if and what is supported as a value here.
+  Defaults to the empty string.
 
-- **Dir::Bin::Solvers**: absolute path of the directory where to look for
-  external solvers. Defaults to `/usr/lib/apt/solvers`.
+The options **Strict-Pinning** and **Preferences** can also be set for
+a specific solver only via **APT::Solver::NAME::Strict-Pinning** and
+**APT::Solver::NAME::Preferences** respectively where `NAME` is the name
+of the external solver this option should apply to. These options if set
+override the generic options; for simplicity the documentation will
+refer only to the generic options.
 
 
 ## Protocol
@@ -171,8 +178,13 @@ The following **preference fields** are supported in request stanzas:
   field comes from the `APT::Solver::Strict-Pinning` configuration
   option.
 
-- **Preferences:** a solver-specific optimization string, usually coming
-  from the `APT::Solver::Preferences` configuration option.
+- **Solver:** (optional, defaults to the empty string) a purely
+  informational string specifying to which solver this request was send
+  initially.
+
+- **Preferences:** (optional, defaults to the empty string)
+  a solver-specific optimization string, usually coming from the
+  `APT::Solver::Preferences` configuration option.
 
 
 #### Package universe