summaryrefslogtreecommitdiff
path: root/apt-pkg
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
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')
-rw-r--r--apt-pkg/edsp.cc42
-rw-r--r--apt-pkg/edsp/edspsystem.cc3
-rw-r--r--apt-pkg/init.cc4
3 files changed, 36 insertions, 13 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);
}
diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc
index 9b23dc3ca..2a78efe58 100644
--- a/apt-pkg/edsp/edspsystem.cc
+++ b/apt-pkg/edsp/edspsystem.cc
@@ -60,9 +60,12 @@ pkgPackageManager *edspLikeSystem::CreatePM(pkgDepCache * /*Cache*/) const
// System::Initialize - Setup the configuration space.. /*{{{*/
bool edspLikeSystem::Initialize(Configuration &Cnf)
{
+ Cnf.Set("Dir::Log", "/dev/null");
// state is included completely in the input files
+ Cnf.Set("Dir::Etc::preferences", "/dev/null");
Cnf.Set("Dir::Etc::preferencesparts", "/dev/null");
Cnf.Set("Dir::State::status","/dev/null");
+ Cnf.Set("Dir::State::extended_states","/dev/null");
Cnf.Set("Dir::State::lists","/dev/null");
// do not store an mmap cache
Cnf.Set("Dir::Cache::pkgcache", "");
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index 0dfb10978..a41d604d3 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -56,7 +56,7 @@ bool pkgInitConfig(Configuration &Cnf)
Cnf.CndSet("Dir::Cache::archives","archives/");
Cnf.CndSet("Dir::Cache::srcpkgcache","srcpkgcache.bin");
Cnf.CndSet("Dir::Cache::pkgcache","pkgcache.bin");
-
+
// Configuration
Cnf.CndSet("Dir::Etc","etc/apt/");
Cnf.CndSet("Dir::Etc::sourcelist","sources.list");
@@ -72,7 +72,7 @@ bool pkgInitConfig(Configuration &Cnf)
Cnf.CndSet("Dir::Bin::solvers::","/usr/lib/apt/solvers");
Cnf.CndSet("Dir::Media::MountPath","/media/apt");
- // State
+ // State
Cnf.CndSet("Dir::Log","var/log/apt");
Cnf.CndSet("Dir::Log::Terminal","term.log");
Cnf.CndSet("Dir::Log::History","history.log");