diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-06-29 19:11:26 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-07-01 11:19:12 +0300 |
commit | ede8a15c2e310b2ae30894dd640f58d87a8a9408 (patch) | |
tree | f3556b9eb1c14ce3710874618c2ee8b187941f70 /bpkg/pkg-build.cxx | |
parent | a6ea97b9844c9b78c7e9b24c241fc16be22e4176 (diff) |
Fix selection of build entry between two in pkg-build
Diffstat (limited to 'bpkg/pkg-build.cxx')
-rw-r--r-- | bpkg/pkg-build.cxx | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index e15a9c9..c70aa9e 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -624,12 +624,20 @@ namespace bpkg { using constraint_type = build_package::constraint_type; - // If the versions differ, we have to pick one. Start with the - // newest version since if both satisfy, then that's the one we - // should prefer. So get the first to try into p1 and the second - // to try -- into p2. + // If the versions differ, we have to pick one. Pick with the + // following preference order: user selection over implicit one, + // source package over a system one, newer version over an older + // one. So get the preferred to try into p1 and the other to try + // -- into p2. // - if (p2->available_version () > p1->available_version ()) + int us (p1->user_selection () - p2->user_selection ()); + int sf (p1->system - p2->system); + + if (us < 0 || + (us == 0 && sf > 0) || + (us == 0 && + sf == 0 && + p2->available_version () > p1->available_version ())) swap (p1, p2); // See if pv's version satisfies pc's constraints. Return the |