From 4128c84679e54e2afda7913946facaf9c52cd3eb Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 1 Apr 2011 16:14:24 +0200 Subject: add a small wrapper to use the internal apt solver as an external one --- cmdline/apt-internal-solver.cc | 129 +++++++++++++++++++++++++++++++++++++++++ cmdline/makefile | 7 +++ 2 files changed, 136 insertions(+) create mode 100644 cmdline/apt-internal-solver.cc (limited to 'cmdline') diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc new file mode 100644 index 000000000..83d79e42a --- /dev/null +++ b/cmdline/apt-internal-solver.cc @@ -0,0 +1,129 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ##################################################################### + + cover around the internal solver to be able to run it like an external + + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + /*}}}*/ + +// ShowHelp - Show a help screen /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool ShowHelp(CommandLine &CmdL) { + ioprintf(std::cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,VERSION, + COMMON_ARCH,__DATE__,__TIME__); + + std::cout << + _("Usage: apt-internal-resolver\n" + "\n" + "apt-internal-resolver is an interface to use the current internal\n" + "like an external resolver for the APT family for debugging or alike\n" + "\n" + "Options:\n" + " -h This help text.\n" + " -q Loggable output - no progress indicator\n" + " -c=? Read this configuration file\n" + " -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n" + "apt.conf(5) manual pages for more information and options.\n" + " This APT has Super Cow Powers.\n"); + return true; +} + /*}}}*/ +int main(int argc,const char *argv[]) /*{{{*/ +{ + CommandLine::Args Args[] = { + {'h',"help","help",0}, + {'v',"version","version",0}, + {'q',"quiet","quiet",CommandLine::IntLevel}, + {'q',"silent","quiet",CommandLine::IntLevel}, + {0,0,0,0}}; + + CommandLine CmdL(Args,_config); + if (pkgInitConfig(*_config) == false || + CmdL.Parse(argc,argv) == false) { + _error->DumpErrors(); + return 2; + } + + // See if the help should be shown + if (_config->FindB("help") == true || + _config->FindB("version") == true) { + ShowHelp(CmdL); + return 1; + } + + // Deal with stdout not being a tty + if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1) + _config->Set("quiet","1"); + + if (_config->FindI("quiet", 0) < 1) + _config->Set("Debug::EDSP::WriteSolution", true); + + _config->Set("APT::Solver::Name", "internal"); + _config->Set("edsp::scenario", "stdin"); + int input = STDIN_FILENO; + FILE* output = stdout; + SetNonBlock(input, false); + + if (pkgInitSystem(*_config,_system) == false) { + std::cerr << "System could not be initialized!" << std::endl; + return 1; + } + + if (WaitFd(input, false, 5) == false) + std::cerr << "WAIT timed out in the resolver" << std::endl; + + std::list install, remove; + bool upgrade, distUpgrade, autoRemove; + if (EDSP::ReadRequest(input, install, remove, upgrade, distUpgrade, autoRemove) == false) { + std::cerr << "Parsing the request failed!" << std::endl; + return 2; + } + + pkgCacheFile CacheFile; + CacheFile.Open(NULL, false); + + if (EDSP::ApplyRequest(install, remove, CacheFile) == false) { + std::cerr << "Failed to apply request to depcache!" << std::endl; + return 3; + } + for (std::list::const_iterator i = install.begin(); + i != install.end(); ++i) + CacheFile->MarkInstall(CacheFile->FindPkg(*i), true); + + pkgProblemResolver Fix(CacheFile); + if (Fix.Resolve() == false) { + EDSP::WriteError("An error occured", output); + return 0; + } + + if (EDSP::WriteSolution(CacheFile, output) == false) { + std::cerr << "Failed to output the solution!" << std::endl; + return 4; + } + + bool const Errors = _error->PendingError(); + if (_config->FindI("quiet",0) > 0) + _error->DumpErrors(); + else + _error->DumpErrors(GlobalError::DEBUG); + return Errors == true ? 100 : 0; +} + /*}}}*/ diff --git a/cmdline/makefile b/cmdline/makefile index 917ccc96a..4462ccaf4 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -64,3 +64,10 @@ include $(COPY_H) #TO=$(BIN) #TARGET=program #include $(COPY_H) + +# The internal solver acting as an external +PROGRAM=apt-internal-solver +SLIBS = -lapt-pkg $(INTLLIBS) +LIB_MAKES = apt-pkg/makefile +SOURCE = apt-internal-solver.cc +include $(PROGRAM_H) -- cgit v1.2.3-70-g09d2 From 56d53b54e795479194eb653741c5a816698db43f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 2 Apr 2011 15:51:37 +0200 Subject: disable the error discarding as it destroyes the error reporting about failures with external solvers for now as long as i can't see a reason for it --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6ffecd777..a1264f54a 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1887,7 +1887,7 @@ bool DoInstall(CommandLine &CmdL) // Call the scored problem resolver Fix->InstallProtect(); if (Fix->Resolve(true) == false) - _error->Discard(); + ; //FIXME: is there a valid reason for? _error->Discard(); delete Fix; } -- cgit v1.2.3-70-g09d2 From d9933172b31e21862b660c182f7c747802dbaa73 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 19 Apr 2011 11:52:47 +0200 Subject: set hint flags for the problem resolver according to request --- cmdline/apt-internal-solver.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index 83d79e42a..83a671a96 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -104,11 +104,28 @@ int main(int argc,const char *argv[]) /*{{{*/ std::cerr << "Failed to apply request to depcache!" << std::endl; return 3; } + + pkgProblemResolver Fix(CacheFile); + for (std::list::const_iterator i = remove.begin(); + i != remove.end(); ++i) { + pkgCache::PkgIterator P = CacheFile->FindPkg(*i); + Fix.Clear(P); + Fix.Protect(P); + Fix.Remove(P); + } + + for (std::list::const_iterator i = install.begin(); + i != install.end(); ++i) { + pkgCache::PkgIterator P = CacheFile->FindPkg(*i); + Fix.Clear(P); + Fix.Protect(P); + } + for (std::list::const_iterator i = install.begin(); i != install.end(); ++i) CacheFile->MarkInstall(CacheFile->FindPkg(*i), true); - pkgProblemResolver Fix(CacheFile); + if (Fix.Resolve() == false) { EDSP::WriteError("An error occured", output); return 0; -- cgit v1.2.3-70-g09d2 From 904be3525223633721dc7b5bff22ae7d8db8cb95 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 25 Apr 2011 15:59:45 +0200 Subject: add scenario command to output a complete or limited scenario --- cmdline/apt-internal-solver.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index 83a671a96..68489e213 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -53,6 +53,8 @@ int main(int argc,const char *argv[]) /*{{{*/ {'v',"version","version",0}, {'q',"quiet","quiet",CommandLine::IntLevel}, {'q',"silent","quiet",CommandLine::IntLevel}, + {'c',"config-file",0,CommandLine::ConfigFile}, + {'o',"option",0,CommandLine::ArbItem}, {0,0,0,0}}; CommandLine CmdL(Args,_config); @@ -69,6 +71,25 @@ int main(int argc,const char *argv[]) /*{{{*/ return 1; } + if (CmdL.FileList[0] != 0 && strcmp(CmdL.FileList[0], "scenario") == 0) + { + if (pkgInitSystem(*_config,_system) == false) { + std::cerr << "System could not be initialized!" << std::endl; + return 1; + } + pkgCacheFile CacheFile; + CacheFile.Open(NULL, false); + APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1); + FILE* output = stdout; + if (pkgset.empty() == true) + EDSP::WriteScenario(CacheFile, output); + else + EDSP::WriteLimitedScenario(CacheFile, output, pkgset); + fclose(output); + _error->DumpErrors(std::cerr); + return 0; + } + // Deal with stdout not being a tty if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1) _config->Set("quiet","1"); @@ -138,9 +159,9 @@ int main(int argc,const char *argv[]) /*{{{*/ bool const Errors = _error->PendingError(); if (_config->FindI("quiet",0) > 0) - _error->DumpErrors(); + _error->DumpErrors(std::cerr); else - _error->DumpErrors(GlobalError::DEBUG); + _error->DumpErrors(std::cerr, GlobalError::DEBUG); return Errors == true ? 100 : 0; } /*}}}*/ -- cgit v1.2.3-70-g09d2 From e876223c704d8cac6246b4aff4bf683fb8b053e3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 2 May 2011 11:51:44 +0200 Subject: implement optional Progress report in EDSP --- apt-pkg/edsp.cc | 21 +++++++++++++++++++-- apt-pkg/edsp.h | 1 + cmdline/apt-internal-solver.cc | 13 +++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) (limited to 'cmdline') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index aec43c7e8..6343b57cd 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -242,8 +242,16 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache) { type = "Install"; else if (section.Exists("Remove") == true) type = "Remove"; - //FIXME: handle progress - else + else if (section.Exists("Progress") == true) { + ioprintf(std::clog, "[ %3d%% ] ", section.FindI("Percentage", 0)); + std::clog << section.FindS("Progress") << " - "; + string const msg = section.FindS("Message"); + if (msg.empty() == true) + std::clog << "Solver is still working on the solution" << std::endl; + else + std::clog << msg << std::endl; + continue; + } else continue; size_t const id = section.FindULL(type.c_str(), VersionCount); @@ -422,4 +430,13 @@ bool EDSP::WriteSolution(pkgDepCache &Cache, FILE* output) return true; } /*}}}*/ +// EDSP::WriteProgess - pulse to the given file descriptor /*{{{*/ +bool EDSP::WriteProgress(unsigned short const percent, const char* const message, FILE* output) { + fprintf(output, "Progress: %s\n", TimeRFC1123(time(NULL)).c_str()); + fprintf(output, "Percentage: %d\n", percent); + fprintf(output, "Message: %s\n\n", message); + fflush(output); + return true; +} + /*}}}*/ bool EDSP::WriteError(std::string const &message, FILE* output) { return false; } diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index db4f06a7c..a05de9448 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -49,6 +49,7 @@ public: std::list const &remove, pkgDepCache &Cache); bool static WriteSolution(pkgDepCache &Cache, FILE* output); + bool static WriteProgress(unsigned short const percent, const char* const message, FILE* output); bool static WriteError(std::string const &message, FILE* output); }; diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index 68489e213..0aa218d52 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -103,11 +103,15 @@ int main(int argc,const char *argv[]) /*{{{*/ FILE* output = stdout; SetNonBlock(input, false); + EDSP::WriteProgress(0, "Start up solver…", output); + if (pkgInitSystem(*_config,_system) == false) { std::cerr << "System could not be initialized!" << std::endl; return 1; } + EDSP::WriteProgress(1, "Read request…", output); + if (WaitFd(input, false, 5) == false) std::cerr << "WAIT timed out in the resolver" << std::endl; @@ -118,9 +122,13 @@ int main(int argc,const char *argv[]) /*{{{*/ return 2; } + EDSP::WriteProgress(5, "Read scenario…", output); + pkgCacheFile CacheFile; CacheFile.Open(NULL, false); + EDSP::WriteProgress(50, "Apply request on scenario…", output); + if (EDSP::ApplyRequest(install, remove, CacheFile) == false) { std::cerr << "Failed to apply request to depcache!" << std::endl; return 3; @@ -146,17 +154,22 @@ int main(int argc,const char *argv[]) /*{{{*/ i != install.end(); ++i) CacheFile->MarkInstall(CacheFile->FindPkg(*i), true); + EDSP::WriteProgress(60, "Call problemresolver on current scenario…", output); if (Fix.Resolve() == false) { EDSP::WriteError("An error occured", output); return 0; } + EDSP::WriteProgress(95, "Write solution…", output); + if (EDSP::WriteSolution(CacheFile, output) == false) { std::cerr << "Failed to output the solution!" << std::endl; return 4; } + EDSP::WriteProgress(100, "Done", output); + bool const Errors = _error->PendingError(); if (_config->FindI("quiet",0) > 0) _error->DumpErrors(std::cerr); -- cgit v1.2.3-70-g09d2 From 80699703b6015a8fe7707302f365020f9782cf2c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 3 May 2011 10:38:49 +0200 Subject: work on requests with the correct upgrade/dist-upgrade/else resolver --- cmdline/apt-internal-solver.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index 0aa218d52..df6a6f569 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -156,7 +156,17 @@ int main(int argc,const char *argv[]) /*{{{*/ EDSP::WriteProgress(60, "Call problemresolver on current scenario…", output); - if (Fix.Resolve() == false) { + if (upgrade == true) { + if (pkgAllUpgrade(CacheFile) == false) { + EDSP::WriteError("An upgrade error occured", output); + return 0; + } + } else if (distUpgrade == true) { + if (pkgDistUpgrade(CacheFile) == false) { + EDSP::WriteError("An dist-upgrade error occured", output); + return 0; + } + } else if (Fix.Resolve() == false) { EDSP::WriteError("An error occured", output); return 0; } -- cgit v1.2.3-70-g09d2 From df783e0aa69f70b7be2b7fb44cc593efd86f7730 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 3 May 2011 14:17:29 +0200 Subject: add a --solver option to apt-get --- cmdline/apt-get.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index a1264f54a..2312f5a10 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -3253,6 +3253,7 @@ int main(int argc,const char *argv[]) /*{{{*/ {0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean}, {0,"install-suggests","APT::Install-Suggests",CommandLine::Boolean}, {0,"fix-policy","APT::Get::Fix-Policy-Broken",0}, + {0,"solver","APT::Solver::Name",CommandLine::HasArg}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, {0,0,0,0}}; -- cgit v1.2.3-70-g09d2 From 7f4713547665e12e032501228a98586e5add48f7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 3 May 2011 17:27:11 +0200 Subject: add a tiny dump solver to quickly output a scenario --- cmdline/apt-dump-solver.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++++ cmdline/makefile | 7 +++++++ debian/apt-utils.install | 1 + debian/apt.dirs | 1 + debian/rules | 2 +- 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 cmdline/apt-dump-solver.cc (limited to 'cmdline') diff --git a/cmdline/apt-dump-solver.cc b/cmdline/apt-dump-solver.cc new file mode 100644 index 000000000..5bcfe4f06 --- /dev/null +++ b/cmdline/apt-dump-solver.cc @@ -0,0 +1,50 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +/* ##################################################################### + + dummy solver to get quickly a scenario file out of APT + + ##################################################################### */ + /*}}}*/ +// Include Files /*{{{*/ +#include + +#include + +#include + /*}}}*/ + +// ShowHelp - Show a help screen /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool ShowHelp() { + + std::cout << + PACKAGE " " VERSION " for " COMMON_ARCH " compiled on " __DATE__ " " __TIME__ << std::endl << + "Usage: apt-dump-resolver\n" + "\n" + "apt-dump-resolver is a dummy solver who just dumps its input to the\n" + "file /tmp/dump.edsp and exists with a proper EDSP error.\n" + "\n" + " This dump has lost Super Cow Powers.\n"; + return true; +} + /*}}}*/ +int main(int argc,const char *argv[]) /*{{{*/ +{ + if (argc > 1 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1],"-h") == 0 || + strcmp(argv[1],"-v") == 0 || strcmp(argv[1],"--version") == 0)) { + ShowHelp(); + return 0; + } + + FILE* input = fdopen(STDIN_FILENO, "r"); + FILE* output = fopen("/tmp/dump.edsp", "w"); + char buffer[400]; + while (fgets(buffer, sizeof(buffer), input) != NULL) + fputs(buffer, output); + fclose(output); + fclose(input); + + EDSP::WriteError("I am too dumb, i can just dump!", stdout); +} diff --git a/cmdline/makefile b/cmdline/makefile index 4462ccaf4..aea5d1db5 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -71,3 +71,10 @@ SLIBS = -lapt-pkg $(INTLLIBS) LIB_MAKES = apt-pkg/makefile SOURCE = apt-internal-solver.cc include $(PROGRAM_H) + +# The internal solver acting as an external +PROGRAM=apt-dump-solver +SLIBS = -lapt-pkg $(INTLLIBS) +LIB_MAKES = apt-pkg/makefile +SOURCE = apt-dump-solver.cc +include $(PROGRAM_H) diff --git a/debian/apt-utils.install b/debian/apt-utils.install index d947f26d4..0c72bfdc8 100644 --- a/debian/apt-utils.install +++ b/debian/apt-utils.install @@ -1 +1,2 @@ bin/libapt-inst*.so.* usr/lib/ +bin/apt-dump-solver usr/lib/apt/solvers/dump diff --git a/debian/apt.dirs b/debian/apt.dirs index 2770d79bb..f9c0b6c3e 100644 --- a/debian/apt.dirs +++ b/debian/apt.dirs @@ -1,5 +1,6 @@ usr/bin usr/lib/apt/methods +usr/lib/apt/solvers usr/lib/dpkg/methods/apt etc/apt etc/apt/apt.conf.d diff --git a/debian/rules b/debian/rules index c8aefee63..77a7b4fdb 100755 --- a/debian/rules +++ b/debian/rules @@ -182,7 +182,7 @@ apt: build build-doc dh_install -p$@ --sourcedir=$(BLD) # Remove the bits that are in apt-utils - rm $(addprefix debian/$@/usr/bin/apt-,$(APT_UTILS)) + rm $(addprefix debian/$@/usr/bin/apt-,$(APT_UTILS) dump-solver) # https has its own package rm debian/$@/usr/lib/apt/methods/https -- cgit v1.2.3-70-g09d2 From ebfeeaedf5bc357170cae971c0f6a1458ff65f65 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 7 May 2011 15:49:51 +0200 Subject: implement correct error reporting --- apt-pkg/edsp.cc | 14 ++++++++++++-- apt-pkg/edsp.h | 7 ++++++- cmdline/apt-dump-solver.cc | 2 +- cmdline/apt-internal-solver.cc | 6 +++--- 4 files changed, 22 insertions(+), 7 deletions(-) (limited to 'cmdline') diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index d604110ef..7ece92d2e 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -256,6 +256,11 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache) { else std::clog << msg << std::endl; continue; + } else if (section.Exists("Error") == true) { + 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; } else if (section.Exists("Autoremove") == true) type = "Autoremove"; else @@ -457,8 +462,13 @@ bool EDSP::WriteProgress(unsigned short const percent, const char* const message return true; } /*}}}*/ -bool EDSP::WriteError(std::string const &message, FILE* output) { return false; } - +// EDSP::WriteError - format an error message to be send to file descriptor /*{{{*/ +bool EDSP::WriteError(char const * const uuid, std::string const &message, FILE* output) { + fprintf(output, "Error: %s\n", uuid); + fprintf(output, "Message: %s\n\n", SubstVar(SubstVar(message, "\n\n", "\n.\n"), "\n", "\n ").c_str()); + return true; +} + /*}}}*/ // EDSP::ExecuteSolver - fork requested solver and setup ipc pipes {{{*/ bool EDSP::ExecuteSolver(const char* const solver, int *solver_in, int *solver_out) { std::vector const solverDirs = _config->FindVector("Dir::Bin::Solvers"); diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index 98a70d7f6..210188d03 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -171,8 +171,13 @@ public: * * The first line of the message should be a short description * of the error so it can be used for dialog titles or alike + * + * \param uuid of this error message + * \param message is free form text to discribe the error + * \param output the front-end listens for error messages */ - bool static WriteError(std::string const &message, FILE* output); + bool static WriteError(char const * const uuid, std::string const &message, FILE* output); + /** \brief executes the given solver and returns the pipe ends * diff --git a/cmdline/apt-dump-solver.cc b/cmdline/apt-dump-solver.cc index 5bcfe4f06..dab0cc6fd 100644 --- a/cmdline/apt-dump-solver.cc +++ b/cmdline/apt-dump-solver.cc @@ -46,5 +46,5 @@ int main(int argc,const char *argv[]) /*{{{*/ fclose(output); fclose(input); - EDSP::WriteError("I am too dumb, i can just dump!", stdout); + EDSP::WriteError("ERR_JUST_DUMPING", "I am too dumb, i can just dump!\nPlease use one of my friends instead!", stdout); } diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index df6a6f569..ad00a0e23 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -158,16 +158,16 @@ int main(int argc,const char *argv[]) /*{{{*/ if (upgrade == true) { if (pkgAllUpgrade(CacheFile) == false) { - EDSP::WriteError("An upgrade error occured", output); + EDSP::WriteError("ERR_UNSOLVABLE_UPGRADE", "An upgrade error occured", output); return 0; } } else if (distUpgrade == true) { if (pkgDistUpgrade(CacheFile) == false) { - EDSP::WriteError("An dist-upgrade error occured", output); + EDSP::WriteError("ERR_UNSOLVABLE_DIST_UPGRADE", "An dist-upgrade error occured", output); return 0; } } else if (Fix.Resolve() == false) { - EDSP::WriteError("An error occured", output); + EDSP::WriteError("ERR_UNSOLVABLE", "An error occured", output); return 0; } -- cgit v1.2.3-70-g09d2 From 98278a81bf554246b70b97852c9b8b92eac390ea Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 17 May 2011 17:42:01 +0200 Subject: rename option APT::Solver::Name to simply APT::Solver --- apt-pkg/algorithms.cc | 8 ++++---- apt-pkg/depcache.cc | 4 ++-- apt-pkg/edsp.cc | 2 +- cmdline/apt-get.cc | 2 +- cmdline/apt-internal-solver.cc | 2 +- doc/external-dependency-solver-protocol.txt | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'cmdline') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 6f1f82d50..47bdd4aba 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -330,7 +330,7 @@ bool pkgFixBroken(pkgDepCache &Cache) */ bool pkgDistUpgrade(pkgDepCache &Cache) { - std::string const solver = _config->Find("APT::Solver::Name", "internal"); + std::string const solver = _config->Find("APT::Solver", "internal"); if (solver != "internal") { OpTextProgress Prog(*_config); return EDSP::ResolveExternal(solver.c_str(), Cache, false, true, false, &Prog); @@ -388,7 +388,7 @@ 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"); + std::string const solver = _config->Find("APT::Solver", "internal"); if (solver != "internal") { OpTextProgress Prog(*_config); return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog); @@ -745,7 +745,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg) /* */ bool pkgProblemResolver::Resolve(bool BrokenFix) { - std::string const solver = _config->Find("APT::Solver::Name", "internal"); + std::string const solver = _config->Find("APT::Solver", "internal"); if (solver != "internal") { OpTextProgress Prog(*_config); return EDSP::ResolveExternal(solver.c_str(), Cache, false, false, false, &Prog); @@ -1211,7 +1211,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) system was non-broken previously. */ bool pkgProblemResolver::ResolveByKeep() { - std::string const solver = _config->Find("APT::Solver::Name", "internal"); + std::string const solver = _config->Find("APT::Solver", "internal"); if (solver != "internal") { OpTextProgress Prog(*_config); return EDSP::ResolveExternal(solver.c_str(), Cache, true, false, false, &Prog); diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 5cb68804d..947435706 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1046,7 +1046,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, Update(Pkg); AddSizes(Pkg); - if (AutoInst == false || _config->Find("APT::Solver::Name", "internal") != "internal") + if (AutoInst == false || _config->Find("APT::Solver", "internal") != "internal") return; if (DebugMarker == true) @@ -1605,7 +1605,7 @@ bool pkgDepCache::MarkFollowsSuggests() // pkgDepCache::MarkRequired - the main mark algorithm /*{{{*/ bool pkgDepCache::MarkRequired(InRootSetFunc &userFunc) { - if (_config->Find("APT::Solver::Name", "internal") != "internal") + if (_config->Find("APT::Solver", "internal") != "internal") return true; bool follow_recommends; diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 218ce9f24..02ef7d04b 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -231,7 +231,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"); diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index fdb1033a1..d48ca18f9 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -3270,7 +3270,7 @@ int main(int argc,const char *argv[]) /*{{{*/ {0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean}, {0,"install-suggests","APT::Install-Suggests",CommandLine::Boolean}, {0,"fix-policy","APT::Get::Fix-Policy-Broken",0}, - {0,"solver","APT::Solver::Name",CommandLine::HasArg}, + {0,"solver","APT::Solver",CommandLine::HasArg}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, {0,0,0,0}}; diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index ad00a0e23..ef6c688fe 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -97,7 +97,7 @@ int main(int argc,const char *argv[]) /*{{{*/ if (_config->FindI("quiet", 0) < 1) _config->Set("Debug::EDSP::WriteSolution", true); - _config->Set("APT::Solver::Name", "internal"); + _config->Set("APT::Solver", "internal"); _config->Set("edsp::scenario", "stdin"); int input = STDIN_FILENO; FILE* output = stdout; diff --git a/doc/external-dependency-solver-protocol.txt b/doc/external-dependency-solver-protocol.txt index ae01fbc35..7a124d8f9 100644 --- a/doc/external-dependency-solver-protocol.txt +++ b/doc/external-dependency-solver-protocol.txt @@ -47,7 +47,7 @@ Several APT options can be used to affect dependency solving in APT. An overview of them is given below. Please refer to proper APT configuration documentation for more, and more up to date, information. -- **APT::Solver::Name**: the name of the solver to be used for +- **APT::Solver**: the name of the solver to be used for dependency solving. Defaults to `internal` - **APT::Solver::Strict-Pinning**: whether pinning must be strictly -- cgit v1.2.3-70-g09d2 From d953d210bb54accb416f2144104b79dcd29198ba Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 17 May 2011 20:20:46 +0200 Subject: * cmdline/apt-get.cc: - do not discard the error messages from the resolver and instead only show the general 'Broken packages' message if nothing else --- cmdline/apt-get.cc | 10 ++++++---- debian/changelog | 5 ++++- test/integration/test-handling-broken-orgroups | 4 ++-- test/integration/test-release-candidate-switching | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index d48ca18f9..65eaef0d8 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1886,8 +1886,7 @@ bool DoInstall(CommandLine &CmdL) { // Call the scored problem resolver Fix->InstallProtect(); - if (Fix->Resolve(true) == false) - ; //FIXME: is there a valid reason for? _error->Discard(); + Fix->Resolve(true); delete Fix; } @@ -1913,8 +1912,11 @@ bool DoInstall(CommandLine &CmdL) c1out << _("The following information may help to resolve the situation:") << endl; c1out << endl; ShowBroken(c1out,Cache,false); - return _error->Error(_("Broken packages")); - } + if (_error->PendingError() == true) + return false; + else + return _error->Error(_("Broken packages")); + } } if (!DoAutomaticRemove(Cache)) return false; diff --git a/debian/changelog b/debian/changelog index 9fc6dc193..71f64dc23 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,12 +16,15 @@ apt (0.8.15) UNRELEASED; urgency=low - let the Mark methods return if their marking was successful - if a Breaks can't be upgraded, remove it. If it or a Conflict can't be removed the installation of the breaker fails. + * cmdline/apt-get.cc: + - do not discard the error messages from the resolver and instead + only show the general 'Broken packages' message if nothing else [ Stefano Zacchiroli ] * doc/external-dependency-solver-protocol.txt: - describe EDSP and the configuration interface around it - -- David Kalnischkies Tue, 17 May 2011 17:59:24 +0200 + -- David Kalnischkies Tue, 17 May 2011 18:43:21 +0200 apt (0.8.14.2) UNRELEASED; urgency=low diff --git a/test/integration/test-handling-broken-orgroups b/test/integration/test-handling-broken-orgroups index d88ad0000..20b314074 100755 --- a/test/integration/test-handling-broken-orgroups +++ b/test/integration/test-handling-broken-orgroups @@ -58,7 +58,7 @@ The following information may help to resolve the situation: The following packages have unmet dependencies: coolstuff-broken : Depends: cool2 but it is not installable or stuff2 but it is not installable -E: Broken packages' aptget install coolstuff-broken -s +E: Unable to correct problems, you have held broken packages.' aptget install coolstuff-broken -s testequal 'Reading package lists... Building dependency tree... @@ -105,4 +105,4 @@ The following information may help to resolve the situation: The following packages have unmet dependencies: coolstuff-provided-broken : Depends: cool2 but it is not installable or stuff-abi-2 -E: Broken packages' aptget install coolstuff-provided-broken -s +E: Unable to correct problems, you have held broken packages.' aptget install coolstuff-provided-broken -s diff --git a/test/integration/test-release-candidate-switching b/test/integration/test-release-candidate-switching index b6dbe99db..0970cb935 100755 --- a/test/integration/test-release-candidate-switching +++ b/test/integration/test-release-candidate-switching @@ -416,4 +416,4 @@ The following information may help to resolve the situation: The following packages have unmet dependencies: uninstallablepkg : Depends: libmtp8 (>= 10:0.20.1) but it is not going to be installed Depends: amarok-utils (= 2.3.2-2+exp) but 2.3.1-1+sid is to be installed -E: Broken packages" aptget install uninstallablepkg/experimental --trivial-only -V -q=0 +E: Unable to correct problems, you have held broken packages." aptget install uninstallablepkg/experimental --trivial-only -V -q=0 -- cgit v1.2.3-70-g09d2