summaryrefslogtreecommitdiff
path: root/apt-pkg/edsp.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-06-07 17:01:33 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2016-06-08 13:07:21 +0200
commit385d9f2f23057bc5808b5e013e77ba16d1c94da4 (patch)
treeed9e6aa988b1f05c84883c3e0f8914b7d00946a3 /apt-pkg/edsp.cc
parent35f3ed061f10a25a3fb28bc988fddbb976344c4d (diff)
edsp: optionally store a compressed copy of the last scenario
For bugreports and co it could be handy to have the scenario and all the settings used in it around later for inspection for EDSP like protocols. EDSP might not be the most interesting as the user can still interrupt the process before the solution is applied and users tend to have an opinion on the "rightness" of a solution, so it is disabled by default.
Diffstat (limited to 'apt-pkg/edsp.cc')
-rw-r--r--apt-pkg/edsp.cc42
1 files changed, 31 insertions, 11 deletions
diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc
index 94cac4eb1..58d2769f9 100644
--- a/apt-pkg/edsp.cc
+++ b/apt-pkg/edsp.cc
@@ -597,10 +597,12 @@ bool EDSP::WriteRequest(pkgDepCache &Cache, FileFd &output,
WriteOkay(Okay, output, "Forbid-New-Install: yes\n");
if (flags & Request::FORBID_REMOVE)
WriteOkay(Okay, output, "Forbid-Remove: yes\n");
+ auto const solver = _config->Find("APT::Solver", "internal");
+ WriteOkay(Okay, output, "Solver: ", solver, "\n");
if (_config->FindB("APT::Solver::Strict-Pinning", true) == false)
WriteOkay(Okay, output, "Strict-Pinning: no\n");
string solverpref("APT::Solver::");
- solverpref.append(_config->Find("APT::Solver", "internal")).append("::Preferences");
+ solverpref.append(solver).append("::Preferences");
if (_config->Exists(solverpref) == true)
WriteOkay(Okay, output, "Preferences: ", _config->Find(solverpref,""), "\n");
return WriteOkay(Okay, output, "\n");
@@ -926,15 +928,23 @@ bool EDSP::WriteError(char const * const uuid, std::string const &message, FileF
"\n\n");
}
/*}}}*/
+static std::string findExecutable(std::vector<std::string> const &dirs, char const * const binary) {/*{{{*/
+ for (auto && dir : dirs) {
+ std::string const file = flCombine(dir, binary);
+ if (RealFileExists(file) == true)
+ return file;
+ }
+ return "";
+}
+ /*}}}*/
static pid_t ExecuteExternal(char const* const type, char const * const binary, char const * const configdir, int * const solver_in, int * const solver_out) {/*{{{*/
- std::vector<std::string> const solverDirs = _config->FindVector(configdir);
- std::string file;
- for (std::vector<std::string>::const_iterator dir = solverDirs.begin();
- dir != solverDirs.end(); ++dir) {
- file = flCombine(*dir, binary);
- if (RealFileExists(file.c_str()) == true)
- break;
- file.clear();
+ auto const solverDirs = _config->FindVector(configdir);
+ auto const file = findExecutable(solverDirs, binary);
+ std::string dumper;
+ {
+ dumper = findExecutable(solverDirs, "apt-dump-solver");
+ if (dumper.empty())
+ dumper = findExecutable(solverDirs, "dump");
}
if (file.empty() == true)
@@ -955,8 +965,18 @@ static pid_t ExecuteExternal(char const* const type, char const * const binary,
if (Solver == 0) {
dup2(external[0], STDIN_FILENO);
dup2(external[3], STDOUT_FILENO);
- const char* calling[2] = { file.c_str(), 0 };
- execv(calling[0], (char**) calling);
+ auto const dumpfile = _config->FindFile((std::string("Dir::Log::") + type).c_str());
+ auto const dumpdir = flNotFile(dumpfile);
+ if (dumper.empty() || dumpfile.empty() || dumper == file || CreateAPTDirectoryIfNeeded(dumpdir, dumpdir) == false)
+ {
+ char const * const calling[] = { file.c_str(), nullptr };
+ execv(calling[0], const_cast<char**>(calling));
+ }
+ else
+ {
+ char const * const calling[] = { dumper.c_str(), dumpfile.c_str(), file.c_str(), nullptr };
+ execv(calling[0], const_cast<char**>(calling));
+ }
std::cerr << "Failed to execute " << type << " '" << binary << "'!" << std::endl;
_exit(100);
}