This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH setup] Report dependencies which don't exist


At the moment, dependencies which can't be found are silently ignored.
Instead, record and report these dependency problems.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
 prereq.cc | 54 ++++++++++++++++++++++++++++++++++++++++++++----------
 prereq.h  |  1 +
 2 files changed, 45 insertions(+), 10 deletions(-)

diff --git a/prereq.cc b/prereq.cc
index c766055..bdc609e 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -163,11 +163,16 @@ PrereqPage::OnUnattended ()
 
 // instantiate the static members
 map <packagemeta *, vector <packagemeta *>, packagemeta_ltcomp> PrereqChecker::unmet;
+map <std::string, vector <packagemeta *> > PrereqChecker::notfound;
 trusts PrereqChecker::theTrust = TRUST_CURR;
 
 /* This function builds a list of unmet dependencies to present to the user on
-   the PrereqPage propsheet.  The data is stored as an associative map of
-   unmet[missing-package] = vector of packages that depend on missing-package */
+   the PrereqPage propsheet.
+
+   The data is stored in two associative maps:
+     unmet[package] = vector of packages that depend on package.
+     notfound[package-name] = vector of packages that depend on package.
+*/
 bool
 PrereqChecker::isMet ()
 {
@@ -177,8 +182,9 @@ PrereqChecker::isMet ()
   Progress.SetText2 ("");
   Progress.SetText3 ("");
 
-  // unmet is static - clear it each time this is called
+  // clear static data each time this is called
   unmet.clear ();
+  notfound.clear ();
 
   // packages that need to be checked for dependencies
   queue <packagemeta *> todo;
@@ -223,20 +229,31 @@ PrereqChecker::isMet ()
           PackageSpecification *dep_spec = (*d)->at(0);
           packagemeta *dep = db.findBinary (*dep_spec);
 
-          if (dep && !(dep->desired && dep_spec->satisfies (dep->desired)))
+          if (dep)
             {
-              // we've got an unmet dependency
-              if (unmet.find (dep) == unmet.end ())
+              if (!(dep->desired && dep_spec->satisfies (dep->desired)))
                 {
-                  // newly found dependency: add to worklist
-                  todo.push (dep);
+                  // we've got an unmet dependency
+                  if (unmet.find (dep) == unmet.end ())
+                    {
+                      // newly found dependency: add to worklist
+                      todo.push (dep);
+                    }
+                  unmet[dep].push_back (pack);
                 }
-              unmet[dep].push_back (pack);
+            }
+          else
+            {
+              // dependency on a package which doesn't have any binary versions
+              // (i.e. it is source only or doesn't exist)
+              Log (LOG_PLAIN) << "package " << pack->name << " has dependency "
+                              << dep_spec->packageName() << " we can't find" << endLog;
+              notfound[dep_spec->packageName()].push_back (pack);
             }
         }
     }
 
-  return unmet.empty ();
+  return unmet.empty () && notfound.empty ();
 }
 
 /* Formats 'unmet' as a string for display to the user.  */
@@ -245,6 +262,23 @@ PrereqChecker::getUnmetString (std::string &s)
 {
   s = "";
 
+  {
+    map <std::string, vector <packagemeta *> >::iterator i;
+    for (i = notfound.begin(); i != notfound.end(); i++)
+      {
+        s = s + i->first
+          + "\t(not found)"
+          + "\r\n\tRequired by: ";
+        for (unsigned int j = 0; j < i->second.size(); j++)
+          {
+            s += i->second[j]->name;
+            if (j != i->second.size() - 1)
+              s += ", ";
+          }
+        s += "\r\n\r\n";
+      }
+  }
+
   map <packagemeta *, vector <packagemeta *>, packagemeta_ltcomp>::iterator i;
   for (i = unmet.begin(); i != unmet.end(); i++)
     {
diff --git a/prereq.h b/prereq.h
index 39347aa..2aed63a 100644
--- a/prereq.h
+++ b/prereq.h
@@ -51,6 +51,7 @@ private:
   
   // this is the actual hash_map that does all the work
   static map <packagemeta *, vector <packagemeta *>, packagemeta_ltcomp> unmet;
+  static map <std::string, vector <packagemeta *> > notfound;
   static trusts theTrust;
 };
 
-- 
2.8.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]