From fd2c0dc9707714d82580dc61854efc06335e6091 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 6 Oct 2015 08:43:01 +0200 Subject: Track prerequisite packages, handle in pkg-{con,dis}figure --- bpkg/pkg-configure.cxx | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'bpkg/pkg-configure.cxx') diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx index 169772c..208fad4 100644 --- a/bpkg/pkg-configure.cxx +++ b/bpkg/pkg-configure.cxx @@ -10,7 +10,9 @@ #include #include #include +#include +#include #include using namespace std; @@ -49,6 +51,7 @@ namespace bpkg database db (open (c, trace)); transaction t (db.begin ()); + session s; shared_ptr p (db.find (n)); @@ -73,6 +76,60 @@ namespace bpkg level4 ([&]{trace << "src_root: " << src_root << ", " << "out_root: " << out_root;}); + // Verify all our prerequisites are configured and populate the + // prerequisites list. + // + { + assert (p->prerequisites.empty ()); + + package_manifest m (pkg_verify (src_root)); + + for (const dependency_alternatives& da: m.dependencies) + { + assert (!da.conditional); //@@ TODO + + bool satisfied (false); + for (const dependency& d: da) + { + if (shared_ptr dp = db.find (d.name)) + { + if (dp->state != state::configured) + continue; + + if (!satisfies (dp->version, d.constraint)) + continue; + + auto r (p->prerequisites.emplace (dp, d.constraint)); + + // If we already have a dependency on this package, pick the + // stricter of the two constraints. + // + if (!r.second) + { + auto& c (r.first->second); + + bool s1 (satisfies (c, d.constraint)); + bool s2 (satisfies (d.constraint, c)); + + if (!s1 && !s2) + fail << "incompatible constraints " + << "(" << d.name << " " << *c << ") and " + << "(" << d.name << " " << *d.constraint << ")"; + + if (s2 && !s1) + c = d.constraint; + } + + satisfied = true; + break; + } + } + + if (!satisfied) + fail << "no configured package satisfies dependency on " << da; + } + } + // Form the buildspec. // string bspec; -- cgit v1.1