This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup 12/15] Stop pretending to support complex dependencies
We pretend that we can parse dependencies of the form "A | B". But
PrereqChecker will just treat that as "A".
This is a hard problem to solve, as we'd need UI to ask, or policy to know
if A or B is preferred.
So just remove the pretense, simplifying lots of stuff.
---
IniDBBuilderPackage.cc | 62 +++++++++++---------------------------------------
IniDBBuilderPackage.h | 6 ++---
iniparse.yy | 16 ++++++-------
package_db.cc | 27 +++++++++-------------
package_version.cc | 29 ++++++++---------------
package_version.h | 12 +++++-----
prereq.cc | 10 +++-----
7 files changed, 52 insertions(+), 110 deletions(-)
diff --git a/IniDBBuilderPackage.cc b/IniDBBuilderPackage.cc
index 303ac34..cd5c922 100644
--- a/IniDBBuilderPackage.cc
+++ b/IniDBBuilderPackage.cc
@@ -34,7 +34,7 @@
using namespace std;
IniDBBuilderPackage::IniDBBuilderPackage (IniParseFeedback const &aFeedback) :
-cp (0), cbpv (), cspv (), currentSpec (0), currentOrList (0), currentAndList (0), trust (0), _feedback (aFeedback){}
+cp (0), cbpv (), cspv (), currentSpec (0), currentNodeList (0), trust (0), _feedback (aFeedback){}
IniDBBuilderPackage::~IniDBBuilderPackage()
{
@@ -76,8 +76,9 @@ IniDBBuilderPackage::buildPackage (const std::string& name)
if (cbpv)
{
Log (LOG_BABBLE) << "Version " << cbpv.Canonical_version() << endLog;
- Log (LOG_BABBLE) << "Depends:" << endLog;
+ Log (LOG_BABBLE) << "Depends:";
dumpAndList (cbpv.depends(), Log (LOG_BABBLE));
+ Log (LOG_BABBLE) << endLog;
}
}
#endif
@@ -91,8 +92,7 @@ IniDBBuilderPackage::buildPackage (const std::string& name)
cbpv = cygpackage::createInstance (name, package_binary);
cspv = packageversion ();
currentSpec = NULL;
- currentOrList = NULL;
- currentAndList = NULL;
+ currentNodeList = NULL;
trust = TRUST_CURR;
#if DEBUG
Log (LOG_BABBLE) << "Created package " << name << endLog;
@@ -191,11 +191,10 @@ IniDBBuilderPackage::buildBeginDepends ()
#if DEBUG
Log (LOG_BABBLE) << "Beginning of a depends statement for " << cp->name
<< endLog;
- dumpAndList (currentAndList, Log (LOG_BABBLE));
+ dumpAndList (currentNodeList, Log (LOG_BABBLE));
#endif
currentSpec = NULL;
- currentOrList = NULL; /* set by the build AndListNode */
- currentAndList = cbpv.depends();
+ currentNodeList = cbpv.depends();
}
void
@@ -241,11 +240,9 @@ IniDBBuilderPackage::buildBeginBuildDepends ()
{
#if DEBUG
Log (LOG_BABBLE) << "Beginning of a Build-Depends statement" << endLog;
- dumpAndList (currentAndList, Log (LOG_BABBLE));
#endif
currentSpec = NULL;
- currentOrList = NULL; /* set by the build AndListNode */
- currentAndList = cspv.depends ();
+ currentNodeList = NULL; /* there is currently nowhere to store Build-Depends information */
}
void
@@ -284,48 +281,16 @@ IniDBBuilderPackage::buildSourceNameVersion (const std::string& version)
}
void
-IniDBBuilderPackage::buildPackageListAndNode ()
+IniDBBuilderPackage::buildPackageListNode (const std::string & name)
{
- if (currentAndList)
+ if (currentNodeList)
{
#if DEBUG
- Log (LOG_BABBLE) << "New AND node for a package list" << endLog;
- if (currentOrList)
- {
- ostream &os = Log (LOG_BABBLE);
- os << "Current OR list is :";
- for (vector<PackageSpecification *>::const_iterator i= currentOrList->begin();
- i != currentOrList->end(); ++i)
- os << endl << **i;
- os << endLog;
- }
+ Log (LOG_BABBLE) << "New node '" << name << "' for package list" << endLog;
#endif
- currentSpec = NULL;
- currentOrList = new vector<PackageSpecification *>;
- currentAndList->push_back (currentOrList);
+ currentSpec = new PackageSpecification (name);
+ currentNodeList->push_back (currentSpec);
}
- else
- _feedback.warning ((std::string ("Attempt to add And node when no AndList"
- " present for package ")
- + std::string(cp->name)).c_str());
-}
-
-void
-IniDBBuilderPackage::buildPackageListOrNode (const std::string& packageName)
-{
- if (currentOrList)
- {
- currentSpec = new PackageSpecification (packageName);
- currentOrList->push_back (currentSpec);
-#if DEBUG
- Log (LOG_BABBLE) << "New OR node in a package list refers to \"" <<
- *currentSpec << "\"." << endLog;
-#endif
- }
- else
- _feedback.warning ((std::string ("Attempt to set specification for package ")
- + std::string(cp->name)
- + " before creation of a version.").c_str());
}
void
@@ -394,8 +359,7 @@ IniDBBuilderPackage::add_correct_version()
*ver.depends() = *cbpv.depends();
/* TODO: other package lists */
/* Prevent dangling references */
- currentOrList = NULL;
- currentAndList = NULL;
+ currentNodeList = NULL;
currentSpec = NULL;
cbpv = *n;
merged = 1;
diff --git a/IniDBBuilderPackage.h b/IniDBBuilderPackage.h
index a39a95f..ef1a6bf 100644
--- a/IniDBBuilderPackage.h
+++ b/IniDBBuilderPackage.h
@@ -49,8 +49,7 @@ public:
void buildMessage (const std::string&, const std::string&);
void buildSourceName (const std::string& );
void buildSourceNameVersion (const std::string& );
- void buildPackageListAndNode ();
- void buildPackageListOrNode (const std::string& );
+ void buildPackageListNode (const std::string& );
void buildPackageListOperator (PackageSpecification::_operators const &);
void buildPackageListOperatorVersion (const std::string& );
@@ -73,8 +72,7 @@ private:
packagemeta *csp;
packageversion cspv;
PackageSpecification *currentSpec;
- std::vector<PackageSpecification *> *currentOrList;
- std::vector<std::vector<PackageSpecification *> *> *currentAndList;
+ std::vector<PackageSpecification *> *currentNodeList;
int trust;
IniParseFeedback const &_feedback;
};
diff --git a/iniparse.yy b/iniparse.yy
index 9ef4801..2480cc6 100644
--- a/iniparse.yy
+++ b/iniparse.yy
@@ -131,30 +131,28 @@ versioninfo: /* empty */
;
versionedpackagelist /* non-empty */
- : { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
- | versionedpackagelist listseparator { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
+ : versionedpackageentry
+ | versionedpackagelist listseparator versionedpackageentry
;
versionedpackagelistsp /* non-empty */
- : { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
- | versionedpackagelistsp { iniBuilder->buildPackageListAndNode(); } versionedpackageentry
+ : versionedpackageentry
+ | versionedpackagelistsp versionedpackageentry
;
-
listseparator: /* empty */
| COMMA
| COMMA NL
;
-
+
versionedpackageentry /* empty not allowed */
- : STRING { iniBuilder->buildPackageListOrNode($1); } versioncriteria
- | versionedpackageentry OR STRING { iniBuilder->buildPackageListOrNode($3); } versioncriteria
+ : STRING { iniBuilder->buildPackageListNode($1); } versioncriteria
;
versioncriteria: /* empty */
| OPENBRACE operator STRING CLOSEBRACE { iniBuilder->buildPackageListOperatorVersion ($3); }
;
-
+
operator /* non-empty */
: EQUAL { iniBuilder->buildPackageListOperator (PackageSpecification::Equals); }
| LT { iniBuilder->buildPackageListOperator (PackageSpecification::LessThan); }
diff --git a/package_db.cc b/package_db.cc
index c2e1b63..e97eea1 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -311,31 +311,27 @@ ConnectedLoopFinder::visit(packagemeta *nodeToVisit)
size_t minimumVisitId = visited;
nodesInStronglyConnectedComponent.push(nodeToVisit);
- vector <vector <PackageSpecification *> *>::const_iterator dp = nodeToVisit->installed.depends()->begin();
- /* walk through each and clause (a link in the graph) */
+ /* walk through each node */
+ std::vector <PackageSpecification *>::const_iterator dp = nodeToVisit->installed.depends()->begin();
while (dp != nodeToVisit->installed.depends()->end())
{
- /* check each or clause for an installed match */
- vector <PackageSpecification *>::const_iterator i = find_if ((*dp)->begin(), (*dp)->end(), checkForInstalled);
- if (i != (*dp)->end())
+ /* check for an installed match */
+ if (checkForInstalled (*dp))
{
/* we found an installed ok package */
/* visit it if needed */
/* UGLY. Need to refactor. iterators in the outer would help as we could simply
* vist the iterator
*/
- const packagedb::packagecollection::iterator n = db.packages.find((*i)->packageName());
+ const packagedb::packagecollection::iterator n = db.packages.find((*dp)->packageName());
if (n == db.packages.end())
- Log (LOG_PLAIN) << "Search for package '" << (*i)->packageName() << "' failed." << endLog;
+ Log (LOG_PLAIN) << "Search for package '" << (*dp)->packageName() << "' failed." << endLog;
else
{
packagemeta *nodeJustVisited = n->second;
minimumVisitId = std::min (minimumVisitId, visit (nodeJustVisited));
}
- /* next and clause */
- ++dp;
- continue;
}
/* not installed or not available we ignore */
++dp;
@@ -492,15 +488,14 @@ packagedb::guessUserPicked()
if (!pkgm.installed)
continue;
- /* walk through each and clause */
- vector <vector <PackageSpecification *> *>::const_iterator dp = pkgm.installed.depends()->begin();
+ /* walk through each node */
+ std::vector <PackageSpecification *>::const_iterator dp = pkgm.installed.depends()->begin();
while (dp != pkgm.installed.depends()->end())
{
- /* check each or clause for an installed match */
- vector <PackageSpecification *>::const_iterator i = find_if ((*dp)->begin(), (*dp)->end(), checkForInstalled);
- if (i != (*dp)->end())
+ /* check for an installed match */
+ if (checkForInstalled(*dp))
{
- const packagedb::packagecollection::iterator n = packages.find((*i)->packageName());
+ const packagedb::packagecollection::iterator n = packages.find((*dp)->packageName());
if (n != packages.end())
{
packagemeta *pkgm2 = n->second;
diff --git a/package_version.cc b/package_version.cc
index 1fc5d77..cd2d509 100644
--- a/package_version.cc
+++ b/package_version.cc
@@ -229,13 +229,13 @@ packageversion::setSourcePackageSpecification (PackageSpecification const &spec)
data->setSourcePackageSpecification(spec);
}
-vector <vector <PackageSpecification *> *> *
+vector <PackageSpecification *> *
packageversion::depends()
{
return &data->depends;
}
-const vector <vector <PackageSpecification *> *> *
+const vector <PackageSpecification *> *
packageversion::depends() const
{
return &data->depends;
@@ -414,28 +414,19 @@ _packageversion::scripts()
}
void
-dumpAndList (vector<vector <PackageSpecification *> *> const *currentAndList,
+dumpAndList (std::vector <PackageSpecification *> const *currentList,
std::ostream &logger)
{
- return;
- if (currentAndList)
+ if (currentList)
{
- vector<vector <PackageSpecification *> *>::const_iterator iAnd =
- currentAndList->begin();
+ Log (LOG_BABBLE) << "( ";
+ std::vector <PackageSpecification *>::const_iterator i = currentList->begin();
while (true)
{
- if ((*iAnd)->size() > 1) Log (LOG_BABBLE) << "( ";
- vector<PackageSpecification *>::const_iterator i= (*iAnd)->begin();
- while (true)
- {
- Log (LOG_BABBLE) << **i;
- if (++i == (*iAnd)->end()) break;
- Log (LOG_BABBLE) << " | ";
- }
- if ((*iAnd)->size() > 1) Log (LOG_BABBLE) << " )";
- if (++iAnd == currentAndList->end()) break;
- Log (LOG_BABBLE) << " & ";
+ if (i == currentList->end()) break;
+ Log (LOG_BABBLE) << **i << " ";
+ ++i;
}
+ Log (LOG_BABBLE) << ")";
}
}
-
diff --git a/package_version.h b/package_version.h
index 1b255a5..2f277bf 100644
--- a/package_version.h
+++ b/package_version.h
@@ -110,8 +110,8 @@ public:
void setSourcePackageSpecification (PackageSpecification const &);
/* invariant: these never return NULL */
- std::vector <std::vector <PackageSpecification *> *> *depends();
- const std::vector <std::vector <PackageSpecification *> *> *depends() const;
+ std::vector <PackageSpecification *> *depends();
+ const std::vector <PackageSpecification *> *depends() const;
bool picked() const; /* true if this version is to be installed */
void pick(bool, packagemeta *); /* trigger an install/reinsall */
@@ -170,9 +170,9 @@ public:
virtual packageversion sourcePackage ();
virtual PackageSpecification & sourcePackageSpecification ();
virtual void setSourcePackageSpecification (PackageSpecification const &);
-
- std::vector <std::vector <PackageSpecification *> *> depends;
-
+
+ std::vector <PackageSpecification *> depends;
+
virtual void pick(bool const &newValue) { picked = newValue;}
bool picked; /* non zero if this version is to be installed */
/* This will also trigger reinstalled if it is set */
@@ -196,6 +196,6 @@ protected:
};
// not sure where this belongs :}.
-void dumpAndList (std::vector<std::vector <PackageSpecification *> *> const *currentAndList, std::ostream &);
+void dumpAndList (std::vector <PackageSpecification *> const *currentList, std::ostream &);
#endif /* SETUP_PACKAGE_VERSION_H */
diff --git a/prereq.cc b/prereq.cc
index 5a94373..7477f79 100644
--- a/prereq.cc
+++ b/prereq.cc
@@ -211,17 +211,13 @@ PrereqChecker::isMet ()
// Fetch the dependencies of the package. This assumes that the
// dependencies of all versions are all the same.
- const vector <vector <PackageSpecification *> *> *deps = pack->curr.depends ();
+ const std::vector <PackageSpecification *> *deps = pack->curr.depends ();
// go through the package's dependencies
- for (vector <vector <PackageSpecification *> *>::const_iterator d =
+ for (std::vector <PackageSpecification *>::const_iterator d =
deps->begin (); d != deps->end (); ++d)
{
- // XXX: the following assumes that there is only a single
- // node in each OR clause, which is currently the case.
- // if setup is ever pushed to use AND/OR in "depends:"
- // lines this will have to be updated
- PackageSpecification *dep_spec = (*d)->at(0);
+ PackageSpecification *dep_spec = *d;
packagemeta *dep = db.findBinary (*dep_spec);
if (dep)
--
2.12.3