From 1374560d558f4cab72f66b3d851e2a052f59998d Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 1 Mar 2018 18:33:16 +0300 Subject: Update pkg-build --- bpkg/package.cxx | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'bpkg/package.cxx') 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 find (const shared_ptr& r, const shared_ptr& ap, - repositories& chain) + repositories& chain, + bool prereq) { + // Prerequisites are not searched through recursively. + // + assert (!prereq || chain.empty ()); + auto pr = [&r] (const shared_ptr& 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 deleter ( @@ -81,7 +85,7 @@ namespace bpkg // Should we consider prerequisites of our complements as our // prerequisites? I'd say not. // - if (shared_ptr r = find (cr.load (), ap, chain)) + if (shared_ptr r = find (cr.load (), ap, chain, false)) return r; } @@ -89,7 +93,7 @@ namespace bpkg { for (const lazy_weak_ptr& pr: ps) { - if (shared_ptr r = find (pr.load (), ap, chain)) + if (shared_ptr r = find (pr.load (), ap, chain, false)) return r; } } @@ -100,20 +104,23 @@ namespace bpkg static inline shared_ptr find (const shared_ptr& r, - const shared_ptr& ap) + const shared_ptr& ap, + bool prereq) { repositories chain; - return find (r, ap, chain); + return find (r, ap, chain, prereq); } vector> - filter (const shared_ptr& r, result&& apr) + filter (const shared_ptr& r, + result&& apr, + bool prereq) { vector> aps; for (shared_ptr 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> - filter_one (const shared_ptr& r, result&& apr) + filter_one (const shared_ptr& r, + result&& apr, + bool prereq) { using result = pair, shared_ptr>; for (shared_ptr ap: pointer_result (apr)) { - if (shared_ptr pr = find (r, ap)) + if (shared_ptr pr = find (r, ap, prereq)) return result (move (ap), move (pr)); } -- cgit v1.1