public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
* [setup - the official Cygwin setup program] branch topic/libsolv, updated. release_2.881-41-gb8ba884
@ 2017-10-09 18:17 jturney
  0 siblings, 0 replies; only message in thread
From: jturney @ 2017-10-09 18:17 UTC (permalink / raw)
  To: cygwin-apps-cvs




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

commit b8ba884d297f4eee4ba143ae63585e70d1d1687d
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Mon Oct 9 18:10:52 2017 +0100

    Take command line package/category install/uninstall into account
    
    Rather than overwriting the packagedb changes made from processing command
    line options in ChooserPage::OnInit(), use the 'initial' flag to
    changeTrust() in createListview() to take them into consideration.
    
    --upgrade-also and --force-current are now handled directly.

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

commit cb44611ca585d2d00410412f195f89bce0d20912
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Mon Oct 9 15:37:06 2017 +0100

    Change UI to add 'Sync' choice and change 'Test' to checkbox
    
    Set the initial update mode in UI correctly:
    - 'Sync', if --force-current option is used
    - 'Keep', if packages are selected on command line without --upgrade-also
    - 'Current', otherwise
    
    Add mapping of 'Sync' to SolverSolution::updateForce to mapping of UI
    update mode to solver update mode.

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

commit caf0f2103b8cbd693d5ee5886bbdca69c31ba3b5
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Mon Oct 9 15:05:22 2017 +0100

    Add distupgrade support to solver
    
    Also, ignore change transactions (these are usually vendorchange as we
    forget the vendor for installed packages)
    
    Also, don't put unknown type transactions into the transaction list


Diff:
---
 PickView.cc   |    3 --
 choose.cc     |   85 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 choose.h      |    7 +---
 libsolv.cc    |   28 ++++++++++++++++---
 libsolv.h     |    8 +++++-
 package_db.cc |    7 +---
 package_db.h  |    2 +-
 prereq.cc     |    2 +-
 res.rc        |   16 +++++++----
 resource.h    |    2 +
 10 files changed, 121 insertions(+), 39 deletions(-)

diff --git a/PickView.cc b/PickView.cc
index c66ddab..885400a 100644
--- a/PickView.cc
+++ b/PickView.cc
@@ -940,9 +940,6 @@ PickView::defaultTrust (trusts trust)
 {
   this->deftrust = trust;
 
-  packagedb db;
-  db.defaultTrust(trust);
-
   // force the picker to redraw
   RECT r = GetClientRect ();
   InvalidateRect (this->GetHWND(), &r, TRUE);
diff --git a/choose.cc b/choose.cc
index 192b81f..f0e6802 100644
--- a/choose.cc
+++ b/choose.cc
@@ -77,6 +77,7 @@ static ControlAdjuster::ControlInfo ChooserControlsInfo[] = {
   {IDC_CHOOSE_SEARCH_EDIT,	CP_LEFT,    CP_TOP},
   {IDC_CHOOSE_KEEP, 		CP_RIGHT,   CP_TOP},
   {IDC_CHOOSE_CURR, 		CP_RIGHT,   CP_TOP},
+  {IDC_CHOOSE_SYNC, 		CP_RIGHT,   CP_TOP},
   {IDC_CHOOSE_EXP, 		CP_RIGHT,   CP_TOP},
   {IDC_CHOOSE_VIEW, 		CP_LEFT,    CP_TOP},
   {IDC_LISTVIEW_POS, 		CP_RIGHT,   CP_TOP},
@@ -150,10 +151,26 @@ ChooserPage::createListview ()
 			PickView::views::PackagePending : PickView::views::Category);
   SendMessage (GetDlgItem (IDC_CHOOSE_VIEW), CB_SETCURSEL, (WPARAM)chooser->getViewMode(), 0);
 
-  /* FIXME: do we need to init the desired fields ? */
-  static int ta[] = { IDC_CHOOSE_KEEP, IDC_CHOOSE_CURR, IDC_CHOOSE_EXP, 0 };
-  rbset (GetHWND (), ta, IDC_CHOOSE_CURR);
-  changeTrust (TRUST_CURR);
+  // set the initial update state
+  if (ForceCurrentOption)
+    {
+      update_mode_id = IDC_CHOOSE_SYNC;
+      changeTrust(update_mode_id, false, true);
+    }
+  else if (hasManualSelections && !UpgradeAlsoOption)
+    {
+      // if packages are added or removed on the command-line and --upgrade-also
+      // isn't used, we keep the current versions of everything else
+      update_mode_id = IDC_CHOOSE_KEEP;
+    }
+  else
+    {
+      update_mode_id = IDC_CHOOSE_CURR;
+      changeTrust (update_mode_id, false, true);
+    }
+
+  static int ta[] = { IDC_CHOOSE_KEEP, IDC_CHOOSE_CURR, IDC_CHOOSE_SYNC, 0 };
+  rbset (GetHWND (), ta, update_mode_id);
 
   ClearBusy ();
 }
@@ -262,8 +279,7 @@ ChooserPage::OnInit ()
       bool deleted   = pkg.isManuallyDeleted();
       bool basemisc  = (pkg.categories.find ("Base") != pkg.categories.end ()
 		     || pkg.categories.find ("Orphaned") != pkg.categories.end ());
-      bool upgrade   = wanted || (!pkg.installed && basemisc)
-		     || UpgradeAlsoOption || !hasManualSelections;
+      bool upgrade   = wanted || (!pkg.installed && basemisc);
       bool install   = wanted  && !deleted && !pkg.installed;
       bool reinstall = (wanted  || basemisc) && deleted;
       bool uninstall = (!(wanted  || basemisc) && (deleted || PruneInstallOption))
@@ -274,7 +290,7 @@ ChooserPage::OnInit ()
 	pkg.set_action (packagemeta::Reinstall_action, pkg.curr);
       else if (uninstall)
 	pkg.set_action (packagemeta::Uninstall_action, packageversion ());
-      else if (PruneInstallOption || ForceCurrentOption)
+      else if (PruneInstallOption)
 	pkg.set_action (packagemeta::Default_action, pkg.curr);
       else if (upgrade)
 	pkg.set_action (packagemeta::Default_action, pkg.trustp(true, TRUST_UNKNOWN));
@@ -292,6 +308,7 @@ ChooserPage::OnInit ()
 
   AddTooltip (IDC_CHOOSE_KEEP, IDS_TRUSTKEEP_TOOLTIP);
   AddTooltip (IDC_CHOOSE_CURR, IDS_TRUSTCURR_TOOLTIP);
+  AddTooltip (IDC_CHOOSE_SYNC, IDS_TRUSTDUP_TOOLTIP);
   AddTooltip (IDC_CHOOSE_EXP, IDS_TRUSTEXP_TOOLTIP);
   AddTooltip (IDC_CHOOSE_VIEW, IDS_VIEWBUTTON_TOOLTIP);
   AddTooltip (IDC_CHOOSE_HIDE, IDS_HIDEOBS_TOOLTIP);
@@ -358,6 +375,7 @@ ChooserPage::OnBack ()
 void
 ChooserPage::keepClicked()
 {
+  update_mode_id = IDC_CHOOSE_KEEP;
   packagedb db;
   for (packagedb::packagecollection::iterator i = db.packages.begin ();
         i != db.packages.end (); ++i)
@@ -370,12 +388,49 @@ ChooserPage::keepClicked()
 }
 
 void
-ChooserPage::changeTrust(trusts aTrust)
+ChooserPage::changeTrust(int button, bool test, bool initial)
 {
   SetBusy ();
-  chooser->defaultTrust (aTrust);
+
+  update_mode_id = button;
+
+  SolverSolution::updateMode mode;
+  switch (button)
+    {
+    default:
+    case IDC_CHOOSE_KEEP:
+      mode = SolverSolution::keep;
+      break;
+
+    case IDC_CHOOSE_CURR:
+      mode = SolverSolution::updateBest;
+      break;
+
+    case IDC_CHOOSE_SYNC:
+      mode = SolverSolution::updateForce;
+      break;
+    }
+
+  packagedb db;
+  SolverTasks q;
+
+  // usually we want to apply the solver to an empty task list to get the list
+  // of packages to upgrade (if any)
+  if (initial)
+    {
+      // but initially we want a task list with any package changes caused by
+      // command line options
+      q.setTasks();
+    }
+  db.defaultTrust(q, mode, test);
+
+  // configure PickView so 'test' or 'curr' version is chosen when an
+  // uninstalled package is first clicked on.
+  chooser->defaultTrust (test ? TRUST_TEST : TRUST_CURR);
+
   chooser->refresh();
-  PrereqChecker::setTestPackages(aTrust == TRUST_TEST);
+
+  PrereqChecker::setTestPackages(test);
   ClearBusy ();
 }
 
@@ -411,12 +466,16 @@ ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
 
     case IDC_CHOOSE_CURR:
       if (IsButtonChecked (id))
-        changeTrust (TRUST_CURR);
+        changeTrust (id, IsButtonChecked(IDC_CHOOSE_EXP), false);
       break;
 
-    case IDC_CHOOSE_EXP:
+    case IDC_CHOOSE_SYNC:
       if (IsButtonChecked (id))
-        changeTrust (TRUST_TEST);
+        changeTrust (id, IsButtonChecked(IDC_CHOOSE_EXP), false);
+      break;
+
+    case IDC_CHOOSE_EXP:
+      changeTrust(update_mode_id, IsButtonChecked (id), false);
       break;
 
     case IDC_CHOOSE_HIDE:
diff --git a/choose.h b/choose.h
index 46f0f35..6839b0b 100644
--- a/choose.h
+++ b/choose.h
@@ -54,7 +54,7 @@ private:
   RECT getDefaultListViewSize();
   void getParentRect (HWND parent, HWND child, RECT * r);
   void keepClicked();
-  void changeTrust(trusts aTrust);
+  void changeTrust(int button, bool test, bool initial);
   void logOnePackageResult(packagemeta const *aPkg);
   void logResults();
   void setPrompt(char const *aPrompt);
@@ -73,10 +73,7 @@ private:
     WINDOWPLACEMENT wp;
     UINT wpi[sizeof (WINDOWPLACEMENT) / sizeof (UINT)];
   };
-
-
-
-
+  int update_mode_id;
 };
 
 #endif /* SETUP_CHOOSE_H */
diff --git a/libsolv.cc b/libsolv.cc
index df9f2fb..78e73a8 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -665,7 +665,7 @@ std::ostream &operator<<(std::ostream &stream,
 }
 
 bool
-SolverSolution::update(SolverTasks &tasks, bool update, bool use_test_packages, bool include_source)
+SolverSolution::update(SolverTasks &tasks, updateMode update, bool use_test_packages, bool include_source)
 {
   Log (LOG_PLAIN) << "solving: " << tasks.tasks.size() << " tasks," <<
     " update: " << (update ? "yes" : "no") << "," <<
@@ -704,8 +704,23 @@ SolverSolution::update(SolverTasks &tasks, bool update, bool use_test_packages,
         }
     }
 
-  if (update)
-    queue_push2(&job, SOLVER_UPDATE | SOLVER_SOLVABLE_ALL, 0);
+  // Ask solver to update packages
+  switch (update)
+    {
+    case keep:
+      break;
+
+    case updateBest:
+      // Update to best version
+      queue_push2(&job, SOLVER_UPDATE | SOLVER_SOLVABLE_ALL, 0);
+      break;
+
+    case updateForce:
+      // Bring installed, non-orphaned packages in sync with the ones in the
+      // repository
+      queue_push2(&job, SOLVER_DISTUPGRADE | SOLVER_SOLVABLE_ALL, 0);
+      break;
+    }
 
   // Ask solver to check dependencies of installed packages.
   queue_push2(&job, SOLVER_VERIFY | SOLVER_SOLVABLE_ALL, 0);
@@ -715,6 +730,8 @@ SolverSolution::update(SolverTasks &tasks, bool update, bool use_test_packages,
 
   solver_set_flag(solv, SOLVER_FLAG_ALLOW_VENDORCHANGE, 1);
   solver_set_flag(solv, SOLVER_FLAG_ALLOW_DOWNGRADE, 0);
+  solver_set_flag(solv, SOLVER_FLAG_DUP_ALLOW_VENDORCHANGE, 1);
+  solver_set_flag(solv, SOLVER_FLAG_DUP_ALLOW_DOWNGRADE, 1);
   solver_solve(solv, &job);
   queue_free(&job);
 
@@ -733,7 +750,8 @@ SolverSolution::update(SolverTasks &tasks, bool update, bool use_test_packages,
     {
       Id id = t->steps.elements[i];
       SolverTransaction::transType tt = type(t, i);
-      trans.push_back(SolverTransaction(SolvableVersion(id, pool.pool), tt));
+      if (tt != SolverTransaction::transIgnore)
+        trans.push_back(SolverTransaction(SolvableVersion(id, pool.pool), tt));
     }
 
   // add install and remove tasks for anything marked as reinstall
@@ -869,6 +887,8 @@ SolverSolution::type(Transaction *trans, int pos)
       return SolverTransaction::transErase;
     default:
       Log (LOG_PLAIN) << "unknown transaction type " << std::hex << tt << endLog;
+    case SOLVER_TRANSACTION_CHANGE:
+    case SOLVER_TRANSACTION_CHANGED:
     case SOLVER_TRANSACTION_IGNORE:
       return SolverTransaction::transIgnore;
     }
diff --git a/libsolv.h b/libsolv.h
index 9acd384..e448841 100644
--- a/libsolv.h
+++ b/libsolv.h
@@ -241,7 +241,13 @@ class SolverSolution
   /* Reset transaction list to correspond to package database */
   void db2trans();
 
-  bool update(SolverTasks &tasks, bool update, bool use_test_packages, bool include_source);
+  enum updateMode
+  {
+    keep,        // don't update
+    updateBest,  // update to best version
+    updateForce, // distupdate: downgrade if necessary to best version in repo
+  };
+  bool update(SolverTasks &tasks, updateMode update, bool use_test_packages, bool include_source);
   std::string report() const;
 
   const SolverTransactionList &transactions() const;
diff --git a/package_db.cc b/package_db.cc
index a87a47b..a9f6905 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -580,12 +580,9 @@ packagedb::fillMissingCategory ()
 }
 
 void
-packagedb::defaultTrust (trusts trust)
+packagedb::defaultTrust (SolverTasks &q, SolverSolution::updateMode mode, bool test)
 {
-  // apply solver to an empty task list to get list of packages to upgrade (if
-  // any)
-  SolverTasks q;
-  solution.update(q, (trust >= TRUST_CURR), (trust == TRUST_TEST), FALSE);
+  solution.update(q, mode, test, FALSE);
 
   // reflect that task list into packagedb
   solution.trans2db();
diff --git a/package_db.h b/package_db.h
index 8d580ff..d7127a6 100644
--- a/package_db.h
+++ b/package_db.h
@@ -79,7 +79,7 @@ public:
   PackageDBConnectedIterator connectedBegin();
   PackageDBConnectedIterator connectedEnd();
   void fillMissingCategory();
-  void defaultTrust (trusts trust);
+  void defaultTrust (SolverTasks &q, SolverSolution::updateMode mode, bool test);
   void setExistence();
   void removeEmptyCategories();
 
diff --git a/prereq.cc b/prereq.cc
index eb3f0be..c5a1fd5 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -175,7 +175,7 @@ PrereqChecker::isMet ()
   q.setTasks();
 
   // apply solver to those tasks and global state (use test, include source)
-  return db.solution.update(q, FALSE, use_test_packages, IncludeSource);
+  return db.solution.update(q, SolverSolution::keep, use_test_packages, IncludeSource);
 }
 
 /* Formats problems and solutions as a string for display to the user.  */
diff --git a/res.rc b/res.rc
index 5e13b0c..3ed57ff 100644
--- a/res.rc
+++ b/res.rc
@@ -315,7 +315,8 @@ END
 
 // Right-aligned controls.
 #define SETUP_EXP_X		(SETUP_STANDARD_DIALOG_W - SETUP_KPCE_W - 7)
-#define SETUP_CURR_X		(SETUP_EXP_X - SETUP_KPCE_W - 5)
+#define SETUP_DUP_X		(SETUP_EXP_X - SETUP_KPCE_W - 5)
+#define SETUP_CURR_X		(SETUP_DUP_X - SETUP_KPCE_W - 5)
 #define SETUP_KEEP_X		(SETUP_CURR_X - SETUP_KPCE_W - 5)
 
 // Left-aligned controls.
@@ -350,7 +351,9 @@ BEGIN
                     | WS_GROUP | WS_TABSTOP, SETUP_KEEP_X, 30, SETUP_KPCE_W, 14
     CONTROL         "C&urrent", IDC_CHOOSE_CURR, "Button", BS_AUTORADIOBUTTON,
                     SETUP_CURR_X, 30, SETUP_KPCE_W, 14
-    CONTROL         "&Test", IDC_CHOOSE_EXP, "Button", BS_AUTORADIOBUTTON,
+    CONTROL         "&Sync", IDC_CHOOSE_SYNC, "Button", BS_AUTORADIOBUTTON,
+                    SETUP_DUP_X, 30, SETUP_KPCE_W, 14
+    CONTROL         "&Test", IDC_CHOOSE_EXP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
                     SETUP_EXP_X, 30, SETUP_KPCE_W, 14
     CONTROL         "", IDC_HEADSEPARATOR, "Static", SS_BLACKFRAME | SS_SUNKEN,
                     0, 28, SETUP_STANDARD_DIALOG_W, 1
@@ -533,10 +536,11 @@ BEGIN
     IDS_TRUSTKEEP_TOOLTIP   "Sets all packages to their currently installed "
        "version.  This is equivalent to telling setup not to make any "
        "changes to any package."
-    IDS_TRUSTCURR_TOOLTIP   "Globally select the version that is currently "
-       "considered the most stable. (RECOMMENDED)"
-    IDS_TRUSTEXP_TOOLTIP    "Globally select the most recent version, even if "
-       "that version is considered experimental or for test use by the maintainer."
+    IDS_TRUSTCURR_TOOLTIP   "Sets all packages to the best version available. "
+       "(RECOMMENDED)"
+    IDS_TRUSTDUP_TOOLTIP    "Sets all packages to the version available from the "
+       "package respository, downgrading if necessary"
+    IDS_TRUSTEXP_TOOLTIP    "Enable test packages."
     IDS_VIEWBUTTON_TOOLTIP  "Select the package view.  This determines "
        "which packages are shown below.\r\n"
        "\r\n"
diff --git a/resource.h b/resource.h
index a2add84..c24cefa 100644
--- a/resource.h
+++ b/resource.h
@@ -39,6 +39,7 @@
 #define IDS_NO_LOCALDIR			  138
 #define IDS_ELEVATED			  139
 #define IDS_INSTALLEDB_VERSION            140
+#define IDS_TRUSTDUP_TOOLTIP              141
 
 // Dialogs
 
@@ -175,3 +176,4 @@
 #define IDC_FILE_INUSE_MSG                591
 #define IDC_FILE_INUSE_HELP               592
 #define IDC_NET_DIRECT_LEGACY             593
+#define IDC_CHOOSE_SYNC                    594


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-09 18:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-09 18:17 [setup - the official Cygwin setup program] branch topic/libsolv, updated. release_2.881-41-gb8ba884 jturney

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).