setup libsolv UI: Silently install dependencies?

Ken Brown kbrown@cornell.edu
Mon Jan 15 17:31:00 GMT 2018


On 1/9/2018 8:32 AM, Jon Turney wrote:
> I'm not sure it's ideal to make a text report of this, though. 
> Displaying it in the chooser somehow seems a better fit.
> 
> (i.e. after you've made your selections, you get something like the 
> "pending" view in the chooser again, showing what will be done, which 
> you can either confirm or go back from)

Here's another attempt, lightly tested, which might still need some 
improvements.  It goes back to the chooser, but it doesn't set the 
pending view.  I'm not sure how to do that without a lot of refactoring, 
but maybe I'm missing something easy.

Ken
-------------- next part --------------
From d183ee53ff0471f22fe2412381e8507e4c109b1e Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Mon, 15 Jan 2018 12:18:30 -0500
Subject: [PATCH] Let the user review added dependencies

If the solver finds no problems but added packages to resolve
dependencies, give the user a chance to go back to the chooser and
review what's about to happen.
---
 prereq.cc | 46 ++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/prereq.cc b/prereq.cc
index a03e79b..4053373 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -140,13 +140,18 @@ PrereqPage::whatNext ()
   return IDD_INSTATUS;
 }
 
-long
-PrereqPage::OnBack ()
+static void
+prepBack ()
 {
   // Reset the package database to correspond to the solver's solution
   packagedb db;
   db.solution.trans2db();
+}
 
+long
+PrereqPage::OnBack ()
+{
+  prepBack ();
   return IDD_CHOOSE;
 }
 
@@ -213,6 +218,23 @@ PrereqChecker::getUnmetString (std::string &s)
 // progress page glue
 // ---------------------------------------------------------------------------
 
+static bool
+added_deps ()
+{
+  packagedb db;
+  const SolverTransactionList & trans = db.solution.transactions ();
+  for (SolverTransactionList::const_iterator i = trans.begin ();
+       i != trans.end (); i++)
+    if (i->type == SolverTransaction::transInstall)
+      {
+	packageversion pv = i->version;
+	packagemeta *pkg = db.findBinary (PackageSpecification (pv.Name ()));
+	if (!pkg->desired)
+	  return true;
+      }
+  return false;
+}
+
 static int
 do_prereq_check_thread(HINSTANCE h, HWND owner)
 {
@@ -223,11 +245,23 @@ do_prereq_check_thread(HINSTANCE h, HWND owner)
     {
       p.finalize();
 
-      if (source == IDC_SOURCE_LOCALDIR)
-	Progress.SetActivateTask (WM_APP_START_INSTALL);  // install
+      if (added_deps () && !unattended_mode
+	  && MessageBox (owner, "Packages were added to resolve dependencies.  "
+			 "Do you want to review them before proceeding?",
+			 "Added Dependencies",
+			 MB_YESNO | MB_DEFBUTTON2) == IDYES)
+	{
+	  prepBack ();
+	  retval = IDD_CHOOSE;
+	}
       else
-	Progress.SetActivateTask (WM_APP_START_DOWNLOAD); // start download
-      retval = IDD_INSTATUS;
+	{
+	  if (source == IDC_SOURCE_LOCALDIR)
+	    Progress.SetActivateTask (WM_APP_START_INSTALL);  // install
+	  else
+	    Progress.SetActivateTask (WM_APP_START_DOWNLOAD); // start download
+	  retval = IDD_INSTATUS;
+	}
     }
   else
     {
-- 
2.15.1



More information about the Cygwin-apps mailing list