public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
From: jturney@sourceware.org
To: cygwin-apps-cvs@sourceware.org
Subject: [setup - the official Cygwin setup program] branch master, updated. release_2.897-11-gdbd295e
Date: Fri, 20 Dec 2019 13:54:00 -0000	[thread overview]
Message-ID: <20191220135408.103282.qmail@sourceware.org> (raw)




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=dbd295e75edfadd5fc6feebe11b482cd672575cf

commit dbd295e75edfadd5fc6feebe11b482cd672575cf
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Thu Jul 11 20:36:42 2019 +0100

    Ensure we only set user_picked when appropriate
    
    Add an optional parameter to set_action(), to indicate the action is the
    result of user action, and only set user_picked then.
    
    Set that parameter when installing from the command line. All other user
    actions come through select_action(), so also set that parameter there.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=a51575e38eb2edf87b01059ec6b8fe7ce165ef3f

commit a51575e38eb2edf87b01059ec6b8fe7ce165ef3f
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Jul 9 18:24:30 2019 +0100

    Use stored action in packagemeta::action_caption()
    
    Use the stored action in packagemeta::action_caption(), rather than
    working backwards from desired/installed/picked.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=a781f82324c4ab7a92a5a38771aebdc693ae784a

commit a781f82324c4ab7a92a5a38771aebdc693ae784a
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Jul 9 18:10:12 2019 +0100

    Use stored action in packagemeta::list_actions()
    
    Use the stored action in packagemeta::list_actions(), rather than
    working backwards from desired/installed/picked.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=20a296665d8648234dcd4fdb8c531bae61cf0af8

commit 20a296665d8648234dcd4fdb8c531bae61cf0af8
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Jul 9 16:53:57 2019 +0100

    Allow better handling of an obsolete package specified on command line
    
    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.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=14579ca8fcbb5b49a01448282dbb9a00efc8a02c

commit 14579ca8fcbb5b49a01448282dbb9a00efc8a02c
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Jul 9 16:10:19 2019 +0100

    Use stored action in setting up solver
    
    Use stored action in setting up the solver, rather than working out what
    the action was from _picked/installed/desired.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=6dc6650acd98c2475157a9596cbbba8cf57e6280

commit 6dc6650acd98c2475157a9596cbbba8cf57e6280
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Jul 9 19:22:37 2019 +0100

    Use packagemeta::set_action() to update action
    
    Use packagemeta::set_action() to update the action for packagemeta
    object in more (hopefully all) the places it gets changed.
    
    (Future work: ideally we'd opaque packagemeta internals more by making
    installed/curr/desired/etc. object private, rather than letting users
    grovel around in those details)

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=8efd971b659507e410787820c1c108a15fb44f57

commit 8efd971b659507e410787820c1c108a15fb44f57
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Jul 9 15:40:04 2019 +0100

    Store the requested action in packagemeta::set_action()
    
    Store the action requested with set_action() in the packagemeta object,
    rather than just encoding it in _picked/installed/desired (see
    discussion in commit 4209699d)
    
    Try to avoid meaningless states occuring, i.e. action=Install with
    desired=installed is converted to action=Keep.
    
    Future work: There's still some odd stuff left in set_action() which we
    need to do some hard thinking about: action=NoChange treats Base
    category packages specially, action=Install will switch to installing
    the source if binary isn't accessible.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=916f2b80a949bbf9d51b057fd24681d00d96cc9c

commit 916f2b80a949bbf9d51b057fd24681d00d96cc9c
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Fri Jul 12 13:56:09 2019 +0100

    Rename 'Default' packagemeta action to 'NoChange' for clarity

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=feed8d92b6c4ef212afc5879fd4f652ed1b814e2

commit feed8d92b6c4ef212afc5879fd4f652ed1b814e2
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Jul 9 17:54:35 2019 +0100

    Make packagemeta::message private

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=4c46018da9226530ec6e319d0a4962617596124f

commit 4c46018da9226530ec6e319d0a4962617596124f
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Jul 9 14:44:27 2019 +0100

    Remove unused packagemeta::key
    
    Contains an identical value to packagemeta::name

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=beb453d3d309e89a0b268262601669f43c4dc5e7

commit beb453d3d309e89a0b268262601669f43c4dc5e7
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Fri Jul 12 12:38:54 2019 +0100

    Remove 'Bin?' column
    
    The only use this column appears to have now is that unticking it is the
    same as selecting 'uninstall'.
    
    Future work: Make 'Src?' column more independent, rather than
    interacting with the 'New' (action) column in non-obvious ways. We
    should be able to choose to install source irrespective of the state of
    the binary package. (That should also take into account the
    '--include-source' option)


Diff:
---
 PickCategoryLine.cc |    2 +-
 PickPackageLine.cc  |   32 +----------------
 PickView.cc         |    3 +-
 PickView.h          |   12 +++---
 choose.cc           |    9 ++---
 libsolv.cc          |   69 +++++++++++++++++++++++---------------
 libsolv.h           |    1 +
 package_db.cc       |    4 +-
 package_meta.cc     |   93 ++++++++++++++++++++++++--------------------------
 package_meta.h      |   16 +++++----
 10 files changed, 113 insertions(+), 128 deletions(-)

diff --git a/PickCategoryLine.cc b/PickCategoryLine.cc
index 7aa1f28..7c1d464 100644
--- a/PickCategoryLine.cc
+++ b/PickCategoryLine.cc
@@ -68,7 +68,7 @@ PickCategoryLine::get_actions(int col) const
   ActionList *al = new ActionList();
   packagemeta::_actions current_default = cat_tree->action();
 
-  al->add("Default", (int)packagemeta::Default_action, (current_default == packagemeta::Default_action), TRUE);
+  al->add("Default", (int)packagemeta::NoChange_action, (current_default == packagemeta::NoChange_action), TRUE);
   al->add("Install", (int)packagemeta::Install_action, (current_default == packagemeta::Install_action), TRUE);
   al->add(packagedb::task == PackageDB_Install ? "Reinstall" : "Retrieve",
           (int)packagemeta::Reinstall_action, (current_default == packagemeta::Reinstall_action), TRUE);
diff --git a/PickPackageLine.cc b/PickPackageLine.cc
index 685d632..f64c101 100644
--- a/PickPackageLine.cc
+++ b/PickPackageLine.cc
@@ -32,20 +32,6 @@ PickPackageLine::get_text(int col_num) const
     {
       return pkg.action_caption ();
     }
-  else if (col_num == bintick_col)
-    {
-      const char *bintick = "?";
-      if (/* uninstall or skip */ !pkg.desired ||
-          /* current version */ pkg.desired == pkg.installed ||
-          /* no source */ !pkg.desired.accessible())
-        bintick = "n/a";
-      else if (pkg.picked())
-        bintick = "yes";
-      else
-        bintick = "no";
-
-      return bintick;
-    }
   else if (col_num == srctick_col)
     {
       const char *srctick = "?";
@@ -118,25 +104,11 @@ PickPackageLine::do_action(int col_num, int action_id)
       pkg.select_action(action_id, theView.deftrust);
       return 1;
     }
-  if (col_num == bintick_col)
-    {
-      if (pkg.desired.accessible ())
-        pkg.pick (!pkg.picked ());
-    }
-  else if (col_num == srctick_col)
+
+  if (col_num == srctick_col)
     {
       if (pkg.desired.sourcePackage ().accessible ())
         pkg.srcpick (!pkg.srcpicked ());
-    }
-
-  /* Unchecking binary while source is unchecked or vice versa is equivalent to
-     uninstalling.  It's essential to set desired correctly, otherwise the
-     package gets uninstalled without visual feedback to the user.  The package
-     will not even show up in the "Pending" view! */
-  if ((col_num == bintick_col) || (col_num == srctick_col))
-    {
-      if (!pkg.picked () && !pkg.srcpicked ())
-        pkg.desired = packageversion ();
 
       return 1;
     }
diff --git a/PickView.cc b/PickView.cc
index 8412282..6d7d83d 100644
--- a/PickView.cc
+++ b/PickView.cc
@@ -236,9 +236,8 @@ PickView::init_headers (void)
 {
   listview->noteColumnWidthStart();
 
-  // widths of the 'bin' and 'src' checkbox columns just need to accommodate the
+  // width of the 'src' checkbox column just needs to accommodate the
   // column name
-  listview->noteColumnWidth (bintick_col, "");
   listview->noteColumnWidth (srctick_col, "");
 
   // (In category view) accommodate the width of each category name
diff --git a/PickView.h b/PickView.h
index 3715d93..2db0562 100644
--- a/PickView.h
+++ b/PickView.h
@@ -71,16 +71,16 @@ private:
   void insert_category (CategoryTree *);
 };
 
+// column numbers, must match index into pkg_headers[]
 enum
 {
  pkgname_col = 0, // package/category name
  current_col = 1,
  new_col = 2,     // action
- bintick_col = 3,
- srctick_col = 4,
- cat_col = 5,
- size_col = 6,
- pkg_col = 7,     // desc
+ srctick_col = 3,
+ cat_col = 4,
+ size_col = 5,
+ pkg_col = 6     // desc
 };
 
 bool isObsolete (std::set <std::string, casecompare_lt_op> &categories);
@@ -97,7 +97,7 @@ public:
   CategoryTree(Category & cat, bool collapsed) :
     _cat (cat),
     _collapsed(collapsed),
-    _action (packagemeta::Default_action)
+    _action (packagemeta::NoChange_action)
   {
   }
 
diff --git a/choose.cc b/choose.cc
index 2b5e465..4fa0c74 100644
--- a/choose.cc
+++ b/choose.cc
@@ -133,7 +133,6 @@ static ListView::Header pkg_headers[] = {
   {"Package",     LVCFMT_LEFT,  ListView::ControlType::text},
   {"Current",     LVCFMT_LEFT,  ListView::ControlType::text},
   {"New",         LVCFMT_LEFT,  ListView::ControlType::popup},
-  {"Bin?",        LVCFMT_LEFT,  ListView::ControlType::checkbox},
   {"Src?",        LVCFMT_LEFT,  ListView::ControlType::checkbox},
   {"Categories",  LVCFMT_LEFT,  ListView::ControlType::text},
   {"Size",        LVCFMT_RIGHT, ListView::ControlType::text},
@@ -300,17 +299,17 @@ 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, true);
       else if (reinstall)
 	pkg.set_action (packagemeta::Reinstall_action, pkg.curr);
       else if (uninstall)
 	pkg.set_action (packagemeta::Uninstall_action, packageversion ());
       else if (PruneInstallOption)
-	pkg.set_action (packagemeta::Default_action, pkg.curr);
+	pkg.set_action (packagemeta::NoChange_action, pkg.curr);
       else if (upgrade)
-	pkg.set_action (packagemeta::Default_action, pkg.trustp(true, TRUST_UNKNOWN));
+	pkg.set_action (packagemeta::Install_action, pkg.trustp(true, TRUST_UNKNOWN));
       else
-	pkg.set_action (packagemeta::Default_action, pkg.installed);
+	pkg.set_action (packagemeta::NoChange_action, pkg.installed);
     }
 }
 
diff --git a/libsolv.cc b/libsolv.cc
index 9e3b066..d7a9d01 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -631,34 +631,42 @@ SolverTasks::setTasks()
     {
       packagemeta *pkg = p->second;
 
-      // decode UI state to action
-      // keep and skip need attention only when they differ from the
-      // solver's solution
-      if (pkg->installed != pkg->desired)
+      switch (pkg->get_action())
         {
-          if (pkg->desired)
-            add(pkg->desired, taskInstall); // install/upgrade
-          else
-            add(pkg->installed, taskUninstall); // uninstall
-        }
-      else if (pkg->installed)
-        {
-          if (pkg->picked())
-            add(pkg->installed, taskReinstall); // reinstall
-          else if (pkg->installed != pkg->default_version)
-            add(pkg->installed, taskKeep); // keep
-          else
+        case packagemeta::NoChange_action: // skip/keep
+          // keep and skip need attention only when they differ from the
+          // solver's solution
+          if (pkg->installed)
             {
-              // if installed (with no action selected), but blacklisted, force
-              // a distupgrade of this package
-              if (pkg->isBlacklisted(pkg->installed))
+              if (!pkg->picked() && pkg->installed != pkg->default_version)
+                add(pkg->installed, taskKeep); // keep
+              else if (pkg->isBlacklisted(pkg->installed))
                 {
+                  // if installed (with no action selected), but blacklisted,
+                  // force a distupgrade of this package
                   add(pkg->installed, taskForceDistUpgrade);
                 }
             }
+          else if (pkg->default_version)
+             add(pkg->default_version, taskSkip); // skip
+
+          break;
+
+        case packagemeta::Install_action:
+          if (pkg->desired)
+            add(pkg->desired, taskInstall); // install/upgrade
+          else
+            add(pkg->curr, taskInstallAny); // install
+          break;
+
+        case packagemeta::Uninstall_action:
+          add(pkg->installed, taskUninstall); // uninstall
+          break;
+
+        case packagemeta::Reinstall_action:
+          add(pkg->installed, taskReinstall); // reinstall
+          break;
         }
-      else if (pkg->default_version)
-        add(pkg->default_version, taskSkip); // skip
 
       // only install action makes sense for source packages
       if (pkg->srcpicked())
@@ -740,16 +748,19 @@ SolverSolution::trans2db() const
         case SolverTransaction::transInstall:
           if (pv.Type() == package_binary)
             {
-              pkg->desired = pkg->default_version = pv;
-              pkg->pick(true);
+              pkg->set_action(packagemeta::Install_action, pv);
+              pkg->default_version = pv;
             }
           else // source package
             pkg->srcpick(true);
           break;
         case SolverTransaction::transErase:
           // Only relevant if pkg is still in its "no change" state
-          if (pkg->desired == pkg->installed && !pkg->picked())
-            pkg->desired = pkg->default_version = packageversion();
+          if (pkg->get_action() == packagemeta::NoChange_action)
+            {
+              pkg->set_action(packagemeta::Uninstall_action, packageversion());
+              pkg->default_version = packageversion();
+            }
           break;
         default:
           break;
@@ -767,13 +778,14 @@ SolverSolution::db2trans()
        p != db.packages.end (); ++p)
     {
       packagemeta *pkg = p->second;
-      if (pkg->desired && pkg->picked()) // install/upgrade/reinstall
+      if ((pkg->get_action() == packagemeta::Install_action) ||
+          (pkg->get_action() == packagemeta::Reinstall_action))
         {
           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
+      else if (pkg->get_action() == packagemeta::Uninstall_action)
         trans.push_back(SolverTransaction(pkg->installed, SolverTransaction::transErase));
 
       if (pkg->srcpicked())
@@ -820,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)
   {
diff --git a/package_db.cc b/package_db.cc
index 59c59ef..847f44e 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -758,7 +758,7 @@ packagedb::noChanges ()
        i != packages.end(); i++)
     {
       packagemeta *pkg = i->second;
-      pkg->desired = pkg->default_version = pkg->installed;
-      pkg->pick(false);
+      pkg->set_action(packagemeta::NoChange_action, pkg->installed);
+      pkg->default_version = pkg->installed;
     }
 }
diff --git a/package_meta.cc b/package_meta.cc
index 3509f05..940f69a 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -51,12 +51,13 @@ bool hasManualSelections = 0;
 
 /*****************/
 
+/* Return an appropriate category caption given the action */
 char const *
 packagemeta::action_caption (_actions _value)
 {
   switch (_value)
     {
-    case Default_action:
+    case NoChange_action:
       return "Default";
     case Install_action:
       return "Install";
@@ -70,7 +71,7 @@ packagemeta::action_caption (_actions _value)
 }
 
 packagemeta::packagemeta (packagemeta const &rhs) :
-  name (rhs.name), key (rhs.name),
+  name (rhs.name),
   categories (rhs.categories), versions (rhs.versions),
   installed (rhs.installed),
   curr (rhs.curr),
@@ -425,19 +426,23 @@ packagemeta::LDesc () const
 std::string
 packagemeta::action_caption () const
 {
-  if (!desired && installed)
-    return "Uninstall";
-  else if (!desired)
-    return "Skip";
-  else if (desired == installed && picked())
-    return packagedb::task == PackageDB_Install ? "Reinstall" : "Retrieve";
-  else if (desired == installed && desired.sourcePackage() && srcpicked())
-    /* FIXME: Redo source should come up if the tarball is already present locally */
-    return "Source";
-  else if (desired == installed)	/* and neither src nor bin */
-    return "Keep";
-  else
-    return desired.Canonical_version ();
+  switch (_action)
+    {
+    case Uninstall_action:
+      return "Uninstall";
+    case NoChange_action:
+      if (!desired)
+        return "Skip";
+      if (desired.sourcePackage() && srcpicked())
+        /* FIXME: Redo source should come up if the tarball is already present locally */
+        return "Source";
+      return "Keep";
+    case Reinstall_action:
+      return packagedb::task == PackageDB_Install ? "Reinstall" : "Retrieve";
+    case Install_action:
+      return desired.Canonical_version ();
+    }
+  return "Unknown";
 }
 
 void
@@ -454,15 +459,11 @@ packagemeta::select_action (int id, trusts const deftrust)
     }
   else
     {
-      if (id == packagemeta::Default_action)
+      if (id == packagemeta::NoChange_action)
         set_action((packagemeta::_actions)id, installed);
       else
-        set_action((packagemeta::_actions)id, trustp (true, deftrust));
+        set_action((packagemeta::_actions)id, trustp (true, deftrust), true);
     }
-
-  /* Memorize the fact that the user picked at least once. */
-  if (!installed)
-    user_picked = true;
 }
 
 // toggle between the currently installed version (or uninstalled, if not
@@ -472,7 +473,7 @@ packagemeta::toggle_action ()
 {
   if (desired != installed)
     {
-      set_action(Default_action, installed);
+      set_action(NoChange_action, installed);
     }
   else
     {
@@ -489,34 +490,20 @@ packagemeta::toggle_action ()
 ActionList *
 packagemeta::list_actions(trusts const trust)
 {
-  // first work out the current action, so we can indicate that
-  _actions action;
-
-  if (!desired && installed)
-    action = Uninstall_action;
-  else if (!desired)
-    action = Default_action; // skip
-  else if (desired == installed && picked())
-    action = Reinstall_action;
-  else if (desired == installed)
-    action = Default_action; // keep
-  else
-    action = Install_action;
-
-  // now build the list of possible actions
+  // build the list of possible actions
   ActionList *al = new ActionList();
 
-  al->add("Uninstall", (int)Uninstall_action, (action == Uninstall_action), bool(installed));
-  al->add("Skip", (int)Default_action, (action == Default_action) && !installed, !installed);
+  al->add("Uninstall", (int)Uninstall_action, (_action == Uninstall_action), bool(installed));
+  al->add("Skip", (int)NoChange_action, (_action == NoChange_action) && !installed, !installed);
 
   std::set<packageversion>::iterator i;
   for (i = versions.begin (); i != versions.end (); ++i)
     {
       if (*i == installed)
         {
-          al->add("Keep", (int)Default_action, (action == Default_action), TRUE);
+          al->add("Keep", (int)NoChange_action, (_action == NoChange_action), TRUE);
           al->add(packagedb::task == PackageDB_Install ? "Reinstall" : "Retrieve",
-                  (int)Reinstall_action, (action == Reinstall_action), TRUE);
+                  (int)Reinstall_action, (_action == Reinstall_action), TRUE);
         }
       else
         {
@@ -525,7 +512,7 @@ packagemeta::list_actions(trusts const trust)
             label += " (Test)";
           al->add(label,
                   -std::distance(versions.begin (), i),
-                  (action == Install_action) && (*i == desired),
+                  (_action == Install_action) && (*i == desired),
                   TRUE);
         }
     }
@@ -535,10 +522,12 @@ packagemeta::list_actions(trusts const trust)
 
 // Set a particular type of action.
 void
-packagemeta::set_action (_actions action, packageversion const &default_version)
+packagemeta::set_action (_actions action, packageversion const &default_version,
+                         bool useraction)
 {
-  if (action == Default_action)
+  if (action == NoChange_action)
     {
+      // if installed, keep
       if (installed
 	  || categories.find ("Base") != categories.end ()
 	  || categories.find ("Orphaned") != categories.end ())
@@ -551,8 +540,11 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
 	    }
 	}
       else
-	desired = packageversion ();
-      return;
+        {
+          // else, if not installed, skip
+          desired = packageversion ();
+          pick(false);
+        }
     }
   else if (action == Install_action)
     {
@@ -562,7 +554,10 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
 	  if (desired != installed)
 	    if (desired.accessible ())
 	      {
-		user_picked = true;
+		/* Memorize the fact that the user picked to install this package at least once. */
+		if (useraction)
+		  user_picked = true;
+
 		pick (true);
 		srcpick (false);
 	      }
@@ -573,11 +568,11 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
 	      }
 	  else
 	    {
+	      action = NoChange_action;
 	      pick (false);
 	      srcpick (false);
 	    }
 	}
-      return;
     }
   else if (action == Reinstall_action)
     {
@@ -592,6 +587,8 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
     {
       desired = packageversion ();
     }
+
+  _action = action;
 }
 
 bool
diff --git a/package_meta.h b/package_meta.h
index c9bfe7c..1f4f3be 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -37,8 +37,8 @@ public:
   static void ScanDownloadedFiles (bool);
   packagemeta (packagemeta const &);
   packagemeta (const std::string& pkgname)
-    : name (pkgname), key(pkgname), user_picked (false),
-    _picked(false), _srcpicked(false)
+    : name (pkgname), user_picked (false),
+      _action(NoChange_action), _picked(false), _srcpicked(false)
   {
   }
 
@@ -53,17 +53,19 @@ public:
 
   enum _actions
     {
-     Default_action = 1,
+     NoChange_action = 1,  // keep if installed, skip if not installed
      Install_action,
      Reinstall_action,
      Uninstall_action,
     };
   static const char *action_caption (_actions value);
 
-  void set_action (_actions, packageversion const & default_version);
+  void set_action (_actions, packageversion const & default_version,
+                   bool useraction = false);
   ActionList *list_actions(trusts const trust);
   void select_action (int id, trusts const deftrust);
   void toggle_action ();
+  _actions get_action () { return _action; }
 
   void set_message (const std::string& message_id, const std::string& message_string)
   {
@@ -103,7 +105,6 @@ public:
   }
 
   std::string name;			/* package name, like "cygwin" */
-  std::string key;
 
   /* true if package was selected on command-line. */
   bool isManuallyWanted() const;
@@ -141,8 +142,6 @@ public:
   bool srcpicked() const;   /* true if source for desired version is to be installed */
   void srcpick(bool);
 
-  packagemessage message;
-
   /* can one or more versions be installed? */
   bool accessible () const;
   bool sourceAccessible() const;
@@ -165,9 +164,12 @@ private:
   std::vector <Script> scripts_;
   static bool scan (const packageversion &pkg, bool mirror_mode);
 
+  _actions _action;
+
   bool _picked; /* true if desired version is to be (re)installed */
   bool _srcpicked;
 
+  packagemessage message;
   std::set <std::string> version_blacklist;
 };
 


                 reply	other threads:[~2019-12-20 13:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20191220135408.103282.qmail@sourceware.org \
    --to=jturney@sourceware.org \
    --cc=cygwin-apps-cvs@sourceware.org \
    /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).