setup libsolv UI: Silently install dependencies?

Ken Brown kbrown@cornell.edu
Sun Dec 24 23:23:00 GMT 2017


Currently the libsolv version of setup silently installs added 
dependencies.  The user gets a chance to review them first only if 
libsolv finds problems and has to display the prerequisite page.

I'm not sure if this was a deliberate design decision, though I 
personally like it.  On the other hand, I suspect that some users won't 
like it because they're used to seeing a report about missing 
dependencies.  So I think we should make this behavior optional.

The attached patch is a start in that direction.  But it needs a 
followup patch to implement the mechanism for selecting the option.  One 
possibility is a checkbox on the chooser page, which then gets saved in 
setup.rc as a user option.  Are there other suggestions?

Ken
-------------- next part --------------
From e3c5d8ac0970d8a6bcb870aff2e6fe0e00ab5b44 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Sun, 24 Dec 2017 16:05:33 -0500
Subject: [PATCH setup libsolv] Let the user review added dependencies

If libsolv finds no problems but there were added dependencies,
optionally activate the prerequisite page so that the user can go back
and see what was added.

This uses a new helper function prereq.cc:added_deps().

The option is contolled by a new bool data member
PrereqChecker::report_added_deps.  At the moment this is always
'true', for consistency with the currently released setup, but a
future commit will enable a way for the user to set the option.
---
 prereq.cc | 23 +++++++++++++++++++++--
 prereq.h  |  1 +
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/prereq.cc b/prereq.cc
index bf7661a..0c06a32 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -157,8 +157,26 @@ PrereqPage::OnUnattended ()
 // implements class PrereqChecker
 // ---------------------------------------------------------------------------
 
-// instantiate the static member
+// instantiate the static members
 bool PrereqChecker::use_test_packages;
+bool PrereqChecker::report_added_deps = true;
+
+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;
+}
 
 bool
 PrereqChecker::isMet ()
@@ -174,7 +192,8 @@ PrereqChecker::isMet ()
   q.setTasks();
 
   // apply solver to those tasks and global state (use test, include source)
-  return db.solution.update(q, SolverSolution::keep, use_test_packages, IncludeSource);
+  return db.solution.update(q, SolverSolution::keep, use_test_packages, IncludeSource)
+    && !(report_added_deps && added_deps ());
 }
 
 /* Formats problems and solutions as a string for display to the user.  */
diff --git a/prereq.h b/prereq.h
index 5ae9323..a14789a 100644
--- a/prereq.h
+++ b/prereq.h
@@ -44,6 +44,7 @@ public:
 
 private:
   static bool use_test_packages;
+  static bool report_added_deps;
 };
 
 #endif /* SETUP_PREREQ_H */
-- 
2.15.1



More information about the Cygwin-apps mailing list