From 9a7507eb2ee52cdddd977b754e1d94c8a1fd1e06 Mon Sep 17 00:00:00 2001 From: Ken Brown Date: Sat, 16 Sep 2017 11:39:40 -0400 Subject: [PATCH] Allow user to refuse the default problem solutions Add new method SolverSolution::db2trans to change the solver's transaction list to reflect the package database. Use it if the user refuses the default problem solutions. Reinstate warning that this could cause breakage. Remove PrereqPage::OnMessageCmd, which is no longer needed (and which disallows clicking Next if the "Accept default problem solutions" box is unchecked). v2: Tweak MessageBox text --- libsolv.cc | 29 +++++++++++++++++++++++++++++ libsolv.h | 3 +++ prereq.cc | 32 +++++++++++++++++++------------- prereq.h | 1 - 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/libsolv.cc b/libsolv.cc index be3dae73..6d916420 100644 --- a/libsolv.cc +++ b/libsolv.cc @@ -582,6 +582,35 @@ SolverSolution::trans2db() const } } +void +SolverSolution::db2trans() +{ + trans.clear(); + packagedb db; + + for (packagedb::packagecollection::iterator p = db.packages.begin (); + p != db.packages.end (); ++p) + { + packagemeta *pkg = p->second; + if (pkg->desired && pkg->picked()) // install/upgrade/reinstall + { + trans.push_back(SolverTransaction(pkg->desired, SolverTransaction::transInstall)); + if (pkg->installed) + trans.push_back(SolverTransaction(pkg->installed, SolverTransaction::transErase)); + } + else if (!pkg->desired && pkg->installed) // uninstall + trans.push_back(SolverTransaction(pkg->installed, SolverTransaction::transErase)); + + if (pkg->srcpicked()) + { + if (pkg->desired) + trans.push_back(SolverTransaction(pkg->desired.sourcePackage(), SolverTransaction::transInstall)); + else + trans.push_back(SolverTransaction(pkg->installed.sourcePackage(), SolverTransaction::transInstall)); + } + } +} + static std::ostream &operator<<(std::ostream &stream, SolverTransaction::transType type) diff --git a/libsolv.h b/libsolv.h index f270e872..e9530ea3 100644 --- a/libsolv.h +++ b/libsolv.h @@ -232,6 +232,9 @@ class SolverSolution /* Reset package database to correspond to trans */ void trans2db() const; + /* Reset transaction list to correspond to package database */ + void db2trans(); + bool update(SolverTasks &tasks, bool update, bool use_test_packages, bool include_source); std::string report() const; diff --git a/prereq.cc b/prereq.cc index 6f3d1d72..df4671e6 100644 --- a/prereq.cc +++ b/prereq.cc @@ -93,7 +93,25 @@ PrereqPage::OnNext () if (!IsDlgButtonChecked (h, IDC_PREREQ_CHECK)) { - return -1; + // breakage imminent! danger, danger + int res = MessageBox (h, + "We strongly recommend that you accept the default solutions. " + "Some packages may not work properly if you don't." + "\r\n\r\n" + "Are you sure you want to proceed?", + "WARNING - Unsolved Problems", + MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2); + if (res == IDNO) + return -1; + else + { + Log (LOG_PLAIN) << + "NOTE! User refused the default solutions! " + "Expect some packages to give errors or not function at all." << endLog; + // Change the solver's transaction list to reflect the user's choices. + packagedb db; + db.solution.db2trans(); + } } return whatNext(); @@ -136,18 +154,6 @@ PrereqPage::OnUnattended () return whatNext(); } -bool -PrereqPage::OnMessageCmd (int id, HWND hwndctl, UINT code) -{ - if ((code == BN_CLICKED) && (id == IDC_PREREQ_CHECK)) - { - GetOwner ()->SetButtons (PSWIZB_BACK | (IsButtonChecked (id) ? PSWIZB_NEXT : 0)); - return true; - } - - return false; -} - // --------------------------------------------------------------------------- // implements class PrereqChecker // --------------------------------------------------------------------------- diff --git a/prereq.h b/prereq.h index 1c0e05b7..1ddb6849 100644 --- a/prereq.h +++ b/prereq.h @@ -27,7 +27,6 @@ public: virtual long OnNext (); virtual long OnBack (); virtual long OnUnattended (); - virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code); private: long whatNext (); }; -- 2.43.5