]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/edsp.cc
remove old APT_COMPATIBILITY ifdef's
[apt.git] / apt-pkg / edsp.cc
index 489dd293336a3c4a47b17b6a787bfb69e4644e4a..137398100673154eba3dd318f028c73a1a483ee8 100644 (file)
@@ -5,19 +5,28 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/edsp.h>
 #include <apt-pkg/error.h>
+#include <apt-pkg/cacheset.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/version.h>
 #include <apt-pkg/policy.h>
 #include <apt-pkg/tagfile.h>
+#include <apt-pkg/fileutl.h>
+#include <apt-pkg/progress.h>
 
-#include <apti18n.h>
 #include <limits>
-
 #include <stdio.h>
+
+#include <string>
+
+#include <apti18n.h>
                                                                        /*}}}*/
 
+using std::string;
+
 // we could use pkgCache::DepType and ::Priority, but these would be localized stringsā€¦
 const char * const EDSP::PrioMap[] = {0, "important", "required", "standard",
                                      "optional", "extra"};
@@ -82,11 +91,11 @@ void EDSP::WriteScenarioVersion(pkgDepCache &Cache, FILE* output, pkgCache::PkgI
    if ((Pkg->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
       fprintf(output, "Essential: yes\n");
    fprintf(output, "Section: %s\n", Ver.Section());
-   if (Ver->MultiArch == pkgCache::Version::Allowed || Ver->MultiArch == pkgCache::Version::AllAllowed)
+   if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
       fprintf(output, "Multi-Arch: allowed\n");
-   else if (Ver->MultiArch == pkgCache::Version::Foreign || Ver->MultiArch == pkgCache::Version::AllForeign)
+   else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign)
       fprintf(output, "Multi-Arch: foreign\n");
-   else if (Ver->MultiArch == pkgCache::Version::Same)
+   else if ((Ver->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same)
       fprintf(output, "Multi-Arch: same\n");
    signed short Pin = std::numeric_limits<signed short>::min();
    for (pkgCache::VerFileIterator File = Ver.FileList(); File.end() == false; ++File) {
@@ -231,7 +240,7 @@ bool EDSP::WriteRequest(pkgDepCache &Cache, FILE* output, bool const Upgrade,
    if (_config->FindB("APT::Solver::Strict-Pinning", true) == false)
       fprintf(output, "Strict-Pinning: no\n");
    string solverpref("APT::Solver::");
-   solverpref.append(_config->Find("APT::Solver::Name", "internal")).append("::Preferences");
+   solverpref.append(_config->Find("APT::Solver", "internal")).append("::Preferences");
    if (_config->Exists(solverpref) == true)
       fprintf(output, "Preferences: %s\n", _config->Find(solverpref,"").c_str());
    fprintf(output, "\n");
@@ -267,19 +276,25 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres
                        type = "Remove";
                else if (section.Exists("Progress") == true) {
                        if (Progress != NULL) {
-                               string const msg = section.FindS("Message");
+                               string msg = section.FindS("Message");
                                if (msg.empty() == true)
-                                       Progress->SubProgress(100, _("Prepare for receiving solution"));
-                               else
-                                       Progress->SubProgress(100, msg);
-                               Progress->Progress(section.FindI("Percentage", 0));
+                                       msg = _("Prepare for receiving solution");
+                               Progress->SubProgress(100, msg, section.FindI("Percentage", 0));
                        }
                        continue;
                } else if (section.Exists("Error") == true) {
+                       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(msg.c_str());
+                       } else
+                               _error->Error("External solver failed with: %s", msg.substr(0,msg.find('\n')).c_str());
+                       if (Progress != NULL)
+                               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;
-                       std::cerr << SubstVar(SubstVar(section.FindS("Message"), "\n .\n", "\n\n"), "\n ", "\n") << std::endl << std::endl;
-                       break;
+                       std::cerr << msg << std::endl << std::endl;
+                       return false;
                } else if (section.Exists("Autoremove") == true)
                        type = "Autoremove";
                else
@@ -551,7 +566,7 @@ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache,
        if (Progress != NULL)
                Progress->OverallProgress(25, 100, 75, _("Execute external solver"));
        if (EDSP::ReadResponse(solver_out, Cache, Progress) == false)
-               return _error->Error("Reading solver response failed");
+               return false;
 
        return true;
 }