]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/edsp.cc
travis: ignore profiling warning in test diffs
[apt.git] / apt-pkg / edsp.cc
index 47b914fd58592dd9d11d20594aab884282387d29..b80b9a45679963899b26e12458a07e6e213bfc4f 100644 (file)
@@ -340,7 +340,7 @@ static bool WriteScenarioLimitedDependency(FileFd &output,
 static bool SkipUnavailableVersions(pkgDepCache &Cache, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver)/*{{{*/
 {
    /* versions which aren't current and aren't available in
-      any "online" source file are bad, expect if they are the choosen
+      any "online" source file are bad, expect if they are the chosen
       candidate: The exception is for build-dep implementation as it creates
       such pseudo (package) versions and removes them later on again.
       We filter out versions at all so packages in 'rc' state only available
@@ -648,13 +648,19 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
                        }
                        continue;
                } else if (section.Exists("Error") == true) {
+                       if (_error->PendingError()) {
+                               if (Progress != nullptr)
+                                       Progress->Done();
+                               Progress = nullptr;
+                               _error->DumpErrors(std::cerr, GlobalError::DEBUG, false);
+                       }
                        std::string msg = SubstVar(SubstVar(section.FindS("Message"), "\n .\n", "\n\n"), "\n ", "\n");
                        if (msg.empty() == true) {
                                msg = _("External solver failed without a proper error message");
                                _error->Error("%s", msg.c_str());
                        } else
                                _error->Error("External solver failed with: %s", msg.substr(0,msg.find('\n')).c_str());
-                       if (Progress != NULL)
+                       if (Progress != nullptr)
                                Progress->Done();
                        std::cerr << "The solver encountered an error of type: " << section.FindS("Error") << std::endl;
                        std::cerr << "The following information might help you to understand what is wrong:" << std::endl;
@@ -1051,8 +1057,9 @@ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache,
                Okay &= EDSP::WriteRequest(Cache, output, flags, nullptr);
                return Okay && EDSP::WriteScenario(Cache, output, nullptr);
        }
+       _error->PushToStack();
        int solver_in, solver_out;
-       pid_t const solver_pid = EDSP::ExecuteSolver(solver, &solver_in, &solver_out, true);
+       pid_t const solver_pid = ExecuteSolver(solver, &solver_in, &solver_out, true);
        if (solver_pid == 0)
                return false;
 
@@ -1061,20 +1068,21 @@ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache,
                return _error->Errno("ResolveExternal", "Opening solver %s stdin on fd %d for writing failed", solver, solver_in);
 
        bool Okay = output.Failed() == false;
-       if (Progress != NULL)
+       if (Okay && Progress != NULL)
                Progress->OverallProgress(0, 100, 5, _("Execute external solver"));
        Okay &= EDSP::WriteRequest(Cache, output, flags, Progress);
-       if (Progress != NULL)
+       if (Okay && Progress != NULL)
                Progress->OverallProgress(5, 100, 20, _("Execute external solver"));
        Okay &= EDSP::WriteScenario(Cache, output, Progress);
        output.Close();
 
-       if (Progress != NULL)
+       if (Okay && Progress != NULL)
                Progress->OverallProgress(25, 100, 75, _("Execute external solver"));
-       if (Okay && EDSP::ReadResponse(solver_out, Cache, Progress) == false)
-               return false;
-
-       return ExecWait(solver_pid, solver);
+       bool const ret = EDSP::ReadResponse(solver_out, Cache, Progress);
+       _error->MergeWithStack();
+       if (ExecWait(solver_pid, solver))
+               return ret;
+       return false;
 }
 bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache,
                         bool const upgrade, bool const distUpgrade,
@@ -1107,7 +1115,7 @@ bool EIPP::OrderInstall(char const * const solver, pkgPackageManager * const PM,
       Okay &= EIPP::WriteRequest(PM->Cache, output, flags, nullptr);
       return Okay && EIPP::WriteScenario(PM->Cache, output, nullptr);
    }
-
+   _error->PushToStack();
    int solver_in, solver_out;
    pid_t const solver_pid = ExecuteExternal("planner", solver, "Dir::Bin::Planners", &solver_in, &solver_out);
    if (solver_pid == 0)
@@ -1118,28 +1126,31 @@ bool EIPP::OrderInstall(char const * const solver, pkgPackageManager * const PM,
       return _error->Errno("EIPP::OrderInstall", "Opening planner %s stdin on fd %d for writing failed", solver, solver_in);
 
    bool Okay = output.Failed() == false;
-   if (Progress != NULL)
+   if (Okay && Progress != NULL)
       Progress->OverallProgress(0, 100, 5, _("Execute external planner"));
    Okay &= EIPP::WriteRequest(PM->Cache, output, flags, Progress);
-   if (Progress != NULL)
+   if (Okay && Progress != NULL)
       Progress->OverallProgress(5, 100, 20, _("Execute external planner"));
    Okay &= EIPP::WriteScenario(PM->Cache, output, Progress);
    output.Close();
 
-   if (Progress != NULL)
-      Progress->OverallProgress(25, 100, 75, _("Execute external planner"));
-
-   // we don't tell the external planners about boring things
-   for (auto Pkg = PM->Cache.PkgBegin(); Pkg.end() == false; ++Pkg)
+   if (Okay)
    {
-      if (Pkg->CurrentState == pkgCache::State::ConfigFiles && PM->Cache[Pkg].Purge() == true)
-        PM->Remove(Pkg, true);
-   }
+      if (Progress != nullptr)
+        Progress->OverallProgress(25, 100, 75, _("Execute external planner"));
 
-   if (Okay && EIPP::ReadResponse(solver_out, PM, Progress) == false)
-      return false;
-
-   return ExecWait(solver_pid, solver);
+      // we don't tell the external planners about boring things
+      for (auto Pkg = PM->Cache.PkgBegin(); Pkg.end() == false; ++Pkg)
+      {
+        if (Pkg->CurrentState == pkgCache::State::ConfigFiles && PM->Cache[Pkg].Purge() == true)
+           PM->Remove(Pkg, true);
+      }
+   }
+   bool const ret = EIPP::ReadResponse(solver_out, PM, Progress);
+   _error->MergeWithStack();
+   if (ExecWait(solver_pid, solver))
+      return ret;
+   return false;
 }
                                                                        /*}}}*/
 bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output,            /*{{{*/
@@ -1336,13 +1347,19 @@ bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM, OpProgres
         }
         continue;
       } else if (section.Exists("Error") == true) {
+        if (_error->PendingError()) {
+           if (Progress != nullptr)
+              Progress->Done();
+           Progress = nullptr;
+           _error->DumpErrors(std::cerr, GlobalError::DEBUG, false);
+        }
         std::string msg = SubstVar(SubstVar(section.FindS("Message"), "\n .\n", "\n\n"), "\n ", "\n");
         if (msg.empty() == true) {
            msg = _("External planner failed without a proper error message");
            _error->Error("%s", msg.c_str());
         } else
            _error->Error("External planner failed with: %s", msg.substr(0,msg.find('\n')).c_str());
-        if (Progress != NULL)
+        if (Progress != nullptr)
            Progress->Done();
         std::cerr << "The planner encountered an error of type: " << section.FindS("Error") << std::endl;
         std::cerr << "The following information might help you to understand what is wrong:" << std::endl;