- 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);
+ std::string failure;
+ if (flags & EDSP::Request::UPGRADE_ALL) {
+ int upgrade_flags = APT::Upgrade::ALLOW_EVERYTHING;
+ if (flags & EDSP::Request::FORBID_NEW_INSTALL)
+ upgrade_flags |= APT::Upgrade::FORBID_INSTALL_NEW_PACKAGES;
+ if (flags & EDSP::Request::FORBID_REMOVE)
+ upgrade_flags |= APT::Upgrade::FORBID_REMOVE_PACKAGES;
+
+ if (APT::Upgrade::Upgrade(CacheFile, upgrade_flags))
+ ;
+ else if (upgrade_flags == APT::Upgrade::ALLOW_EVERYTHING)
+ failure = "ERR_UNSOLVABLE_FULL_UPGRADE";
+ else
+ failure = "ERR_UNSOLVABLE_UPGRADE";
+ } else if (Fix.Resolve() == false)
+ failure = "ERR_UNSOLVABLE";
+
+ if (failure.empty() == false) {
+ std::ostringstream broken;
+ ShowBroken(broken, CacheFile, false);
+ EDSP::WriteError(failure.c_str(), broken.str(), output);