public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 08/11] Allow better handling of an obsolete package specified on command line
Date: Thu, 01 Aug 2019 16:08:00 -0000	[thread overview]
Message-ID: <20190801160519.32745-9-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20190801160519.32745-1-jon.turney@dronecode.org.uk>

Now we have the flexibilty to record a package as explicitly required to
be installed, rather than merely installed because the desired version
is different to the installed version, we can record packages selected
for installation on the command line as distinct from choosing a
specific version of that package via the picker.

Use this to allow the solver to make a better choice of what provides a
package name specified on the command line.

(Note that we need to use SOLVER_SOLVABLE_PROVIDES rather than
SOLVER_SOLVABLE_NAME to allow the solver to take packages which provide
and obsolete the named package into account.)

Only turn this behaviour on when --upgrade-also is specified.

e.g. setup -q -g -P python3-lxml currently gets you an (empty)
python3-lxml package, which is replaced by python36-lxml (which
obsoletes it) on the next setup run.  After this change, python36-lxml
is installed instead.

See also the dicusssion at
https://cygwin.com/ml/cygwin-apps/2017-10/msg00092.html et seq.
---
 choose.cc  | 2 +-
 libsolv.cc | 8 +++++++-
 libsolv.h  | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/choose.cc b/choose.cc
index 7f6e332..be08627 100644
--- a/choose.cc
+++ b/choose.cc
@@ -299,7 +299,7 @@ ChooserPage::applyCommandLinePackageSelection()
       bool uninstall = (!(wanted  || base) && (deleted || PruneInstallOption))
 		     || (orphaned && CleanOrphansOption);
       if (install)
-	pkg.set_action (packagemeta::Install_action, pkg.curr);
+	pkg.set_action (packagemeta::Install_action, UpgradeAlsoOption ? packageversion () : pkg.curr);
       else if (reinstall)
 	pkg.set_action (packagemeta::Reinstall_action, pkg.curr);
       else if (uninstall)
diff --git a/libsolv.cc b/libsolv.cc
index cbc651b..d7a9d01 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -653,7 +653,10 @@ SolverTasks::setTasks()
           break;
 
         case packagemeta::Install_action:
-          add(pkg->desired, taskInstall); // install/upgrade
+          if (pkg->desired)
+            add(pkg->desired, taskInstall); // install/upgrade
+          else
+            add(pkg->curr, taskInstallAny); // install
           break;
 
         case packagemeta::Uninstall_action:
@@ -829,6 +832,9 @@ SolverSolution::tasksToJobs(SolverTasks &tasks, updateMode update, Queue &job)
         case SolverTasks::taskInstall:
           queue_push2(&job, SOLVER_INSTALL | SOLVER_SOLVABLE, sv.id);
           break;
+        case SolverTasks::taskInstallAny:
+          queue_push2(&job, SOLVER_INSTALL | SOLVER_SOLVABLE_PROVIDES, sv.name_id());
+          break;
         case SolverTasks::taskUninstall:
           queue_push2(&job, SOLVER_ERASE | SOLVER_SOLVABLE, sv.id);
           break;
diff --git a/libsolv.h b/libsolv.h
index 4fd6d61..43f7269 100644
--- a/libsolv.h
+++ b/libsolv.h
@@ -197,6 +197,7 @@ class SolverTasks
     taskKeep,
     taskSkip,
     taskForceDistUpgrade,
+    taskInstallAny,
   };
   void add(const SolvableVersion &v, task t)
   {
-- 
2.21.0

  parent reply	other threads:[~2019-08-01 16:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 16:05 [PATCH setup 00/11] Improve handling of specifying an obsolete package to be installed on the " Jon Turney
2019-08-01 16:05 ` [PATCH setup 01/11] Remove 'Bin?' column Jon Turney
2019-08-01 16:05 ` [PATCH setup 02/11] Remove unused packagemeta::key Jon Turney
2019-08-01 16:06 ` [PATCH setup 03/11] Make packagemeta::message private Jon Turney
2019-08-01 16:07 ` [PATCH setup 05/11] Store the requested action in packagemeta::set_action() Jon Turney
2019-08-01 16:07 ` [PATCH setup 04/11] Rename 'Default' packagemeta action to 'NoChange' for clarity Jon Turney
2019-08-01 16:07 ` [PATCH setup 06/11] Use packagemeta::set_action() to update action Jon Turney
2019-08-01 16:08 ` [PATCH setup 09/11] Use stored action in packagemeta::list_actions() Jon Turney
2019-08-01 16:08 ` Jon Turney [this message]
2019-08-01 16:08 ` [PATCH setup 07/11] Use stored action in setting up solver Jon Turney
2019-08-01 16:09 ` [PATCH setup 10/11] Use stored action in packagemeta::action_caption() Jon Turney
2019-08-01 16:10 ` [PATCH setup 11/11] Ensure we only set user_picked when appropriate Jon Turney
2019-12-01 19:32 ` [PATCH setup 00/11] Improve handling of specifying an obsolete package to be installed on the command line Ken Brown
2019-12-03 20:44   ` Jon Turney
2019-12-03 21:16     ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190801160519.32745-9-jon.turney@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-apps@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).