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] Don't do unneeded work when changing stability level
Date: Fri, 28 Apr 2017 12:13:00 -0000	[thread overview]
Message-ID: <20170428121205.12240-9-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20170428121205.12240-1-jon.turney@dronecode.org.uk>

Since 2c4487b3, we stopped recomputing all the dependencies every time
something was changed in the PickView.  Remove all the depsolver code which
was used to do that.

The only remaining use was when we changed stability level, to select all
the package versions at that stability level.  That work is already being
done by packagedb::defaultTrust() (called by ChooserPage::changeTrust()).

(Note that this changes behaviour slightly: New dependencies of currently
installed packages used to be shown in the PickView, but now they won't be
reported until the PrereqChecker)

(This still leaves the crude depsolver we actually use in PrereqChecker,
which just selects all the unmet dependencies with the current trust level)
---
 choose.cc          |   8 ---
 package_db.cc      |  11 -----
 package_db.h       |   1 -
 package_meta.cc    |  35 +-------------
 package_meta.h     |  11 +----
 package_version.cc | 140 -----------------------------------------------------
 6 files changed, 3 insertions(+), 203 deletions(-)

diff --git a/choose.cc b/choose.cc
index a0dcc1b..2016caa 100644
--- a/choose.cc
+++ b/choose.cc
@@ -372,14 +372,6 @@ ChooserPage::changeTrust(trusts aTrust)
 {
   SetBusy ();
   chooser->defaultTrust (aTrust);
-  packagedb db;
-  db.markUnVisited ();
-
-  for (packagedb::packagecollection::iterator i = db.packages.begin(); i != db.packages.end(); i++)
-    {
-      i->second->set_requirements(aTrust);
-    }
-
   chooser->refresh();
   PrereqChecker p;
   p.setTrust (aTrust);
diff --git a/package_db.cc b/package_db.cc
index a47fb11..c2e1b63 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -381,17 +381,6 @@ packagedb::connectedEnd()
 }
 
 void
-packagedb::markUnVisited()
-{
-  for (packagedb::packagecollection::iterator n = packages.begin ();
-       n != packages.end (); ++n)
-    {
-      packagemeta & pkgm = *(n->second);
-      pkgm.visited(false);
-    }
-}
-
-void
 packagedb::setExistence ()
 {
   /* binary packages */
diff --git a/package_db.h b/package_db.h
index 6a99398..d02dbc4 100644
--- a/package_db.h
+++ b/package_db.h
@@ -72,7 +72,6 @@ public:
   PackageDBConnectedIterator connectedEnd();
   void fillMissingCategory();
   void defaultTrust (trusts trust);
-  void markUnVisited();
   void setExistence();
   typedef std::map <std::string, packagemeta *> packagecollection;
   /* all seen binary packages */
diff --git a/package_meta.cc b/package_meta.cc
index 4ea9a4f..0f97f1d 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -92,8 +92,7 @@ packagemeta::packagemeta (packagemeta const &rhs) :
   installed (rhs.installed), prev (rhs.prev),
   curr (rhs.curr),
   exp (rhs.exp),
-  desired (rhs.desired),
-  visited_(rhs.visited_)
+  desired (rhs.desired)
 {
   
 }
@@ -457,26 +456,6 @@ packagemeta::set_action (trusts const trust)
     user_picked = true;
 }
 
-int
-packagemeta::set_requirements (trusts deftrust, size_t depth)
-{
-  if (visited())
-    return 0;
-  /* Only prevent further checks once we have been required by something else */
-  if (depth)
-    visited(true);
-  int changed = 0;
-  /* handle build-depends */
-  if (depth == 0 && desired.sourcePackage ().picked())
-    changed += desired.sourcePackage ().set_requirements (deftrust, depth + 1);
-  if (!desired || (desired != installed && !desired.picked ()))
-    /* uninstall || source only */
-    return changed;
-
-  return changed + desired.set_requirements (deftrust, depth);
-}
-
-
 // Set a particular type of action.
 void
 packagemeta::set_action (_actions action, packageversion const &default_version)
@@ -612,18 +591,6 @@ packagemeta::trustLabel(packageversion const &aVersion) const
 }
 
 void
-packagemeta::visited(bool const &aBool)
-{
-  visited_ = aBool;
-}
-
-bool
-packagemeta::visited() const
-{
-  return visited_;
-}
-
-void
 packagemeta::logSelectionStatus() const
 {
   packagemeta const & pkg = *this;
diff --git a/package_meta.h b/package_meta.h
index f23073e..9bf8336 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -35,8 +35,7 @@ public:
   static void ScanDownloadedFiles (bool);
   packagemeta (packagemeta const &);
   packagemeta (const std::string& pkgname)
-  : name (pkgname), key(pkgname), user_picked (false),
-    visited_(false)
+  : name (pkgname), key(pkgname), user_picked (false)
   {
   }
 
@@ -44,8 +43,6 @@ public:
 
   void add_version (packageversion &);
   void set_installed (packageversion &);
-  void visited(bool const &);
-  bool visited() const;
   void addToCategoryBase();
   bool hasNoCategories() const;
   void setDefaultCategories();
@@ -74,10 +71,7 @@ public:
   void set_action (trusts const t);
   void set_action (_actions, packageversion const & default_version);
   void uninstall ();
-  int set_requirements (trusts deftrust, size_t depth);
-  // explicit separation for generic programming.
-  int set_requirements (trusts deftrust) 
-    { return set_requirements (deftrust, 0); }
+
   void set_message (const std::string& message_id, const std::string& message_string)
   {
     message.set (message_id, message_string);
@@ -155,7 +149,6 @@ protected:
   packagemeta &operator= (packagemeta const &);
 private:
   std::string trustLabel(packageversion const &) const;
-  bool visited_;
 };
 
 #endif /* SETUP_PACKAGE_META_H */
diff --git a/package_version.cc b/package_version.cc
index 1f9f2d8..7f52c27 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -309,146 +309,6 @@ packageversion::scan (bool mirror_mode)
     }
 }
 
-static bool
-checkForInstalled (PackageSpecification *spec)
-{
-  packagedb db;
-  packagemeta *required = db.findBinary (*spec);
-  if (!required)
-    return false;
-  if (spec->satisfies (required->installed)
-      && required->desired == required->installed )
-    /* done, found a satisfactory installed version that will remain
-       installed */
-    return true;
-  return false;
-}
-
-static bool
-checkForUpgradeable (PackageSpecification *spec)
-{
-  packagedb db;
-  packagemeta *required = db.findBinary (*spec);
-  if (!required || !required->installed)
-    return false;
-  for (set <packageversion>::iterator i = required->versions.begin();
-       i != required->versions.end(); ++i)
-    if (spec->satisfies (*i))
-      return true;
-  return false;
-}
-
-static bool
-checkForSatisfiable (PackageSpecification *spec)
-{
-  packagedb db;
-  packagemeta *required = db.findBinary (*spec);
-  if (!required)
-    return false;
-  for (set <packageversion>::iterator i = required->versions.begin();
-       i != required->versions.end(); ++i)
-    if (spec->satisfies (*i))
-      return true;
-  return false;
-}
-
-static int
-select (trusts deftrust, size_t depth, packagemeta *required,
-        const packageversion &aVersion)
-{
-  /* preserve source */
-  bool sourceticked = required->desired.sourcePackage ().picked();
-  /* install this version */
-  required->desired = aVersion;
-  required->desired.pick (required->installed != required->desired, required);
-  required->desired.sourcePackage ().pick (sourceticked, NULL);
-  /* does this requirement have requirements? */
-  return required->set_requirements (deftrust, depth + 1);
-}
-
-static int
-processOneDependency (trusts deftrust, size_t depth,
-                      PackageSpecification *spec)
-{
-  /* TODO: add this to a set of packages to be offered to meet the
-     requirement. For now, simply set the install to the first
-     satisfactory version. The user can step through the list if
-     desired */
-  packagedb db;
-  packagemeta *required = db.findBinary (*spec);
-
-  packageversion trusted = required->trustp(false, deftrust);
-  if (spec->satisfies (trusted)) {
-      return select (deftrust, depth, required, trusted);
-  }
-
-  Log (LOG_TIMESTAMP) << "Warning, the default trust level for package "
-    << trusted.Name() << " does not meet this specification " << *spec
-    << endLog;
-  
-  set <packageversion>::iterator v;
-  for (v = required->versions.begin();
-    v != required->versions.end() && !spec->satisfies (*v); ++v);
-
-  if (v == required->versions.end())
-      /* assert ?! */
-      return 0;
-  
-  return select (deftrust, depth, required, *v);
-}
-
-int
-packageversion::set_requirements (trusts deftrust, size_t depth)
-{
-  int changed = 0;
-  vector <vector <PackageSpecification *> *>::iterator dp = depends ()->begin();
-  /* cheap test for too much recursion */
-  if (depth > 30)
-    return changed;
-  /* walk through each and clause */
-  while (dp != depends ()->end())
-    {
-      /* three step:
-	 1) is a satisfactory or clause installed?
-	 2) is an unsatisfactory version of an or clause which has
-	 a satisfactory version available installed?
-	 3) is a satisfactory package available?
-	 */
-      /* check each or clause for an installed match */
-      vector <PackageSpecification *>::iterator i =
-	find_if ((*dp)->begin(), (*dp)->end(), checkForInstalled);
-      if (i != (*dp)->end())
-	{
-	  /* we found an installed ok package */
-	  /* next and clause */
-	  ++dp;
-	  continue;
-	}
-      /* check each or clause for an upgradeable version */
-      i = find_if ((*dp)->begin(), (*dp)->end(), checkForUpgradeable);
-      if (i != (*dp)->end())
-	{
-	  /* we found a package that can be up/downgraded to meet the
-	     requirement. (*i is the packagespec that can be satisfied.)
-	     */
-	  ++dp;
-	  changed += processOneDependency (deftrust, depth, *i) + 1;
-	  continue;
-	}
-      /* check each or clause for an installable version */
-      i = find_if ((*dp)->begin(), (*dp)->end(), checkForSatisfiable);
-      if (i != (*dp)->end())
-	{
-	  /* we found a package that can be installed to meet the requirement */
-	  ++dp;
-	  changed += processOneDependency (deftrust, depth, *i) + 1;
-	  continue;
-	}
-      ++dp;
-    }
-  return changed;
-}
-
 void
 packageversion::addScript(Script const &aScript)
 {
-- 
2.12.2

  parent reply	other threads:[~2017-04-28 12:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-28 12:12 [PATCH setup 00/11] Various setup patches Jon Turney
2017-04-28 12:12 ` [PATCH setup 01/11] Remove pointless abstract base class IniDBBuilder Jon Turney
2017-04-28 12:12 ` [PATCH setup 02/11] Remove unused package_status_t stored in packageversion class Jon Turney
2017-04-28 12:13 ` [PATCH setup 09/11] Make building with DEBUG less useless Jon Turney
2017-04-28 12:13 ` [PATCH setup 04/11] Make packageversion::source(|s) const Jon Turney
2017-04-28 12:13 ` Jon Turney [this message]
2017-04-28 12:13 ` [PATCH setup 07/11] Don't handle missing 'version:' Jon Turney
2017-04-28 12:13 ` [PATCH setup 03/11] Remove cygpackage::destroy() because it does nothing Jon Turney
2017-04-28 12:13 ` [PATCH setup 10/11] Don't show source-only packages in package list Jon Turney
2017-05-01 14:45   ` Yaakov Selkowitz
2017-05-01 19:35     ` Jon Turney
2017-04-28 12:13 ` [PATCH setup 06/11] packageversion::sourcePackageSpecification() is const Jon Turney
2017-04-28 12:13 ` [PATCH setup 11/11] Use wininet for fetching URLs in direct (non-proxy) case (DO NOT APPLY) Jon Turney
2017-04-28 15:33   ` Åke Rehnman
2017-04-29 10:53     ` Jon Turney
2017-05-01 12:58       ` Jon Turney
2017-05-01 15:31         ` Åke Rehnman
2017-05-01 20:45           ` Jon Turney
2017-05-02  7:28             ` Åke Rehnman
2017-05-02 11:05               ` Jon Turney
2017-05-02 19:29                 ` Åke Rehnman
2017-05-03 16:37                   ` Jon Turney
     [not found]                     ` <60ed2d4e-7c89-a9b8-e3ab-e3d0819b7e56@gmail.com>
2017-05-04 10:11                       ` Jon Turney
2017-05-16 14:00                         ` Jon Turney
     [not found]                           ` <e402101c-8e7d-98ed-b39a-c82100d6d59f@gmail.com>
2017-05-17 10:55                             ` Jon Turney
2017-05-03  7:22                 ` Brian Inglis
2017-05-03 16:37                   ` Jon Turney
2017-04-28 12:13 ` [PATCH setup 05/11] Use const version of packageversion::depends() in PrereqChecker Jon Turney

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