diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-03-01 18:33:16 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-03-02 20:04:26 +0300 |
commit | 1374560d558f4cab72f66b3d851e2a052f59998d (patch) | |
tree | c12564709e52e17699fe9932eb2b07b07189a5c0 /bpkg/package.cxx | |
parent | 780290277a51853b2e515b16898ca0fcfa1e9e71 (diff) |
Update pkg-build
Diffstat (limited to 'bpkg/package.cxx')
-rw-r--r-- | bpkg/package.cxx | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/bpkg/package.cxx b/bpkg/package.cxx index e9db6d6..2e5bffe 100644 --- a/bpkg/package.cxx +++ b/bpkg/package.cxx @@ -41,15 +41,19 @@ namespace bpkg static shared_ptr<repository> find (const shared_ptr<repository>& r, const shared_ptr<available_package>& ap, - repositories& chain) + repositories& chain, + bool prereq) { + // Prerequisites are not searched through recursively. + // + assert (!prereq || chain.empty ()); + auto pr = [&r] (const shared_ptr<repository>& i) -> bool {return i == r;}; auto i (find_if (chain.begin (), chain.end (), pr)); if (i != chain.end ()) return nullptr; - bool prereq (chain.empty ()); // Check prerequisites in top-level only. chain.emplace_back (r); unique_ptr<repositories, void (*)(repositories*)> deleter ( @@ -81,7 +85,7 @@ namespace bpkg // Should we consider prerequisites of our complements as our // prerequisites? I'd say not. // - if (shared_ptr<repository> r = find (cr.load (), ap, chain)) + if (shared_ptr<repository> r = find (cr.load (), ap, chain, false)) return r; } @@ -89,7 +93,7 @@ namespace bpkg { for (const lazy_weak_ptr<repository>& pr: ps) { - if (shared_ptr<repository> r = find (pr.load (), ap, chain)) + if (shared_ptr<repository> r = find (pr.load (), ap, chain, false)) return r; } } @@ -100,20 +104,23 @@ namespace bpkg static inline shared_ptr<repository> find (const shared_ptr<repository>& r, - const shared_ptr<available_package>& ap) + const shared_ptr<available_package>& ap, + bool prereq) { repositories chain; - return find (r, ap, chain); + return find (r, ap, chain, prereq); } vector<shared_ptr<available_package>> - filter (const shared_ptr<repository>& r, result<available_package>&& apr) + filter (const shared_ptr<repository>& r, + result<available_package>&& apr, + bool prereq) { vector<shared_ptr<available_package>> aps; for (shared_ptr<available_package> ap: pointer_result (apr)) { - if (find (r, ap) != nullptr) + if (find (r, ap, prereq) != nullptr) aps.push_back (move (ap)); } @@ -121,13 +128,15 @@ namespace bpkg } pair<shared_ptr<available_package>, shared_ptr<repository>> - filter_one (const shared_ptr<repository>& r, result<available_package>&& apr) + filter_one (const shared_ptr<repository>& r, + result<available_package>&& apr, + bool prereq) { using result = pair<shared_ptr<available_package>, shared_ptr<repository>>; for (shared_ptr<available_package> ap: pointer_result (apr)) { - if (shared_ptr<repository> pr = find (r, ap)) + if (shared_ptr<repository> pr = find (r, ap, prereq)) return result (move (ap), move (pr)); } |