]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
* PickPackageLine.cc (PickPackageLine::paint): Call trustp with default
authorCorinna Vinschen <corinna@vinschen.de>
Mon, 26 Jan 2015 21:05:46 +0000 (21:05 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Mon, 26 Jan 2015 21:05:46 +0000 (21:05 +0000)
flag set to false.
(PickPackageLine::click): Drop parameter from packagemeta::set_action
call.
(PickPackageLine::set_action): Call trustp with default flag set to
true.
* choose.cc (ChooserPage::OnInit): Call trustp with default flag set to
true to fetch default package version, rather than defaulting to curr.
* package_db.cc (packagedb::defaultTrust): Call trustp with default
flag set to true.
* package_meta.cc (packagemeta::set_action): Drop default_version
parameter.  Rewrite to simplify mechanism, and to account for correct
stepping through versions if installed version is not available anymore.
* package_meta.h (packagemeta::set_action): Align prototype.
(packagemeta::trustp): Add bool to request default package handling.
Add code to make sure not to downgrade packages by default.
* package_version.cc (processOneDependency): Call trustp with default
flag set to false.
* prereq.cc (PrereqChecker::getUnmetString): Ditto.
(PrereqChecker::selectMissing): Ditto.

ChangeLog
PickPackageLine.cc
choose.cc
package_db.cc
package_meta.cc
package_meta.h
package_version.cc
prereq.cc

index 86a7ddf69ba7b84ea7c424eff722d80c3db8131f..cb4aa5a6b55e7abd02330b3c2c9dbc6abea2ede6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2015-01-26  Corinna Vinschen  <corinna@vinschen.de>
+
+       * PickPackageLine.cc (PickPackageLine::paint): Call trustp with default
+       flag set to false.
+       (PickPackageLine::click): Drop parameter from packagemeta::set_action
+       call.
+       (PickPackageLine::set_action): Call trustp with default flag set to
+       true.
+       * choose.cc (ChooserPage::OnInit): Call trustp with default flag set to
+       true to fetch default package version, rather than defaulting to curr.
+       * package_db.cc (packagedb::defaultTrust): Call trustp with default
+       flag set to true.
+       * package_meta.cc (packagemeta::set_action): Drop default_version
+       parameter.  Rewrite to simplify mechanism, and to account for correct
+       stepping through versions if installed version is not available anymore.
+       * package_meta.h (packagemeta::set_action): Align prototype.
+       (packagemeta::trustp): Add bool to request default package handling.
+       Add code to make sure not to downgrade packages by default.
+       * package_version.cc (processOneDependency): Call trustp with default
+       flag set to false.
+       * prereq.cc (PrereqChecker::getUnmetString): Ditto.
+       (PrereqChecker::selectMissing): Ditto.
+
 2015-01-25  Corinna Vinschen  <corinna@vinschen.de>
 
        * package_version.cc (packageversion::compareVersions): Get arguments
index f5fba392211127e6bc54e6e7c04c6d78e9dc1b69..bf3556e15eee1b52651c8e9e519adc355db2aae5 100644 (file)
@@ -95,7 +95,7 @@ PickPackageLine::paint (HDC hdc, HRGN unused, int x, int y, int col_num, int sho
       else if (pkg.installed)
         picked = pkg.installed;
       else
-        picked = pkg.trustp (theView.deftrust);
+        picked = pkg.trustp (false, theView.deftrust);
 
       /* Include the size of the binary package, and if selected, the source
          package as well.  */
@@ -134,13 +134,13 @@ PickPackageLine::click (int const myrow, int const ClickedRow, int const x)
 
   if (x >= theView.headers[theView.new_col].x - HMARGIN / 2
       && x <= theView.headers[theView.new_col + 1].x - HMARGIN / 2)
-    pkg.set_action (pkg.trustp(theView.deftrust));
+    pkg.set_action ();
 
   return 0;
 }
 
 int PickPackageLine::set_action (packagemeta::_actions action)
 {
-  pkg.set_action (action, pkg.trustp(theView.deftrust));
+  pkg.set_action (action, pkg.trustp (true, theView.deftrust));
   return 1;
 }
index 7e69136a44a2d82ef000178d49d4dc6dad6d692b..a1f940a3a27eed1f6b76b8dee209206661a9c13d 100644 (file)
--- a/choose.cc
+++ b/choose.cc
@@ -264,7 +264,7 @@ ChooserPage::OnInit ()
       else if (uninstall)
        pkg.set_action( packagemeta::Uninstall_action, packageversion() );
       else
-       pkg.set_action( packagemeta::Default_action, ((upgrade && current) ? pkg.curr : pkg.installed) );
+       pkg.set_action( packagemeta::Default_action, ((upgrade && current) ? pkg.trustp (true,  TRUST_UNKNOWN) : pkg.installed) );
     }
 
   ClearBusy ();
index 5625aebf812e6be8a4accd18b66aacb7b994c47c..73dfbf605a95f212ac9dcdf8e4bff526d40ca941 100644 (file)
@@ -432,7 +432,7 @@ packagedb::defaultTrust (trusts trust)
             || pkg.categories.find ("Base") != pkg.categories.end ()
             || pkg.categories.find ("Misc") != pkg.categories.end ())
         {
-          pkg.desired = pkg.trustp (trust);
+          pkg.desired = pkg.trustp (true, trust);
           if (pkg.desired)
             pkg.desired.pick (pkg.desired.accessible() && pkg.desired != pkg.installed, &pkg);
         }
index f7a60e83e3e4f450a3a61621e55b67c54269acf1..808ff4a7b4d1f705305f45ae82971f9269c375b9 100644 (file)
@@ -404,139 +404,47 @@ packagemeta::action_caption () const
 
 /* Set the next action given a current action.  */
 void
-packagemeta::set_action (packageversion const &default_version)
+packagemeta::set_action ()
 {
-  /* actions are the following:
-
-     for install modes (from net/local)
-     for each version:
-     install this version
-     install the source for this version
-     and a boolean flag - force install to allow reinstallation, or bypassing requirements
-     globally:
-     install the source for the current version.
-
-     to uninstall a package, the desired version is set to NULL;
-
-     for mirroring modes (download only)
-     for each version
-     download this version
-     download source for this version
-
-     these are represented by the following:
-     the desired pointer in the packagemetadata indicated which version we are operating on.
-     if we are operating on the installed version, reinstall is a valid option.
-     for the selected version, forceinstall means Do an install no matter what, and
-     srcpicked means download the source.
-
-     The default action for any installed package is to install the 'curr version'
-     if it is not already installed.
-
-     The default action for any non-installed package is to do nothing.
-
-     To achieve a no-op, set desired==installed, and if (installed) set forceinstall=0 and
-     srcpicked = 0;
-
-     Iteration through versions should follow the following rules:
-     selected radio button (prev/curr/test) (show as reinstall if that is the
-     current version) ->source only (only if the package is installed) ->oldest version....s
-     kip version of radio button...
-     newest version->uninstall->no-op->selected radio button.
-
-     If any state cannot be set (ie because (say) no prev entry exists for a package
-     simply progress to the next option.
-
-   */
-
-  /* We were set to uninstall the package */
-  if (!desired && installed)
-    {
-      /* No-op - keep whatever we've got */
-      desired = installed;
-      if (desired)
-       {
-         desired.pick (false, NULL);
-         desired.sourcePackage().pick (false, NULL);
-       }
-      return;
-    }
-  else if (desired == installed &&
-          (!installed || 
-           // neither bin nor source are being installed
-           (!(installed.picked() || installed.sourcePackage().picked()) &&
-            // bin or source are available
-            (installed.accessible() || installed.sourcePackage().accessible()) ))
-          )
-    /* Install the default trust version - this is a 'reinstall' for installed
-       * packages */
-    {
-      /* No-op */
-      desired = default_version;
-      if (desired)
-       {
-         if (desired.accessible())
-           desired.pick (true, this);
-         else
-           desired.sourcePackage().pick (true, NULL);
-         return;
-       }
-    }
-  /* are we currently on the radio button selection and installed */
-  if (desired == default_version && installed &&
-      (!desired || desired.picked())
-      && (desired && desired.sourcePackage().accessible())
-      )
+  if (!desired)
     {
-      /* source only this file */
-      desired = installed;
-      desired.pick (false, NULL);
-      desired.sourcePackage().pick (true, NULL);
+      /* If we were on "Uninstall", switch to the first version in the list.
+         If that's the installed version it will be automatically in state
+        "Keep". */
+      desired = *versions.begin ();
+      desired.pick (false, this);
+      desired.sourcePackage ().pick (false, NULL);
       return;
     }
-  /* are we currently on source only or on the radio button but not installed */
-  else if ((desired == installed 
-           && installed.sourcePackage().picked ()) || desired == default_version)
+
+  if (desired == installed && !desired.picked () && installed.accessible ())
     {
-      /* move onto the loop through versions */
-      set<packageversion>::iterator i = versions.begin();
-      if (*i == default_version)
-       ++i;
-      if (i != versions.end())
-       {
-         desired = *i;
-         desired.pick (desired.accessible(), this);
-         desired.sourcePackage ().pick (false, NULL);
-       }
-      else
-       desired = packageversion ();
+      /* If we're on "Keep" on the installed version, and the installed version
+         is available, switch to "Reinstall". */
+      desired.pick (true, this);
+      desired.sourcePackage ().pick (false, NULL);
       return;
     }
+
+  bool binary_picked = desired.picked();
+  bool source_picked = desired.sourcePackage().picked();
+
+  /* So we're on "some" version, switch to the next in line. */
+  set<packageversion>::iterator i;
+  for (i = versions.begin(); i != versions.end() && *i != desired; ++i)
+    ;
+  ++i;
+  /* If there's another version in the list, switch to it, otherwise
+     switch to "Uninstall". */
+  if (i != versions.end ())
+    desired = *i;
   else
+    desired = packageversion ();
+  if (desired)
     {
-      /* preserve the src tick box */
-      bool sourceticked = desired.sourcePackage().picked();
-      /* bump the version selected, skipping the radio button trust along the way */
-      set<packageversion>::iterator i;
-      for (i=versions.begin(); i != versions.end() && *i != desired; ++i);
-      /* i points at desired in the versions set */
-      ++i;
-      if (i != versions.end ())
-       {
-         if (default_version == *i)
-           ++i;
-         if (i != versions.end ())
-           {
-             desired = *i;
-             desired.pick (desired.accessible(), this);
-             if (desired.sourcePackage().accessible ())
-               desired.sourcePackage ().pick (sourceticked, NULL);
-             else
-               desired.sourcePackage ().pick (false, NULL);
-             return;
-           }
-       }
-      /* went past the end - uninstall the package */
-      desired = packageversion ();
+      desired.pick (desired.accessible() && binary_picked, this);
+      desired.sourcePackage ().pick (desired.sourcePackage().accessible ()
+                                    && source_picked, NULL);
     }
 }
 
index 2da4a65024844dce788cc2f5142f0c33fbcdfa48..4f8543033a64ad8f609463853dfa855285259a12 100644 (file)
@@ -77,7 +77,7 @@ public:
   static const _actions Install_action;
   static const _actions Reinstall_action;
   static const _actions Uninstall_action;
-  void set_action (packageversion const &default_version);
+  void set_action ();
   void set_action (_actions, packageversion const & default_version);
   void uninstall ();
   int set_requirements (trusts deftrust, size_t depth);
@@ -90,14 +90,24 @@ public:
   }
 
   std::string action_caption () const;
-  packageversion trustp (trusts const t) const
+  packageversion trustp (bool _default, trusts const t) const
   {
+    /* If the user chose "test" and a "test" version is available, return it. */
     if (t == TRUST_TEST && exp)
       return exp;
-    else if (curr)
+    /* Are we looking for the default version and does the installed version
+       have a higher version number than the "curr" package?  This means the
+       user has installed a "test" version, or built her own version newer
+       than "curr".  Rather than pulling the user back to "curr", we stick to
+       "test" if a "test" version is available, or to "installed" if not.
+       This reflects the behaviour of `yum update' on Fedora. */
+    if (_default && packageversion::compareVersions (curr, installed) < 0)
+      return exp ? exp : installed;
+    /* Otherwise, if a "curr" version exists, return "curr". */
+    if (curr)
       return curr;
-    else
-      return installed;
+    /* Otherwise return the installed version. */
+    return installed;
   }
 
   std::string name;                    /* package name, like "cygwin" */
index 326cf8497f215ee719488499db7d5aafdf38dab7..6a32ce74d5da06b7c85949b166b87a812c941cea 100644 (file)
@@ -431,7 +431,7 @@ processOneDependency (trusts deftrust, size_t depth,
   packagedb db;
   packagemeta *required = db.findBinary (*spec);
 
-  packageversion trusted = required->trustp(deftrust);
+  packageversion trusted = required->trustp(false, deftrust);
   if (spec->satisfies (trusted)) {
       return select (deftrust, depth, required, trusted);
   }
index 5d60dca8a64b9411123c69fc27ff4602c7b0fdaf..c76605572a38e0fc86da32f7b3d44a4e3acd7089 100644 (file)
--- a/prereq.cc
+++ b/prereq.cc
@@ -249,7 +249,7 @@ PrereqChecker::getUnmetString (std::string &s)
   for (i = unmet.begin(); i != unmet.end(); i++)
     {
       s = s + i->first->name
-           + "\t(" + i->first->trustp (theTrust).Canonical_version ()
+           + "\t(" + i->first->trustp (false, theTrust).Canonical_version ()
            + ")\r\n\t" + i->first->SDesc ()
            + "\r\n\tRequired by: ";
       for (unsigned int j = 0; j < i->second.size(); j++)
@@ -276,7 +276,7 @@ PrereqChecker::selectMissing ()
   map <packagemeta *, vector <packagemeta *>, packagemeta_ltcomp>::iterator i;
   for (i = unmet.begin(); i != unmet.end(); i++)
     {
-      packageversion vers = i->first->trustp (theTrust);
+      packageversion vers = i->first->trustp (false, theTrust);
       i->first->desired = vers;
       vers.sourcePackage ().pick (false, NULL);
 
This page took 0.054978 seconds and 5 git commands to generate.