]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/algorithms.cc
send the first line of the error message to the error list and fail a bit
[apt.git] / apt-pkg / algorithms.cc
index bbe315ef79fb62692fc2325731d0e6d93be483e8..31c3e9c28633316d7835f7e4743229e4e99a0bf6 100644 (file)
@@ -332,6 +332,12 @@ bool pkgFixBroken(pkgDepCache &Cache)
  */
 bool pkgDistUpgrade(pkgDepCache &Cache)
 {
+   std::string const solver = _config->Find("APT::Solver::Name", "internal");
+   if (solver != "internal") {
+      OpTextProgress Prog(*_config);
+      return EDSP::ResolveExternal(solver.c_str(), Cache, false, true, false, &Prog);
+   }
+
    pkgDepCache::ActionGroup group(Cache);
 
    /* Upgrade all installed packages first without autoinst to help the resolver
@@ -384,6 +390,12 @@ bool pkgDistUpgrade(pkgDepCache &Cache)
    to install packages not marked for install */
 bool pkgAllUpgrade(pkgDepCache &Cache)
 {
+   std::string const solver = _config->Find("APT::Solver::Name", "internal");
+   if (solver != "internal") {
+      OpTextProgress Prog(*_config);
+      return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog);
+   }
+
    pkgDepCache::ActionGroup group(Cache);
 
    pkgProblemResolver Fix(&Cache);
@@ -740,46 +752,9 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg)
 bool pkgProblemResolver::Resolve(bool BrokenFix)
 {
    std::string const solver = _config->Find("APT::Solver::Name", "internal");
-
-   if (solver != "internal")
-   {
-//       std::string const file = _config->FindDir("Dir::Bin::Solvers") + solver;
-      std::string const file = solver;
-      if (RealFileExists(file.c_str()) == false)
-        return _error->Error("Can't call external solver '%s' as it is not available: %s", solver.c_str(), file.c_str());
-      int external[4] = {-1, -1, -1, -1};
-      if (pipe(external) != 0 || pipe(external + 2) != 0)
-        return _error->Errno("Resolve", "Can't create needed IPC pipes for EDSP");
-      for (int i = 0; i < 4; ++i)
-        SetCloseExec(external[i], true);
-
-      pid_t Solver = ExecFork();
-      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);
-        std::cerr << "Failed to execute solver '" << solver << "'!" << std::endl;
-        _exit(100);
-      }
-      close(external[0]);
-      close(external[3]);
-
-      if (WaitFd(external[1], true, 5) == false)
-         return _error->Errno("Resolve", "Waiting on availability of solver stdin timed out");
-
-      FILE* output = fdopen(external[1], "w");
-      if (output == NULL)
-         return _error->Errno("Resolve", "fdopen on solver stdin failed");
-      EDSP::WriteRequest(Cache, output);
-      EDSP::WriteScenario(Cache, output);
-      fclose(output);
-
-      if (EDSP::ReadResponse(external[2], Cache) == false)
-        return _error->Error("Reading solver response failed");
-
-      return ExecWait(Solver, solver.c_str(), false);
+   if (solver != "internal") {
+      OpTextProgress Prog(*_config);
+      return EDSP::ResolveExternal(solver.c_str(), Cache, false, false, false, &Prog);
    }
    return ResolveInternal(BrokenFix);
 }
@@ -1252,6 +1227,21 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix)
    in that it does not install or remove any packages. It is assumed that the
    system was non-broken previously. */
 bool pkgProblemResolver::ResolveByKeep()
+{
+   std::string const solver = _config->Find("APT::Solver::Name", "internal");
+   if (solver != "internal") {
+      OpTextProgress Prog(*_config);
+      return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog);
+   }
+   return ResolveByKeepInternal();
+}
+                                                                       /*}}}*/
+// ProblemResolver::ResolveByKeepInternal - Resolve problems using keep        /*{{{*/
+// ---------------------------------------------------------------------
+/* This is the work horse of the soft upgrade routine. It is very gental
+   in that it does not install or remove any packages. It is assumed that the
+   system was non-broken previously. */
+bool pkgProblemResolver::ResolveByKeepInternal()
 {
    pkgDepCache::ActionGroup group(Cache);