[PATCH setup 00/14] Use libsolv, solve all our problems... (WIP)

Ken Brown kbrown@cornell.edu
Wed Aug 30 21:47:00 GMT 2017


On 8/29/2017 9:37 AM, Ken Brown wrote:
> On 5/31/2017 6:50 AM, Jon Turney wrote:
>> ... solve some problems, perhaps add some new ones, I guess.  I'm not 
>> 100%
>> sure this is the right approach to take, but I wrote it, so here it is.
> [...]
>> - As implemented, selecting "Current" overrides "Keep".  This is 
>> wrong, and a
>> change from current behaviour, but is probably a symptom of some deeper
>> confusion in the picker UI I'm not sure how to address
> 
> I think the problem might be the following lines in the definition of 
> SolverSolution::update:
> 
>    if (update)
>      queue_push2(&job, SOLVER_UPDATE | SOLVER_SOLVABLE_ALL, 0);
> 
> When the prerequisite checker calls SolverSolution::update, doesn't this 
> cause the upgrading of old versions that we want to keep (assuming 
> "Current" has been selected)?  As a quick test, I commented out those 
> lines and found that setup.exe let me keep an old version of a package.
> 
> Maybe you need to add a DISABLE_UPDATE command to the solver task list 
> to implement "Keep" for packages that would otherwise be updated.

DISABLE_UPDATE is not a command.  But SOLVER_LOCK seems to do the job. 
Jon, I'm attaching a patch that should apply to the libsolv branch of 
your github cygwin-setup repo.  So far I've only tested it very lightly, 
enough to verify that it lets me keep an old version of a package.

Ken

-------------- next part --------------
From 26231d3c83c392e6fa267bcea9135f2b5e5af1ca Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Wed, 30 Aug 2017 17:36:13 -0400
Subject: [PATCH] Don't override a Keep selection

---
 libsolv.cc     |  3 +++
 libsolv.h      |  3 ++-
 package_db.cc  |  2 +-
 package_meta.h |  2 ++
 prereq.cc      | 12 ++++++++----
 5 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/libsolv.cc b/libsolv.cc
index f509617..67b99b2 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -526,6 +526,9 @@ SolverSolution::update(SolverTasks &tasks, bool update, bool use_test_packages,
           // we don't know how to ask solver for this, so we just add the erase
           // and install later
           break;
+	case SolverTasks::taskKeep:
+	  queue_push2(&job, SOLVER_LOCK | SOLVER_SOLVABLE, sv.id);
+	  break;
         default:
           Log (LOG_PLAIN) << "unknown task " << (*i).second << endLog;
         }
diff --git a/libsolv.h b/libsolv.h
index be518e9..7768128 100644
--- a/libsolv.h
+++ b/libsolv.h
@@ -165,7 +165,8 @@ class SolverTasks
   {
     taskInstall,
     taskUninstall,
-    taskReinstall
+    taskReinstall,
+    taskKeep,
   };
   void add(const SolvableVersion &v, task t)
   {
diff --git a/package_db.cc b/package_db.cc
index 9f9e0a6..d7ec043 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -522,7 +522,7 @@ packagedb::defaultTrust (trusts trust)
             || pkg.categories.find ("Base") != pkg.categories.end ()
             || pkg.categories.find ("Orphaned") != pkg.categories.end ())
         {
-          pkg.desired = pkg.trustp (true, trust);
+          pkg.desired = pkg.default_version = pkg.trustp (true, trust);
           if (pkg.desired)
             pkg.pick (pkg.desired.accessible() && pkg.desired != pkg.installed);
         }
diff --git a/package_meta.h b/package_meta.h
index b6faab8..d91f7c9 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -131,6 +131,8 @@ public:
   packageversion curr;
   /* ditto for "test" (experimental) */
   packageversion exp;
+  /* which one is the default according to the chooser global state */
+  packageversion default_version;
   /* Now for the user stuff :] */
   /* What version does the user want ? */
   packageversion desired;
diff --git a/prereq.cc b/prereq.cc
index 49fbd77..8922cc6 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -170,6 +170,7 @@ PrereqChecker::isMet ()
 
       // decode UI state to action
       // skip and keep don't change dependency solution
+      // except when we want to keep an old version
       if (pkg->installed != pkg->desired)
         {
           if (pkg->desired)
@@ -177,10 +178,13 @@ PrereqChecker::isMet ()
           else
             q.add(pkg->installed, SolverTasks::taskUninstall); // uninstall
         }
-      else
-        if (pkg->picked())
-          q.add(pkg->installed, SolverTasks::taskReinstall); // reinstall
-
+      else if (pkg->installed)
+	{
+	  if (pkg->picked())
+	    q.add(pkg->installed, SolverTasks::taskReinstall); // reinstall
+	  else if (upgrade && pkg->installed < pkg->default_version)
+	    q.add(pkg->installed, SolverTasks::taskKeep); // keep
+	}
       // only install action makes sense for source packages
       if (pkg->srcpicked())
         {
-- 
2.14.1



More information about the Cygwin-apps mailing list