]> git.saurik.com Git - apt.git/commitdiff
edsp: if logging is requested, do it for internal, too
authorDavid Kalnischkies <david@kalnischkies.de>
Wed, 8 Jun 2016 09:34:53 +0000 (11:34 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Wed, 8 Jun 2016 11:09:42 +0000 (13:09 +0200)
Create and log the EDSP(like) request even if we use the internal
resolver.

apt-pkg/algorithms.cc
apt-pkg/edsp.cc
apt-pkg/upgrade.cc

index d202951a95c35012e121e93415633c4d64837bcf..b173979c3a4f5eaf25dcef28c488de9e0a8ddb1f 100644 (file)
@@ -636,8 +636,9 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 bool pkgProblemResolver::Resolve(bool BrokenFix, OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
 bool pkgProblemResolver::Resolve(bool BrokenFix, OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
+   auto const ret = EDSP::ResolveExternal(solver.c_str(), Cache, 0, Progress);
    if (solver != "internal")
    if (solver != "internal")
-      return EDSP::ResolveExternal(solver.c_str(), Cache, 0, Progress);
+      return ret;
    return ResolveInternal(BrokenFix);
 }
                                                                        /*}}}*/
    return ResolveInternal(BrokenFix);
 }
                                                                        /*}}}*/
@@ -1133,10 +1134,10 @@ bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I)
 bool pkgProblemResolver::ResolveByKeep(OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
 bool pkgProblemResolver::ResolveByKeep(OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
+   constexpr auto flags = EDSP::Request::UPGRADE_ALL | EDSP::Request::FORBID_NEW_INSTALL | EDSP::Request::FORBID_REMOVE;
+   auto const ret = EDSP::ResolveExternal(solver.c_str(), Cache, flags, Progress);
    if (solver != "internal")
    if (solver != "internal")
-      return EDSP::ResolveExternal(solver.c_str(), Cache,
-           EDSP::Request::UPGRADE_ALL | EDSP::Request::FORBID_NEW_INSTALL | EDSP::Request::FORBID_REMOVE,
-           Progress);
+      return ret;
    return ResolveByKeepInternal();
 }
                                                                        /*}}}*/
    return ResolveByKeepInternal();
 }
                                                                        /*}}}*/
index 58d2769f99a365639438c843c528ddae5756e133..fcff208c102ed2e734b103b71edf28105090a533 100644 (file)
@@ -20,6 +20,7 @@
 #include <apt-pkg/string_view.h>
 #include <apt-pkg/pkgsystem.h>
 
 #include <apt-pkg/string_view.h>
 #include <apt-pkg/pkgsystem.h>
 
+#include <sys/stat.h>
 #include <ctype.h>
 #include <stddef.h>
 #include <string.h>
 #include <ctype.h>
 #include <stddef.h>
 #include <string.h>
@@ -1007,6 +1008,19 @@ bool EDSP::ExecuteSolver(const char* const solver, int *solver_in, int *solver_o
 // EDSP::ResolveExternal - resolve problems by asking external for help        {{{*/
 bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache,
                         unsigned int const flags, OpProgress *Progress) {
 // EDSP::ResolveExternal - resolve problems by asking external for help        {{{*/
 bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache,
                         unsigned int const flags, OpProgress *Progress) {
+       if (strcmp(solver, "internal") == 0)
+       {
+               auto const dumpfile = _config->FindFile("Dir::Log::Solver");
+               if (dumpfile.empty())
+                       return false;
+               auto const dumpdir = flNotFile(dumpfile);
+               FileFd output;
+               if (CreateAPTDirectoryIfNeeded(dumpdir, dumpdir) == false ||
+                     output.Open(dumpfile, FileFd::WriteOnly | FileFd::Exclusive | FileFd::Create, FileFd::Extension, 0644) == false)
+                       return _error->WarningE("EDSP::Resolve", _("Could not open file '%s'"), dumpfile.c_str());
+               bool Okay = EDSP::WriteRequest(Cache, output, flags, nullptr);
+               return Okay && EDSP::WriteScenario(Cache, output, nullptr);
+       }
        int solver_in, solver_out;
        pid_t const solver_pid = EDSP::ExecuteSolver(solver, &solver_in, &solver_out, true);
        if (solver_pid == 0)
        int solver_in, solver_out;
        pid_t const solver_pid = EDSP::ExecuteSolver(solver, &solver_in, &solver_out, true);
        if (solver_pid == 0)
index c3be9b64f88e1877c95ac93385cc8912a7c6c306..afc9ad613ca0920320ae829eadcff8ee663d4854 100644 (file)
@@ -27,8 +27,9 @@
 static bool pkgDistUpgrade(pkgDepCache &Cache, OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
 static bool pkgDistUpgrade(pkgDepCache &Cache, OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
+   auto const ret = EDSP::ResolveExternal(solver.c_str(), Cache, EDSP::Request::UPGRADE_ALL, Progress);
    if (solver != "internal")
    if (solver != "internal")
-      return EDSP::ResolveExternal(solver.c_str(), Cache, EDSP::Request::UPGRADE_ALL, Progress);
+      return ret;
 
    if (Progress != NULL)
       Progress->OverallProgress(0, 100, 1, _("Calculating upgrade"));
 
    if (Progress != NULL)
       Progress->OverallProgress(0, 100, 1, _("Calculating upgrade"));
@@ -129,10 +130,10 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
 static bool pkgAllUpgradeNoNewPackages(pkgDepCache &Cache, OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
 static bool pkgAllUpgradeNoNewPackages(pkgDepCache &Cache, OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
+   constexpr auto flags = EDSP::Request::UPGRADE_ALL | EDSP::Request::FORBID_NEW_INSTALL | EDSP::Request::FORBID_REMOVE;
+   auto const ret = EDSP::ResolveExternal(solver.c_str(), Cache, flags, Progress);
    if (solver != "internal")
    if (solver != "internal")
-      return EDSP::ResolveExternal(solver.c_str(), Cache,
-           EDSP::Request::UPGRADE_ALL | EDSP::Request::FORBID_NEW_INSTALL | EDSP::Request::FORBID_REMOVE,
-           Progress);
+      return ret;
 
    if (Progress != NULL)
       Progress->OverallProgress(0, 100, 1, _("Calculating upgrade"));
 
    if (Progress != NULL)
       Progress->OverallProgress(0, 100, 1, _("Calculating upgrade"));
@@ -173,10 +174,10 @@ static bool pkgAllUpgradeNoNewPackages(pkgDepCache &Cache, OpProgress * const Pr
 static bool pkgAllUpgradeWithNewPackages(pkgDepCache &Cache, OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
 static bool pkgAllUpgradeWithNewPackages(pkgDepCache &Cache, OpProgress * const Progress)
 {
    std::string const solver = _config->Find("APT::Solver", "internal");
+   constexpr auto flags = EDSP::Request::UPGRADE_ALL | EDSP::Request::FORBID_REMOVE;
+   auto const ret = EDSP::ResolveExternal(solver.c_str(), Cache, flags, Progress);
    if (solver != "internal")
    if (solver != "internal")
-       return EDSP::ResolveExternal(solver.c_str(), Cache,
-           EDSP::Request::UPGRADE_ALL | EDSP::Request::FORBID_REMOVE,
-           Progress);
+      return ret;
 
    if (Progress != NULL)
       Progress->OverallProgress(0, 100, 1, _("Calculating upgrade"));
 
    if (Progress != NULL)
       Progress->OverallProgress(0, 100, 1, _("Calculating upgrade"));